Esempio n. 1
0
        private void SetInitRowitm()
        {
            DataTable dt = new DataTable();
            DataRow   dr = null;

            dt.Columns.Add(new DataColumn("ITEMS", typeof(string)));
            dt.Columns.Add(new DataColumn("DESCRIPTIONS", typeof(string)));
            dt.Columns.Add(new DataColumn("QTY", typeof(string)));
            dt.Columns.Add(new DataColumn("UNIT", typeof(string)));
            dt.Columns.Add(new DataColumn("rat", typeof(string)));
            dt.Columns.Add(new DataColumn("Amount", typeof(string)));
            dt.Columns.Add(new DataColumn("REMARKS", typeof(string)));

            dr = dt.NewRow();

            dr["ITEMS"]        = string.Empty;
            dr["DESCRIPTIONS"] = string.Empty;
            dr["QTY"]          = string.Empty;
            dr["UNIT"]         = string.Empty;
            dr["rat"]          = string.Empty;
            dr["Amount"]       = string.Empty;
            dr["REMARKS"]      = string.Empty;

            dt.Rows.Add(dr);

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

            GVDNItm.DataSource = dt;
            GVDNItm.DataBind();
        }
Esempio n. 2
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 ddl_Itm            = (DropDownList)GVDNItm.Rows[rowIndex].Cells[0].FindControl("ddl_Itm");
                        TextBox      TbaddSalItmDscptin = (TextBox)GVDNItm.Rows[rowIndex].Cells[1].FindControl("TbaddSalItmDscptin");
                        TextBox      TbAddSalItmQty     = (TextBox)GVDNItm.Rows[rowIndex].Cells[2].FindControl("TbAddSalItmQty");
                        TextBox      TbAddSalUnit       = (TextBox)GVDNItm.Rows[rowIndex].Cells[3].FindControl("TbAddSalUnit");
                        TextBox      TBTtl    = (TextBox)GVDNItm.Rows[rowIndex].Cells[4].FindControl("TBTtl");
                        TextBox      TBamt    = (TextBox)GVDNItm.Rows[rowIndex].Cells[5].FindControl("TBamt");
                        TextBox      TBDDNRmk = (TextBox)GVDNItm.Rows[rowIndex].Cells[6].FindControl("TBDDNRmk");


                        drRow = dt.NewRow();

                        dt.Rows[i - 1]["ITEMS"]        = ddl_Itm.SelectedValue;
                        dt.Rows[i - 1]["DESCRIPTIONS"] = TbaddSalItmDscptin.Text;
                        dt.Rows[i - 1]["QTY"]          = TbAddSalItmQty.Text;
                        dt.Rows[i - 1]["UNIT"]         = TbAddSalUnit.Text;
                        dt.Rows[i - 1]["rat"]          = TBTtl.Text;
                        dt.Rows[i - 1]["Amount"]       = TBamt.Text;
                        dt.Rows[i - 1]["REMARKS"]      = TBDDNRmk.Text;


                        rowIndex++;

                        ddl_Itm.Focus();
                    }

                    dt.Rows.Add(drRow);
                    ViewState["dt_adItm"] = dt;

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

            //Set Previous Data on Postbacks
            SetPreRowitm();
        }
Esempio n. 3
0
        protected void GVDNItm_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;

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

                    SetPreRowitm();
                }
            }
        }
Esempio n. 4
0
        protected void TB_Sal_TextChanged2(object sender, EventArgs e)
        {
            v_sal.Text = "";
            try
            {
                using (SqlCommand cmdpro = new SqlCommand())
                {
                    cmdpro.CommandText = " select MSal_sono, MSal_dat, custacc,Booker,SalMan,tbl_MSal.CustomerID,* from tbl_MSal " +
                                         " inner join SubHeadCategories on tbl_MSal.CustomerID= SubHeadCategories.SubHeadCategoriesGeneratedID  " +
                                         " where tbl_MSal.ISActive = 'True' and MSal_sono='" + TB_Sal.Text.Trim() + "'";

                    cmdpro.Connection = con;
                    con.Open();

                    DataTable      dtSal = new DataTable();
                    SqlDataAdapter adp   = new SqlDataAdapter(cmdpro);
                    adp.Fill(dtSal);
                    //AMT
                    if (dtSal.Rows.Count > 0)
                    {
                        TBSalDat.Text          = dtSal.Rows[0]["MSal_dat"].ToString();
                        ddl_Cust.SelectedValue = dtSal.Rows[0]["custacc"].ToString();
                        //ddl_bokr.SelectedValue = dtSal.Rows[0]["Booker"].ToString();
                        HFSAL.Value = dtSal.Rows[0]["MSal_id"].ToString();
                        //ddl_sup.SelectedValue = dtSal.Rows[0]["ddl_sup"].ToString();
                    }

                    query = " select tbl_MSal.MSal_id,tbl_DSal.ProductID as [ITEMS],ProductName as [DESCRIPTIONS] , " +
                            " DSal_ItmQty as [QTY], DSal_ItmUnt as [UNIT],'' as [REMARKS],amt as [AMT],rat,(DSal_ItmQty * rat) as [Amount], " +
                            " * from tbl_MSal inner join tbl_DSal " +
                            " on tbl_MSal.MSal_id = tbl_DSal.MSal_id inner join Products " +
                            " on tbl_DSal.ProductID = Products.ProductID " +
                            // " inner join  tbl_unts on products.Unit = tbl_unts.untid" +
                            " where tbl_MSal.ISActive = 'True' " +
                            " and tbl_MSal.MSal_sono='" + TB_Sal.Text.Trim() + "'";

                    dt_ = DBConnection.GetQueryData(query);

                    ViewState["dt_adItm"] = dt_;

                    if (dt_.Rows.Count > 0)
                    {
                        GVDNItm.DataSource = dt_;
                        GVDNItm.DataBind();

                        //lbl_ttl.Text = dt_.Rows[0]["AMT"].ToString();
                    }

                    for (int i = 0; i < GVDNItm.Rows.Count; i++)
                    {
                        DropDownList ddl_Itm = (DropDownList)GVDNItm.Rows[i].Cells[0].FindControl("ddl_Itm");
                        Label        lbl_itm = (Label)GVDNItm.Rows[i].Cells[0].FindControl("lbl_itm");

                        ddl_Itm.SelectedValue = lbl_itm.Text;
                    }
                    con.Close();

                    DataTable dtsalcre = new DataTable();
                    query = "select CredAmt from tbl_Salcredit where CustomerID='" + ddl_Cust.SelectedValue.Trim() + "'";

                    dtsalcre = DBConnection.GetQueryData(query);


                    if (dtsalcre.Rows.Count > 0)
                    {
                        lbl_ttl.Text = dtsalcre.Rows[0]["CredAmt"].ToString();
                    }
                    ddl_Cust.Focus();
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "Alert();", true);
                lblalert.Text = ex.Message;
            }
        }