private void btnXoaDV_Click(object sender, EventArgs e) { int id = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString()); Model.DichVu dv = db.DichVus.Single(p => p.MaDV == id); db.DichVus.Remove(dv); db.SaveChanges(); DichVu_Load(sender, e); }
private void datphong() { khachhang.TenKH = textBox1.Text; khachhang.CMND = textBox2.Text; khachhang.SDT = textBox7.Text; if (comboBox1.SelectedIndex == 0) { khachhang.GioiTinh = false; } else { khachhang.GioiTinh = true; } khachhang.QuocTich = textBox5.Text; khachhang.Email = textBox6.Text; phieudk.NgayDen = dateTimePicker1.Value; phieudk.NguoiLon = int.Parse(textBox9.Text); phieudk.TreEm = int.Parse(textBox10.Text); phieudk.SoPhong = int.Parse(textBox11.Text); for (int i = 0; i < dataGridView4.Rows.Count; i++) { string v = dataGridView4.Rows[i].Cells[0].Value.ToString().TrimEnd(); dichvuchon = db.DichVus.SingleOrDefault(p => p.TenDV == v); dichvu.Add(dichvuchon); } phieudk.DichVus = dichvu; for (int i = 0; i < dataGridView2.Rows.Count; i++) { string n = dataGridView2.Rows[i].Cells[0].Value.ToString().TrimEnd(); phong = db.Phongs.SingleOrDefault(p => p.TenPhong == n); phong.TrangThai = true; listphong.Add(phong); } phieudk.Phongs = listphong; if (int.TryParse(txtDatTruoc.Text, out int a)) { phieudk.TraTruoc = a; } else { MessageBox.Show("Xin nhập số vào ô trả trước!"); } phieudk.ChuThich = textBox12.Text; db.KhachHangs.Add(khachhang); db.SaveChanges(); var makh = db.KhachHangs.SingleOrDefault(p => p.TenKH == textBox1.Text); phieudk.KhachHang = makh; db.MaPhieuDKs.Add(phieudk); db.SaveChanges(); MessageBox.Show("Luu thanh cong!"); huydatphong(); }
private void btnThemDV_Click(object sender, EventArgs e) { int GiaDV; if (!int.TryParse(textBox2.Text, out GiaDV)) { MessageBox.Show("Giá dịch vụ là số!"); return; } string TenDV = textBox1.Text; if (TenDV == "") { MessageBox.Show("Nhap lai ten dich vu!"); return; } Model.DichVu dv = new Model.DichVu(); dv.TenDV = TenDV; dv.GiaDV = GiaDV; db.DichVus.Add(dv); db.SaveChanges(); DichVu_Load(sender, e); }