public void addNewShoes(List <string> shoes, List <string> shoesCost, List <string> variety, DateTime date)
        {
            int count = 0;
            int i     = 0;

            foreach (string shoe in shoes)
            {
                //checked
                count = habib.Shoes.Where(c => c.shoeArticle == shoe).Count();
                if (count == 0)
                {
                    Shoe obj = new Shoe()
                    {
                        shoeArticle = shoe,
                        shoeCost    = Convert.ToInt32(shoesCost[i]),
                        shoeVariety = variety[i],
                        UpdateDate  = date
                    };

                    habib.Shoes.Add(obj);
                }
                else
                {
                    //checked
                    Shoe obj = habib.Shoes.Where(c => c.shoeArticle == shoe).First();
                    obj.UpdateDate = date;
                    obj.shoeCost   = Convert.ToInt32(shoesCost[i]);
                }

                //addNewBatch(obj.shoe_Id,Convert.ToInt32(obj.shoeCost),obj.UpdateDate);
            }
            habib.SaveChanges();
        }
Exemplo n.º 2
0
 public ActionResult Create(Vendor model)
 {
     if (ModelState.IsValid)
     {
         model.DeleteStatus = 0;
         habib.Vendors.Add(model);
         habib.SaveChanges();
         return(RedirectToAction("Index", "Vendor"));
     }
     else
     {
         return(View());
     }
 }
Exemplo n.º 3
0
        // constructor

        public int TransferShoes(int transferId, int outletId, List <Shoe> shoes, List <Size> sizes, List <Color> colors, List <string> qty)
        {
            int totalQty  = 0;
            var shoeName  = "";
            var sizeNo    = 0;
            var colorName = "";

            using (Habib habib = new Habib())
            {
                for (int i = 0; i < shoes.Count; i++)
                {
                    shoeName  = shoes[i].shoeArticle;
                    sizeNo    = Convert.ToInt32(sizes[i].sizeNo);
                    colorName = colors[i].colorName;
                    totalQty += Convert.ToInt32(qty[i]);

                    Shoe_Size_Color obj = habib.Shoe_Size_Color.Where(c => c.Shoe_Size.Shoe.shoeArticle == shoeName &&
                                                                      c.Shoe_Size.Size.sizeNo == sizeNo && c.Color.colorName == colorName).First();

                    int count = habib.Outlet_ShoeSizeColor.Where(c => c.Shoe_Size_Color.shoeSizeColor_Id == obj.shoeSizeColor_Id &&
                                                                 c.outlet_Id == outletId).Count();

                    if (count == 0)
                    {
                        Outlet_ShoeSizeColor outletShoe = new Outlet_ShoeSizeColor()
                        {
                            outlet_Id        = outletId,
                            shoeSizeColor_Id = obj.shoeSizeColor_Id,
                            quantity         = Convert.ToInt32(qty[i])
                        };

                        habib.Outlet_ShoeSizeColor.Add(outletShoe);
                    }
                    else
                    {
                        Outlet_ShoeSizeColor outletShoe = habib.Outlet_ShoeSizeColor.Where(c => c.shoeSizeColor_Id == obj.shoeSizeColor_Id &&
                                                                                           c.outlet_Id == outletId).First();

                        outletShoe.quantity += Convert.ToInt32(qty[i]);
                    }

                    obj.quantityInWH -= Convert.ToInt32(qty[i]);

                    Transfer_ShoeSizeColor transfer = new Transfer_ShoeSizeColor()
                    {
                        transfer_Id      = transferId,
                        shoeSizeColor_Id = obj.shoeSizeColor_Id,
                        quantity         = Convert.ToInt32(qty[i])
                    };

                    habib.Transfer_ShoeSizeColor.Add(transfer);
                }
                habib.SaveChanges();
            }

            return(totalQty);
        }
Exemplo n.º 4
0
        public ActionResult CreateTransfer(ShoesTransferViewModel model, FormCollection form)
        {
            TransferHandler handler = new TransferHandler();
            TransferRecord  record  = new TransferRecord()
            {
                outlet_Id      = model.transferRecord.outlet_Id,
                dateOfTransfer = model.transferRecord.dateOfTransfer
            };

            habib.TransferRecords.Add(record);
            habib.SaveChanges();
            int outletId = Convert.ToInt32(model.transferRecord.outlet_Id);

            record.shoesTransfered = handler.TransferShoes(record.transfer_Id, outletId, model.shoes, model.sizes, model.colors, model.qty);

            habib.SaveChanges();


            return(View("OutletSelect"));
        }
 public ActionResult Create(Employee model, FormCollection form)
 {
     if (ModelState.IsValid)
     {
         model.DeleteStatus   = 0;
         model.typeOfEmployee = form["typeofemp"];
         try
         {
             model.dateOfHiring = form["dateobj"].ToString();;
         }
         catch
         {
             model.dateOfHiring = null;
         }
         habib.Employees.Add(model);
         habib.SaveChanges();
         return(RedirectToAction("Index", "Employee"));
     }
     else
     {
         return(View());
     }
 }