private void DiseaseRecord_Load(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 Patient_Details";
OleDbDataReader reader = Com.ExecuteReader();
object[] obj = new object[256];
int dt = 0;
while (reader.Read())
{
reader.GetValues(obj);
DiseaseLV.Items.Add(obj[0].ToString());
DiseaseLV.Items[dt].SubItems.Add(obj[1].ToString());
DiseaseLV.Items[dt].SubItems.Add(obj[2].ToString());
DiseaseLV.Items[dt].SubItems.Add(obj[3].ToString());
DiseaseLV.Items[dt].SubItems.Add(obj[4].ToString());
DiseaseLV.Items[dt].SubItems.Add(obj[5].ToString());
DiseaseLV.Items[dt].SubItems.Add(obj[6].ToString());
DiseaseLV.Items[dt].SubItems.Add(obj[19].ToString());
dt++;
}
reader.Close();
Con.Close();
updatebtn.Enabled = false;
deletebtn.Enabled = false;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
{
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 Patient_Details";
OleDbDataReader reader = Com.ExecuteReader();
object[] obj = new object[256];
int dt = 0;
while (reader.Read())
{
reader.GetValues(obj);
DiseaseLV.Items.Add(obj[0].ToString());
DiseaseLV.Items[dt].SubItems.Add(obj[1].ToString());
DiseaseLV.Items[dt].SubItems.Add(obj[2].ToString());
DiseaseLV.Items[dt].SubItems.Add(obj[3].ToString());
DiseaseLV.Items[dt].SubItems.Add(obj[4].ToString());
DiseaseLV.Items[dt].SubItems.Add(obj[5].ToString());
DiseaseLV.Items[dt].SubItems.Add(obj[6].ToString());
DiseaseLV.Items[dt].SubItems.Add(obj[19].ToString());
dt++;
}
reader.Close();
Con.Close();
updatebtn.Enabled = false;
deletebtn.Enabled = false;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
------------------------------------------------
private void DiseaseLV_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
btnImage.Enabled = true;
updatebtn.Enabled = true;
deletebtn.Enabled = true;
}
catch (Exception exe)
{
MessageBox.Show(exe.Message);
}
}
------------------------------------
Search Data from ListView:-
private void Searchbtn_Click(object sender, EventArgs e)
{
try
{
bool recordFound = false;
if (searchtxtbox.Text == "")
{
MessageBox.Show("No Letter Typed", "PIS Search Engine");
}
else
{
for (int i = 0; i <= studentvisitLV.Items.Count - 1; i++)
{
string s1 = (searchtxtbox.Text).ToLower();
string s2 = (studentvisitLV.Items[i].SubItems[2].Text).ToLower();
if (s1 == s2)
{
studentvisitLV.Items[i].BackColor = Color.Yellow;
recordFound = true;
}
}
if (!recordFound)
{
MessageBox.Show("Record Not Found", "PIS Search Engine", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Search Data from ListView:-
private void Searchbtn_Click(object sender, EventArgs e)
{
try
{
bool recordFound = false;
if (searchtxtbox.Text == "")
{
MessageBox.Show("No Letter Typed", "PIS Search Engine");
}
else
{
for (int i = 0; i <= studentvisitLV.Items.Count - 1; i++)
{
string s1 = (searchtxtbox.Text).ToLower();
string s2 = (studentvisitLV.Items[i].SubItems[2].Text).ToLower();
if (s1 == s2)
{
studentvisitLV.Items[i].BackColor = Color.Yellow;
recordFound = true;
}
}
if (!recordFound)
{
MessageBox.Show("Record Not Found", "PIS Search Engine", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
No comments:
Post a Comment