Ejemplo n.º 1
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            StockIn stockIn = new StockIn();

            stockIn.CompanyId         = Convert.ToInt32(companyDropDownList.SelectedValue);
            stockIn.ItemId            = Convert.ToInt32(itemDropDownList.SelectedValue);
            stockIn.ReorderLevel      = Convert.ToInt32(reorderLevelTextBox.Text);
            stockIn.AvailableQuantity = Convert.ToInt32(stockInQuantityTextBox.Text);
            stockIn.StockInQuantity   = Convert.ToInt32(stockInQuantityTextBox.Text);
            StockIn aStockIn = stockInManager.GetAvailableAndStockInQuantity(stockIn.ItemId);

            if (aStockIn != null)
            {
                int availableQuantity = aStockIn.AvailableQuantity;
                int stockInQuantity   = aStockIn.StockInQuantity;
                stockIn.AvailableQuantity     = stockIn.AvailableQuantity + availableQuantity;
                stockIn.StockInQuantity       = stockIn.StockInQuantity + stockInQuantity;
                messageLabel.Text             = stockInManager.Update(stockIn);
                availableQuantityTextBox.Text = stockIn.AvailableQuantity.ToString();
            }
            else
            {
                messageLabel.Text             = stockInManager.Save(stockIn);
                availableQuantityTextBox.Text = stockIn.AvailableQuantity.ToString();
            }
            stockInQuantityTextBox.Text = "";
        }
Ejemplo n.º 2
0
        protected void saveButton_OnClick(object sender, EventArgs e)
        {
            // save on stock in and update on available quantity
            // get selected item details
            Items item = (Items)ViewState["ItemVS"];

            // check any valid item selected or not
            if (item != null)
            {
                if (stockInQuantityTextBox.Text.Equals("") || companyDropDownList.Text.Equals("--Select Company--") || itemDropDownList.Text.Equals("--Select Item--"))
                {
                    quantityEmptyTextBoxMessage.Text = "Enter quantity or Select company or Item properly";
                    messageLabel.Text = string.Empty;
                }


                else
                {
                    if (stockInQuantityTextBox.Text.All(char.IsDigit))
                    {
                        int stockInQuantity = Convert.ToInt32(stockInQuantityTextBox.Text);
                        if (stockInQuantity < 0)

                        {
                            quantityEmptyTextBoxMessage.Text = "Enter quantity properly";
                            messageLabel.Text = string.Empty;
                        }

                        else
                        {
                            StockIn stockIn = new StockIn();
                            stockIn.ItemId          = item.Id;
                            stockIn.CompanyId       = item.CompanyId;
                            stockIn.StockInQuantity = stockInQuantity;

                            // get previous quantity of item and update the quantity
                            int previousAvailableQuantity = item.AvailableQuantity;
                            int newAvailableQuantity      = previousAvailableQuantity + stockInQuantity;

                            quantityEmptyTextBoxMessage.Text = "";

                            // save on StockIn table and update on available quantity
                            messageLabel.Text =
                                itemManager.UpdateAvailableQuantityByItemIdAndCompany(stockIn, newAvailableQuantity);
                            GoToPreviousState();
                        }
                    }
                    else
                    {
                        quantityEmptyTextBoxMessage.Text = "Enter quantity correctly";
                    }
                }
            }
            else
            {
                messageLabel.Text = "Select company and item properly";
            }
        }
        protected void addButton_Click(object sender, EventArgs e)
        {
            messageLevel.Text = "";
            StockOut stockOut = new StockOut();

            stockOut.CompanyId         = Convert.ToInt32(companyDropDownList.SelectedValue);
            stockOut.Company           = companyDropDownList.SelectedItem.Text;
            stockOut.ItemId            = Convert.ToInt32(itemDropDownList.SelectedValue);
            stockOut.Item              = itemDropDownList.SelectedItem.Text;
            stockOut.StockOutQuantity  = Convert.ToInt32(stockOutQuantityTextBox.Text);
            stockOut.AvailableQuantity = Convert.ToInt32(availableQuantityTextBox.Text);
            if ((stockOut.AvailableQuantity - stockOut.StockOutQuantity) >= 0)
            {
                StockIn stockIn = new StockIn();
                stockIn.ItemId            = Convert.ToInt32(itemDropDownList.SelectedValue);
                stockIn.AvailableQuantity = stockOut.StockOutQuantity - stockOut.AvailableQuantity;
                if (ViewState["stockOutItem"] == null)
                {
                    List <StockOut> stockOuts = new List <StockOut>();
                    stockOuts.Add(stockOut);
                    stockOut.AvailableQuantity  = stockOut.AvailableQuantity - stockOut.StockOutQuantity;
                    ViewState["stockOutItem"]   = stockOuts;
                    stockOutGridView.DataSource = stockOuts;
                    stockOutGridView.DataBind();
                }
                else
                {
                    List <StockOut> stockOuts = (List <StockOut>)ViewState["stockOutItem"];
                    bool            hasItem   = false;
                    foreach (var stock in stockOuts)
                    {
                        if (stock.Item == stockOut.Item)
                        {
                            hasItem = true;
                            stock.StockOutQuantity     = stock.StockOutQuantity + stockOut.StockOutQuantity;
                            stock.AvailableQuantity    = stock.AvailableQuantity - stockOut.StockOutQuantity;
                            stockOut.AvailableQuantity = stock.AvailableQuantity;
                        }
                    }
                    if (hasItem != true)
                    {
                        stockOut.AvailableQuantity = stockOut.AvailableQuantity - stockOut.StockOutQuantity;
                        stockOuts.Add(stockOut);
                    }

                    stockOutGridView.DataSource = stockOuts;
                    stockOutGridView.DataBind();
                }
                availableQuantityTextBox.Text = stockOut.AvailableQuantity.ToString();
            }
            else
            {
                messageLevel.Text = "Available quantity will not be negative";
            }
            availableQuantityTextBox.Text = stockOut.AvailableQuantity.ToString();
        }
