Пример #1
0
 private void GetTonerInventory()
 {
     try
     {
         Business.Inventory.Inventory objInventory = new Business.Inventory.Inventory();
         DataTable dt = objInventory.Inventory_GetApprovedInventorySpareByServiceBookId(Business.Common.Context.ServiceBookId, AssetLocation.Store, ItemType.Toner, Convert.ToInt32(ddlStore.SelectedValue));
         dt.Columns.Add("IsSelected");
         if (Business.Common.Context.SelectedAssets.Rows.Count > 0)
         {
             foreach (DataRow drSelected in Business.Common.Context.SelectedAssets.Rows)
             {
                 if (dt.AsEnumerable().Select(item => item["AssetId"] == drSelected["AssetId"]).Any())
                 {
                     dt.AsEnumerable().Where(item => Guid.Parse(item["AssetId"].ToString()) == Guid.Parse(drSelected["AssetId"].ToString())).FirstOrDefault()["IsSelected"] = "1";
                     dt.AcceptChanges();
                 }
             }
         }
         if (dt != null)
         {
             RepeaterInventory.DataSource = dt;
             RepeaterInventory.DataBind();
         }
     }
     catch (Exception ex)
     {
         ex.WriteException();
     }
 }
        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);
        }
Пример #3
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();
     }
 }
Пример #4
0
        private void LoadItemFromStore()
        {
            Business.Inventory.Inventory objInventory = new Business.Inventory.Inventory();
            DataTable dt = objInventory.Inventory_GetInventoryItem(AssetLocation.Store, _ItemType, _ItemName, _StoreId);

            dt.Columns.Add("IsSelected");
            if (Business.Common.Context.SelectedSaleAssets.Rows.Count > 0)
            {
                foreach (DataRow drSelected in Business.Common.Context.SelectedSaleAssets.Rows)
                {
                    if (dt.AsEnumerable().Where(item => item["AssetId"].ToString() == drSelected["AssetId"].ToString()).Any())
                    {
                        dt.AsEnumerable().Where(item => Guid.Parse(item["AssetId"].ToString()) == Guid.Parse(drSelected["AssetId"].ToString())).FirstOrDefault()["IsSelected"] = "1";
                        dt.AcceptChanges();
                    }
                }
            }
            if (dt != null)
            {
                RepeaterInventory.DataSource = dt;
                RepeaterInventory.DataBind();
            }
        }
