private void btThem_Click(object sender, EventArgs e) { HopDong hopdong = new HopDong(); hopdong.MaHD = txtSoDH.Text; hopdong.idXe = (int)cbbSoXe.SelectedValue; hopdong.idNV = (int)cbbMaNV.SelectedValue; hopdong.idKH = (int)cbbMaKH.SelectedValue; hopdong.NgayHD = DateTime.Parse(msktbNgayHD.Text.ToString()); hopdong.TienDat = txtTienDat.Text; hopdong.KhuyenMai = txtKhuyenMai.Text; hopdong.NoiDungHD = txtNoiDungHD.Text; hopdong.GiayToGiuLai = txtGiayTo.Text; if (HopDongController.AddHopDong(hopdong)) { XtraMessageBox.Show("Nhập thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("Nhập không thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } CNPMEntities context = new CNPMEntities(); List <HopDong> lstHopDong = context.HopDongs.ToList(); BindGrid(lstHopDong); }
private void ThongTinLoaiXe_Load(object sender, EventArgs e) { CNPMEntities context = new CNPMEntities(); List <LoaiXe> listLoaiXe = context.LoaiXes.ToList(); BindGrid(listLoaiXe); }
private void KhachHang_Load(object sender, EventArgs e) { CNPMEntities context = new CNPMEntities(); List <KhachHang> listKhachHang = context.KhachHangs.ToList(); BindGrid(listKhachHang); }
private void HopDongThueXe_Load(object sender, EventArgs e) { using (CNPMEntities db = new CNPMEntities()) { var getnv = (from nv in db.NhanViens select nv).ToList(); var getkh = (from kh in db.KhachHangs select kh).ToList(); var xe = (from x in db.Xes select x).ToList(); this.cbbMaNV.DataSource = getnv; this.cbbMaNV.ValueMember = "idNV"; this.cbbMaNV.DisplayMember = "MaNV"; this.cbbMaKH.DataSource = getkh; this.cbbMaKH.ValueMember = "idKH"; this.cbbMaKH.DisplayMember = "MaKH"; this.cbbSoXe.DataSource = xe; this.cbbSoXe.ValueMember = "idXe"; this.cbbSoXe.DisplayMember = "Biensoxe"; } CNPMEntities context = new CNPMEntities(); List <HopDong> lstHopDong = context.HopDongs.ToList(); BindGrid(lstHopDong); }
private void btThem_Click(object sender, EventArgs e) { NhanVien nhanvien = new NhanVien(); nhanvien.MaNV = txtMaNV.Text; nhanvien.TenNV = txtTenNV.Text; nhanvien.VaiTro = txtVaiTro.Text; nhanvien.sdtNV = txtSDT.Text; nhanvien.cmtNV = txtCMT.Text; if (NhanVienController.AddNhanVien(nhanvien)) { XtraMessageBox.Show("Thêm nhân viên thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("Thêm nhân viên thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } CNPMEntities context = new CNPMEntities(); List <NhanVien> listNhanVien = context.NhanViens.ToList(); BindGrid(listNhanVien); }
private void NhanVien_Load(object sender, EventArgs e) { CNPMEntities context = new CNPMEntities(); List <NhanVien> listNhanVien = context.NhanViens.ToList(); BindGrid(listNhanVien); }
private void btSua_Click(object sender, EventArgs e) { using (CNPMEntities db = new CNPMEntities()) { var xe = (from x in db.Xes where x.Biensoxe == GetBSX select x).FirstOrDefault(); xe.Biensoxe = txtBSX.Text; xe.idLoaiXe = (int)cbbLoaiXe.SelectedValue; xe.TenXe = txtTenXe.Text; xe.PhiXang = txtPhiXang.Text; xe.PhiQuaKm = txtPhiQuaKm.Text; xe.DonGia = txtDonGia.Text; xe.MoTaTT = txtMoTaTT.Text; xe.TrangThai = int.Parse(txtTrangThai.Text); db.SaveChanges(); MessageBox.Show("Edit success", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } GetBSX = null; CNPMEntities context = new CNPMEntities(); List <Xe> xes = context.Xes.ToList(); BindGrid(xes); }
private void btThem_Click(object sender, EventArgs e) { Xe xe = new Xe(); xe.Biensoxe = txtBSX.Text; xe.idLoaiXe = (int)cbbLoaiXe.SelectedValue; xe.TenXe = txtTenXe.Text; xe.PhiXang = txtPhiXang.Text; xe.PhiQuaKm = txtPhiQuaKm.Text; xe.DonGia = txtDonGia.Text; xe.MoTaTT = txtMoTaTT.Text; xe.TrangThai = int.Parse(txtTrangThai.Text); if (XeController.AddXe(xe)) { XtraMessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("Thêm thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } CNPMEntities context = new CNPMEntities(); List <Xe> listXe = context.Xes.ToList(); BindGrid(listXe); }
private void ThongTinBBGN_Load(object sender, EventArgs e) { using (CNPMEntities db = new CNPMEntities()) { var getxe = (from xe in db.Xes select xe).ToList(); var getkh = (from kh in db.KhachHangs select kh).ToList(); var getnv = (from nv in db.NhanViens select nv).ToList(); this.cbbSoXe.DataSource = getxe; this.cbbSoXe.ValueMember = "idXe"; this.cbbSoXe.DisplayMember = "Biensoxe"; this.cbbMaKH.DataSource = getkh; this.cbbMaKH.ValueMember = "idKH"; this.cbbMaKH.DisplayMember = "MaKH"; this.cbbMaNV.DataSource = getnv; this.cbbMaNV.ValueMember = "idNV"; this.cbbMaNV.DisplayMember = "MaNV"; } CNPMEntities context = new CNPMEntities(); List <BBGN> lstBBGn = context.BBGNs.ToList(); BindGrid(lstBBGn); }
private void btThem_Click(object sender, EventArgs e) { BBGN bbgn = new BBGN(); bbgn.MaBBGN = txtMaBBGN.Text; bbgn.NgayGiao = DateTime.Parse(mskNgayGiao.Text.ToString()); bbgn.idXe = (int)cbbSoXe.SelectedValue; bbgn.idKH = (int)cbbMaKH.SelectedValue; bbgn.idNV = (int)cbbMaNV.SelectedValue; bbgn.KmDi = int.Parse(txtKmDi.Text); bbgn.XangDi = txtXangDi.Text; bbgn.TrangThaiDi = txtTTDi.Text; bbgn.NgayNhan = DateTime.Parse(mskNgayNhan.Text.ToString()); bbgn.KmVe = int.Parse(txtKmVe.Text); bbgn.XangVe = txtXangVe.Text; bbgn.TrangThaiVe = txtTTVe.Text; if (BBGNController.AddBBGN(bbgn)) { XtraMessageBox.Show("Nhập thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("Nhập không thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } CNPMEntities context = new CNPMEntities(); List <BBGN> lstBBGn = context.BBGNs.ToList(); BindGrid(lstBBGn); }
private void btSua_Click(object sender, EventArgs e) { using (CNPMEntities db = new CNPMEntities()) { var bbgn = (from bb in db.BBGNs where bb.MaBBGN == GetMaBBGN select bb).FirstOrDefault(); bbgn.MaBBGN = txtMaBBGN.Text; bbgn.NgayGiao = DateTime.Parse(mskNgayGiao.Text.ToString()); bbgn.idXe = (int)cbbSoXe.SelectedValue; bbgn.idKH = (int)cbbMaKH.SelectedValue; bbgn.idNV = (int)cbbMaNV.SelectedValue; bbgn.KmDi = int.Parse(txtKmDi.Text); bbgn.XangDi = txtXangDi.Text; bbgn.TrangThaiDi = txtTTDi.Text; bbgn.NgayNhan = DateTime.Parse(mskNgayNhan.Text.ToString()); bbgn.KmVe = int.Parse(txtKmVe.Text); bbgn.XangVe = txtXangVe.Text; bbgn.TrangThaiVe = txtTTVe.Text; db.SaveChanges(); XtraMessageBox.Show("Edit success", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } GetMaBBGN = null; CNPMEntities context = new CNPMEntities(); List <BBGN> lstBBGn = context.BBGNs.ToList(); BindGrid(lstBBGn); }
//private void BindGrid(List<HopDong> listHopDong) //{ // //dgvHD.Rows.Clear(); // //foreach (var item in listHopDong) // //{ // // int index = dgvHD.Rows.Add(); // // dgvHD.Rows[index].Cells[0].Value = item.idHopDong; // // dgvHD.Rows[index].Cells[1].Value = item.; // // dgvHD.Rows[index].Cells[2].Value = item. // // dgvHD.Rows[index].Cells[3].Value = item.MaKH; // // dgvHD.Rows[index].Cells[4].Value = item.NgayHD; // // dgvHD.Rows[index].Cells[5].Value = item.TienDat; // // dgvHD.Rows[index].Cells[6].Value = item.KhuyenMai; // // dgvHD.Rows[index].Cells[7].Value = item.NoiDungHD; // // dgvHD.Rows[index].Cells[8].Value = item.GiayToGiuLai; // //} //} //private void FillMaKHCombobox(List<KhachHang> listKhachHang) //{ // this.cbbMaKH.DataSource = listKhachHang; // this.cbbMaKH.DisplayMember = "MaKH"; //} //private void FillMaNVCombobox(List<NhanVien> listNHANVIENs) //{ // this.cbbMaNV.DataSource = listNHANVIENs; // this.cbbMaNV.DisplayMember = "MaNV"; //} //private void FillSoXeCombobox(List<Xe> listXE) //{ // this.cbbSoXe.DataSource = listXE; // this.cbbSoXe.DisplayMember = "SoXe"; //} private void BindGrid(List <HopDong> lstHopDong) { dgvHD.Rows.Clear(); int i = 0; foreach (var item in lstHopDong) { using (CNPMEntities db = new CNPMEntities()) { var getnv = (from hd in db.HopDongs join nv in db.NhanViens on hd.idNV equals nv.idNV select nv).ToList(); var getkh = (from hd in db.HopDongs join kh in db.KhachHangs on hd.idKH equals kh.idKH select kh).ToList(); var xe = (from hd in db.HopDongs join x in db.Xes on hd.idXe equals x.idXe select x).ToList(); int index = dgvHD.Rows.Add(); dgvHD.Rows[index].Cells[0].Value = item.MaHD; dgvHD.Rows[index].Cells[1].Value = xe[i].Biensoxe; dgvHD.Rows[index].Cells[2].Value = getnv[i].MaNV; dgvHD.Rows[index].Cells[3].Value = getkh[i].MaKH; dgvHD.Rows[index].Cells[4].Value = item.NgayHD; dgvHD.Rows[index].Cells[5].Value = item.TienDat; dgvHD.Rows[index].Cells[6].Value = item.KhuyenMai; dgvHD.Rows[index].Cells[7].Value = item.NoiDungHD; dgvHD.Rows[index].Cells[8].Value = item.GiayToGiuLai; i++; } } }
private void NguoiDung_Load(object sender, EventArgs e) { CNPMEntities context = new CNPMEntities(); List <Account> accounts = context.Accounts.ToList(); BindGrid(accounts); }
private void btSua_Click(object sender, EventArgs e) { using (CNPMEntities db = new CNPMEntities()) { var dbhd = (from hd in db.HopDongs where hd.MaHD == GetMaHD select hd).FirstOrDefault(); dbhd.MaHD = txtSoDH.Text.ToString(); dbhd.idXe = (int)cbbSoXe.SelectedValue; dbhd.idNV = (int)cbbMaNV.SelectedValue; dbhd.idKH = (int)cbbMaKH.SelectedValue; dbhd.NgayHD = DateTime.Parse(msktbNgayHD.Text.ToString()); dbhd.TienDat = txtTienDat.Text; dbhd.KhuyenMai = txtKhuyenMai.Text.ToString(); dbhd.NoiDungHD = txtNoiDungHD.Text.ToString(); dbhd.GiayToGiuLai = txtGiayTo.Text.ToString(); db.SaveChanges(); XtraMessageBox.Show("Edit success", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } GetMaHD = null; CNPMEntities context = new CNPMEntities(); List <HopDong> lstHopDong = context.HopDongs.ToList(); BindGrid(lstHopDong); }
public static bool AddLoaiXe(LoaiXe loaixe) { using (var _context = new CNPMEntities()) { _context.LoaiXes.Add(loaixe); _context.SaveChanges(); return(true); } }
public static bool AddBBGN(BBGN bbgn) { using (var _context = new CNPMEntities()) { _context.BBGNs.Add(bbgn); _context.SaveChanges(); return(true); } }
public static bool AddHopDong(HopDong hopdong) { using (var _context = new CNPMEntities()) { _context.HopDongs.Add(hopdong); _context.SaveChanges(); return(true); } }
public static bool AddAccount(Account a) { using (var _context = new CNPMEntities()) { _context.Accounts.Add(a); _context.SaveChanges(); return(true); } }
public static bool AddNhanVien(NhanVien nhanvien) { using (var _context = new CNPMEntities()) { _context.NhanViens.Add(nhanvien); _context.SaveChanges(); return(true); } }
public static bool AddKhachHang(KhachHang khachhang) { using (var _context = new CNPMEntities()) { _context.KhachHangs.Add(khachhang); _context.SaveChanges(); return(true); } }
public static bool AddXe(Xe xe) { using (var _context = new CNPMEntities()) { _context.Xes.Add(xe); _context.SaveChanges(); return(true); } }
private void btThem_Click(object sender, EventArgs e) { DangKy f = new DangKy(); f.Show(); CNPMEntities context = new CNPMEntities(); List <Account> accounts = context.Accounts.ToList(); BindGrid(accounts); }
public static bool RemoveAccount(string a) { using (CNPMEntities _context = new CNPMEntities()) { var getaccount = (from ac in _context.Accounts where ac.TaiKhoan == a select ac).FirstOrDefault(); _context.Accounts.Remove(getaccount); _context.SaveChanges(); return(true); } }
public static bool RemoveNhanVien(string MaNV) { using (CNPMEntities _context = new CNPMEntities()) { var dbnv = (from nv in _context.NhanViens where nv.MaNV == MaNV select nv).FirstOrDefault(); _context.NhanViens.Remove(dbnv); _context.SaveChanges(); return(true); } }
public static bool RemoveKhachHang(string MaKH) { using (CNPMEntities _context = new CNPMEntities()) { var dbkh = (from kh in _context.KhachHangs where kh.MaKH == MaKH select kh).FirstOrDefault(); _context.KhachHangs.Remove(dbkh); _context.SaveChanges(); return(true); } }
public static bool RemoveHopDong(string MaHD) { using (CNPMEntities _context = new CNPMEntities()) { var dbhd = (from hd in _context.HopDongs where hd.MaHD == MaHD select hd).FirstOrDefault(); _context.HopDongs.Remove(dbhd); _context.SaveChanges(); return(true); } }
public static bool RemoveXe(string BSX) { using (CNPMEntities _context = new CNPMEntities()) { var dbxe = (from xe in _context.Xes where xe.Biensoxe == BSX select xe).FirstOrDefault(); _context.Xes.Remove(dbxe); _context.SaveChanges(); return(true); } }
public static bool RemoveLoaiXe(string TenLoai) { using (CNPMEntities _context = new CNPMEntities()) { var dblx = (from lx in _context.LoaiXes where lx.TenLoai == TenLoai select lx).FirstOrDefault(); _context.LoaiXes.Remove(dblx); _context.SaveChanges(); return(true); } }
public static bool RemoveBBGN(string MaBBGN) { using (CNPMEntities _context = new CNPMEntities()) { var dbbbgn = (from bbgn in _context.BBGNs where bbgn.MaBBGN == MaBBGN select bbgn).FirstOrDefault(); _context.BBGNs.Remove(dbbbgn); _context.SaveChanges(); return(true); } }
private void btXoa_Click(object sender, EventArgs e) { if (LoaiXeController.RemoveLoaiXe(GetTenLoai)) { MessageBox.Show("Xóa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Vui lòng chọn loại xe để xóa"); } CNPMEntities context = new CNPMEntities(); List <LoaiXe> listLoaiXe = context.LoaiXes.ToList(); BindGrid(listLoaiXe); }