/// <summary> /// constructor for the first dept receipt /// </summary> /// <param name="receipt"></param> public PhieuThuTienNo_Form(PHIEUBANHANG receipt) { InitializeComponent(); this.bulKhachHang = new BUL_KhachHang(); this.bulDeptReceipt = new BUL_PhieuThuTienNo(); this.bulBangThamSo = new BUL_BangThamSo(); this.receipt = receipt; // set defaul value for date time picker : system current date this.dateTimePickerNgayLap.DateTime = DateTime.Now.Date; this.dateTimePickerNgayLap.ReadOnly = true; this.dateTimePickerNgayTra.DateTime = DateTime.Now.Date; this.previousDeptRecepit = null; // indicate that, this is the first dept this.isTheFirstDept = true; // this is the first decpt receipt this.textEditMaPhieuBanHang.Text = receipt.SoPhieuBH.ToString(); this.textEditTenKhachHang.Text = this.bulKhachHang.GetKhachhangById(receipt.MaKH).TenKH; this.textEditMaKhachHang.Text = receipt.MaKH.ToString(); // the first dept this.textEditSoTienNo.Text = receipt.TongTien.ToString(); this.labelControlRecommendedInput.Visible = true; decimal ACCEPTABLE_FIRST_PREPAID_PERCENTAGE = Convert.ToDecimal(this.bulBangThamSo.getValueByArgument("TienTraToiThieu")); decimal minimumAmout = decimal.Multiply(ACCEPTABLE_FIRST_PREPAID_PERCENTAGE, receipt.TongTien); this.labelControlRecommendedInput.Text = "(Tối thiểu: " + Math.Round(minimumAmout) + ")"; }
private void lậpPhiếuNợToolStripMenuItem_Click(object sender, EventArgs e) { // get the focused row if (this.gridViewDanhSachPhieuBanHang.DataRowCount == 0) { return; } PHIEUBANHANG selectedReceipt = (PHIEUBANHANG)this.gridViewDanhSachPhieuBanHang.GetRow(this.gridViewDanhSachPhieuBanHang.FocusedRowHandle); // check if this recept has dept recepit or not ? if (this.bulPhieuBanHang.hasDebtReceipts(selectedReceipt.SoPhieuBH) == false) { // create the first dept receipt PhieuThuTienNo_Form firstDeptReceiptForm = new PhieuThuTienNo_Form(selectedReceipt); firstDeptReceiptForm.refreshDebtReceiptDataCallback = new PhieuThuTienNo_Form.RefreshDebtReceiptData(this.refreshDebtReceiptData); firstDeptReceiptForm.ShowDialog(); } else // otherwise { // get the last dept recpeit PHIEUTHUTIENNO lastDeptReceip = this.bulPhieuBanHang.findTheLastDeiptReceiptFromReceiptId(selectedReceipt.SoPhieuBH); // check if user paid for all the depts if (decimal.Equals(lastDeptReceip.SoTienConLai, decimal.Zero)) { MessageBox.Show("Phiếu bán hàng này đã được trả nợ hết !", ErrorMessage.ERROR_MESSARE_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // start to show the form PhieuThuTienNo_Form deptReceiptForm = new PhieuThuTienNo_Form(lastDeptReceip); deptReceiptForm.refreshDebtReceiptDataCallback = new PhieuThuTienNo_Form.RefreshDebtReceiptData(this.refreshDebtReceiptData); deptReceiptForm.ShowDialog(); } }
public ActionResult DeleteConfirmed(int id) { PHIEUBANHANG pHIEUBANHANG = db.PHIEUBANHANGs.Find(id); db.PHIEUBANHANGs.Remove(pHIEUBANHANG); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "MaPBH,TenKH,NgayLap,TongTien")] PHIEUBANHANG pHIEUBANHANG) { if (ModelState.IsValid) { db.Entry(pHIEUBANHANG).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pHIEUBANHANG)); }
public void UpdateTongTien(int sophieu, decimal thanhtien) { PHIEUBANHANG p = datacontext.PHIEUBANHANGs.Where(x => x.SoPhieuBan == sophieu).FirstOrDefault(); if (p != null) { p.TongTien += thanhtien; } this.Save(); }
public ActionResult Create([Bind(Include = "MaPBH,TenKH,NgayLap,TongTien")] PHIEUBANHANG pHIEUBANHANG) { if (ModelState.IsValid) { db.PHIEUBANHANGs.Add(pHIEUBANHANG); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pHIEUBANHANG)); }
public string GetTenKH(int sophieu) { String r = ""; PHIEUBANHANG p = datacontext.PHIEUBANHANGs.Where(x => x.SoPhieuBan == sophieu).FirstOrDefault(); if (p != null) { KHACHHANG kh = datacontext.KHACHHANGs.Where(xy => xy.MaKH == p.MaKH).FirstOrDefault(); r = kh.TenKh; } return(r); }
// GET: Manager/PhieuBanHang/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PHIEUBANHANG pHIEUBANHANG = db.PHIEUBANHANGs.Find(id); if (pHIEUBANHANG == null) { return(HttpNotFound()); } return(View(pHIEUBANHANG)); }
public decimal GetTongTien(int sophieu) { this.Save(); PHIEUBANHANG p = datacontext.PHIEUBANHANGs.Where(x => x.SoPhieuBan == sophieu).FirstOrDefault(); if (p != null) { return(p.TongTien.Value); } else { return(-1); } }
public void Update(int sophieu, int makh, string ngayban, string ngaythanhtoan, decimal tongtien, decimal sotientra) { PHIEUBANHANG p = datacontext.PHIEUBANHANGs.Where(x => x.SoPhieuBan == sophieu).FirstOrDefault(); if (p != null) { p.MaKH = makh; p.NgayBan = DateTime.Parse(ngayban); p.NgayThanhToan = DateTime.Parse(ngaythanhtoan); p.TongTien = tongtien; p.SoTienTra = sotientra; } this.Save(); }
public void Insert(int makh, string ngayban, string ngaythanhtoan, decimal tongtien, decimal sotientra) { PHIEUBANHANG p = new PHIEUBANHANG(); p.SoPhieuBan = GetSoPhieu(); p.MaKH = makh; p.NgayBan = DateTime.Parse(ngayban); p.NgayThanhToan = DateTime.Parse(ngaythanhtoan); p.TongTien = tongtien; p.SoTienTra = sotientra; datacontext.PHIEUBANHANGs.InsertOnSubmit(p); this.Save(); }
private void xemPhiếuNợToolStripMenuItem_Click(object sender, EventArgs e) { if (this.gridViewDanhSachPhieuBanHang.DataRowCount == 0) { return; } PHIEUBANHANG selectedReceipt = (PHIEUBANHANG)this.gridViewDanhSachPhieuBanHang.GetRow(this.gridViewDanhSachPhieuBanHang.FocusedRowHandle); // start to look up all dept receipts this.bulPhieuBanHang = new BUL_PhieuBanHang(); this.gridControlDanhSachPhieuNo.RefreshDataSource(); this.gridControlDanhSachPhieuNo.DataSource = this.bulPhieuBanHang.findDeptReceiptsByReceiptId(selectedReceipt.SoPhieuBH); this.renameColumnsOfDebReceiptsGridView(); // all uninformative columns will be invisible this.gridViewDanhSachPhieuNo.Columns[8].Visible = false; this.gridViewDanhSachPhieuNo.Columns[9].Visible = false; }
public PhieuThuTienNo_Form(PHIEUTHUTIENNO previousDeptReceipt) { InitializeComponent(); this.bulKhachHang = new BUL_KhachHang(); this.bulDeptReceipt = new BUL_PhieuThuTienNo(); this.previousDeptRecepit = previousDeptReceipt; // indicate that, this is NOT the first dept this.isTheFirstDept = false; // this is the first decpt receipt this.textEditMaPhieuBanHang.Text = this.previousDeptRecepit.SoPhieuBH.ToString(); this.receipt = new BUL_PhieuBanHang().findReceiptById(this.previousDeptRecepit.SoPhieuBH); this.textEditTenKhachHang.Text = this.bulKhachHang.GetKhachhangById(this.receipt.MaKH).TenKH; this.textEditMaKhachHang.Text = this.receipt.MaKH.ToString(); // the first dept this.textEditSoTienNo.Text = this.previousDeptRecepit.SoTienConLai.ToString(); // set defaul value for date time picker : system current date this.dateTimePickerNgayLap.DateTime = DateTime.Now.Date; this.dateTimePickerNgayLap.ReadOnly = true; this.dateTimePickerNgayTra.DateTime = DateTime.Now.Date; this.labelControlRecommendedInput.Visible = false; }
public bool AddCT_PhieuBanHang(PhieuBanHangViewModel phieuBanHangViewModel) { PHIEUBANHANG phieubanhang = new PHIEUBANHANG(); phieubanhang.TenKH = phieuBanHangViewModel.TenKH; phieubanhang.NgayLap = phieuBanHangViewModel.NgayLap; phieubanhang.TongTien = phieuBanHangViewModel.TongTien; objQUANLYCUAHANGEntity.PHIEUBANHANGs.Add(phieubanhang); objQUANLYCUAHANGEntity.SaveChanges(); int maPBH = phieubanhang.MaPBH; foreach (var item in phieuBanHangViewModel.DSChiTiet) { CT_PHIEUBANHANG ct_phieubanhang = new CT_PHIEUBANHANG(); ct_phieubanhang.MaPBH = maPBH; ct_phieubanhang.MaSP = item.MaSP; ct_phieubanhang.SoLuong = item.SoLuong; ct_phieubanhang.DonGia = item.DonGia; ct_phieubanhang.ThanhTien = item.ThanhTien; objQUANLYCUAHANGEntity.CT_PHIEUBANHANG.Add(ct_phieubanhang); objQUANLYCUAHANGEntity.SaveChanges(); } return(true); }
public void Delete(int sophieu)// xóa tất cả chi tiết sau đó xóa phiếu bán { // xoa chi tiet truoc :: nha' var chitiet = datacontext.CTPHIEUBANs.Where(x => x.SoPhieuBan == sophieu); foreach (var item in chitiet.ToList()) { //trc khi xóa phải trả số lượng tồn lại SANPHAM sp = datacontext.SANPHAMs.Where(x => x.MaSP == item.MaSP).FirstOrDefault(); sp.SoLuongTon += item.SoLuong; //giờ thì xóa chi tiết datacontext.CTPHIEUBANs.DeleteOnSubmit(item); datacontext.SubmitChanges(); } // giờ thì xóa phiếu bán PHIEUBANHANG p = datacontext.PHIEUBANHANGs.Where(x => x.SoPhieuBan == sophieu).FirstOrDefault(); if (p != null) { datacontext.PHIEUBANHANGs.DeleteOnSubmit(p); } this.Save(); }