Ejemplo n.º 1
0
    protected void ButDelete_Click(object sender, EventArgs e)
    {
        //int RowIndex = 0;
        //GvStockList.Rows[RowIndex]
        // int abc= GvStockList.SelectedIndex;

        //int abc=  ((System.Web.UI.WebControls.GridViewRow)(((System.Web.UI.Control)(sender))._parent._parent))._rowIndex;

        // int abc = ((System.Web.UI.WebControls.GridViewRow)(((System.Web.UI.Control)(sender)).Parent.Parent)).RowIndex;
        //DataTable dt = (DataTable)ViewState["StockDetail"];
        //dt.Rows.RemoveAt(abc);
        //ViewState["StockDetail"] = dt;
        //GvStockList.DataSource = dt;
        //GvStockList.DataBind();
        if (GvStockList.Rows.Count > 1)
        {
            if (ViewState["StockDetail"] != null)
            {
                dt = (DataTable)ViewState["StockDetail"];
                int abc = ((System.Web.UI.WebControls.GridViewRow)(((System.Web.UI.Control)(sender)).Parent.Parent)).RowIndex;
                //int rowIndex=Convert.ToInt32(e.
                // dt.Rows[e.Ro].Delete();
            }
            dt.AcceptChanges();
            GvStockList.DataSource = dt;
            GvStockList.DataBind();
            ViewState["StockDetail"] = dt;
        }
    }
Ejemplo n.º 2
0
    private void SetInitialRow()
    {
        DataTable dt = new DataTable();

        DataRow dr = null;

        dt.Columns.Add(new DataColumn("RowNumber", typeof(string)));
        dt.Columns.Add(new DataColumn("Size", typeof(string)));
        dt.Columns.Add(new DataColumn("Qty", typeof(string)));
        dt.Columns.Add(new DataColumn("PRate", typeof(string)));
        dt.Columns.Add(new DataColumn("SRate", typeof(string)));
        dt.Columns.Add(new DataColumn("Amount", typeof(decimal)));
        dt.Columns.Add(new DataColumn("StockId", typeof(int)));
        dt.Columns.Add(new DataColumn("PurchseId", typeof(int)));


        //dt.Columns.Add(new DataColumn("PurchaseBillDate",typeof(DateTime)));
        //dt.Columns.Add(new DataColumn("ReturnStatus",typeof(string)));
        //dt.Columns.Add(new DataColumn("PurchseId", typeof(int)));
        dr = dt.NewRow();

        dr["RowNumber"] = 1;
        dr["Size"]      = string.Empty;
        dr["Qty"]       = string.Empty;
        dr["PRate"]     = string.Empty;
        dr["SRate"]     = string.Empty;
        dr["Amount"]    = decimal.MinValue;
        dr["StockId"]   = int.MinValue;
        dr["PurchseId"] = int.MinValue;

        // dr["PurchaseBillDate"] = DBNull.Value;
        //dr["ReturnStatus"] =string.Empty;
        // dr["PurchseId"] = 0;

        //DataRow dr= dt.NewRow();

        //dt.Rows.Add(totalsRow);
        dt.Rows.Add(dr);
        ViewState["StockDetail"] = dt;
        GvStockList.DataSource   = dt;

        GvStockList.DataBind();
    }
Ejemplo n.º 3
0
    private void AddNewRowToGrid()
    {
        int RowIndex = 0;

        if (ViewState["StockDetail"] != null)
        {
            //DataSet ds = new DataSet();
            DataTable dt = (DataTable)ViewState["StockDetail"];
            DataRow   dr = null;
            if (dt.Rows.Count > 0)
            {
                for (int i = 1; i <= dt.Rows.Count; i++)
                {
                    DropDownList Data1 = (DropDownList)GvStockList.Rows[RowIndex].Cells[1].FindControl("DropSize");

                    TextBox Data2 = (TextBox)GvStockList.Rows[RowIndex].Cells[2].FindControl("TxtQty");
                    //int p1 = Convert.ToInt32(TxtQty.Text);
                    TextBox Data3 = (TextBox)GvStockList.Rows[RowIndex].Cells[3].FindControl("TxtPRate");
                    //double p2 = Convert.ToDouble(TxtPRate.Text);
                    TextBox Data4 = (TextBox)GvStockList.Rows[RowIndex].Cells[4].FindControl("TxtSRate");

                    Label       Data5 = (Label)GvStockList.Rows[RowIndex].Cells[5].FindControl("LblAmount");
                    HiddenField Data6 = (HiddenField)GvStockList.Rows[RowIndex].Cells[6].FindControl("hidStockId");
                    HiddenField Data7 = (HiddenField)GvStockList.Rows[RowIndex].Cells[6].FindControl("hidPurchaseId");


                    //double Amount = (Data2.Text)(Data3.Text);

                    //TextBox Data6 = (TextBox)GvStockList.Rows[RowIndex].Cells[6].FindControl("TxtPBillDate");
                    //TextBox Data7 = (TextBox)GvStockList.Rows[RowIndex].Cells[7].FindControl("TxtReturnStatus");
                    dr = dt.NewRow();
                    dr["RowNumber"] = i + 1;



                    dt.Rows[i - 1]["Size"]  = Data1.SelectedItem.Text;
                    dt.Rows[i - 1]["Qty"]   = Data2.Text;
                    dt.Rows[i - 1]["PRate"] = Data3.Text;
                    dt.Rows[i - 1]["SRate"] = Data4.Text;
                    //dt.Rows[i - 1]["Amount"] =Data5.Text;
                    dt.Rows[i - 1]["Amount"]    = DBNull.Value;
                    dt.Rows[i - 1]["StockId"]   = DBNull.Value;
                    dt.Rows[i - 1]["PurchseId"] = DBNull.Value;

                    RowIndex++;
                    //if (Data6.Text != "")
                    //{
                    //    dt.Rows[i - 1]["PurchaseBillDate"] = Convert.ToDateTime(Data6.Text);
                    //}
                    //else if (Data6.Text == "")
                    //{
                    //    dt.Rows[i - 1]["PurchaseBillDate"] = DBNull.Value;
                    //}
                    //dt.Rows[i - 1]["ReturnStatus"] = Data7.Text;
                }
                dt.Rows.Add(dr);
                ViewState["StockDetail"] = dt;
                GvStockList.DataSource   = dt;

                GvStockList.DataBind();
            }


            //GvStockList.Rows[RowIndex].Cells[5].FindControl("LblAmount");
            // GvStockList.FooterRow.Cells[1].Text = dt.Compute("sum(" + dt.Columns[3].ColumnName + ")", null).ToString();
        }
        else
        {
            Response.Write("ViewState is Null");
        }
        SetPriviousData();
    }