Exemplo n.º 1
0
        protected void GVDetQuot_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            if (ViewState["dt_adItm"] != null)
            {
                DataTable dt           = (DataTable)ViewState["dt_adItm"];
                DataRow   drCurrentRow = null;
                int       rowIndex     = Convert.ToInt32(e.RowIndex);
                if (dt.Rows.Count > 1)
                {
                    dt.Rows.Remove(dt.Rows[rowIndex]);
                    drCurrentRow          = dt.NewRow();
                    ViewState["dt_adItm"] = dt;

                    GVDetQuot.DataSource = dt;
                    GVDetQuot.DataBind();

                    SetPreRowquot();

                    float GTotal = 0;
                    for (int j = 0; j < GVDetQuot.Rows.Count; j++)
                    {
                        TextBox total = (TextBox)GVDetQuot.Rows[j].FindControl("TBAmt");
                        //GTotal = Convert.ToSingle(TbAddPurNetTtl.Text);
                        GTotal += Convert.ToSingle(total.Text);
                    }
                    TBGrssTotal.Text = GTotal.ToString();
                    ptnSno();
                }
            }
        }
Exemplo n.º 2
0
        private void SetInitRowQuot()
        {
            DataTable dt = new DataTable();
            DataRow   dr = null;

            dt.Columns.Add(new DataColumn("PRODUCTS", typeof(string)));
            dt.Columns.Add(new DataColumn("QUANTITY", typeof(string)));
            dt.Columns.Add(new DataColumn("RATE", typeof(string)));
            dt.Columns.Add(new DataColumn("AMOUNT", typeof(string)));
            dt.Columns.Add(new DataColumn("NARRATION", typeof(string)));

            dr              = dt.NewRow();
            dr["PRODUCTS"]  = string.Empty;
            dr["QUANTITY"]  = string.Empty;
            dr["RATE"]      = string.Empty;
            dr["AMOUNT"]    = string.Empty;
            dr["NARRATION"] = string.Empty;

            dt.Rows.Add(dr);

            //Store the DataTable in ViewState
            ViewState["dt_adItm"] = dt;

            GVDetQuot.DataSource = dt;
            GVDetQuot.DataBind();
        }
Exemplo n.º 3
0
 public void Clear()
 {
     TBQuot_dat.Text      = DateTime.Now.ToShortDateString();
     TBRmk.Text           = "";
     TBGrssTotal.Text     = "";
     GVDetQuot.DataSource = null;
     GVDetQuot.DataBind();
     SetInitRowQuot();
     BindPro();
 }
Exemplo n.º 4
0
        private void AddNewRow()
        {
            int rowIndex = 0;

            if (ViewState["dt_adItm"] != null)
            {
                DataTable dt    = (DataTable)ViewState["dt_adItm"];
                DataRow   drRow = null;
                if (dt.Rows.Count > 0)
                {
                    for (int i = 1; i <= dt.Rows.Count; i++)
                    {
                        //extract the TextBox values
                        DropDownList DDLPro   = (DropDownList)GVDetQuot.Rows[rowIndex].Cells[0].FindControl("DDL_Pro");
                        TextBox      TBProQty = (TextBox)GVDetQuot.Rows[rowIndex].Cells[1].FindControl("TBProQty");
                        TextBox      TBProrat = (TextBox)GVDetQuot.Rows[rowIndex].Cells[2].FindControl("TBProrat");
                        TextBox      TBAmt    = (TextBox)GVDetQuot.Rows[rowIndex].Cells[3].FindControl("TBAmt");
                        TextBox      TBNarr   = (TextBox)GVDetQuot.Rows[rowIndex].Cells[4].FindControl("TBNarr");

                        drRow = dt.NewRow();

                        dt.Rows[i - 1]["PRODUCTS"]  = DDLPro.Text;
                        dt.Rows[i - 1]["QUANTITY"]  = TBProQty.Text;
                        dt.Rows[i - 1]["RATE"]      = TBProrat.Text;
                        dt.Rows[i - 1]["AMOUNT"]    = TBAmt.Text;
                        dt.Rows[i - 1]["NARRATION"] = TBNarr.Text;

                        rowIndex++;

                        float GTotal = 0;
                        for (int j = 0; j < GVDetQuot.Rows.Count; j++)
                        {
                            TextBox total = (TextBox)GVDetQuot.Rows[j].FindControl("TBAmt");
                            //GTotal = Convert.ToSingle(TbAddPurNetTtl.Text);
                            GTotal += Convert.ToSingle(total.Text);
                        }
                        TBGrssTotal.Text = GTotal.ToString();
                    }
                    dt.Rows.Add(drRow);
                    ViewState["dt_adItm"] = dt;

                    GVDetQuot.DataSource = dt;
                    GVDetQuot.DataBind();
                }
            }
            else
            {
                Response.Write("ViewState is null");
            }

            //Set Previous Data on Postbacks
            SetPreRowquot();
        }