private void btnThem_Click(object sender, EventArgs e) { if (txtTenNV.Text == "" || txtSDT.Text == "" || txtLuong.Text == "" || txtLuong.Text == "") { MessageBox.Show("Chưa nhập đủ thông tin"); return; } using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { NHANVIEN nv = new NHANVIEN(); if (String.IsNullOrEmpty(txtTK.Text) == false) { TAIKHOAN tk = new TAIKHOAN(); tk.TENTK = txtTK.Text; tk.MK = "1"; db.TAIKHOANs.Add(tk); db.SaveChanges(); } int matk = int.Parse(db.laymatk().FirstOrDefault().ToString()); nv.TENNV = txtTenNV.Text; nv.SDT = txtSDT.Text; nv.LUONG = decimal.Parse(txtLuong.Text); nv.GMAIL = txtGmail.Text; nv.MATK = matk; nv.MACV = int.Parse(cbChucVu.SelectedValue.ToString()); db.NHANVIENs.Add(nv); db.SaveChanges(); } loadDL(); }
void loadDL() { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { var ds_nvbh = from c in db.NHANVIENs where c.MACV == 5 select c; cbTenNV.DataSource = ds_nvbh.ToList(); cbTenNV.DisplayMember = "TENNV"; cbTenNV.ValueMember = "MANV"; List <DANHSACHHOADON_Result> ds_hd = db.DANHSACHHOADON().ToList(); DataTable dt = new DataTable(); dt.Columns.Add("mahd"); dt.Columns.Add("ngayhd"); dt.Columns.Add("tongtien"); dt.Columns.Add("tennv"); dt.Columns.Add("makh"); foreach (DANHSACHHOADON_Result item in ds_hd) { DateTime ngayhd = (DateTime)item.NGAYHD; dt.Rows.Add(item.MAHD, ngayhd.ToString("yyyy-MM-dd"), item.TONGTIEN, item.TENNV, item.MAKH); } dgvHoaDon.DataSource = dt; } }
void loadDL() { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { cbLoaiSP.DataSource = db.LOAISPs.ToList(); cbLoaiSP.DisplayMember = "TENLOAI"; cbLoaiSP.ValueMember = "MALOAI"; List <DGVHANGHOA_Result> ds_hanghoa = db.DGVHANGHOA().ToList(); DataTable dt = new DataTable(); dt.Columns.Add("mahang"); dt.Columns.Add("tenhang"); dt.Columns.Add("hsd"); dt.Columns.Add("donvitinh"); dt.Columns.Add("soluong"); dt.Columns.Add("loaihang"); dt.Columns.Add("hinh"); dt.Columns.Add("giaban"); foreach (DGVHANGHOA_Result item in ds_hanghoa) { DateTime hsd = (DateTime)item.HSD; dt.Rows.Add(item.MAHANG, item.TENHANG, hsd.ToString("yyyy-MM-dd"), item.DONVITINH, item.SOLUONG, item.TENLOAI, item.Hinh, item.GIABAN); } dgvHangHoa.DataSource = dt; } }
private void dgvHangHoa_CellClick(object sender, DataGridViewCellEventArgs e) { txtMaHang.Text = dgvHangHoa.CurrentRow.Cells["mahang"].Value.ToString(); txtTenhang.Text = dgvHangHoa.CurrentRow.Cells["tenhang"].Value.ToString(); txtSL.Text = dgvHangHoa.CurrentRow.Cells["soluong"].Value.ToString(); txtHSD.Text = dgvHangHoa.CurrentRow.Cells["hsd"].Value.ToString(); txtGiaBan.Text = dgvHangHoa.CurrentRow.Cells["giaban"].Value.ToString(); txtDVT.Text = dgvHangHoa.CurrentRow.Cells["donvitinh"].Value.ToString(); cbLoaiSP.Text = dgvHangHoa.CurrentRow.Cells["loaihang"].Value.ToString(); using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { DGVHANGHOA_Result s = db.DGVHANGHOA().Where(p => p.MAHANG == int.Parse(txtMaHang.Text)).FirstOrDefault(); if (s == null || s.Hinh == null) { picSP.Image = null; } else { MemoryStream stream = new MemoryStream(s.Hinh.ToArray()); Image im = Image.FromStream(stream); if (im == null) { return; } else { picSP.Image = im; } } } }
private void guna2TextBox1_KeyDown(object sender, KeyEventArgs e) { if (txtSearch.Text == "") { loadDL(); } using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { List <DGVHANGHOA_Result> ds_hanghoa = db.DGVHANGHOA().Where(p => RemoveUnicode(p.TENHANG.ToLower()).Contains(RemoveUnicode(txtSearch.Text.ToLower()))).ToList(); DataTable dt = new DataTable(); dt.Columns.Add("mahang"); dt.Columns.Add("tenhang"); dt.Columns.Add("hsd"); dt.Columns.Add("donvitinh"); dt.Columns.Add("soluong"); dt.Columns.Add("loaihang"); dt.Columns.Add("hinh"); dt.Columns.Add("giaban"); foreach (DGVHANGHOA_Result item in ds_hanghoa) { DateTime hsd = (DateTime)item.HSD; dt.Rows.Add(item.MAHANG, item.TENHANG, hsd.ToString("yyyy-MM-dd"), item.DONVITINH, item.SOLUONG, item.TENLOAI, item.Hinh, item.GIABAN); } dgvHangHoa.DataSource = dt; } }
private void btnThem_Click(object sender, EventArgs e) { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { HOADON hd = new HOADON(); DateTime ngayhd = DateTime.Now; hd.NGAYHD = DateTime.Parse(ngayhd.ToString("yyyy-MM-dd")); hd.MANV = int.Parse(cbTenNV.SelectedValue.ToString()); if (db.KHACHHANGs.Where(p => p.SDT == txtSDT.Text).FirstOrDefault() != null) { int makh = db.KHACHHANGs.Where(p => p.SDT == txtSDT.Text).FirstOrDefault().MAKH; hd.MAKH = makh; } hd.TONGTIEN = 0; db.HOADONs.Add(hd); db.SaveChanges(); foreach (ListViewItem item in lvSP.Items) { if (item.Checked) { string tenhang = item.SubItems[0].Text.ToString(); int mahang = db.danhsachhanghoa().Where(p => p.TENHANG.Contains(tenhang)).FirstOrDefault().MAHANG; CTHOADON cthd = new CTHOADON(); cthd.MAHANG = mahang; cthd.SLBAN = int.Parse(item.SubItems[4].Text); cthd.MAHD = int.Parse(db.LAYMAHD().FirstOrDefault().ToString()); db.CTHOADONs.Add(cthd); db.SaveChanges(); } } MessageBox.Show("Thêm hoá đơn thành công"); } }
private void txtTenSP_KeyDown(object sender, KeyEventArgs e) { if (txtTenSP.Text == "") { loadDL(); } lvSP.Items.Clear(); using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { List <danhsachhanghoa_Result> ds_hh = db.danhsachhanghoa().ToList(); foreach (danhsachhanghoa_Result item in ds_hh) { if (RemoveUnicode(item.TENHANG.ToLower()).Contains(RemoveUnicode(txtTenSP.Text.ToLower()))) { ListViewItem it = new ListViewItem(); it.Text = item.TENHANG.ToString(); DateTime hsd = (DateTime)item.HSD; it.SubItems.Add(hsd.ToString("yyyy-MM-dd")); it.SubItems.Add(item.DONVITINH.ToString()); it.SubItems.Add(((int)item.GIABAN) + " VND"); it.SubItems.Add(" "); lvSP.Items.Add(it); } } } }
private void frm_GuiMailNCC_Load(object sender, EventArgs e) { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { cbNCC.DataSource = db.NHACUNGCAPs.ToList(); cbNCC.DisplayMember = "TENNCC"; cbNCC.ValueMember = "GMAIL"; } }
private void frm_InHoaDon_Load(object sender, EventArgs e) { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { rpt_Hoadon1BindingSource.DataSource = db.rpt_Hoadon_final().ToList(); //reportViewer1.LocalReport.DataSources = } this.reportViewer1.RefreshReport(); }
private void btnXoa_Click(object sender, EventArgs e) { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { KHACHHANG kh = db.KHACHHANGs.Where(p => p.MAKH.ToString() == txtMaKH.Text).FirstOrDefault(); db.KHACHHANGs.Remove(kh); db.SaveChanges(); } loadDL(); }
private void btnXoa_Click(object sender, EventArgs e) { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { NHACUNGCAP ncc = db.NHACUNGCAPs.Where(p => p.MANCC.ToString() == txtMaNCC.Text).FirstOrDefault(); db.NHACUNGCAPs.Remove(ncc); db.SaveChanges(); } loadDL(); }
private void btnSua_Click(object sender, EventArgs e) { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { NHACUNGCAP ncc = db.NHACUNGCAPs.Where(p => p.MANCC.ToString() == txtMaNCC.Text).FirstOrDefault(); ncc.TENNCC = txtTenNCC.Text; ncc.SDT = txtSDT.Text; ncc.GMAIL = txtGmail.Text; ncc.DIACHI = txtDiaChi.Text; db.SaveChanges(); } loadDL(); }
private void btnSua_Click(object sender, EventArgs e) { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { KHACHHANG kh = db.KHACHHANGs.Where(p => p.MAKH.ToString() == txtMaKH.Text).FirstOrDefault(); kh.TENKH = txtTenKH.Text; kh.SDT = txtSDT.Text; kh.DIEMTICHLUY = int.Parse(txtDiemTichLuy.Text); db.SaveChanges(); } loadDL(); reset(); }
private void btnThem_Click(object sender, EventArgs e) { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { NHACUNGCAP ncc = new NHACUNGCAP(); ncc.TENNCC = txtTenNCC.Text; ncc.SDT = txtSDT.Text; ncc.GMAIL = txtGmail.Text; ncc.DIACHI = txtDiaChi.Text; db.NHACUNGCAPs.Add(ncc); db.SaveChanges(); } loadDL(); }
private void btnTimKiem_Click(object sender, EventArgs e) { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { if (db.KHACHHANGs.Where(p => p.SDT == txtSDT.Text).FirstOrDefault() != null) { string tenkh = db.KHACHHANGs.Where(p => p.SDT == txtSDT.Text).FirstOrDefault().TENKH; MessageBox.Show(tenkh); } else { MessageBox.Show("Không có khách hàng này"); } } }
private void btnXoa_Click(object sender, EventArgs e) { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { if (txtMaNV.Text == "") { MessageBox.Show("Chưa chọn thông tin"); return; } NHANVIEN nv = db.NHANVIENs.Where(p => p.MANV.ToString() == txtMaNV.Text).FirstOrDefault(); db.NHANVIENs.Remove(nv); db.SaveChanges(); } loadDL(); }
public frm_NhapHang() { InitializeComponent(); using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { cbLoaiSP.DataSource = db.LOAISPs.ToList(); cbLoaiSP.DisplayMember = "TENLOAI"; cbLoaiSP.ValueMember = "MALOAI"; cbNCC.DataSource = db.NHACUNGCAPs.ToList(); cbNCC.DisplayMember = "TENNCC"; cbNCC.ValueMember = "MANCC"; string macv = db.CHUCVUs.Where(p => p.TENCV == "Quản lý hàng").FirstOrDefault().MACV.ToString(); cbNV.DataSource = db.NHANVIENs.Where(c => c.MACV.ToString() == macv).ToList(); cbNV.DisplayMember = "TENNV"; cbNV.ValueMember = "MANV"; } }
void loadDL() { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { List <KHACHHANG> ds_kh = db.KHACHHANGs.ToList(); DataTable dt = new DataTable(); dt.Columns.Add("makh"); dt.Columns.Add("tenkh"); dt.Columns.Add("sdt"); dt.Columns.Add("diemtichluy"); foreach (KHACHHANG item in ds_kh) { dt.Rows.Add(item.MAKH, item.TENKH, item.SDT, item.DIEMTICHLUY); } dgvDSKH.DataSource = dt; } }
private void guna2Button1_Click(object sender, EventArgs e) { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { TAIKHOAN tk = db.TAIKHOANs.Where(p => p.TENTK == txtUser.Text && p.MK == txtPass.Text).FirstOrDefault(); if (tk != null) { string manv = db.NHANVIENs.FirstOrDefault(p => p.MATK == tk.MATK).MANV.ToString(); frm_Menu f = new frm_Menu(manv); this.Hide(); f.Visible = true; } else { MessageBox.Show("Nhập sai tài khoản rồi"); } } }
void loadDL() { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { List <NHACUNGCAP> ds_ncc = db.NHACUNGCAPs.ToList(); DataTable dt = new DataTable(); dt.Columns.Add("mancc"); dt.Columns.Add("tenncc"); dt.Columns.Add("sdt"); dt.Columns.Add("diachi"); dt.Columns.Add("gmail"); foreach (NHACUNGCAP item in ds_ncc) { dt.Rows.Add(item.MANCC, item.TENNCC, item.SDT, item.DIACHI, item.GMAIL); } dgvDSNCC.DataSource = dt; } }
private void btnGui_Click(object sender, EventArgs e) { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { if (string.IsNullOrEmpty(txtMaXN.Text)) { if (db.NHANVIENs.Where(p => p.GMAIL == txtGmail.Text).FirstOrDefault() != null) { String txttendangnhap = "*****@*****.**"; String txtmk = "123456cuahang"; string email = txtGmail.Text; maxn = randomma.Next(1000, 9999); MailMessage mail = new MailMessage(txttendangnhap, email, "Mã xác nhận", maxn.ToString()); // mail.IsBodyHtml = true; SmtpClient client = new SmtpClient("smtp.gmail.com"); client.Host = "smtp.gmail.com"; client.UseDefaultCredentials = false; client.Port = 587; client.Credentials = new System.Net.NetworkCredential(txttendangnhap, txtmk); client.EnableSsl = true; client.Send(mail); } else { MessageBox.Show("Không có tài khoản này"); return; } } else { if (txtMaXN.Text == maxn.ToString()) { pnDoiMK.Visible = true; } else { MessageBox.Show("Sai mã xác nhận rồi"); txtMaXN.Text = ""; } } } }
private void btnThem_Click(object sender, EventArgs e) { if (Kiemtra() == false) { MessageBox.Show("Chưa nhập đủ thông tin"); return; } using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { byte[] img = null; FileStream fs = new FileStream(imgSP, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); img = br.ReadBytes((int)fs.Length); HANGHOA hh = new HANGHOA(); PHIEUNHAP pn = new PHIEUNHAP(); CTPHIEUNHAP ctpn = new CTPHIEUNHAP(); hh.TENHANG = txtTenhang.Text; hh.HSD = DateTime.Parse(txtHSD.Text); hh.Hinh = img; hh.MALOAI = int.Parse(cbLoaiSP.SelectedValue.ToString()); hh.DONVITINH = txtDVT.Text; hh.SOLUONG = 0; hh.GIABAN = 0; db.HANGHOAs.Add(hh); pn.MANCC = int.Parse(cbNCC.SelectedValue.ToString()); pn.MANV = int.Parse(cbNV.SelectedValue.ToString()); DateTime ngaynhap = DateTime.Now; pn.NGAYNHAP = DateTime.Parse(ngaynhap.ToString("yyyy-MM-dd")); db.PHIEUNHAPs.Add(pn); db.SaveChanges(); string mapn = db.LAYMAPN().FirstOrDefault().ToString(); string mahang = db.LAYMAHANG().FirstOrDefault().ToString(); ctpn.MAHANG = int.Parse(mahang); ctpn.MAPN = int.Parse(mapn); ctpn.GIANHAP = decimal.Parse(txtGiaNhap.Text); ctpn.SLNHAP = int.Parse(txtSL.Text); db.CTPHIEUNHAPs.Add(ctpn); db.SaveChanges(); } MessageBox.Show("Thêm thành công"); this.Hide(); }
private void btnSua_Click(object sender, EventArgs e) { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { if (txtMaNV.Text == "") { MessageBox.Show("Chưa chọn thông tin"); return; } NHANVIEN nv = db.NHANVIENs.Where(p => p.MANV.ToString() == txtMaNV.Text).FirstOrDefault(); nv.TENNV = txtTenNV.Text; nv.SDT = txtSDT.Text; nv.LUONG = decimal.Parse(txtLuong.Text); nv.GMAIL = txtGmail.Text; db.SaveChanges(); } loadDL(); }
private void btnThem_Click(object sender, EventArgs e) { if (kiemtra() == false) { MessageBox.Show("Chưa nhập đủ thông tin"); return; } using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { KHACHHANG kh = new KHACHHANG(); kh.TENKH = txtTenKH.Text; kh.SDT = txtSDT.Text; kh.DIEMTICHLUY = 0; db.KHACHHANGs.Add(kh); db.SaveChanges(); } loadDL(); reset(); }
void loadDL() { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { chSLBANnam.DataSource = db.SLHH_Nam1().ToList(); chSLBANnam.Series["Số lượng"].XValueMember = "Thoigian"; chSLBANnam.Series["Số lượng"].YValueMembers = "Soluong"; chSLhethan.DataSource = db.SLHH_hethan1().ToList(); chSLhethan.Series["Số lượng"].XValueMember = "TENHANG"; chSLhethan.Series["Số lượng"].YValueMembers = "Soluong"; chTongTienTrongNam.DataSource = db.TONGTIENTHUDC().ToList(); chTongTienTrongNam.Series["VND"].XValueMember = "thoigian"; chTongTienTrongNam.Series["VND"].YValueMembers = "tongtien"; lbDoanhThu.Text = db.Doanhthu().FirstOrDefault().ToString(); lbSLBan.Text = db.SLbanduoc_TK().FirstOrDefault().ToString(); lbSLHETHAN.Text = db.SLhethan_TK().FirstOrDefault().ToString(); lbSLNHAP.Text = db.SLNhap_TK().FirstOrDefault().soluongnhap.ToString(); lbThoiGian.Text = db.SLNhap_TK().FirstOrDefault().thoigian.ToString(); } }
private void guna2Button3_Click(object sender, EventArgs e) { if (txtPasswordMoi.Text == "" || txtPasswordMoi2.Text == "") { MessageBox.Show("Chưa nhập đủ"); return; } if (txtPasswordMoi.Text != txtPasswordMoi2.Text) { MessageBox.Show("Mật khẩu không trùng nhau"); return; } using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { string matk = db.NHANVIENs.Where(p => p.GMAIL == txtGmail.Text).FirstOrDefault().MATK.ToString(); TAIKHOAN tk = db.TAIKHOANs.Where(p => p.MATK.ToString() == matk.ToString()).FirstOrDefault(); tk.MK = txtPasswordMoi2.Text; db.SaveChanges(); } pnDoiMK.Visible = false; pnQuenMK.Visible = false; }
private void btnSua_Click(object sender, EventArgs e) { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { byte[] img = null; FileStream fs = new FileStream(imgSP, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); img = br.ReadBytes((int)fs.Length); HANGHOA hh = db.HANGHOAs.FirstOrDefault(p => p.MAHANG.ToString() == txtMaHang.Text); CTPHIEUNHAP ctpn = db.CTPHIEUNHAPs.FirstOrDefault(p => p.MAHANG.ToString() == txtMaHang.Text); hh.TENHANG = txtTenhang.Text; ctpn.SLNHAP = int.Parse(txtSL.Text); hh.HSD = DateTime.Parse(txtHSD.Text); hh.Hinh = img; hh.MALOAI = int.Parse(cbLoaiSP.SelectedValue.ToString()); hh.DONVITINH = txtDVT.Text; hh.GIABAN = decimal.Parse(txtGiaBan.Text); db.SaveChanges(); } MessageBox.Show("Sửa thành công", "Thông báo"); loadDL(); }
void loadDL() { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { List <DANHSACHNV_Result> ds_nv = db.DANHSACHNV().ToList(); DataTable dt = new DataTable(); dt.Columns.Add("manv"); dt.Columns.Add("tennv"); dt.Columns.Add("gmail"); dt.Columns.Add("sdt"); dt.Columns.Add("luong"); dt.Columns.Add("chucvu"); dt.Columns.Add("taikhoan"); foreach (DANHSACHNV_Result item in ds_nv) { dt.Rows.Add(item.MANV, item.TENNV, item.GMAIL, item.SDT, item.LUONG, item.TENCV, item.MATK); } dgvDSNV.DataSource = dt; cbChucVu.DataSource = db.CHUCVUs.ToList(); cbChucVu.DisplayMember = "TENCV"; cbChucVu.ValueMember = "MACV"; } }
private void btnTimKiem_Click(object sender, EventArgs e) { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { if (string.IsNullOrEmpty(txtTenKH.Text)) { if (db.HOADONs.Where(p => p.MAHD.ToString() == txtMaHD.Text).FirstOrDefault() != null) { var ds_nvbh = from c in db.DANHSACHHOADON() where c.MAHD.Equals(int.Parse(txtMaHD.Text)) select c; dgvHoaDon.DataSource = ds_nvbh.ToList(); } else { MessageBox.Show("Không tim thấy"); loadDL(); } } else if (string.IsNullOrEmpty(txtMaHD.Text)) { if (db.KHACHHANGs.Where(p => p.TENKH.Contains(txtTenKH.Text)).FirstOrDefault() != null) { var ds_nvbh = from c in db.DANHSACHHOADON() where c.MAKH == db.KHACHHANGs.Where(p => p.TENKH.Contains(txtTenKH.Text)).FirstOrDefault().MAKH select c; dgvHoaDon.DataSource = ds_nvbh.ToList(); } else { MessageBox.Show("Không tim thấy"); loadDL(); } } } }
void loadDL() { using (CUAHANGTIENLOI db = new CUAHANGTIENLOI()) { var ds_nvbh = from c in db.NHANVIENs where c.MACV == 5 select c; cbTenNV.DataSource = ds_nvbh.ToList(); cbTenNV.DisplayMember = "TENNV"; cbTenNV.ValueMember = "MANV"; List <danhsachhanghoa_Result> ds_hh = db.danhsachhanghoa().ToList(); foreach (danhsachhanghoa_Result item in ds_hh) { ListViewItem it = new ListViewItem(); it.Text = item.TENHANG.ToString(); DateTime hsd = (DateTime)item.HSD; it.SubItems.Add(hsd.ToString("yyyy-MM-dd")); it.SubItems.Add(item.DONVITINH.ToString()); it.SubItems.Add(((int)item.GIABAN) + " VND"); it.SubItems.Add(" "); lvSP.Items.Add(it); } } }