Exemplo n.º 1
0
        private static void UpdatePayment(Payment Payment, string StatusPayment, long SaleRefrenceID, string RefID,
                                          int StatePortal = 0)
        {
            var p = db.Payments.Find(Payment);

            p.StatusPayment   = StatusPayment;
            p.SaleReferenceId = SaleRefrenceID;
            p.StatePortal     = StatePortal;
            if (RefID != null)
            {
                p.ReferenceNumber = RefID;
            }
            db.SaveChanges();
            db.Dispose();
        }
Exemplo n.º 2
0
 public static void UpdateUser()
 {
     db.Dispose();
     db   = new AnbariiEntities();
     User = db.Users.Where(i => i.ID.Equals(User.ID)).FirstOrDefault();
 }
Exemplo n.º 3
0
 public ActionResult AddProduct(Receipt receipt, long OwnerID)
 {
     if (!Permission(new int[] { RolesInt.Admin, RolesInt.Anbar }))
     {
         return(Return());
     }
     if (receipt == null || OwnerID <= 0)
     {
         ModelState.AddModelError(string.Empty, "مقادیر اجباری فرم را وارد نمایید.");
         return(View(new Load()));
     }
     else
     {
         List <string> Errorlist = receipt.Validate();
         Errorlist.Union(receipt.Driver.Validate());
         Errorlist.Union(OwnerID.ValidateDestination());
         if (!Errorlist.Any())
         {
             receipt.DriverID = receipt.Driver.ID;
             if (!db.Drivers.Where(i => i.ID.Equals(receipt.Driver.ID, StringComparison.OrdinalIgnoreCase)).Any())
             {
                 receipt.Driver.Date = DateTime.Now;
             }
             else
             {
                 receipt.Driver = null;
             }
             receipt.ID          = (db.Receipts.Where(i => i.WherHouseID.Equals(Members.User.ID)).Max(i => (long?)i.ID) ?? default(long)) + 1;
             receipt.WherHouseID = Members.User.ID;
             receipt.Date        = DateTime.Now;
             receipt.Year        = Members.Year;
             foreach (var item in receipt.ReceiptDetails)
             {
                 Load load = db.Loads
                             .Where(i => i.Name.Equals(item.Details, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                 if (load == null)
                 {
                     load = new Load()
                     {
                         Change_date     = DateTime.Now,
                         Weight          = item.Weight,
                         Count           = item.Count,
                         Add_Date        = DateTime.Now,
                         Details         = item.Details,
                         ID              = receipt.ID,
                         Input_Name      = item.Details,
                         Inventory_price = 0,
                         Load_TypeID     = item.Load_TypeID,
                         Name            = item.Details,
                         OwnerID         = OwnerID,
                         Packaging_Price = 0,
                         Pic1            = Strings.ImageEmpty,
                         Pic2            = Strings.ImageEmpty,
                         Pic3            = Strings.ImageEmpty,
                         Pic4            = Strings.ImageEmpty,
                         Pic5            = Strings.ImageEmpty,
                         Weight_Type     = item.WeightType,
                         WherhouseID     = receipt.WherHouseID
                     };
                     db.Loads.Add(load);
                 }
                 else
                 {
                     load.Count      += item.Count;
                     load.Weight      = item.Weight;
                     load.Change_date = DateTime.Now;
                 }
                 item.Load        = load;
                 item.ID          = receipt.ID;
                 item.WherHouseID = receipt.WherHouseID;
             }
             db.Receipts.Add(receipt);
             db.SaveChanges();
             db.Dispose();
             db      = new AnbariiEntities();
             receipt = db.Receipts.Where(i => i.ID.Equals(receipt.ID) && i.WherHouseID.Equals(receipt.WherHouseID)).FirstOrDefault();
             return(View(SReceiptPrint, receipt));
         }
         else
         {
             foreach (string item in Errorlist)
             {
                 ModelState.AddModelError(item, item);
             }
         }
         return(View(receipt));
     }
 }