private double Tinhthanhtien() { SaleDao sdao = new SaleDao(); int km = sdao.phantramKM(makm); return(soluong * gia * km / 100.0); }
public FrmSaleQuery() { InitializeComponent(); sales = SaleDao.QueryAll(); DgvSalAdd(sales); DgvGoodAdd(sales); RdoSale.Checked = true; }
public void Atualizar(int id, SaleModelView saleModelView) { var saleDao = new SaleDao(); var sale = saleDao.obeterPorId(id); var saleAt = PreparaSale(saleModelView, sale); saleAt.IdContribuitor = id; saleDao.Atualizar(saleAt); }
public void Inserir(SaleModelView saleModelView) { var sale = new Sale(); sale = PreparaSale(saleModelView, sale); var saleDao = new SaleDao(); saleDao.Inserir(sale); }
private void BtnSaleCancel_Click(object sender, EventArgs e) { if (hasUpdated) { Sales = SaleDao.QueryAll(); salesPreSize = 0; salesCurSize = Sales.Count; DgvSaleInsert.Rows.Clear(); DgvAdd(); hasUpdated = false; } }
public FrmSale() { InitializeComponent(); Sales = new List <EtSale>(); salesPreSize = 0; salesCurSize = 0; hasUpdated = false; List <EtStaff> staffs = StaffDao.QueryByRole((int)ERole.销售员); LblSaleID.Text = (SaleDao.QueryAll().Last().SaleID + 1).ToString(); foreach (EtStaff staff in staffs) { CmbOperator.Items.Add(staff.StaffName); } }
private void DgvGoodAdd(List <EtSale> sales) { DgvGoodInfo.Rows.Clear(); sales = SaleDao.QueryBySaleID(sales[0].SaleID); for (int i = 0; i < sales.Count; i++) { goods = GoodDao.QueryByGoodID(sales[i].Good.GoodID); DgvGoodInfo.Rows.Add(new object[] { goods[0].GoodID, goods[0].Category.CategoryName, goods[0].Category.Unit, goods[0].Price }); } }
private List <EtSale> QuerySalesFromDB() { List <EtSale> sales = new List <EtSale>(); string beginDate = DtpBegin.Value.ToString("yyyyMMdd"); string endDate = DtpEnd.Value.ToString("yyyyMMdd"); if (CmbCategory.SelectedIndex != 0) { ECategory parentCategoryID = (ECategory)(CmbCategory.SelectedIndex - 1); sales = SaleDao.QueryBySaleDate(beginDate, endDate, parentCategoryID); } else { sales = SaleDao.QueryBySaleDate(beginDate, endDate); } if (sales.Count == 0) { MsgBoxUtil.ErrMsgBox("没有符合条件的记录"); } return(sales); }
private bool Save() { if (CmbOperator.SelectedIndex == -1) { MsgBoxUtil.ErrMsgBox("经办人不能为空!"); return(false); } int res = 0; foreach (EtSale sale in Sales) { res += SaleDao.InsertSale(sale); GoodDao.UpdateGood(sale.Good); } if (res == Sales.Count) { return(true); } else { return(false); } }
public int ThemVaoGio(int masp, int soluong) { if (Session["giohang"] == null) { List <CartItem> giohang = new List <CartItem>(); Session.Add("giohang", giohang); } if (((List <CartItem>)Session["giohang"]).FirstOrDefault(m => m.MASP == masp) == null) { ProductDao dao = new ProductDao(); sanpham sp = dao.GetItemByID(masp).FirstOrDefault(); double ptkm = 1; SaleDao saledao = new SaleDao(); ptkm = saledao.phantramKM(sp.MAKM) / 100.0; CartItem newItem = new CartItem(); { newItem.MASP = masp; newItem.TENSP = sp.TENSP; newItem.HINHANH = sp.HINHANH; newItem.SoLuong = soluong; newItem.GIA = sp.GIA; newItem.ThanhTien = sp.GIA * (1 - ptkm) * soluong; } ((List <CartItem>)Session["giohang"]).Add(newItem); return(1); } else { ((List <CartItem>)Session["giohang"]).FirstOrDefault(m => m.MASP == masp).SoLuong += soluong; ((List <CartItem>)Session["giohang"]).FirstOrDefault(m => m.MASP == masp).ThanhTien = ((List <CartItem>)Session["giohang"]).FirstOrDefault(m => m.MASP == masp).SoLuong *((List <CartItem>)Session["giohang"]).FirstOrDefault(m => m.MASP == masp).GIA; return(1); } }
public Sale ObterPorId(int id) { var saleDao = new SaleDao(); return(saleDao.obeterPorId(id)); }
public SaleService() { dao = new SaleDao(); daoStore = new StoreDao(); }
public void Delete(int id) { var saleDao = new SaleDao(); saleDao.Deletar(id); }
public List <Sale> ObterTodos() { var saleDao = new SaleDao(); return(saleDao.ObterTodos()); }
private void DgvGoodInfo_CellClick(object sender, DataGridViewCellEventArgs e) { sales = SaleDao.QueryByGoodID(int.Parse(DgvGoodInfo.SelectedRows[0].Cells[0].Value.ToString())); DgvSalAdd(sales); }
private void BtnQuery_Click(object sender, EventArgs e) { if (TxtQuery.Text != "") { List <EtSale> subSales = new List <EtSale>(); List <EtGood> subGoods = new List <EtGood>(); string query = TxtQuery.Text; string RegexStr = "^[0-9]+$"; if (RdoSale.Checked) { if (Regex.IsMatch(query, RegexStr)) { subSales = SaleDao.QueryBySaleID(int.Parse(query)); if (subSales.Count == 0) { subSales = SaleDao.QueryByStaffID(int.Parse(query)); } } if (subSales.Count == 0) { MsgBoxUtil.ErrMsgBox("未找到销售单!"); } else { subGoods = GoodDao.QueryByGoodID(subSales[0].Good.GoodID); } } else { if (Regex.IsMatch(query, RegexStr)) { subGoods = GoodDao.QueryByGoodID(int.Parse(query)); } else { subGoods = GoodDao.QueryByCategoryID(CategoryDao.QueryByCategoryName(query)[0].CategoryID); } if (subGoods.Count == 0) { MsgBoxUtil.ErrMsgBox("未找到商品!"); } else { for (int i = 0; i < subGoods.Count; i++) { if (subGoods[i].State == Enums.EState.已出售) { subSales.Add(SaleDao.QueryByGoodID(subGoods[i].GoodID)[0]); } else { subGoods.RemoveAt(i); i--; } } } } DgvAdd(subSales, subGoods); } else { MsgBoxUtil.ErrMsgBox("请输入查询条件!"); } }
public SaleNeg() { saleDao = new SaleDao(); }