CODE FOR CREATING LIST:-
public partial class Disease : Form
{
////List<string> Ditems = new List<string>();
////List<string> Sitems = new List<string>();
////List<string> Titems = new List<string>();
public Disease()
{
InitializeComponent();
////Ditems.Add("Fever");
////Ditems.Add("Cancer");
////Ditems.Add("Pain");
////lstDisease.DataSource = Ditems;
////Sitems.Add("1st");
////Sitems.Add("2nd");
////Sitems.Add("3rd");
////lstSymptoms.DataSource = Sitems;
////Titems.Add("Treatment1");
////Titems.Add("Treatment2");
////Titems.Add("Treatment3");
////lstTreatment.DataSource = Titems;
}
--------------------------------------------
CODE FOR ADD BUTTON FROM LISTBOX TO TEXTBOX:-
private void btnAddDisease_Click(object sender, EventArgs e)
{
txtDisease.Text += lstDisease.SelectedItem.ToString() + ",";
lstDisease.Items.Remove(lstDisease.SelectedItem);
//// //txtDisease.Text += lstDisease.SelectedItem.ToString() + ",";
//// //lstDisease.Items.Remove(lstDisease.SelectedItem.ToString());
//// //lstDisease.DataSource = null;
//// //lstDisease.DataSource = lstDisease;
}
------------------------------------------
CODE FOR CHECKBOX:-
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBoxImage.Checked)
{
// groupBoxImage.Show();
btnBrowse.Visible = true;
btnSubmit.Visible = true;
}
else if (!checkBoxImage.Checked )
{
// groupBoxImage.Hide();
btnBrowse.Visible = false;
btnSubmit.Visible = false;
}
}
--------------------------------------------------------
CODE FOR BACK BUTTON:-
private void btnBack_Click(object sender, EventArgs e)
{
PatientVisitationRecord sv = new PatientVisitationRecord();
sv.Show();
this.Close();
}
------------------------------------------------------------
CODE FOR LOGIN BUTTON:-
private void loginbtn_Click(object sender, EventArgs e)
{
try
{
string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\\PIS(ACU).mdb;";
Con = new OleDbConnection(@constr);
Con.Open();
Com = new OleDbCommand();
Com.Connection = Con;
Com.CommandText = "SELECT * FROM Security";
OleDbDataReader reader = Com.ExecuteReader();
object[] obj = new object[256];
bool st = false;
while (reader.Read())
{
reader.GetValues(obj);
if ((usernametxt.Text == obj[0].ToString()) && (passwordtxt.Text == obj[1].ToString()))
{
st = true;
break;
}
}
reader.Close();
Con.Close();
if (st)
{
// MessageBox.Show("Log in Successful!!!", "PIS System", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Visible = false;
Sectionselect f = new Sectionselect();
f.Show();
}
else
MessageBox.Show("INVALID!!! Try again", "PIS System", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
----------------------------------------------------------------
CODE FOR CANCEL BUTTON:-
private void cancelbtn_Click(object sender, EventArgs e)
{
try
{
DialogResult dResult;
dResult = MessageBox.Show("Do you want to Exit?", "PIS System",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dResult.ToString() == "Yes")
{
Application.Exit();
}
else
this.Visible = false;
LogIn v = new LogIn();
v.Show();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
--------------------------------------------------------------------------------------
Code to Validate TextBox:-
private void okbtn_Click(object sender, EventArgs e)
{
try
{
{
if (textBox2.Text == "")
{
MessageBox.Show("please enter a Surname");
textBox2.BackColor = Color.Pink;
textBox2.Focus();
}
else if (textBox3.Text == "")
{
MessageBox.Show("Please enter a First Name");
textBox3.BackColor = Color.Pink;
textBox3.Focus();
}
else if (comboBox2.Text == "")
{
MessageBox.Show("Please Select the Gender");
comboBox2.BackColor = Color.Pink;
comboBox2.Focus();
}
else if (textBox6.Text == "")
{
MessageBox.Show("Contact No. not Entered");
textBox6.BackColor = Color.Pink;
textBox6.Focus();
}
}
public partial class Disease : Form
{
////List<string> Ditems = new List<string>();
////List<string> Sitems = new List<string>();
////List<string> Titems = new List<string>();
public Disease()
{
InitializeComponent();
////Ditems.Add("Fever");
////Ditems.Add("Cancer");
////Ditems.Add("Pain");
////lstDisease.DataSource = Ditems;
////Sitems.Add("1st");
////Sitems.Add("2nd");
////Sitems.Add("3rd");
////lstSymptoms.DataSource = Sitems;
////Titems.Add("Treatment1");
////Titems.Add("Treatment2");
////Titems.Add("Treatment3");
////lstTreatment.DataSource = Titems;
}
--------------------------------------------
CODE FOR ADD BUTTON FROM LISTBOX TO TEXTBOX:-
private void btnAddDisease_Click(object sender, EventArgs e)
{
txtDisease.Text += lstDisease.SelectedItem.ToString() + ",";
lstDisease.Items.Remove(lstDisease.SelectedItem);
//// //txtDisease.Text += lstDisease.SelectedItem.ToString() + ",";
//// //lstDisease.Items.Remove(lstDisease.SelectedItem.ToString());
//// //lstDisease.DataSource = null;
//// //lstDisease.DataSource = lstDisease;
}
------------------------------------------
CODE FOR CHECKBOX:-
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBoxImage.Checked)
{
// groupBoxImage.Show();
btnBrowse.Visible = true;
btnSubmit.Visible = true;
}
else if (!checkBoxImage.Checked )
{
// groupBoxImage.Hide();
btnBrowse.Visible = false;
btnSubmit.Visible = false;
}
}
--------------------------------------------------------
CODE FOR BACK BUTTON:-
private void btnBack_Click(object sender, EventArgs e)
{
PatientVisitationRecord sv = new PatientVisitationRecord();
sv.Show();
this.Close();
}
------------------------------------------------------------
CODE FOR LOGIN BUTTON:-
private void loginbtn_Click(object sender, EventArgs e)
{
try
{
string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\\PIS(ACU).mdb;";
Con = new OleDbConnection(@constr);
Con.Open();
Com = new OleDbCommand();
Com.Connection = Con;
Com.CommandText = "SELECT * FROM Security";
OleDbDataReader reader = Com.ExecuteReader();
object[] obj = new object[256];
bool st = false;
while (reader.Read())
{
reader.GetValues(obj);
if ((usernametxt.Text == obj[0].ToString()) && (passwordtxt.Text == obj[1].ToString()))
{
st = true;
break;
}
}
reader.Close();
Con.Close();
if (st)
{
// MessageBox.Show("Log in Successful!!!", "PIS System", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Visible = false;
Sectionselect f = new Sectionselect();
f.Show();
}
else
MessageBox.Show("INVALID!!! Try again", "PIS System", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
----------------------------------------------------------------
CODE FOR CANCEL BUTTON:-
private void cancelbtn_Click(object sender, EventArgs e)
{
try
{
DialogResult dResult;
dResult = MessageBox.Show("Do you want to Exit?", "PIS System",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dResult.ToString() == "Yes")
{
Application.Exit();
}
else
this.Visible = false;
LogIn v = new LogIn();
v.Show();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
--------------------------------------------------------------------------------------
Code to Validate TextBox:-
private void okbtn_Click(object sender, EventArgs e)
{
try
{
{
if (textBox2.Text == "")
{
MessageBox.Show("please enter a Surname");
textBox2.BackColor = Color.Pink;
textBox2.Focus();
}
else if (textBox3.Text == "")
{
MessageBox.Show("Please enter a First Name");
textBox3.BackColor = Color.Pink;
textBox3.Focus();
}
else if (comboBox2.Text == "")
{
MessageBox.Show("Please Select the Gender");
comboBox2.BackColor = Color.Pink;
comboBox2.Focus();
}
else if (textBox6.Text == "")
{
MessageBox.Show("Contact No. not Entered");
textBox6.BackColor = Color.Pink;
textBox6.Focus();
}
}
No comments:
Post a Comment