Example #1
0
        private void buttonOk_Click(object sender, EventArgs e)
        {

            if (!superValidator1.Validate())
                return;
                try
                {
                    if (UserAction == "edit")
                    {
                        DiseaseDetail.DiseaseName = textBoxDiseaseName.Text;
                        DiseaseDetail.Symptom = textBoxDiseaseSymptom.Text;
                        DialogResult dialogResult = MessageBox.Show("Xác nhận cập nhập thông tin bệnh", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (dialogResult == DialogResult.Yes)
                        {
                            if (Disease.UpdateDisease(DiseaseDetail) > 0)
                                MessageBox.Show("Cập nhập thông tin bệnh thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        
                    }
                    else
                    {
                        Disease newDisease = new Disease(0, textBoxDiseaseName.Text, textBoxDiseaseSymptom.Text);
                        if(Disease.InsertDisease(newDisease)>0)
                            MessageBox.Show("Thêm bệnh thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.None);
                    }
                }
                catch
                {
                    MessageBox.Show("Lỗi dữ liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
           
            this.Close();

        }
Example #2
0
 public static int InsertDisease(Disease newDisease)
 {
     String sqlInsert = @"INSERT INTO DISEASE(DISEASENAME,SYMPTOM)
                         VALUES        (@DISEASENAME,@SYMPTOM)";
     SqlParameter[] sqlParameters = { new SqlParameter("@DISEASENAME", newDisease.DiseaseName),
                                    new SqlParameter("@SYMPTOM",newDisease.Symptom)};
     return SqlResult.ExecuteNonQuery(sqlInsert, sqlParameters);
 }
Example #3
0
 public FormDiseaseDetail(Disease diseaseDetail, String usertAction)
 {
     InitializeComponent();
     this.DiseaseDetail = diseaseDetail;
     this.UserAction = usertAction;
     if (this.UserAction == "edit")
         SetDiseaseDetail(diseaseDetail);
 }
Example #4
0
 public static int UpdateDisease(Disease updateDisease)
 {
     string sqlUpdate = @"UPDATE DISEASE
                         SET DISEASENAME = @DISEASENAME,SYMPTOM=@SYMPTOM
                         WHERE (DISEASEID =@DISEASEID)";
     SqlParameter[] sqlParameters = { new SqlParameter("@DISEASEID", updateDisease.DiseaseID),
                                    new SqlParameter("@DISEASENAME", updateDisease.DiseaseName),
                                    new SqlParameter("@SYMPTOM", updateDisease.Symptom)};
     return SqlResult.ExecuteNonQuery(sqlUpdate, sqlParameters);
 }
Example #5
0
 public static Disease GetDisease(int diseaseID)
 {
     int tempInterger;
     Disease newDisease = new Disease();
     string sqlSelect = @"SELECT DISEASEID, DISEASENAME,SYMPTOM
                         FROM DISEASE
                         WHERE (DISEASEID = @DISEASEID)";
     SqlParameter[] sqlParameters = { new SqlParameter("@DISEASEID", diseaseID) };
     DataTable dataTable = SqlResult.ExecuteQuery(sqlSelect,sqlParameters);
     if (dataTable.Rows.Count > 0)
     {
         int.TryParse(dataTable.Rows[0][0].ToString(), out tempInterger);
         newDisease.DiseaseID = tempInterger;
         newDisease.DiseaseName = dataTable.Rows[0][1].ToString();
         newDisease.Symptom = dataTable.Rows[0][2].ToString();
     }
     return newDisease;
 }
Example #6
0
 public void SetDiseaseDetail(Disease diseaseDetail)
 {
     textBoxDiseaseID.Text = diseaseDetail.DiseaseID.ToString();
     textBoxDiseaseName.Text = diseaseDetail.DiseaseName;
     textBoxDiseaseSymptom.Text = diseaseDetail.Symptom;
 }