Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Session["ProfileMonitorBroker"] != null)
                {
                    if (Session["ProfileMonitorBroker"].GetType() != typeof(AdminAgent))
                    {
                        _pmb = new AdminAgent();
                    }
                    else
                    {
                        _pmb = (AdminAgent)Session["ProfileMonitorBroker"];
                    }
                }
                else
                {
                    _pmb = new AdminAgent();
                }

                if (Session["StockBroker"] != null)
                {
                    if (Session["StockBroker"].GetType() != typeof(AdminAgent))
                    {
                        _sb = new AdminAgent();
                    }
                    else
                    {
                        _sb = (AdminAgent)Session["StockBroker"];
                    }
                }
                else
                {
                    _sb = new AdminAgent();
                }

                _sb._CustomerId = _pmb._Id;

                firstNamelbl.Text  = _pmb._FirstName;
                lastNamelbl.Text   = _pmb._LastName;
                MiddleNamelbl.Text = _pmb._MiddleName;

                if (Session["SelectedBookOut"] != null)
                {
                    SelectedBookOutDT = (DataTable)Session["SelectedBookOut"];
                }
                else
                {
                    SelectedBookOutDT = new DataTable();
                }

                SelectedBookOutGV.DataSource = SelectedBookOutDT;
                SelectedBookOutGV.DataBind();
                Calculate();
            }
        }
Exemple #2
0
        protected void SelectedBookOutGV_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                string t     = e.CommandName;
                int    index = int.Parse(e.CommandArgument.ToString());
                if (t == "Inc" || t == "Dec")
                {
                    int   a = int.Parse(SelectedBookOutDT.Rows[index]["Amount"].ToString());
                    int   q = int.Parse(SelectedBookOutDT.Rows[index]["Quantity"].ToString());
                    float p = float.Parse(SelectedBookOutDT.Rows[index]["BookPrice"].ToString());

                    if (t == "Inc")
                    {
                        q++;
                        if (q <= a)
                        {
                            SelectedBookOutDT.Rows[index]["Quantity"] = q;
                        }
                    }
                    else if (t == "Dec")
                    {
                        if (q > 1)
                        {
                            q--;
                            SelectedBookOutDT.Rows[index]["Quantity"] = q;
                        }
                    }

                    SelectedBookOutDT.Rows[index]["Total"] = Math.Round(q * p, 1);
                    SelectedBookOutGV.DataSource           = SelectedBookOutDT;
                    SelectedBookOutGV.DataBind();
                    Calculate();
                    Save();
                }
                else if (t == "Delete")
                {
                    SelectedBookOutDT.Rows.RemoveAt(index);

                    SelectedBookOutGV.DataSource = SelectedBookOutDT;
                    SelectedBookOutGV.DataBind();

                    if (SelectedBookOutDT.Rows.Count == 0)
                    {
                        Save();
                        Response.Redirect("~/Pages/BookPages/EditBookPage.aspx");
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Session["SelectedBookOut"] != null)
                {
                    SelectedBookOutDT = (DataTable)Session["SelectedBookOut"];
                }
                else
                {
                    SelectedBookOutDT = new DataTable();
                }

                SelectedBookOutGV.DataSource = SelectedBookOutDT;
                SelectedBookOutGV.DataBind();

                Calculate();
            }
        }