Ejemplo n.º 4
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            StockIn stockIn = new StockIn();

            stockIn.CompanyId         = companyDropDownList.SelectedItem.Value;
            stockIn.ItemId            = Int32.Parse(itemDropDownList.SelectedItem.Value);
            stockIn.ItemName          = itemDropDownList.SelectedItem.Text;
            stockIn.AvailableQuantity = Int32.Parse(avilableQuantityTextBox.Text);
            stockIn.StockInQuantity   = Int32.Parse(stockInTextBox.Text);

            outputMsgLabel.Text = stockManager.StockSaveUpdate(stockIn);
        }
Ejemplo n.º 5
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            StockIn item = new StockIn();

            item.CompanyId         = companyDropDownList.SelectedItem.Value;
            item.ItemId            = Int32.Parse(itemDropDownList.SelectedItem.Value);
            item.ItemName          = itemDropDownList.SelectedItem.Text;
            item.AvailableQuantity = Int32.Parse(avilableQuantityTextBox.Text);
            item.StockInQuantity   = Int32.Parse(stockInTextBox.Text);

            string message = stockManager.StockSaveUpdate(item);


            outputMsgLabel.Text = message;

            //Clear All
            companyDropDownList.DataSource     = companyManager.GetAllCompany();
            companyDropDownList.DataTextField  = "Name";
            companyDropDownList.DataValueField = "Sl";
            companyDropDownList.DataBind();

            ListItem liComapny = new ListItem("--- Select Item---", "-1");

            companyDropDownList.Items.Insert(0, liComapny);

            itemDropDownList.Items.Clear();

            ListItem liItem = new ListItem("--- Select Item---", "-1");

            itemDropDownList.Items.Insert(0, liItem);
            itemDropDownList.DataTextField  = "Name";
            itemDropDownList.DataValueField = "Sl";
            itemDropDownList.DataBind();

            itemDropDownList.Enabled        = false;
            reorderTextBox.Enabled          = false;
            avilableQuantityTextBox.Enabled = false;

            reorderTextBox.Text          = "";
            avilableQuantityTextBox.Text = "";
            stockInTextBox.Text          = "";
        }
        protected void lostButton_Click(object sender, EventArgs e)
        {
            foreach (GridViewRow row in stockOutGridView.Rows)
            {
                StockIn  stockIn  = new StockIn();
                StockOut stockOut = new StockOut();
                stockOut.Item              = ((Label)row.FindControl("ItemNameLabel")).Text;
                stockOut.Company           = ((Label)row.FindControl("companyNameLabel")).Text;
                stockOut.StockOutQuantity  = Convert.ToInt32(((Label)row.FindControl("stockOutQuantityLabel")).Text);
                stockOut.ActionType        = "Lost";
                stockOut.ItemId            = itemManager.GetItemIdByItemName(stockOut.Item);
                stockOut.AvailableQuantity = stockInManager.GetAvailableQuantity(stockOut.ItemId) -
                                             stockOut.StockOutQuantity;
                messageLevel.Text = stockOutManager.AddStockOut(stockOut);

                stockIn.ItemId            = stockOut.ItemId;
                stockIn.AvailableQuantity = stockOut.AvailableQuantity;
                stockInManager.UpdateAvailableQuantity(stockIn);
            }
            SettingNull();
        }
Ejemplo n.º 7
0
        private void StockInButton_Click(object sender, EventArgs e)
        {
            StockIn stockIn = new StockIn();

            stockIn.Show(this);
        }