Пример #5
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validation())
                {
                    Entity.Purchase.Purchase        purchase        = new Entity.Purchase.Purchase();
                    Business.Purchase.Purchase      objPurchase     = new Business.Purchase.Purchase();
                    Entity.Purchase.PurchaseDetails purchaseDetails = new Entity.Purchase.PurchaseDetails();
                    Entity.Inventory.Inventory      inventory       = new Entity.Inventory.Inventory();
                    Business.Inventory.Inventory    objInventory    = new Business.Inventory.Inventory();

                    purchase.PurchaseOrderNo = (!string.IsNullOrEmpty(txtPurchaseOrderNo.Text.Trim())) ? txtPurchaseOrderNo.Text.Trim() : string.Empty;
                    purchase.PurchaseDate    = Convert.ToDateTime(txtPurchaseDate.Text.Trim());
                    purchase.VendorId        = Convert.ToInt32(ddlVendor.SelectedValue);
                    purchase.InvoiceNo       = (!string.IsNullOrEmpty(txtInvoiceNo.Text.Trim())) ? txtInvoiceNo.Text.Trim() : string.Empty;
                    purchase.InvoiceDate     = (!string.IsNullOrEmpty(txtInvoiceDate.Text.Trim())) ? Convert.ToDateTime(txtInvoiceDate.Text.Trim()) : DateTime.MinValue;
                    purchase.BillAmount      = (!string.IsNullOrEmpty(txtBillAmount.Text.Trim())) ? Convert.ToDecimal(txtBillAmount.Text.Trim()) : 0;
                    purchase.PaymentAmount   = (!string.IsNullOrEmpty(txtPaymentAmount.Text.Trim())) ? Convert.ToDecimal(txtPaymentAmount.Text.Trim()) : 0;
                    int purchaseId = objPurchase.Purchase_Save(purchase);

                    foreach (DataRow drItem in _ItemsList.Rows)
                    {
                        purchase.PurchaseDetailsCollection.Add(
                            new Entity.Purchase.PurchaseDetails()
                        {
                            PurchaseId = purchaseId,
                            ItemId     = Convert.ToInt32(drItem["ItemIdType"].ToString().Split('|')[0]),
                            ItemType   = Convert.ToInt32(drItem["ItemIdType"].ToString().Split('|')[1]),
                            ItemQty    = (!string.IsNullOrEmpty(drItem["Quantity"].ToString())) ? Convert.ToDecimal(drItem["Quantity"].ToString()) : 0,
                            ItemRate   = (!string.IsNullOrEmpty(drItem["Rate"].ToString())) ? Convert.ToDecimal(drItem["Rate"].ToString()) : 0,
                            Discount   = (!string.IsNullOrEmpty(drItem["Discount"].ToString())) ? Convert.ToDecimal(drItem["Discount"].ToString()) : 0,
                            GST        = (!string.IsNullOrEmpty(drItem["GST"].ToString())) ? Convert.ToDecimal(drItem["GST"].ToString()) : 0,
                            HsnCode    = drItem["HsnCode"].ToString()
                        });
                    }
                    int purchaseDetailsResponse = objPurchase.PurchaseDetails_Save(purchase);

                    if (purchaseDetailsResponse > 0)
                    {
                        using (DataTable dtInventory = new DataTable())
                        {
                            dtInventory.Columns.Add("AssetId");
                            dtInventory.Columns.Add("ItemId");
                            dtInventory.Columns.Add("ItemType");
                            dtInventory.Columns.Add("AssetLocationId");
                            dtInventory.Columns.Add("CustomerId");
                            dtInventory.Columns.Add("SaleChallanId");
                            dtInventory.Columns.Add("EmployeeId");
                            dtInventory.Columns.Add("StoreId");

                            foreach (DataRow drItem in _ItemsList.Rows)
                            {
                                for (int qty = 1; qty <= Convert.ToInt32(drItem["Quantity"]); qty++)
                                {
                                    DataRow drInventoryItem = dtInventory.NewRow();
                                    drInventoryItem["AssetId"]         = Guid.NewGuid().ToString().ToUpper();
                                    drInventoryItem["ItemId"]          = drItem["ItemIdType"].ToString().Split('|')[0];
                                    drInventoryItem["ItemType"]        = drItem["ItemIdType"].ToString().Split('|')[1];
                                    drInventoryItem["AssetLocationId"] = (int)AssetLocation.Store; //Stock In
                                    drInventoryItem["CustomerId"]      = "";
                                    drInventoryItem["SaleChallanId"]   = "";
                                    drInventoryItem["EmployeeId"]      = Convert.ToInt32(HttpContext.Current.User.Identity.Name);
                                    drInventoryItem["StoreId"]         = Convert.ToInt32(ddlStore.SelectedValue);
                                    dtInventory.Rows.Add(drInventoryItem);
                                    dtInventory.AcceptChanges();
                                }
                            }

                            inventory.InventoryDetails = dtInventory;
                            int inventoryResponse = objInventory.Inventory_Save(inventory);

                            if (inventoryResponse > 0)
                            {
                                GlobalCache.RemoveAll();
                                ClearMasterControls();
                                ClearItemControls();
                                LoadItemList();
                                Message.IsSuccess = true;
                                Message.Text      = "Purchase Order saved";
                            }
                            else
                            {
                                Message.IsSuccess = false;
                                Message.Text      = "Inventory not saved";
                            }
                        }
                    }
                    else
                    {
                        Message.IsSuccess = false;
                        Message.Text      = "Purchase Order not saved";
                    }
                    Message.Show = true;
                }
            }
            catch (Exception ex)
            {
                ex.WriteException();

                Message.IsSuccess = false;
                Message.Text      = ex.Message;
                Message.Show      = true;
            }
        }
