예제 #1
0
        private void guna2Button2_Click(object sender, EventArgs e)
        {
            using (var context = new YTeDbContext())
            {
                var phongKham = context.PhongKhams.Where(s => s.TenPhongKham == phongkham).FirstOrDefault();
                var People    = context.DatLichKhams.Where(s => s.ID_PhongKham == phongKham.ID_PhongKham).FirstOrDefault();
                var people    = new ConNguoi();
                {
                    people.HoTen       = txtHoTen.Text;
                    people.SoCMND      = txtCMND.Text;
                    people.SoDienThoai = txtSDT.Text;
                    people.Email       = txtEmail.Text;
                    people.DiaChi      = txtDiaChi.Text;
                    //  people.GioiTinh = cbGioiTinh.Text;
                }
                context.ConNguois.Add(people);
                context.SaveChanges();

                var connguoi = new DatLichKham();
                {
                    connguoi.GhiChu       = txtGhiChu.Text;
                    connguoi.LyDoKham     = txtLyDoKham.Text;
                    connguoi.ID_PhongKham = People.ID_PhongKham;
                }
                context.DatLichKhams.Add(connguoi);
                context.SaveChanges();
            }
        }
예제 #2
0
 private void guna2Button1_Click_1(object sender, EventArgs e)
 {
     using (var context = new YTeDbContext())
     {
         var people = context.ConNguois.Where(s => s.SoDienThoai == c).FirstOrDefault();
         if (people == null)
         {
             MessageBox.Show("Không tìm thấy bệnh nhân!");
         }
         else
         {
             MessageBox.Show("ID bệnh nhân đã xóa: " + people.ID_Nguoi.ToString(), "Thông báo!");
         }
         var people1 = context.DatLichKhams.Where(s => s.ID_Nguoi == people.ID_Nguoi).FirstOrDefault();
         context.DatLichKhams.Remove(people1);
         context.SaveChanges();
         LoadingTable ld = new LoadingTable();
         dataGridView1.DataSource = ld.datlichkham();
     }
 }
예제 #3
0
 private void guna2Button2_Click(object sender, EventArgs e)
 {
     using (var context = new YTeDbContext())
     {
         var oldconnguoi = context.ConNguois.Where(s => s.SoDienThoai == c).FirstOrDefault();
         var oldpeople   = context.DatLichKhams.Where(s => s.ID_Nguoi == oldconnguoi.ID_Nguoi).FirstOrDefault();
         {
             oldpeople.LyDoKham = textboxLyDoKham.Text;
             // oldpeople.ThoiGianHenKham = guna2DateTimePicker1.Value.ToString();
             oldconnguoi.HoTen       = textboxHoTen.Text;
             oldconnguoi.SoCMND      = textboxCMND.Text;
             oldconnguoi.SoDienThoai = textboxSDT.Text;
             oldconnguoi.DiaChi      = textboxDiaChi.Text;
             oldconnguoi.Email       = textboxEmail.Text;
         }
         context.SaveChanges();
         LoadingTable ld = new LoadingTable();
         dataGridView1.DataSource = ld.datlichkham();
         MessageBox.Show(oldconnguoi.DiaChi);
         MessageBox.Show(oldpeople.LyDoKham);
         MessageBox.Show(oldpeople.ID_Nguoi + "  " + oldconnguoi.ID_Nguoi);
     }
 }