public void xuatKho(DateTime from, DateTime to) { // so luong sp int slsp = 0; // so luong nguyen lieu de lam ra sp int slnl = 0; List <HOADON> lstHD = layDSHDTheoNgay(from, to); foreach (HOADON sp in lstHD) { // lay tung san pham cua hoa don foreach (CT_HOADON chitietHD in hd.CT_HOADONs.Where(t => t.MAHD == sp.MAHD)) { slsp = (int)chitietHD.SOLUONG; // lay tung nguyen lieu cua san pham do foreach (CT_SANPHAM_NGUYENLIEU nlsp in hd.CT_SANPHAM_NGUYENLIEUs.Where(t => t.MASP == chitietHD.MASP)) { slnl = (int)nlsp.SOLUONG; NGUYENLIEU nl = hd.NGUYENLIEUs.SingleOrDefault(t => t.MANL == nlsp.MANL); nl.SOLUONG -= slnl * slsp; if (nl.SOLUONG <= 0) { nl.SOLUONG = 0; } } } } hd.SubmitChanges(); }
public MonAn(MonAn ma) { this.TenMonAn = ma.TenMonAn; this.Kcal = ma.Kcal; this.NguyenLieu = ma.NguyenLieu; System.Threading.Interlocked.Increment(ref Count); }
public void XoaNL(string ma) { NGUYENLIEU nv = da.NGUYENLIEUs.Where(t => t.MANL == ma).SingleOrDefault(); da.NGUYENLIEUs.DeleteOnSubmit(nv); da.SubmitChanges(); }
public MonAn(string name, int calo, NGUYENLIEU nguyenlieu) { this.TenMonAn = name; this.Kcal = calo; this.NguyenLieu = nguyenlieu; System.Threading.Interlocked.Increment(ref Count); }
public void xoa(string a) { RestaurantManagerDataContext dbs = new RestaurantManagerDataContext(); NGUYENLIEU dc = dbs.NGUYENLIEUs.Single(p => p.ID.ToString() == a); dc.TrangThai = false; dbs.SubmitChanges(); }
public ActionResult Add(NGUYENLIEU model) { var NguyenLieu = db.NGUYENLIEUx.Find(model.MaNL); db.NGUYENLIEUx.Add(model); db.SaveChanges(); return(RedirectToAction("Index")); }
public void sua(string a) { RestaurantManagerDataContext dbs = new RestaurantManagerDataContext(); NGUYENLIEU dc = dbs.NGUYENLIEUs.Single(p => p.ID.ToString() == a); dc.TenSP = txtten.Text; dc.DonGia = Convert.ToInt32(txtgia.Text); dbs.SubmitChanges(); }
public ActionResult Edit(NGUYENLIEU model) { var obj = db.NGUYENLIEUx.Find(model.MaNL); obj.MaNL = model.MaNL; obj.TenNguyenLieu = model.TenNguyenLieu; obj.DonViTinh = model.DonViTinh; db.SaveChanges(); return(RedirectToAction("index", model)); }
public void SuaNL(string ma, string ten, float dongia, string mancc) { NGUYENLIEU nv = da.NGUYENLIEUs.Where(t => t.MANL == ma).SingleOrDefault(); nv.TENNL = ten; nv.DONGIA = dongia; nv.MANCC = mancc; da.SubmitChanges(); }
// Xóa Nguyên liệu public void xoaNguyenLieu(string maNL) { NGUYENLIEU xoaNL = ff.NGUYENLIEUs.Where(n => n.MANL == maNL).FirstOrDefault(); if (xoaNL != null) { ff.NGUYENLIEUs.DeleteOnSubmit(xoaNL); ff.SubmitChanges(); } }
public void them(string ten, string gia, bool Trangthai) { txtma.Enabled = true; RestaurantManagerDataContext dbs = new RestaurantManagerDataContext(); NGUYENLIEU nl = new NGUYENLIEU(); nl.TenSP = ten; nl.DonGia = Convert.ToInt32(txtgia.Text); nl.TrangThai = true; dbs.NGUYENLIEUs.InsertOnSubmit(nl); dbs.SubmitChanges(); }
public void ThemNL(string ma, string ten, float dongia, string mancc) { NGUYENLIEU nv = new NGUYENLIEU(); nv.MANL = ma; nv.TENNL = ten; nv.DONGIA = dongia; nv.MANCC = mancc; da.NGUYENLIEUs.InsertOnSubmit(nv); da.SubmitChanges(); }
private bool ktSLNL(SANPHAM sp) { foreach (CT_SANPHAM_NGUYENLIEU item in qlsp.CT_SANPHAM_NGUYENLIEUs.Where(t => t.MASP == sp.MASP)) { NGUYENLIEU nl = qlsp.NGUYENLIEUs.SingleOrDefault(t => t.MANL == item.MANL); if (nl.SOLUONG == 0) { return(false); } } return(true); }
// Thêm Nguyên liệu public void themNguyenLieu(string maNL, string tenNL, string donVi, int soLuong, DateTime hanSD, string maLoaiNL) { NGUYENLIEU nl = new NGUYENLIEU(); nl.MANL = maNL; nl.TENNL = tenNL; nl.DVT = donVi; nl.SOLUONG = soLuong; nl.HSD = hanSD; nl.MALNL = maLoaiNL; ff.NGUYENLIEUs.InsertOnSubmit(nl); ff.SubmitChanges(); }
public string getMANLLast() { List <NGUYENLIEU> a = da.NGUYENLIEUs.ToList(); if (a.Count == 0)// neu chua co nhan vien nao { return(""); } //da co ma nhan vien NGUYENLIEU b = da.NGUYENLIEUs.ToList().OrderByDescending(t => t.MANL).First(); return(b.MANL); }
// Sửa nguyên liệu public void suaNguyenLieu(string maNL, string tenNL, string donVi, int soLuong, DateTime hanSD, string maLoaiNL) { NGUYENLIEU suaNL = ff.NGUYENLIEUs.Where(n => n.MANL == maNL).FirstOrDefault(); if (suaNL != null) { suaNL.TENNL = tenNL; suaNL.DVT = donVi; suaNL.SOLUONG = soLuong; suaNL.HSD = hanSD; suaNL.MALNL = maLoaiNL; ff.SubmitChanges(); } }
private void btnThemNL_Click(object sender, EventArgs e) { if (gvNguyenLieu.SelectedRows == null) { MessageBox.Show("Chưa chọn nguyện liệu"); } foreach (DataGridViewRow item in gvNguyenLieu.SelectedRows) { NGUYENLIEU nl = lstNL.Single(t => t.MANL == item.Cells["MANL"].Value.ToString()); lstNLHienTai.Add(nl); gvNL_SP.DataSource = loadNL_SP(); gvNguyenLieu.DataSource = lstNL_KoThuocSP(); } }
public bool Update(NGUYENLIEU nl, out string message) { message = ""; try { //QLBH_FastFoodDataContext context = new QLBH_FastFoodDataContext(); Global.global_datacontext.sp_SuaNguyenLieu(nl.MaNL, nl.TenNL, nl.GiaNL, nl.DonVi, nl.SLTonKho, nl.TT_Ban); return(true); } catch (Exception e) { message = e.Message; } return(false); }
//List nguyên liệu có trong sanpham public List <NGUYENLIEU> lstNLCuaSP() { List <NGUYENLIEU> lst = new List <NGUYENLIEU>(); gvNL_SP.AllowUserToAddRows = false; if (gvNL_SP.Rows.Count == 0) { gvNL_SP.AllowUserToAddRows = true; return(lst); } foreach (DataGridViewRow item in gvNL_SP.Rows) { NGUYENLIEU nl = lstNL.Single(t => t.MANL == item.Cells["MANL"].Value.ToString()); lst.Add(nl); } return(lst); }
private void btnDelete_Click(object sender, EventArgs e) { if (dgvNguyenLieu.SelectedRows.Count > 0) { if (rowselect == -1 || rowselect >= dsNL.Count) { return; } int vt = 0; for (int i = 0; i < dsNL.Count; i++) { if (dsNL[i].MaNL == (int)(dgvNguyenLieu.Rows[rowselect].Cells[0].Value)) { vt = i; break; } } DialogResult dialog = MessageBox.Show("Bạn có muốn xoá không?", "Xoá", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialog == DialogResult.Yes) { NGUYENLIEU NL = new NGUYENLIEU() { MaNL = dsNL[vt].MaNL, TenNL = dsNL[vt].TenNL, GiaNL = dsNL[vt].GiaNL, SLTonKho = dsNL[vt].SLTonKho, DonVi = dsNL[vt].DonVi, TT_Ban = false }; string message; bool result = blNL.Update(NL, out message); if (result == false) { MessageBox.Show(message); } LoadData(); } } }
private void btnSave_Click(object sender, EventArgs e) { errorProvider1.Clear(); int Num; bool k = int.TryParse(txtSL.Text, out Num); if (k == false) { errorProvider1.SetError(txtSL, "Số lượng nguyên liệu không hợp lệ"); return; } k = int.TryParse(txtGiaNL.Text, out Num); if (k == false) { errorProvider1.SetError(txtGiaNL, "Giá nguyên liệu không hợp lệ"); return; } if (Them == true) { int value = 0; var ds = (from nl in blNL.dsNguyenLieu() select nl.MaNL).ToList(); if (ds.Count > 0) { value = ds.Max(); } NGUYENLIEU NL = new NGUYENLIEU() { MaNL = value + 1, TenNL = txtTenNL.Text, GiaNL = int.Parse(txtGiaNL.Text), SLTonKho = int.Parse(txtSL.Text), DonVi = txtDonVi.Text, TT_Ban = true }; string message; bool result = blNL.Insert(NL, out message); if (result == false) { MessageBox.Show(message); } this.Close(); } else { NGUYENLIEU NL = new NGUYENLIEU() { MaNL = nl.MaNL, TenNL = txtTenNL.Text, GiaNL = int.Parse(txtGiaNL.Text), SLTonKho = int.Parse(txtSL.Text), DonVi = txtDonVi.Text, TT_Ban = true }; string message; bool result = blNL.Update(NL, out message); if (result == false) { MessageBox.Show(message); } this.Close(); } }
public ThucUong(string name, int calo, NGUYENLIEU nguyenlieu) { this.TenMonAn = name; this.Kcal = calo; this.NguyenLieu = nguyenlieu; }
public void updateSLNL(string maNL) { NGUYENLIEU nl = db.NGUYENLIEUs.Where(t => t.MANL == maNL).FirstOrDefault(); }