private void iconBtnSearch_Click(object sender, EventArgs e) { ProductDAO1 p = new ProductDAO1(); DBContextSV db = new DBContextSV(Program.connectionString); dataGridViewListProduct.DataSource = db.sanphams.Where(x => x.masp.Contains(txtIDProduct.Text)).ToList(); }
private void updateInventory(string SID, string productID, int amount) { DBContextSV db = new DBContextSV(Program.connectionString); try { var result = db.tonkhoes.Where(x => x.makho == SID && x.masp == productID).FirstOrDefault(); ; if (result != null && result.soluong > amount) { //code update db result.makho = SID; result.masp = productID; result.soluong = result.soluong - amount; db.SaveChanges(); } else { MessageBox.Show("Không đủ số lượng!"); } } catch { MessageBox.Show("Thêm thất bại!"); } }
private void dataGridViewHistory_CellClick(object sender, DataGridViewCellEventArgs e) { myWebBrowser.DocumentCompleted += myWebBrowser_DocumentCompleted; string s = Properties.Resources.invoice; //string html = System.IO.File.ReadAllText(s); DataGridViewRow row = this.dataGridViewHistory.Rows[e.RowIndex]; string mahd = row.Cells["mahd"].Value.ToString(); Console.WriteLine(mahd); DBContextSV db = new DBContextSV(Program.connectionString); hoadon hd = db.hoadons.Find(mahd); s = s.Replace("{{customerName}}", hd.hoten); s = s.Replace("{{customerPhone}}", hd.sdt); s = s.Replace("{{tong}}", hd.tong.ToString()); s = s.Replace("{{mahd}}", hd.mahd); s = s.Replace("{{ngay}}", hd.ngaylap.ToString()); chitiethoadon[] cthd = hd.chitiethoadons.ToArray(); string list = ""; foreach (chitiethoadon chitiethoadon in cthd) { string template = $"<tr><td>{chitiethoadon.sanpham.tensp}</td><td>{chitiethoadon.sanpham.giaban} vnd</td><td>{chitiethoadon.soluong}</td></tr> "; list += template; } s = s.Replace("{{list}}", list); myWebBrowser.DocumentText = s; }
private void txtNameProduct_TextChanged_1(object sender, EventArgs e) { ProductDAO1 p = new ProductDAO1(); DBContextSV db = new DBContextSV(Program.connectionString); dataGridViewListProduct.DataSource = db.sanphams.Where(x => x.tensp.Contains(txtNameProduct.Text)).ToList(); }
private void LoadData() { StorageDAO s = new StorageDAO(); DBContextSV db = new DBContextSV(Program.connectionString); comboBox1.DataSource = db.chinhanhs.Select(x => x.tencn).ToList(); dgvTonKho.DataSource = s.listCustom().ToList(); SetEditingMode(false); }
private void LoadData() { DBContextSV db = new DBContextSV(Program.connectionString); dataGridViewListProduct.DataSource = db.khoes.ToList(); SetEditingMode(false); }
private void LoadListStaff() { DBContextSV db = new DBContextSV(Program.connectionString); dgvListStaff.DataSource = db.nhanviens.ToList(); dgvListStaff.Columns[6].Visible = false; dgvListStaff.Columns[10].Visible = false; dgvListStaff.Columns[11].Visible = false; dgvListStaff.Columns[12].Visible = false; }
private void LoadData() { DBContextSV db = new DBContextSV(Program.connectionString); dataGridViewListProduct.DataSource = db.sanphams.ToList(); dataGridViewListProduct.Columns[6].Visible = false; dataGridViewListProduct.Columns[7].Visible = false; dataGridViewListProduct.Columns[8].Visible = false; dataGridViewListProduct.Columns[9].Visible = false; dataGridViewListProduct.Columns[10].Visible = false; SetEditingMode(false); }
private void LoadHistory() { DBContextSV db = new DBContextSV(Program.connectionString); DateTime time = dtbTime.Value.Date; //data = BillDAO.Instance.History(time); //int n = data.Rows.Count; dataGridViewHistory.DataSource = db.hoadons.Where(x => x.ngaylap.Value == time).ToList(); int TotalValueMoney = 0; int TotalDiscountMoney = 0; int TotalPay = 0; //for (int i = 1; i <= db.hoadons.ToList().Count; i++) //{ // dataGridViewHistory.Rows[i].Cells[0].Value = i.ToString(); //// TotalValueMoney = TotalValueMoney + Int32.Parse(dataGridViewHistory.Rows[i - 1].Cells[5].Value.ToString()); //// TotalDiscountMoney = TotalDiscountMoney + Int32.Parse(dataGridViewHistory.Rows[i - 1].Cells[6].Value.ToString()); // TotalPay = TotalPay + Int32.Parse(dataGridViewHistory.Rows[i - 1].Cells[4].Value.ToString()); //} //lblTotalPay.Text = TotalPay.ToString() + "đ"; }
private void printBtn_Click(object sender, EventArgs e) { myWebBrowser.DocumentCompleted += myWebBrowser_DocumentCompleted; string html = Properties.Resources.inventory; int month = cbMonth.SelectedIndex + 1; int year; if (Int32.TryParse(txtYear.Text, out year)) { if (year < 0 || year > DateTime.Now.Year) { MessageBox.Show("Năm không hợp lệ"); } } else { MessageBox.Show("Năm không hợp lệ"); } DBContextSV db = new DBContextSV(Program.connectionString); phieunhap[] pnList = db.phieunhaps.Where(pn => pn.ngaynhap.Value.Month == month && pn.ngaynhap.Value.Year == year).ToArray(); string list = ""; int tong = 0; foreach (phieunhap pn in pnList) { tong += pn.tong; foreach (chitietphieunhap ctpn in pn.chitietphieunhaps) { string template = $"<tr><td>{ctpn.sanpham.tensp}</td><td>{ctpn.gianhap} vnd</td><td>{ctpn.soluong}</td><td>{pn.ngaynhap}</td></tr> "; list += template; } } html = html.Replace("{{list}}", list).Replace("{{month}}", month.ToString()).Replace("{{tong}}", tong.ToString()).Replace("{{year}}", year.ToString()); myWebBrowser.DocumentText = html; }
private void printBtn_Click(object sender, EventArgs e) { myWebBrowser.DocumentCompleted += myWebBrowser_DocumentCompleted; string html = Properties.Resources.invoicelist; int month = cbMonth.SelectedIndex + 1; int year; if (Int32.TryParse(txtYear.Text, out year)) { if (year < 0 || year > DateTime.Now.Year) { MessageBox.Show("Năm không hợp lệ"); } } else { MessageBox.Show("Năm không hợp lệ"); } DBContextSV db = new DBContextSV(Program.connectionString); hoadon[] pnList = db.hoadons.Where(hd => hd.ngaylap.Value.Month == month && hd.ngaylap.Value.Year == year).ToArray(); string list = ""; int tong = 0; foreach (hoadon hd in pnList) { tong += hd.tong ?? default(int); string template = $"<tr><td>{hd.hoten}</td><td>{hd.ngaylap} vnd</td><td>{hd.tong} vnd</td></tr> "; list += template; } html = html.Replace("{{list}}", list).Replace("{{month}}", month.ToString()).Replace("{{tong}}", tong.ToString()).Replace("{{year}}", year.ToString()); myWebBrowser.DocumentText = html; }
public SupplierDAO() { db = new DBContextSV(Program.connectionString); }
public StorageDAO() { db = new DBContextSV(Program.connectionString); }
public NhaCCDAO() { db = new DBContextSV(Program.connectionString); }
public ImportDAO() { db = new DBContextSV(Program.connectionString); }
public InitialDataController(DBContextSV context) { _context = context; }
public ProductDAO1() { db = new DBContextSV(Program.connectionString); }
private void btnLogin_Click(object sender, EventArgs e) { if (rd_Admin.Checked == true) { try { string password = Script.MD5Hash(txtPassword.Text); string connect = "data source=DESKTOP-BELSK30\\HOST;initial catalog=cuahanglinhkienmaytinh;user id=sa;password=123456;MultipleActiveResultSets=True;App=EntityFramework"; DBContextSV db = new DBContextSV(connect); var result = db.taikhoans.SingleOrDefault(x => x.tentaikhoan == txtUsername.Text && x.matkhau == password); if (result != null) { if (result.nhanvien.chucvu != "ADMIN") { MessageBox.Show("Bạn không có quyền truy cập"); } else { Program.connectionString = connect; if (cb_cn.Text == "Chi Nhánh 1") { Program.station = "CN01"; } else if (cb_cn.Text == "Chi Nhánh 2") { Program.station = "CN02"; } else { Program.station = "CN01"; } Program.idLoged = txtUsername.Text; MainScreen ms = new MainScreen(); ms.Show(); this.Hide(); } } else { MessageBox.Show("Đăng nhập thất bại"); } } catch { MessageBox.Show("Đăng nhập thất bại"); } } else { if (cb_cn.Text != "" && txtPassword.Text != "" && txtUsername.Text != "") { if (cb_cn.Text == "Chi Nhánh 1") { try { string password = Script.MD5Hash(txtPassword.Text); string connect = "data source=DESKTOP-BELSK30\\STORE1;initial catalog=cuahanglinhkienmaytinh;user id=sa;password=123456;MultipleActiveResultSets=True;App=EntityFramework"; DBContextSV db = new DBContextSV(connect); var result = db.taikhoans.SingleOrDefault(x => x.tentaikhoan == txtUsername.Text && x.matkhau == password); if (result != null) { Program.connectionString = connect; Program.station = "CN01"; Program.idLoged = txtUsername.Text; MainScreen ms = new MainScreen(); ms.Show(); this.Hide(); } else { MessageBox.Show("Đăng nhập thất bại"); } } catch { MessageBox.Show("Đăng nhập thất bại"); } } else { try { string password = Script.MD5Hash(txtPassword.Text); string connect = "data source=DESKTOP-BELSK30\\STORE2;initial catalog=cuahanglinhkienmaytinh;user id=sa;password=123456;MultipleActiveResultSets=True;App=EntityFramework"; DBContextSV db = new DBContextSV(connect); var result = db.taikhoans.SingleOrDefault(x => x.tentaikhoan == txtUsername.Text && x.matkhau == password); if (result != null) { Program.connectionString = connect; Program.station = "CN02"; Program.idLoged = txtUsername.Text; MainScreen ms = new MainScreen(); ms.Show(); this.Hide(); } else { MessageBox.Show("Đăng nhập thất bại"); } } catch { MessageBox.Show("Đăng nhập thất bại"); } } } else { MessageBox.Show("Vui lòng nhập đầy đủ thông tin"); } } }
private void tabHistory_Click(object sender, EventArgs e) { DBContextSV db = new DBContextSV(Program.connectionString); dataGridViewHistory.DataSource = db.hoadons.ToList(); }
public StaffDAO1() { db = new DBContextSV(Program.connectionString); }
public AccountDAO1() { db = new DBContextSV(Program.connectionString); }