コード例 #1
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                using (ModelBD md = new ModelBD())
                {
                    var compId = md.Company.Where(p => p.Name.Equals(CompNameBox.Text)).FirstOrDefault();

                    Patients patients = new Patients
                    {
                        ID              = IDPAT,
                        FIO             = pFIO.Text,
                        DateOfBirth     = DaT.SelectedDate,
                        Email           = pEmail.Text,
                        PassportData    = pPassportData.Text,
                        Phone           = long.Parse(pPhone.Text),
                        InsurancePolicy = long.Parse(pInsPolicy.Text),
                        TypeOfPolicy    = PolNameBox.Text,
                        IDCompany       = compId.ID
                    };

                    md.Entry(patients).State = System.Data.Entity.EntityState.Modified;
                    md.SaveChanges();
                }

                MessageBox.Show("Данные успешно созранены в БД");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
        private void SaveAgent(object sender, RoutedEventArgs e)
        {
            try
            {
                using (ModelBD model = new ModelBD())
                {
                    int?        idComb     = int.Parse(FIOComb.SelectedItem.ToString().Split(':')[1]);
                    Realtors    realtors   = model.Realtors.Where(p => p.ID == idComb).FirstOrDefault();
                    int?        idAP       = int.Parse(APComb.SelectedItem.ToString().Split(':')[1]);
                    Apartaments apartament = model.Apartaments.Where(p => p.ID == idAP).FirstOrDefault();

                    realtors.FIO     = FIOText.Text;
                    realtors.Percent = int.Parse(PercentText.Text);

                    model.Entry(realtors).State = System.Data.Entity.EntityState.Modified;
                    model.SaveChanges();

                    SetChangeComboBox(realtors, apartament);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #3
0
        private void SaveAP(object sender, RoutedEventArgs e)
        {
            try
            {
                using (ModelBD model = new ModelBD())
                {
                    int?        idAP       = int.Parse(APComb.SelectedItem.ToString().Split(':')[1]);
                    Apartaments apartament = model.Apartaments.Where(p => p.ID == idAP).FirstOrDefault();
                    int?        idComb     = int.Parse(FIOComb.SelectedItem.ToString().Split(':')[1]);
                    Realtors    realtors   = model.Realtors.Where(p => p.ID == idComb).FirstOrDefault();

                    apartament.StreetName       = STNameText.Text;
                    apartament.HouseNumber      = HouseNumText.Text;
                    apartament.ApartamentNumber = int.Parse(APNumText.Text);
                    apartament.SquareApartament = double.Parse(SquareText.Text);
                    apartament.AmountRoom       = int.Parse(AmountRoomText.Text);
                    apartament.Price            = decimal.Parse(PriceText.Text);

                    model.Entry(apartament).State = System.Data.Entity.EntityState.Modified;
                    model.SaveChanges();

                    SetChangeComboBox(realtors, apartament);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #4
0
 public ActionResult Edit([Bind(Include = "CourseID,Title,Credits,DepartmentID")] Course course)
 {
     if (ModelState.IsValid)
     {
         db.Entry(course).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "Name", course.DepartmentID);
     return(View(course));
 }
コード例 #5
0
        public void GetId(string[] masJson, int num, int num_2)
        {
            using (ModelBD md = new ModelBD())
            {
                int msPatId     = int.Parse(masJson[0].Split(':')[1]);
                int msLsServId  = int.Parse(masJson[1].Split(':')[2].Substring(0, 1));
                int msSetServId = int.Parse(masJson[num].Split(':')[num_2].Substring(0, 1));

                var labserv = md.LabServices.Where(p => p.ID.Equals(msLsServId)).FirstOrDefault();
                var patient = md.Patients.Where(p => p.ID.Equals(msPatId)).FirstOrDefault();
                var setserv = md.SetServicee.Where(p => p.ID.Equals(msSetServId)).FirstOrDefault();

                if (num == 2)
                {
                    MessageBox.Show($"FIO: {patient.FIO}, IDSetServ: {setserv.ID}, IDLabServ: {labserv.ID}");
                }
                else
                {
                    MessageBox.Show($"FIO: {patient.FIO}, IDSetServ: {setserv.ID}");
                }

                try
                {
                    int idpat = msPatId;
                    var order = md.Orderr.Where(p => p.IDPatient.Equals(idpat)).FirstOrDefault();

                    Orderr orderr = new Orderr
                    {
                        IDPatient = order.IDPatient,
                        IDService = order.IDService,
                        Status    = "IN PROGRESS"
                    };

                    md.Entry(orderr).State = System.Data.Entity.EntityState.Modified;
                    md.SaveChanges();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    Clipboard.SetText(ex.Message);
                }
            }
        }