コード例 #1
0
 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);
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 /*===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;
 }
コード例 #5
0
 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);
     }
 }
コード例 #6
0
 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);
 }