private void txtSDT_KeyDown(object sender, KeyEventArgs e) { bool dem = false; CuaHangDienTuEntities entities = new CuaHangDienTuEntities(); List <KhachHang> lstKhachHang = entities.KhachHangs.ToList(); if (e.KeyCode == Keys.Enter) { foreach (var kh in lstKhachHang) { if (kh.SDT == Convert.ToInt64(txtSDT.Text)) { txtTenKH.Text = kh.TenKH; dem = true; pnCTHD.Visible = true; entities.HoaDons.Add(new HoaDon { SDT = long.Parse(txtSDT.Text), MaNV = manhanvien, NgayLap = DateTime.Now, }); entities.SaveChanges(); MaHD = entities.HoaDons.ToList().Last().MaHD; LoadData(); //btnThemHD.Enabled = false; } } if (dem == false) { MessageBox.Show("Không tìm thấy khách hàng!"); } } }
private void btnLuu_Click(object sender, EventArgs e) { using (CuaHangDienTuEntities entities = new CuaHangDienTuEntities()) { long input_Id = Convert.ToInt64(txtmanv.Text.Trim()); NhanVien nv = entities.NhanViens.Where(p => p.MaNV == input_Id).FirstOrDefault(); DialogResult dialogResult = MessageBox.Show("Bạn có chắc chăn thực hiện thao tác?", "Thông báo", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { if (nv == null) { entities.NhanViens.Add(new NhanVien { MaNV = input_Id, TenNV = txttennv.Text, ChucVu = cbbChucVu.Text, NgaySinh = dtpngaysinh.Value, GioiTinh = cbbgioitinh.Text, SDT = txtsdt.Text }); entities.SaveChanges(); Reset(); } else { nv.TenNV = txttennv.Text; nv.ChucVu = cbbChucVu.Text; nv.NgaySinh = dtpngaysinh.Value; nv.GioiTinh = cbbgioitinh.Text; entities.SaveChanges(); Reset(); } } else if (dialogResult == DialogResult.No) { Reset(); } } LoadDuLieu(); }
private void btnLap_Click(object sender, EventArgs e) { CuaHangDienTuEntities entities = new CuaHangDienTuEntities(); entities.PhieuBaoHanhs.Add(new PhieuBaoHanh { SDT = long.Parse(txtSDT.Text), MaSP = long.Parse(cbbMaSP.SelectedValue.ToString()), NgayMua = DateTime.Now, NgayHetHan = dtpHetHan.Value }); entities.SaveChanges(); }
private void btnLuu_Click(object sender, EventArgs e) { using (CuaHangDienTuEntities entities = new CuaHangDienTuEntities()) { long input_Id = Convert.ToInt64(txtmancc.Text.Trim()); NhaCungCap ncc = entities.NhaCungCaps.Where(p => p.MaNCC == input_Id).FirstOrDefault(); DialogResult dialogResult = MessageBox.Show("Bạn có chắc chắn thực hiện thao tác?", "Thông báo", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { if (ncc == null) { entities.NhaCungCaps.Add(new NhaCungCap { MaNCC = input_Id, TenNCC = txttenncc.Text, DiaChi = txtdiachi.Text }); entities.SaveChanges(); Reset(); } else { ncc.TenNCC = txttenncc.Text; ncc.DiaChi = txtdiachi.Text; entities.SaveChanges(); Reset(); } } else if (dialogResult == DialogResult.No) { Reset(); } } LoadDuLieu(); }
private void btnLuu_Click(object sender, EventArgs e) { CuaHangDienTuEntities entities = new CuaHangDienTuEntities(); entities.CTPNs.Add(new CTPN { MaPhieuNhap = this.maphieu, MaSP = long.Parse(cbbMaSP.SelectedValue.ToString()), SoLuong = int.Parse(txtSL.Text), GiaNhap = long.Parse(txtGiaNhap.Text), ThanhTien = (long)(int.Parse(txtSL.Text) * long.Parse(txtGiaNhap.Text)) }); entities.SaveChanges(); LoadDuLieu(); }
private void btnLuu_Click(object sender, EventArgs e) { using (CuaHangDienTuEntities entities = new CuaHangDienTuEntities()) { entities.KhachHangs.Add(new KhachHang { SDT = long.Parse(txtSDT.Text), TenKH = txtTen.Text, GioiTinh = cbbGioiTinh.Text, NamSinh = int.Parse(txtNS.Text), CMND = txtcmnd.Text }); entities.SaveChanges(); } }
private void btnPhieuNhap_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Thêm phiếu nhập mới", "Thông báo", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { CuaHangDienTuEntities entities = new CuaHangDienTuEntities(); entities.PhieuNhaps.Add(new PhieuNhap { MaNV = manhanvien, NgayLap = DateTime.Now }); entities.SaveChanges(); UC_NhapHang nh = new UC_NhapHang(entities.PhieuNhaps.ToList().Last().MaPhieuNhap); AddControl(nh); } }
private void btnXoa_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Bạn có chắc chắn muốn xóa?", "Thông báo", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { using (CuaHangDienTuEntities db = new CuaHangDienTuEntities()) { int input_Id = int.Parse(txtmanv.Text.Trim()); db.NhanViens.Remove(db.NhanViens.Where(p => p.MaNV == input_Id).FirstOrDefault()); db.SaveChanges(); Reset(); } } else if (dialogResult == DialogResult.No) { Reset(); } LoadDuLieu(); }