private List <StockDetailModel> GetStockDetails(string itemId, string itemType, string assetLocationId)
        {
            List <StockDetailModel> model = new List <StockDetailModel>();

            Business.Inventory.Stock objStock = new Business.Inventory.Stock();

            Business.Inventory.Inventory objInventory = new Business.Inventory.Inventory();
            DataTable response = new DataTable();

            if (Convert.ToInt32(assetLocationId) == (int)AssetLocation.Store)
            {
                response = objInventory.Inventory_StockLocationWiseQuantity(Convert.ToInt32(itemId), (ItemType)Enum.Parse(typeof(ItemType), itemType));
                if (response != null && response.AsEnumerable().Any())
                {
                    foreach (DataRow dr in response.Rows)
                    {
                        model.Add(new Models.StockDetailModel
                        {
                            Quantity = string.Format("Quantity: {0}", dr["Quantity"].ToString()),
                            Name     = string.Format("Store: {0}", dr["StoreName"].ToString()),
                        });
                    }
                }
            }
            else if ((Convert.ToInt32(assetLocationId) == (int)AssetLocation.FOC) ||
                     (Convert.ToInt32(assetLocationId) == (int)AssetLocation.Sale))
            {
                int challanTypeId = 0;
                if ((AssetLocation)Enum.Parse(typeof(AssetLocation), assetLocationId) == AssetLocation.Sale)
                {
                    challanTypeId = 1;
                }
                else
                {
                    challanTypeId = 2;
                }
                response = objInventory.Inventory_SaleFocWiseQuantity(Convert.ToInt32(itemId), (ItemType)Enum.Parse(typeof(ItemType), itemType), challanTypeId);
                if (response != null && response.AsEnumerable().Any())
                {
                    foreach (DataRow dr in response.Rows)
                    {
                        model.Add(new Models.StockDetailModel
                        {
                            Quantity = string.Format("Quantity: {0}", dr["Quantity"].ToString()),
                            Name     = string.Format("Customer Name: {0}", dr["Customer"].ToString()),
                        });
                    }
                }
            }

            return(model);
        }
Пример #2
0
 protected void gvStockSnap_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "Details")
         {
             string itemId          = e.CommandArgument.ToString().Split('|')[0];
             string itemType        = e.CommandArgument.ToString().Split('|')[1];
             string assetLocationId = e.CommandArgument.ToString().Split('|')[2];
             Business.Inventory.Inventory objInventory = new Business.Inventory.Inventory();
             if (Convert.ToInt32(assetLocationId) == (int)AssetLocation.Store)
             {
                 DataTable dtDetails = objInventory.Inventory_StockLocationWiseQuantity(Convert.ToInt32(itemId), (ItemType)Enum.Parse(typeof(ItemType), itemType));
                 gvStockLocation.DataSource = dtDetails;
                 gvStockLocation.DataBind();
             }
             else if ((Convert.ToInt32(assetLocationId) == (int)AssetLocation.FOC) ||
                      (Convert.ToInt32(assetLocationId) == (int)AssetLocation.Sale))
             {
                 int challanTypeId = 0;
                 if ((AssetLocation)Enum.Parse(typeof(AssetLocation), assetLocationId) == AssetLocation.Sale)
                 {
                     challanTypeId = 1;
                 }
                 else
                 {
                     challanTypeId = 2;
                 }
                 DataTable dtDetails = objInventory.Inventory_SaleFocWiseQuantity(Convert.ToInt32(itemId), (ItemType)Enum.Parse(typeof(ItemType), itemType), challanTypeId);
                 gvStockLocation.DataSource = dtDetails;
                 gvStockLocation.DataBind();
             }
             ModalPopupExtender2.Show();
         }
     }
     catch (Exception ex)
     {
         ex.WriteException();
     }
 }