Exemplo n.º 1
0
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            Cabinets temp = new Cabinets();

            using (ClinicEntities1 db = new ClinicEntities1())
            {
                if (db.Cabinets.Find(id) == null)
                {
                    Cabinets c = new Cabinets();
                    c.Id          = id;
                    c.Name        = NameTxtBx.Text;
                    c.Description = DescTxtBx.Text;
                    db.Cabinets.Add(c);
                    db.SaveChanges();
                    MessageBox.Show("Сохранение успешно", "Ортопедическая клиника!");
                    this.Close();
                }
                else
                {
                    var temp1 = db.Cabinets.Where(x => x.Id == id).FirstOrDefault <Cabinets>();
                    temp             = temp1;
                    temp.Name        = NameTxtBx.Text;
                    temp.Description = DescTxtBx.Text;
                    db.SaveChanges();
                    MessageBox.Show("Сохранение успешно", "Ортопедическая клиника");
                    this.Close();
                }
            }
        }
Exemplo n.º 2
0
 private void CabinetLkLbl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     using (ClinicEntities1 db = new ClinicEntities1())
     {
         Cabinets    c  = db.Cabinets.Where(x => x.Name == CabinetLkLbl.Text).FirstOrDefault <Cabinets>();
         CabinetCard cc = new CabinetCard();
         cc.Currentid = c.Id;
         cc.ShowDialog();
     }
 }
Exemplo n.º 3
0
 private void RefreshFormData(int id)
 {
     using (ClinicEntities1 db = new ClinicEntities1())
     {
         Cabinets temp = db.Cabinets.Where(x => x.Id == id).FirstOrDefault <Cabinets>();
         CabinetNameLbl.Text = temp.Name;
         DescriptionLbl.Text = temp.Description;
     }
     FillGrid();
 }
Exemplo n.º 4
0
 private void DelBtn_Click(object sender, EventArgs e)
 {
     using (ClinicEntities1 db = new ClinicEntities1())
     {
         Cabinets c = db.Cabinets.Where(x => x.Id == id).FirstOrDefault <Cabinets>();
         c.DeleteTime = DateTime.Now;
         MessageBox.Show("Кабинет успешно удален!", "Ортопедическая клиника");
         db.SaveChanges();
         this.Close();
     }
 }
Exemplo n.º 5
0
 private void CabinetEdit_Load(object sender, EventArgs e)
 {
     using (ClinicEntities1 db = new ClinicEntities1())
     {
         if (db.Cabinets.Find(id) != null)
         {
             Cabinets temp = db.Cabinets.Where(x => x.Id == id).FirstOrDefault <Cabinets>();
             NameTxtBx.Text = temp.Name;
             DescTxtBx.Text = temp.Description;
             FillGrid();
         }
         else
         {
             SaveBtn.Enabled = false;
             Cabinets c = new Cabinets();
             c.Id      = db.Cabinets.Count() + 1;
             Currentid = Convert.ToInt16(c.Id);
         }
     }
 }