CODE FOR INSERT & UPDATE;-
public void Disease_Load(object sender, EventArgs e)
{
try
{
DiseaseList();
TreatmentList();
SymptomsList();
btnSubmit.Visible = false;
btnBrowse.Visible = false;
txtPatient_Id.Text = val.ToString();
txtPatientId.Text = val.ToString();
if (flag == 1)
{
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 Patient_Id,Date_of_visit,Date_of_discharge,DoctorName,Symptoms,Disease,Treatment,age,Occupation,Sensitivity,MentalStatus,Sleep,Nutrition,Vitality,PhysicalStatus,Nature,Proving,RemedySource,RemedyType FROM Patient_Details WHERE DetailsId =" + val;
OleDbDataReader reader = Com.ExecuteReader();
object[] obj = new object[256];
txtPatient_Id.Text = val.ToString();
while (reader.Read())
{
reader.GetValues(obj);
dateTimePickerVisit.Text = obj[1].ToString();
dateTimePickerDischarge.Text = obj[2].ToString();
txtDoctorName.Text = obj[3].ToString();
txtSymptoms.Text = obj[4].ToString();
txtDisease.Text = obj[5].ToString();
txtTreatment.Text = obj[6].ToString();
cmbAge.Text = obj[7].ToString();
cmbOccupation.Text = obj[8].ToString();
cmbSensitivity.Text = obj[9].ToString();
cmbMeritalStatus.Text = obj[10].ToString();
cmbSleep.Text = obj[11].ToString();
cmbNutrition.Text = obj[12].ToString();
cmbVitality.Text = obj[13].ToString();
cmbPhysicalStatus.Text = obj[14].ToString();
cmbNature.Text = obj[15].ToString();
cmbProving.Text = obj[16].ToString();
cmbRemedySource.Text = obj[17].ToString();
cmbRemedyType.Text = obj[18].ToString();
}
reader.Close();
Con.Close();
checkBoxImage.Enabled = false;
}
}
catch (Exception exe)
{
MessageBox.Show(exe.Message);
}
}
public void okbtn_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;
if (flag != 1)
{
Com.CommandText = "INSERT INTO Patient_Details(Patient_Id,Date_of_visit,Date_of_discharge,Symptoms,Disease,Treatment,DoctorName,age,Occupation,Sensitivity,MentalStatus,Sleep,Nutrition,Vitality,PhysicalStatus,Nature,Proving,RemedySource,RemedyType) VALUES('" + txtPatient_Id.Text + "','" + dateTimePickerVisit.Text + "','" + dateTimePickerDischarge.Text + "','" + txtSymptoms.Text + "','" + txtDisease.Text + "','" + txtTreatment.Text + "','" + txtDoctorName.Text + "','" + cmbAge.Text + "','" + cmbOccupation.Text + "','" + cmbSensitivity.Text + "','" + cmbMeritalStatus.Text + "','" + cmbSleep.Text + "','" + cmbNutrition.Text + "','" + cmbVitality.Text + "','" + cmbPhysicalStatus.Text + "','" + cmbNature.Text + "','" + cmbProving.Text + "','" + cmbRemedySource.Text + "' ,'" + cmbRemedyType.Text + "')";
Com.ExecuteNonQuery();
Con.Close();
MessageBox.Show("Record Added Successfully", "PIS System");
DiseaseRecord D = new DiseaseRecord();
D.Show();
//checkBoxImage.Visible = true;
checkBoxImage.Enabled = true;
this.Close();
}
else if (flag == 1)
{
Com.CommandText = "UPDATE Patient_Details SET Date_of_visit ='" + dateTimePickerVisit.Text + "',Date_of_discharge = '" + dateTimePickerDischarge.Text + "',DoctorName = '" + txtDoctorName.Text + "',Symptoms = '" + txtSymptoms.Text + "',Disease = '" + txtDisease.Text + "',Treatment = '" + txtTreatment.Text + "' ,Age ='" + cmbAge.Text + "',Occupation ='" + cmbOccupation.Text + "',Sensitivity ='" + cmbSensitivity.Text + "',MentalStatus ='" + cmbMeritalStatus.Text + "',Sleep ='" + cmbSleep.Text + "',Nutrition ='" + cmbNutrition.Text + "',Vitality ='" + cmbVitality.Text + "',PhysicalStatus ='" + cmbPhysicalStatus.Text + "',Nature ='" + cmbNature.Text + "',Proving ='" + cmbProving.Text + "',RemedySource ='" + cmbRemedySource.Text + "' ,RemedyType ='" + cmbRemedyType.Text + "' WHERE DetailsId =" + val + "";
Com.ExecuteNonQuery();
Con.Close();
MessageBox.Show("Record Updated Successfully", "PIS System");
DiseaseRecord D = new DiseaseRecord();
D.Show();
this.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
---------------------
private void updatebtn_Click(object sender, EventArgs e)
{
try
{
Disease di = new Disease();
di.flag = 1;
string s = "";
// s = DiseaseLV.SelectedItems[0].SubItems[0].Text;
s = DiseaseLV.SelectedItems[0].SubItems[7].Text;
di.val = Convert.ToInt32(s);
di.Show();
this.Close();
}
catch (Exception exet)
{
MessageBox.Show(" Please Select The Index:" + Environment.NewLine + exet.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
CODE FOR DELETE:-
private void deletebtn_Click(object sender, EventArgs e)
{
try
{
string delval = DiseaseLV.SelectedItems[0].SubItems[7].Text;
DialogResult r = MessageBox.Show("Are you sure you want to delete record: " + delval, "PIS System", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (r == DialogResult.Yes)
{
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 = "DELETE FROM Patient_Details WHERE DetailsId = " + delval + "";
Com.ExecuteNonQuery();
Con.Close();
DiseaseRecord dr = new DiseaseRecord();
dr.Show();
this.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(" Please Select The Index:" + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
public void Disease_Load(object sender, EventArgs e)
{
try
{
DiseaseList();
TreatmentList();
SymptomsList();
btnSubmit.Visible = false;
btnBrowse.Visible = false;
txtPatient_Id.Text = val.ToString();
txtPatientId.Text = val.ToString();
if (flag == 1)
{
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 Patient_Id,Date_of_visit,Date_of_discharge,DoctorName,Symptoms,Disease,Treatment,age,Occupation,Sensitivity,MentalStatus,Sleep,Nutrition,Vitality,PhysicalStatus,Nature,Proving,RemedySource,RemedyType FROM Patient_Details WHERE DetailsId =" + val;
OleDbDataReader reader = Com.ExecuteReader();
object[] obj = new object[256];
txtPatient_Id.Text = val.ToString();
while (reader.Read())
{
reader.GetValues(obj);
dateTimePickerVisit.Text = obj[1].ToString();
dateTimePickerDischarge.Text = obj[2].ToString();
txtDoctorName.Text = obj[3].ToString();
txtSymptoms.Text = obj[4].ToString();
txtDisease.Text = obj[5].ToString();
txtTreatment.Text = obj[6].ToString();
cmbAge.Text = obj[7].ToString();
cmbOccupation.Text = obj[8].ToString();
cmbSensitivity.Text = obj[9].ToString();
cmbMeritalStatus.Text = obj[10].ToString();
cmbSleep.Text = obj[11].ToString();
cmbNutrition.Text = obj[12].ToString();
cmbVitality.Text = obj[13].ToString();
cmbPhysicalStatus.Text = obj[14].ToString();
cmbNature.Text = obj[15].ToString();
cmbProving.Text = obj[16].ToString();
cmbRemedySource.Text = obj[17].ToString();
cmbRemedyType.Text = obj[18].ToString();
}
reader.Close();
Con.Close();
checkBoxImage.Enabled = false;
}
}
catch (Exception exe)
{
MessageBox.Show(exe.Message);
}
}
public void okbtn_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;
if (flag != 1)
{
Com.CommandText = "INSERT INTO Patient_Details(Patient_Id,Date_of_visit,Date_of_discharge,Symptoms,Disease,Treatment,DoctorName,age,Occupation,Sensitivity,MentalStatus,Sleep,Nutrition,Vitality,PhysicalStatus,Nature,Proving,RemedySource,RemedyType) VALUES('" + txtPatient_Id.Text + "','" + dateTimePickerVisit.Text + "','" + dateTimePickerDischarge.Text + "','" + txtSymptoms.Text + "','" + txtDisease.Text + "','" + txtTreatment.Text + "','" + txtDoctorName.Text + "','" + cmbAge.Text + "','" + cmbOccupation.Text + "','" + cmbSensitivity.Text + "','" + cmbMeritalStatus.Text + "','" + cmbSleep.Text + "','" + cmbNutrition.Text + "','" + cmbVitality.Text + "','" + cmbPhysicalStatus.Text + "','" + cmbNature.Text + "','" + cmbProving.Text + "','" + cmbRemedySource.Text + "' ,'" + cmbRemedyType.Text + "')";
Com.ExecuteNonQuery();
Con.Close();
MessageBox.Show("Record Added Successfully", "PIS System");
DiseaseRecord D = new DiseaseRecord();
D.Show();
//checkBoxImage.Visible = true;
checkBoxImage.Enabled = true;
this.Close();
}
else if (flag == 1)
{
Com.CommandText = "UPDATE Patient_Details SET Date_of_visit ='" + dateTimePickerVisit.Text + "',Date_of_discharge = '" + dateTimePickerDischarge.Text + "',DoctorName = '" + txtDoctorName.Text + "',Symptoms = '" + txtSymptoms.Text + "',Disease = '" + txtDisease.Text + "',Treatment = '" + txtTreatment.Text + "' ,Age ='" + cmbAge.Text + "',Occupation ='" + cmbOccupation.Text + "',Sensitivity ='" + cmbSensitivity.Text + "',MentalStatus ='" + cmbMeritalStatus.Text + "',Sleep ='" + cmbSleep.Text + "',Nutrition ='" + cmbNutrition.Text + "',Vitality ='" + cmbVitality.Text + "',PhysicalStatus ='" + cmbPhysicalStatus.Text + "',Nature ='" + cmbNature.Text + "',Proving ='" + cmbProving.Text + "',RemedySource ='" + cmbRemedySource.Text + "' ,RemedyType ='" + cmbRemedyType.Text + "' WHERE DetailsId =" + val + "";
Com.ExecuteNonQuery();
Con.Close();
MessageBox.Show("Record Updated Successfully", "PIS System");
DiseaseRecord D = new DiseaseRecord();
D.Show();
this.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
---------------------
private void updatebtn_Click(object sender, EventArgs e)
{
try
{
Disease di = new Disease();
di.flag = 1;
string s = "";
// s = DiseaseLV.SelectedItems[0].SubItems[0].Text;
s = DiseaseLV.SelectedItems[0].SubItems[7].Text;
di.val = Convert.ToInt32(s);
di.Show();
this.Close();
}
catch (Exception exet)
{
MessageBox.Show(" Please Select The Index:" + Environment.NewLine + exet.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
CODE FOR DELETE:-
private void deletebtn_Click(object sender, EventArgs e)
{
try
{
string delval = DiseaseLV.SelectedItems[0].SubItems[7].Text;
DialogResult r = MessageBox.Show("Are you sure you want to delete record: " + delval, "PIS System", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (r == DialogResult.Yes)
{
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 = "DELETE FROM Patient_Details WHERE DetailsId = " + delval + "";
Com.ExecuteNonQuery();
Con.Close();
DiseaseRecord dr = new DiseaseRecord();
dr.Show();
this.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(" Please Select The Index:" + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
CODE FOR SEARCH:-
private void btnShowImage_Click(object sender, EventArgs e)
{
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 Photo FROM PatientImages WHERE Patient_Id = " + val + " ";
OleDbDataReader reader = Com.ExecuteReader();
if (reader.Read())
{
byte[] picbyte = reader["Photo"] as byte[] ?? null;
if (picbyte != null)
{
MemoryStream mstream = new MemoryStream(picbyte);
pictureBoxForImage.Image = System.Drawing.Image.FromStream(mstream);
pictureBoxForImage.SizeMode = PictureBoxSizeMode.StretchImage;
{
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(mstream);
}
}
}
No comments:
Post a Comment