コード例 #1
0
 private void DiagnosisEdit_Load(object sender, EventArgs e)
 {
     using (ClinicEntities1 db = new ClinicEntities1())
     {
         FillStatusCmbx();
         FillWorkersCmbx();
         if (db.Diagnosises.Find(id) != null)
         {
             Diagnosises temp = db.Diagnosises.Where(x => x.Id == id).FirstOrDefault <Diagnosises>();
             PatientLbl.Text    = temp.Patients.Name;
             WorkerCmbx.Text    = temp.Workers.Name;
             Diagnosisname.Text = temp.Name;
             DateDTP.Value      = Convert.ToDateTime(temp.Date);
             StatusCmbx.Text    = temp.Status;
             Desc.Text          = temp.Description;
         }
         else
         {
             SaveBtn.Enabled = false;
             Diagnosises c = new Diagnosises();
             c.Id      = db.Diagnosises.Count() + 1;
             Currentid = Convert.ToInt16(c.Id);
             WorkerCmbx.SelectedIndex = 0;
             StatusCmbx.SelectedIndex = 0;
         }
     }
 }
コード例 #2
0
 private void DelBtn_Click(object sender, EventArgs e)
 {
     using (ClinicEntities1 db = new ClinicEntities1())
     {
         Diagnosises c = db.Diagnosises.Where(x => x.Id == id).FirstOrDefault <Diagnosises>();
         c.DeleteTime = DateTime.Now;
         MessageBox.Show("Диагноз успешно удален!", "Ортопедическая клиника");
         db.SaveChanges();
         this.Close();
     }
 }
コード例 #3
0
 private void RefreshFormData(int id)
 {
     using (ClinicEntities1 db = new ClinicEntities1())
     {
         Diagnosises temp = db.Diagnosises.Where(x => x.Id == id).FirstOrDefault <Diagnosises>();
         PatientNameLkLbl.Text = db.Patients.Find(temp.Patient_ID).Name;
         WorkerNameLkLbl.Text  = db.Workers.Find(temp.Worker_ID).Name;
         DiagnosisNameLbl.Text = temp.Name;
         DateLbl.Text          = Convert.ToString(temp.Date);
         StatusLbl.Text        = temp.Status;
         DescLbl.Text          = temp.Description;
     }
 }
コード例 #4
0
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            Diagnosises temp = new Diagnosises();

            using (ClinicEntities1 db = new ClinicEntities1())
            {
                if (db.Diagnosises.Find(id) == null)
                {
                    try
                    {
                        Diagnosises c = new Diagnosises();
                        c.Id          = id;
                        c.Patient_ID  = db.Patients.Where(x => x.Name == PatientLbl.Text).FirstOrDefault <Patients>().Id;
                        c.Worker_ID   = db.Workers.Where(x => x.Name == WorkerCmbx.Text).FirstOrDefault <Workers>().Id;
                        c.Name        = Diagnosisname.Text;
                        c.Date        = Convert.ToDateTime(DateDTP.Value);
                        c.Status      = StatusCmbx.Text;
                        c.Description = Desc.Text;
                        db.Diagnosises.Add(c);
                        db.SaveChanges();
                        MessageBox.Show("Сохранение успешно", "Ортопедическая клиника!");
                        this.Close();
                    }
                    catch
                    {
                        MessageBox.Show("Вы не выбрали пациента");
                    }
                }
                else
                {
                    var temp1 = db.Diagnosises.Where(x => x.Id == id).FirstOrDefault <Diagnosises>();
                    temp             = temp1;
                    temp.Patient_ID  = db.Patients.Where(x => x.Name == PatientLbl.Text).FirstOrDefault <Patients>().Id;
                    temp.Worker_ID   = db.Workers.Where(x => x.Name == WorkerCmbx.Text).FirstOrDefault <Workers>().Id;
                    temp.Name        = Diagnosisname.Text;
                    temp.Date        = Convert.ToDateTime(DateDTP.Value);
                    temp.Description = Desc.Text;
                    db.SaveChanges();
                    MessageBox.Show("Сохранение успешно", "Ортопедическая клиника");
                    this.Close();
                }
            }
        }