/*===UPDATE CONTROLLER===*/ public bool updatePriceHistory(string productCode, float price, DateTime effectiveDate) { if (!checkExistPriceHistory(productCode, price, effectiveDate)) { try { using (var db = new CMART2Entities1()) { var priceHistory = new PriceHistory { ProductCode = productCode, Price = price, EffectiveDate = effectiveDate }; db.PriceHistories.Add(priceHistory); //var priceHistory = db.PriceHistories.Single(s => s.ProductCode == productCode); //priceHistory.Price = price; //priceHistory.EffectiveDate = effectiveDate; //db.Entry(priceHistory).State = EntityState.Modified; db.SaveChanges(); return(true); } } catch (Exception) { return(false); } } return(false); }
public bool insertNewPriceHistory(string productCode, float price, DateTime effectiveDate) { if (!checkExistPriceHistory(productCode, price, effectiveDate)) { try { using (var db = new CMART2Entities1()) { var priceHistory = new PriceHistory { ProductCode = productCode, Price = price, EffectiveDate = effectiveDate }; db.PriceHistories.Add(priceHistory); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } } return(false); }
/*===INSERT CONTROLLER===*/ public bool insertNewPromotion(string productCode, float promotionPrice, DateTime startTime, DateTime endTime, string promotionContent, string promotionImage) { try { using (var db = new CMART2Entities1()) { ObjectParameter idoutput = new ObjectParameter("Code", typeof(String)); db.SP_PROMOTIONINFORMATION_ID_AUTO(idoutput); var id_auto = idoutput.Value.ToString(); var promotion = new PromotionInformation { PromotionCode = id_auto, ProductCode = productCode, PricePromotion = promotionPrice, StartTime = startTime, EndTime = endTime, Cont = promotionContent, Image = promotionImage }; db.PromotionInformations.Add(promotion); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public bool updateNewProduct(string productCode, string productName, string image, string typeCode, string supplierCode) { //Mean of if: Nothing change => Can't update! if (!checkExistProduct(productName, image, typeCode, supplierCode)) { try { using (var db = new CMART2Entities1()) { var product = db.Products.Single(p => p.ProductCode == productCode); product.ProductName = productName; product.Image = image; product.TypeCode = typeCode; product.SupplierCode = supplierCode; db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(true); } } catch (Exception) { return(false); } } return(false); }
public bool updatePromotion(string promotionCode, string productCode, float promotionPrice, DateTime startTime, DateTime endTime, string promotionContent, string promotionImage) { if (!checkExistPromotion(promotionPrice, startTime, endTime, promotionContent, promotionImage)) { try { using (var db = new CMART2Entities1()) { var promotion = db.PromotionInformations.Single(s => s.PromotionCode == promotionCode); promotion.ProductCode = productCode; promotion.PricePromotion = promotionPrice; promotion.StartTime = startTime; promotion.EndTime = endTime; promotion.Cont = promotionContent; promotion.Image = promotionImage; db.Entry(promotion).State = EntityState.Modified; db.SaveChanges(); return(true); } } catch (Exception) { return(false); } } return(false); }
public bool insertBranchImportBallot(string headquarterBallotNum, DateTime inputDate, string branch, string accountCode) { try { using (var db = new CMART2Entities1()) { ObjectParameter idoutput = new ObjectParameter("ID", typeof(String)); db.SP_BRANCHIMPORTBALLOT_ID_AUTO_V2(idoutput); var id_auto = idoutput.Value.ToString(); var branchImportBallot = new BranchImportBallot { BallotNum = id_auto, HeadquaterBallotNum = headquarterBallotNum, InputDate = inputDate, Branch = branch, AccountCode = accountCode }; db.BranchImportBallots.Add(branchImportBallot); db.SaveChanges(); id = Convert.ToString(id_auto); return(true); } } catch (Exception) { return(false); } }
public bool insertHeadquarterImportBallotDetail(string productCode, int number, double inputPrice, DateTime exp, string status) { try { using (var db = new CMART2Entities1()) { var headquarterImportBallotDetail = new HeadquaterImportBallotDetail { BallotNum = id, ProductCode = productCode, Number = number, InputPrice = inputPrice, EXP = exp, State = status }; db.HeadquaterImportBallotDetails.Add(headquarterImportBallotDetail); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public bool insertHeadquarterImportBallot(string proposeNum, DateTime date, double total, string accountCode) { try { using (var db = new CMART2Entities1()) { ObjectParameter idoutput = new ObjectParameter("ID", typeof(String)); db.SP_HEADQUATERIMPORTBALLOT_ID_AUTO_V2(idoutput); var id_auto = idoutput.Value.ToString(); var headquarterImportBallot = new HeadquaterImportBallot { BallotNum = id_auto, ProposeBallotNum = proposeNum, InputDate = date, Total = total, AccountCode = accountCode }; db.HeadquaterImportBallots.Add(headquarterImportBallot); db.SaveChanges(); id = Convert.ToString(id_auto); return(true); } } catch (Exception) { return(false); } }
public bool insertNewBill(DateTime daySales, double total, double guestMoney, double excessCash, int totalNum, int POS, string accountCode) { try { using (var db = new CMART2Entities1()) { ObjectParameter idoutput = new ObjectParameter("ID", typeof(String)); db.SP_BILL_ID_AUTO_Test(idoutput); var id_auto = idoutput.Value.ToString(); var bill = new Bill { BallotNum = id_auto, Date = daySales, Total = total, GuestMoney = guestMoney, ExcessCash = excessCash, TotalNum = totalNum, POS = POS, AccountCode = accountCode }; db.Bills.Add(bill); db.SaveChanges(); id = Convert.ToString(id_auto); return(true); } } catch (Exception) { return(false); } }
public bool insertNewProduct(string productName, string image, string typeCode, string supplierCode) { if (!checkExistProduct(productName)) { try { using (var db = new CMART2Entities1()) { ObjectParameter Output = new ObjectParameter("CODE", typeof(String)); db.SP_PRODUCT_ID_AUTO(Output); var id_auto = Output.Value.ToString(); var product = new Product { ProductCode = id_auto, ProductName = productName, Image = image, TypeCode = typeCode, SupplierCode = supplierCode }; db.Products.Add(product); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } } return(false); }
public bool updateBill(string ballotNum, DateTime date, double total, double guestMoney, double excessCash, int totalNum, int pos, string accountCode) { if (!checkExistBill(date, total, guestMoney, excessCash, totalNum, pos, accountCode)) { try { using (var db = new CMART2Entities1()) { var bill = db.Bills.Single(s => s.BallotNum == ballotNum); bill.Date = date; bill.Total = total; bill.GuestMoney = guestMoney; bill.ExcessCash = excessCash; bill.TotalNum = totalNum; bill.POS = pos; bill.AccountCode = accountCode; db.Entry(bill).State = EntityState.Modified; db.SaveChanges(); return(true); } } catch (Exception) { return(false); } } return(false); }
/*===INSERT CONTROLLER===*/ private bool checkExistPriceHistory(string productCode, float price, DateTime effectiveDate) { using (var db = new CMART2Entities1()) return(db.PriceHistories.Count(s => s.ProductCode == productCode && s.Price == price && s.EffectiveDate == effectiveDate) > 0); }
private void showInserPriceHistoryForm(object sender, EventArgs e) { CMART2Entities1 db = new CMART2Entities1(); this.cboProductID.DataSource = db.Products.ToList(); this.cboProductID.ValueMember = "ProductCode"; this.cboProductID.DisplayMember = "ProductName"; }
public void loadInsertPromotionForm() { CMART2Entities1 db = new CMART2Entities1(); cboProductCode.DataSource = db.Products.ToList(); cboProductCode.ValueMember = "ProductCode"; cboProductCode.DisplayMember = "ProductName"; }
private void showInsertProductForm(object sender, EventArgs e) { CMART2Entities1 db = new CMART2Entities1(); this.cboTypeCode.DataSource = db.ProductCategories.ToList(); this.cboTypeCode.ValueMember = "TypeCode"; // set the value member this.cboTypeCode.DisplayMember = "TypeName"; // set the display member this.cboSupplierCode.DataSource = db.Suppliers.ToList(); this.cboSupplierCode.ValueMember = "SupplierCode"; // set the value member this.cboSupplierCode.DisplayMember = "SupplierName"; // set the display member }
/*===UPDATE CONTROLLER===*/ private bool checkExistHeadquarterImportBallot(DateTime exp, string status) { using (var db = new CMART2Entities1()) { if (db.HeadquaterImportBallotDetails.Count(s => s.EXP == exp && s.State == status) > 0) { return(true); } return(false); } }
public GUI_UpdatePriceHistory(string productCode, double price, DateTime effectiveDate) { InitializeComponent(); this.btnSave.Click += new EventHandler(clickUpdate); this.btnCancel.Click += new EventHandler(clickCancel); this.Load += new EventHandler(showUpdatePriceHistoryForm); db = new CMART2Entities1(); pricehistory = db.PriceHistories.Single(s => s.ProductCode == productCode && s.Price == price && s.EffectiveDate == effectiveDate); }
/*===SHOW MANAGE FORM===*/ private void showManageBillForm(List <usp_BillSelectAll_Result> bill) { CMART2Entities1 db = new CMART2Entities1(); lstBill.DataSource = bill; foreach (DataGridViewColumn column in lstBill.Columns) { column.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } lstBill.Columns["BallotNum"].HeaderText = "Số phiếu"; lstBill.Columns["FullName"].HeaderText = "Tên thu ngân"; btnUpdate.Enabled = false; }
/*===UPDATE CONTROLLER===*/ private bool checkExistProduct(string productName, string image, string typeCode, string supplierCode) { using (var db = new CMART2Entities1()) { if (db.Products.Count(s => s.ProductName == productName && s.Image == image && s.TypeCode == typeCode && s.SupplierCode == supplierCode) > 0) { return(true); } return(false); } }
/*===UPDATE CONTROLLER===*/ private bool checkExistPromotion(float promotionPrice, DateTime startTime, DateTime endTime, string promotionContent, string promotionImage) { using (var db = new CMART2Entities1()) { if (db.PromotionInformations.Count(s => s.PricePromotion == promotionPrice && s.StartTime == startTime && s.EndTime == endTime && s.Cont == promotionContent && s.Image == promotionImage) > 0) { return(true); } return(false); } }
private bool checkExistBill(DateTime date, double total, double guestmoney, double excesscash, int totalnum, int pos, string account) { using (var db = new CMART2Entities1()) { if (db.Bills.Count(s => s.Date == date && s.Total == total && s.GuestMoney == guestmoney && s.ExcessCash == excesscash && s.Total == totalnum && s.POS == pos && s.AccountCode == account) > 0) { return(true); } return(false); } }
public bool deleteProduct(string productCode) { if (checkExistProductCode(productCode)) { try { using (var db = new CMART2Entities1()) { var product = db.Products.Single(s => s.ProductCode == productCode); db.Products.Remove(product); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } } return(false); }
/*===UPDATE CONTROLLER===*/ public bool updateBranchImportBallotDetail(string ballotNum, string productCode, int number, string status) { //if (!checkUpdateBranchImportBallot(status)) try { using (var db = new CMART2Entities1()) { var importBallotDetail = db.BranchImportBallotDetails.Single (p => p.BallotNum == ballotNum && p.ProductCode == productCode); importBallotDetail.State = status; db.Entry(importBallotDetail).State = EntityState.Modified; db.SaveChanges(); return(true); } } catch (Exception) { return(false); } //return false; }
public bool deletePromotion(string id) { if (checkExistPromotion(id)) { try { var db = new CMART2Entities1(); { var pro = db.PromotionInformations.Single(s => s.PromotionCode.Equals(id)); db.PromotionInformations.Remove(pro); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } } return(false); }
public bool updateBillDetail(string ballotNum, string productcode, double unitprice, int number) { try { using (var db = new CMART2Entities1()) { var billdetail = db.BillDetails.Single(s => s.BallotNum == ballotNum); { billdetail.ProductCode = productcode; billdetail.UnitPrice = unitprice; billdetail.Number = number; db.Entry(billdetail).State = EntityState.Modified; db.SaveChanges(); return(true); }; } } catch (Exception) { return(false); } }
/*===DELETE CONTROLLER===*/ public bool deletePriceHistory(string productCode, double price, DateTime effectiveDate) { if (checkExistPriceHistory(productCode, (float)price, effectiveDate)) { try { using (var db = new CMART2Entities1()) { var priceHistory = db.PriceHistories.Single(s => s.ProductCode == productCode && s.Price == price && s.EffectiveDate == effectiveDate); db.PriceHistories.Remove(priceHistory); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } } return(false); }
public bool insertNewBillDetail(string productcode, double unitprice, int number) { try { using (var db = new CMART2Entities1()) { var billdetail = new BillDetail { BallotNum = id, ProductCode = productcode, UnitPrice = unitprice, Number = number }; db.BillDetails.Add(billdetail); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public bool insertBranchImportBallotDetail(string productCode, int number, string status) { try { using (var db = new CMART2Entities1()) { var branchImportBallotDetail = new BranchImportBallotDetail { BallotNum = id, ProductCode = productCode, Number = number, State = status }; db.BranchImportBallotDetails.Add(branchImportBallotDetail); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public bool updateHeadquarterImportBallotDetail(string ballotNum, string productCode, int number, double inputPrice, DateTime exp, string status) { if (!checkExistHeadquarterImportBallot(exp, status)) { try { using (var db = new CMART2Entities1()) { var importBallotDetail = db.HeadquaterImportBallotDetails.Single (p => p.BallotNum == ballotNum && p.ProductCode == productCode); importBallotDetail.EXP = exp; importBallotDetail.State = status; db.Entry(importBallotDetail).State = EntityState.Modified; db.SaveChanges(); return(true); } } catch (Exception) { return(false); } } return(false); }
/*===INSERT CONTROLLER===*/ private bool checkExistProduct(string productName) { using (var db = new CMART2Entities1()) return(db.Products.Count(s => s.ProductName == productName) > 0); }