Example #1
0
        protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow && ((AVRequestDetail)e.Row.DataItem).ItemID != null)
            {
                AVRequestDetail avR      = (AVRequestDetail)e.Row.DataItem;
                string          itemId   = avR.ItemID;
                string          itemName = InventoryLogic.GetItemName(itemId);
                string          adjValue = ((double)(InventoryLogic.GetInventoryPrice(itemId) * avR.Quantity)).ToString("c");

                Label LblDesc = (e.Row.FindControl("LblDesc") as Label);
                if (LblDesc != null)
                {
                    LblDesc.Text = itemName;
                }
                Label LblValue = (e.Row.FindControl("LblValue") as Label);
                if (LblValue != null)
                {
                    LblValue.Text = adjValue;
                }
                DropDownList DdlType = (e.Row.FindControl("DdlAdjType") as DropDownList);
                if (DdlType != null)
                {
                    DdlType.Text = avR.Type;
                }
            }
        }
Example #2
0
        protected void BtnAddItem_Click(object sender, EventArgs e)
        {
            List <AVRequestDetail> adjDetailList = new List <AVRequestDetail>();

            try
            {
                foreach (GridViewRow r in GridViewAdjV.Rows)
                {
                    AVRequestDetail adjVDetail = new AVRequestDetail();
                    adjVDetail.ItemID   = (r.FindControl("TxtItemCode") as TextBox).Text;
                    adjVDetail.Type     = (r.FindControl("DdlAdjType") as DropDownList).SelectedValue;
                    adjVDetail.Quantity = int.Parse((r.FindControl("TxtAdjQty") as TextBox).Text);
                    adjVDetail.Reason   = (r.FindControl("TxtReason") as TextBox).Text;
                    adjVDetail.UOM      = (r.FindControl("LblUOM") as Label).Text;
                    adjDetailList.Add(adjVDetail);
                }
            }catch (Exception ex)
            {
                statusMessage.Text      = "Error! Please enter an item before added new line item.";
                statusMessage.ForeColor = Color.Red;
                statusMessage.Visible   = true;
                Console.WriteLine(ex.ToString());
                return;
            }
            AVRequestDetail adjVDetailNew = new AVRequestDetail();

            adjDetailList.Add(adjVDetailNew);
            GridViewAdjV.DataSource = adjDetailList;
            GridViewAdjV.DataBind();
        }
Example #3
0
        protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            statusMessage.Visible = false;

            try
            {
                Label LblSn = GridViewAdjV.Rows[e.RowIndex].Cells[0].FindControl("LblSn") as Label;
                int   sN    = int.Parse(LblSn.Text);

                List <AVRequestDetail> adjDetailList = new List <AVRequestDetail>();
                foreach (GridViewRow r in GridViewAdjV.Rows)
                {
                    AVRequestDetail adjVDetail = new AVRequestDetail();
                    adjVDetail.ItemID   = (r.FindControl("TxtItemCode") as TextBox).Text;
                    adjVDetail.Type     = (r.FindControl("DdlAdjType") as DropDownList).SelectedValue;
                    adjVDetail.Quantity = int.Parse((r.FindControl("TxtAdjQty") as TextBox).Text);
                    adjVDetail.Reason   = (r.FindControl("TxtReason") as TextBox).Text;
                    adjVDetail.UOM      = (r.FindControl("LblUOM") as Label).Text;
                    adjDetailList.Add(adjVDetail);
                }
                AVRequestDetail adjVDetailNew = new AVRequestDetail();
                adjDetailList.RemoveAt(sN - 1);
                GridViewAdjV.DataSource = adjDetailList;
                GridViewAdjV.DataBind();
            }catch (Exception ex)
            {
                statusMessage.Text      = "Invalid delete action.";
                statusMessage.ForeColor = Color.Red;
                statusMessage.Visible   = true;
            }
        }
Example #4
0
        protected void BindGrid()
        {
            AVRequestDetail        adjVDetail    = new AVRequestDetail();
            List <AVRequestDetail> adjDetailList = new List <AVRequestDetail>();

            adjDetailList.Add(adjVDetail);
            GridViewAdjV.DataSource = adjDetailList;
            GridViewAdjV.DataBind();
        }