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 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); }
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 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 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); } }
/*===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); }
/*===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 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); }
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 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 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 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); }
/*===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 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); }
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); } }
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); } }
/*===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 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); }