예제 #1
0
        public void AddSymptomsToDb()
        {
            MedDbEntities db = new MedDbEntities();

            foreach (Symptoms s in lstSym)
            {
                if (s.Id == 0)
                {
                    Symptom sTbl = new Symptom();
                    sTbl.SymptomName = s.SymptomName;
                    db.Symptoms.Add(sTbl);
                }
            }
            db.SaveChanges();
        }
예제 #2
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            errorFlag = false;
            lbl_errorCauseName.Text       = "";
            lbl_ErrorEnglishName.Text     = "";
            lbl_ErrorMedicalCureName.Text = "";
            lbl_ErrorPotency.Text         = "";
            lbl_ErrorSymptom.Text         = "";
            //lbl_ErrorType.Text = "";
            lbl_ErrorUrduName.Text = "";
            MedDbEntities db = new MedDbEntities();
            Diseases      d  = new Diseases();

            d.englishName  = txt_DiseaseEnglishName.Text;
            d.urduName     = txt_DiseaseUrduName.Text;
            d.description  = txt_DiseaseDetails.Text;
            d.categoryName = cmb_DiseaseCategory.Text;
            d.Add(db);
            if (d.errorUrduName != "" || d.errorEnglishName != "")
            {
                cmb_DiseaseCategory.Items.Clear();
                d.AddCategoryToCombobox(cmb_DiseaseCategory);
                lbl_ErrorEnglishName.Text      = d.errorEnglishName;
                lbl_ErrorEnglishName.ForeColor = System.Drawing.Color.Red;
                lbl_ErrorUrduName.Text         = d.errorUrduName;
                lbl_ErrorUrduName.ForeColor    = System.Drawing.Color.Red;
                txt_DiseaseEnglishName.Clear();
                txt_DiseaseUrduName.Clear();
                errorFlag = true;
            }
            Symptoms s = new Symptoms();

            if (Symptoms.lstSym.Count == 0)
            {
                lbl_ErrorSymptom.Text      = "علامت کا انتخاب کریں";
                lbl_ErrorSymptom.ForeColor = System.Drawing.Color.Red;
                errorFlag = true;
            }
            if (Causes.lstCause.Count == 0)
            {
                lbl_errorCauseName.Text      = "سبب کا ینتخاب کریں";
                lbl_errorCauseName.ForeColor = System.Drawing.Color.Red;
                errorFlag = true;
            }
            if (Treatment.lstMedicalTreatment.Count == 0)
            {
                lbl_ErrorMedicalCureName.Text      = "علاج کا انتخاب کریں";
                lbl_ErrorMedicalCureName.ForeColor = System.Drawing.Color.Red;
                //lbl_ErrorType.Text = "طرز کا انتخاب کریں";
                //lbl_ErrorType.ForeColor = System.Drawing.Color.Red;
                lbl_ErrorPotency.Text      = "قوت درج کریں";
                lbl_ErrorPotency.ForeColor = System.Drawing.Color.Red;

                lbl_ErrorTreatmentNameHomoeo.Text      = "علاج کا انتخاب کریں";
                lbl_ErrorTreatmentNameHomoeo.ForeColor = System.Drawing.Color.Red;
                lbl_ErrorPotencyHomoeo.Text            = "قوت درج کریں";
                lbl_ErrorPotencyHomoeo.ForeColor       = System.Drawing.Color.Red;

                lbl_ErrorTreatmentNameAloe.Text      = "علاج کا انتخاب کریں";
                lbl_ErrorTreatmentNameAloe.ForeColor = System.Drawing.Color.Red;
                lbl_ErrorPotencyAloe.Text            = "قوت درج کریں";
                lbl_ErrorPotencyAloe.ForeColor       = System.Drawing.Color.Red;

                errorFlag = true;
            }
            if (errorFlag == true)
            {
                MessageBox.Show("تفصیلات درست نہیں۔ تمام ٹیب دوبارہ دیکھیں۔ غلطیاں نمایاں کر دی گیؑ ہیں");
                return;
            }



            db.SaveChanges();

            s.AddSymptomsToDb();

            List <string> lstSymName = new List <string>();

            foreach (Symptoms s1 in Symptoms.lstSym)
            {
                string s2 = s1.SymptomName;
                lstSymName.Add(s2);
            }

            int diseaseId = d.getDiseaseIdFromName(d.urduName);

            foreach (string s3 in lstSymName)
            {
                MedDbEntities db1 = new MedDbEntities();

                int     symId = s.getSymIdFromName(s3);
                Disease dt    = new Disease();
                dt.Id = diseaseId;
                db1.Diseases.Add(dt);
                db1.Diseases.Attach(dt);
                Symptom st = new Symptom();
                st.Id = symId;
                db1.Symptoms.Add(st);
                db1.Symptoms.Attach(st);
                dt.Symptoms.Add(st);
                db1.SaveChanges();
            }
            Symptoms.lstSym.Clear();
            dgv_symptoms.DataSource = null;
            dgv_symptoms.Rows.Clear();



            Causes c = new Causes();

            c.AddCauseToDb();

            List <string> lstCauseName = new List <string>();

            foreach (Causes c1 in Causes.lstCause)
            {
                string ctemp1 = c1.ReasonName;
                lstCauseName.Add(ctemp1);
            }

            foreach (string s4 in lstCauseName)
            {
                MedDbEntities db2 = new MedDbEntities();

                int     causeId = c.getReasonIdFromName(s4);
                Disease dt      = new Disease();
                dt.Id = diseaseId;
                db2.Diseases.Add(dt);
                db2.Diseases.Attach(dt);
                Reason rt = new Reason();
                rt.ReasonId = causeId;
                db2.Reasons.Add(rt);
                db2.Reasons.Attach(rt);
                dt.Reasons.Add(rt);
                db2.SaveChanges();
            }
            Causes.lstCause.Clear();
            dgv_Causes.DataSource = null;
            dgv_Causes.Rows.Clear();

            Treatment t = new Treatment();

            t.AddToDb();

            foreach (Treatment t1 in Treatment.lstMedicalTreatment)
            {
                DiseaseMedicine dmTbl = new DiseaseMedicine();
                dmTbl.DiseaseId             = diseaseId;
                dmTbl.MedicineId            = t1.getMedIdFromName(t1.MedName);
                dmTbl.DoctorRecommendations = txt_DoctorsRecomendation.Text;
                db.DiseaseMedicines.Add(dmTbl);
                db.SaveChanges();
            }
            Treatment.lstMedicalTreatment.Clear();
            dgv_MedicalCure.DataSource = null;
            dgv_MedicalCure.Rows.Clear();


            cmb_DiseaseCategory.Items.Clear();
            d.AddCategoryToCombobox(cmb_DiseaseCategory);

            cmb_Symptom.Items.Clear();
            s.AddSymptomsToComboBox(cmb_Symptom);

            //cmb_CauseName.Items.Clear();
            //c.AddCausesToComboBox(cmb_CauseName);

            cmb_MedicalCure.Items.Clear();
            t.AddTreatmentToCombobox(cmb_MedicalCure);
            //cmb_Types.Items.Clear();
            //t.AddTypeToComboBox(cmb_Types);
            cmb_Potency.Items.Clear();
            t.AddPotencyToComboBox(cmb_Potency);

            cmb_TreatmentNameHomoeo.Items.Clear();
            t.AddTreatmentToComboBoxHomoeo(cmb_TreatmentNameHomoeo);
            cmb_PotencyHomoeo.Items.Clear();
            t.AddPotencyToComboBoxHomoeo(cmb_PotencyHomoeo);

            cmb_CauseName.Text       = "";
            cmb_DiseaseCategory.Text = "";
            cmb_MedicalCure.Text     = "";
            cmb_Potency.Text         = "";
            cmb_Symptom.Text         = "";
            //cmb_Types.Text = "";
            txt_DiseaseDetails.Text       = "";
            txt_DiseaseEnglishName.Text   = "";
            txt_DiseaseUrduName.Text      = "";
            txt_DoctorsRecomendation.Text = "";

            cmb_TreatmentNameHomoeo.Text         = "";
            cmb_PotencyHomoeo.Text               = "";
            txt_DoctorsRecommendationHomoeo.Text = "";

            cmb_TreatmentNameAloe.Text         = "";
            cmb_PotencyAloe.Text               = "";
            txt_DoctorsRecommendationAloe.Text = "";


            MessageBox.Show("تفصیلات محفوظ ہو چکی ہیں");



            //if (d.Add() == true)
            //{
            //    MessageBox.Show("بیماری محفوظ کر دی گیؑ ہے");
            //    txt_DiseaseEnglishName.Clear();
            //    txt_DiseaseUrduName.Clear();
            //    txt_DiseaseDetails.Clear();
            //    cmb_DiseaseCategory.Text = "";
            //}
            //else
            //{
            //    MessageBox.Show("بیماری کا نام پہلے سے موجود ہے");
            //}
        }