Beispiel #1
0
        public ActionResult EditDeliveryQuantity(DeliveryQuantity deliveryQuantity, int id)
        {
            var concernId = Convert.ToInt32(Session["ConcernId"]);
            var userId    = Convert.ToInt32(Session["UserId"]);

            if (concernId > 0 && userId > 0)
            {
                _sales.UpdateDeliveryQuantity(deliveryQuantity, userId, concernId, id);
                return(RedirectToAction("Orders", "PermessData", new { Area = "Permess" }));
            }
            return(RedirectToAction("LogIn", "GlobalData", new { Area = "Global" }));
        }
        public void UpdateDeliveryQuantity(DeliveryQuantity deliveryQuantity, int userId, int concernId, int id)
        {
            using (DbContextTransaction transaction = _context.Database.BeginTransaction())
            {
                var delivery = _context.DeliveryQuantities.FirstOrDefault(x => x.DeliveryQuantityID == id);
                delivery.Quantity  = deliveryQuantity.Quantity;
                delivery.ConcernId = concernId;
                delivery.Creator   = userId;
                _context.SaveChanges();

                var product = _context.SRIProductDetails.FirstOrDefault(x => x.SICode == deliveryQuantity.ProductCode);
                product.DeliveryQuantity = deliveryQuantity.Quantity;
                _context.SaveChanges();

                transaction.Commit();
            }
        }
        public ActionResult AddQuantity(int id, DeliveryQuantity delivery)
        {
            var concernId = Convert.ToInt32(Session["ConcernId"]);
            var userId    = Convert.ToInt32(Session["UserId"]);

            if (concernId > 0 && userId > 0)
            {
                //DeliveryQuantity deliveryQuantity = new DeliveryQuantity();
                var del = _context.DeliveryQuantities.FirstOrDefault(x => x.SIProductDetailsCode == id.ToString());
                delivery.CreationDate         = DateTime.Now;
                delivery.SIProductDetailsCode = id.ToString();
                delivery.Creator              = userId;
                delivery.ConcernId            = concernId;
                delivery.SIProductDetailsCode = del.SIProductDetailsCode;
                _context.DeliveryQuantities.Add(delivery);
                _context.SaveChanges();
                return(RedirectToAction(nameof(Orders)));
            }
            return(RedirectToAction("LogIn", "GlobalData", new { Area = "Global" }));
        }
        public void AddSIProductDetails(SIProductDetails sIProductDetails, int userId, int concernId)
        {
            var code         = sIProductDetails.ProductId + "" + sIProductDetails.ArticleId + "" + sIProductDetails.WidthId + "" + sIProductDetails.ConstructionId + "" + sIProductDetails.SoftnessId + "" + sIProductDetails.SourceId + "" + sIProductDetails.ColorId;
            var productCode  = _context.ProductNames.FirstOrDefault(m => m.ProductCode == code);
            var quantityCode = DateTime.Now.ToString("mmddfff");
            var quantityCod  = "5" + "" + quantityCode;

            using (DbContextTransaction transaction = _context.Database.BeginTransaction())
            {
                if (productCode == null)
                {
                    ProductName product = new ProductName();
                    product.ProductCode    = code;
                    product.ProductId      = sIProductDetails.ProductId;
                    product.ArticleId      = sIProductDetails.ArticleId;
                    product.WidthId        = sIProductDetails.WidthId;
                    product.ConstructionId = sIProductDetails.ConstructionId;
                    product.SoftnessId     = sIProductDetails.SoftnessId;
                    product.SourceId       = sIProductDetails.SourceId;
                    product.ColorId        = sIProductDetails.ColorId;
                    _context.ProductNames.Add(product);
                    _context.SaveChanges();

                    sIProductDetails.ConcernId            = concernId;
                    sIProductDetails.SIProductDetailsCode = quantityCod;
                    sIProductDetails.ProductCode          = code;
                    sIProductDetails.CreationDate         = DateTime.Now;
                    sIProductDetails.Creator = userId;
                    //sIProductDetails.DeliveryQuantity = 0;
                    _context.SIProductDetails.Add(sIProductDetails);
                    _context.SaveChanges();

                    DeliveryQuantity delivery = new DeliveryQuantity();

                    delivery.ConcernId            = concernId;
                    delivery.SIProductDetailsCode = quantityCod;
                    delivery.DeliveryDate         = DateTime.Now;
                    delivery.ProductCode          = sIProductDetails.SICode;
                    delivery.CreationDate         = DateTime.Now;
                    delivery.Creator  = userId;
                    delivery.Quantity = sIProductDetails.DeliveryQuantity;
                    _context.DeliveryQuantities.Add(delivery);
                    _context.SaveChanges();

                    transaction.Commit();
                }
                else
                {
                    sIProductDetails.ConcernId            = concernId;
                    sIProductDetails.SIProductDetailsCode = quantityCod;
                    sIProductDetails.ProductCode          = code;
                    sIProductDetails.CreationDate         = DateTime.Now;
                    sIProductDetails.Creator = userId;
                    _context.SIProductDetails.Add(sIProductDetails);
                    _context.SaveChanges();

                    DeliveryQuantity delivery = new DeliveryQuantity();
                    delivery.ConcernId            = concernId;
                    delivery.SIProductDetailsCode = quantityCod;
                    delivery.DeliveryDate         = DateTime.Now;
                    delivery.ProductCode          = sIProductDetails.SICode;
                    delivery.CreationDate         = DateTime.Now;
                    delivery.Creator  = userId;
                    delivery.Quantity = sIProductDetails.DeliveryQuantity;
                    _context.DeliveryQuantities.Add(delivery);
                    _context.SaveChanges();

                    transaction.Commit();
                }
            }
        }