Пример #6
0
        private int SaveInventoryDetails(Entity.Inventory.Inventory inventory, Business.Inventory.Inventory objInventory)
        {
            int inventoryResponse = objInventory.Inventory_Movement(inventory);

            return(inventoryResponse);
        }
Пример #7
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validation())
                {
                    Entity.Sale.SaleChallan        saleChallan        = new Entity.Sale.SaleChallan();
                    Business.Sale.SaleChallan      objSaleChallan     = new Business.Sale.SaleChallan();
                    Entity.Sale.SaleChallanDetails saleChallanDetails = new Entity.Sale.SaleChallanDetails();
                    Entity.Inventory.Inventory     inventory          = new Entity.Inventory.Inventory();
                    Business.Inventory.Inventory   objInventory       = new Business.Inventory.Inventory();

                    saleChallan.CustomerMasterId = GetCustomerIdByName(txtCustomerName.Text.Trim());
                    saleChallan.Note             = txtNote.Text.Trim();
                    saleChallan.ChallanNo        = (!string.IsNullOrEmpty(txtChallanNo.Text.Trim())) ? txtChallanNo.Text.Trim() : string.Empty;
                    saleChallan.OrderNo          = (!string.IsNullOrEmpty(txtOrderNo.Text.Trim())) ? txtOrderNo.Text.Trim() : string.Empty;
                    saleChallan.OrderDate        = (!string.IsNullOrEmpty(txtOrderDate.Text.Trim())) ? Convert.ToDateTime(txtOrderDate.Text.Trim()) : DateTime.MinValue;
                    saleChallan.ChallanTypeId    = Convert.ToInt32(ddlChallanType.SelectedValue);
                    saleChallan.CreatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name);
                    int saleChallanId = objSaleChallan.SaleChallan_Save(saleChallan);

                    int purchaseDetailsResponse = 0;
                    if (saleChallanId > 0)
                    {
                        purchaseDetailsResponse = SaveSaleChallanDetails(saleChallan, objSaleChallan, saleChallanId);
                    }
                    else
                    {
                        throw new Exception("Something went wrong! Sale challan master value not inserted.");
                    }

                    if (purchaseDetailsResponse > 0)
                    {
                        using (DataTable dtInventory = new DataTable())
                        {
                            inventory = PrepareInventoryDetails(saleChallanId, inventory, dtInventory);
                            if (ddlChallanType.SelectedValue == "3")//Stock Transfer
                            {
                                StockLocation_Save(inventory);
                                StockLocationTransaction_Save(inventory);
                                Message.IsSuccess = true;
                                Message.Text      = "Stock transfer successful.";
                            }
                            else
                            {
                                int inventoryResponse = SaveInventoryDetails(inventory, objInventory);
                                StockLocation_Delete(inventory);
                                if (inventoryResponse > 0)
                                {
                                    LoadItemList();
                                    Message.IsSuccess = true;
                                    Message.Text      = "Sale Order saved";
                                }
                                else
                                {
                                    Message.IsSuccess = false;
                                    Message.Text      = "Inventory not saved";
                                }
                            }
                            ClearAllControls();
                        }
                    }
                    else
                    {
                        Message.IsSuccess = false;
                        Message.Text      = "Sale Order not saved";
                    }
                    Message.Show = true;
                }
            }
            catch (Exception ex)
            {
                ex.WriteException();

                Message.IsSuccess = false;
                Message.Text      = ex.Message;
                Message.Show      = true;
            }
        }