Exemple #1
0
        public WCF_ItemList GetItemListByID(string Itemid)
        {
            ItemList I = Business.GetitemListbyItemId(Itemid);
            String   a = Convert.ToString(I.Stock);

            return(new WCF_ItemList(I.ItemId, I.Description, I.Bin, a));
        }
        //This method is to obtain the itemid, quantityadjusted and reason for discrepancy as per input by user on web application.
        protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Session["quantitydiscrepancylist"] != null)
            {
                dt = (DataTable)Session["quantitydiscrepancylist"];
            }
            Page.Validate();
            if (Page.IsValid)
            {
                string       itid        = GridView2.SelectedDataKey.Value.ToString();
                TextBox      tb          = (TextBox)GridView2.SelectedRow.Cells[4].FindControl("TextBox1");
                DropDownList reasons     = (DropDownList)(GridView2.SelectedRow.Cells[5].FindControl("DropDownList2"));
                string       adjquantity = tb.Text;
                string       reason      = (string)reasons.SelectedItem.Text;
                string       sysquantity = Business.GetitemListbyItemId(itid).Stock.ToString();

                int adquantity;
                if (adjquantity != "")
                {
                    adquantity = Int32.Parse(adjquantity);
                }
                else
                {
                    adquantity = Int32.Parse(sysquantity);
                }
                int syquantity         = Int32.Parse(sysquantity);
                int quantitydifference = adquantity - syquantity;

                //setting up datatable with all the information required for adjustment voucher
                //and pass to the next webpage in a session to diplay in a gridview
                if (dt.Columns.Count == 0)
                {
                    dt.Columns.Add("ItemId", typeof(string));
                    dt.Columns.Add("AdjustedQuantity", typeof(string));
                    dt.Columns.Add("Reason", typeof(string));
                }
                //This if condition is add to prevent cases where store clerk submits a adjustment voucher
                //for an item that does not require adjustment voucher. meaning 50 stock in both system and bin.
                if (quantitydifference != 0)
                {
                    DataRow NewRow = dt.NewRow();
                    NewRow[0] = itid;
                    NewRow[1] = quantitydifference;
                    NewRow[2] = reason;

                    dt.Rows.Add(NewRow);
                    Session["quantitydiscrepancylist"] = dt;
                    Label aa = (Label)GridView2.SelectedRow.Cells[4].FindControl("Label1");
                    aa.Text = "Item Added!";
                }
                else
                {
                    Label aa = (Label)GridView2.SelectedRow.Cells[4].FindControl("Label1");
                    aa.Text = "Please enter Quantity.";
                }
            }
        }