Exemplo n.º 1
0
        public DisplayWShelfItemDetails LoadEditShelfItems(string shelfId)
        {
            var obj = new DisplayWShelfItemDetails();
            WShelfItemDetailsDAL shelfDAl = new WShelfItemDetailsDAL(ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString);

            obj = shelfDAl.GetDisplayWShelfItemDetailsBYId(Convert.ToInt32(shelfId));
            WareShelfDAL shelRow = new WareShelfDAL(ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString);
            var          shelf   = shelRow.GetShelfById(obj.LocationId);

            obj.LocationColumnName = shelf.ColumnName;
            return(obj);
        }
        public DisplayWShelfItemDetails LoadEditShelfItems(string suppItemCode)
        {
            var obj = new DisplayWShelfItemDetails();
            WShelfItemDetailsDAL shelfDAl = new WShelfItemDetailsDAL(ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString);
            var supplierIdForInhouse      = 8;

            var          itemHouse = shelfDAl.GetItemBySupplierIdAndItemCode(suppItemCode.Trim(), supplierIdForInhouse);
            WareShelfDAL shelRow   = new WareShelfDAL(ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString);



            if (itemHouse.ItemID > 0)
            {
                var listItmesShelf = shelfDAl.GetAllShelfItems();
                var itemSelected   = (from sh in listItmesShelf where sh.ItemId == itemHouse.ItemID select sh).ToList();
                if (itemSelected.Count() > 0)
                {
                    obj.ItemId             = itemSelected[0].ItemId;
                    obj.Boxing             = listItmesShelf[0].Boxing;
                    obj.Brand              = listItmesShelf[0].Brand;
                    obj.COG                = listItmesShelf[0].COG;
                    obj.Damaged            = listItmesShelf[0].Damaged;
                    obj.Description        = listItmesShelf[0].Description;
                    obj.DSB                = listItmesShelf[0].DSB;
                    obj.Height             = listItmesShelf[0].Height;
                    obj.Id                 = listItmesShelf[0].Id;
                    obj.Length             = listItmesShelf[0].Length;
                    obj.LocationColumnName = listItmesShelf[0].LocationColumnName;
                    obj.LocationId         = listItmesShelf[0].LocationId;
                    obj.LocationRowNumber  = listItmesShelf[0].LocationRowNumber;
                    obj.ManagerUnitPrice   = listItmesShelf[0].ManagerUnitPrice;
                    obj.Name               = listItmesShelf[0].Name;
                    obj.Notes              = listItmesShelf[0].Notes;
                    obj.OEMCode            = listItmesShelf[0].OEMCode;
                    obj.Quantity           = listItmesShelf[0].Quantity;
                    obj.RepUnitPrice       = listItmesShelf[0].RepUnitPrice;
                    obj.SupplierItemCode   = listItmesShelf[0].SupplierItemCode;
                }
            }

            return(obj);
        }
Exemplo n.º 3
0
        public void CreateShelfItems(DisplayWShelfItemDetails obj)
        {
            if (obj != null)
            {
                var connString = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
                var itemDal    = new ItemDAL(connString);
                var listItems  = obj.DisplayWItemQuantity;
                WShelfItemDetailsDAL shelfDAl = new WShelfItemDetailsDAL(ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString);

                obj.CreatedUserId = Convert.ToInt32(Session["LoggedUserID"].ToString());

                var supplierIdForInhouse = 30; //TW-INHOUSE
                var splitChar            = obj.SupplierItemCode.Trim().Substring(0, 2);
                if (splitChar.ToUpper() == "DS")
                {
                    supplierIdForInhouse = 8;
                }

                var itemHouse = shelfDAl.GetItemBySupplierIdAndItemCode(obj.SupplierItemCode.Trim(), supplierIdForInhouse);
                if (string.IsNullOrEmpty(obj.Length))
                {
                    obj.Length = "0";
                }
                if (string.IsNullOrEmpty(obj.Weight))
                {
                    obj.Weight = "0";
                }
                if (string.IsNullOrEmpty(obj.Height))
                {
                    obj.Height = "0";
                }
                if (string.IsNullOrEmpty(obj.Width))
                {
                    obj.Width = "0";
                }

                if (itemHouse.ItemID > 0)
                {
                    var cog          = float.Parse(obj.COG);
                    var managerPrice = float.Parse(obj.RepUnitPrice);
                    int qty          = 0;
                    if (!string.IsNullOrEmpty(obj.Quantity))
                    {
                        qty = Convert.ToInt32(obj.Quantity);
                    }
                    double?dsb = null;
                    if (!string.IsNullOrEmpty(obj.DSB))
                    {
                        dsb = Convert.ToDouble(obj.DSB);
                    }
                    var active = "Y";
                    if (obj.ActiveSts == false)
                    {
                        active = "N";
                    }
                    shelfDAl.UpdateItem(itemHouse.ItemID, obj.Description.Trim(), cog, managerPrice, supplierIdForInhouse,
                                        obj.SupplierItemCode.Trim(), active, "Y", "N", qty, dsb, obj.OEMCode);
                    var itemIdINShelf = shelfDAl.CheckItemIdExistOrNotInShelf(itemHouse.ItemID);
                    obj.ItemId = itemHouse.ItemID;
                    if (itemIdINShelf > 0)
                    {
                        obj.Id = itemIdINShelf;
                        shelfDAl.UpdateWShelfItemDetailsAndWItemQuantity(obj);
                    }
                    else
                    {
                        shelfDAl.CreateWShelfItemDetailsAndWItemQuantity(obj);
                    }
                }
                else
                {
                    int qty          = 0;
                    var cog          = float.Parse(obj.COG);
                    var managerPrice = float.Parse(obj.RepUnitPrice);
                    if (!string.IsNullOrEmpty(obj.Quantity))
                    {
                        qty = Convert.ToInt32(obj.Quantity);
                    }
                    double?dsb = null;
                    if (!string.IsNullOrEmpty(obj.DSB))
                    {
                        dsb = Convert.ToDouble(obj.DSB);
                    }
                    shelfDAl.AddNewItem(supplierIdForInhouse.ToString(), obj.SupplierItemCode.Trim(), obj.Description.Trim(),
                                        cog, managerPrice, "Y", "N", qty, dsb, obj.OEMCode);
                    var user   = "******";
                    var itemId = shelfDAl.GetLastInsertedItemId(obj.SupplierItemCode, supplierIdForInhouse, user);
                    //insert item and create itemshelf
                    obj.ItemId = itemId;
                    shelfDAl.CreateWShelfItemDetailsAndWItemQuantity(obj);
                }
            }
        }