Пример #1
0
        protected void GV_POS_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;

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

                    SetPreRowitm();

                    float GTotal = 0;
                    for (int j = 0; j < GV_POS.Rows.Count; j++)
                    {
                        Label lblttl = (Label)GV_POS.Rows[j].FindControl("lblttl");

                        GTotal += Convert.ToSingle(lblttl.Text);
                    }

                    TBTtl.Text = GTotal.ToString();

                    ptnSno();
                }
            }
        }
Пример #2
0
        private void SetInitRowPuritm()
        {
            DataTable dt = new DataTable();
            DataRow   dr = null;

            dt.Columns.Add(new DataColumn("Items", typeof(string)));
            dt.Columns.Add(new DataColumn("Itempric", typeof(string)));
            dt.Columns.Add(new DataColumn("QTY", typeof(string)));
            dt.Columns.Add(new DataColumn("Itemcat", typeof(string)));
            dt.Columns.Add(new DataColumn("TTL", typeof(string)));
            dt.Columns.Add(new DataColumn("Dposid", typeof(string)));
            dt.Columns.Add(new DataColumn("ProductID", typeof(string)));
            dt.Columns.Add(new DataColumn("ProductTypeID", typeof(string)));

            dr = dt.NewRow();

            dr["Items"]         = string.Empty;
            dr["Itempric"]      = "0.00";
            dr["QTY"]           = "0.00";
            dr["Itemcat"]       = string.Empty;
            dr["TTL"]           = "0.00";
            dr["Dposid"]        = string.Empty;
            dr["ProductID"]     = string.Empty;
            dr["ProductTypeID"] = string.Empty;

            dt.Rows.Add(dr);

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

            GV_POS.DataSource = dt;
            GV_POS.DataBind();
        }
Пример #3
0
        protected void TBPos_TextChanged(object sender, EventArgs e)
        {
            try
            {
                string query = " select tbl_MPos.Mposid,tbl_DPos.ProductID,ProductName as [Items],grntttl,tbl_MPos.CustomerName,  " +
                               " Cost as [Itempric],tbl_DPos.ProQty as [Qty],tbl_MPos.BillNO,custtyp, " +
                               " Products.ProductTypeID,ProductTypeName as [Itemcat],tbl_DPos.Ttl as [TTL],Dposid " +
                               " from tbl_MPos inner join tbl_DPos on tbl_MPos.Mposid = tbl_DPos.Mposid  " +
                               //" inner join  Customers_ on tbl_MPos.CustomerName= Customers_.CustomerName  " +
                               " inner join Products on tbl_DPos.ProductID = Products.ProductID " +
                               " inner join tbl_producttype on Products.ProductTypeID = tbl_producttype.ProductTypeID " +
                               " where tbl_MPos.BillNO = '" + TBPos.Text.Trim() + "'";

                SqlCommand     cmd = new SqlCommand(query, con);
                DataTable      dt_ = new DataTable();
                SqlDataAdapter adp = new SqlDataAdapter(cmd);

                adp.Fill(dt_);

                if (dt_.Rows.Count > 0)
                {
                    ddl_custtyp.SelectedValue = dt_.Rows[0]["custtyp"].ToString();
                    TBCust.Text   = dt_.Rows[0]["CustomerName"].ToString();
                    lblbilno.Text = dt_.Rows[0]["BillNO"].ToString();
                    TBTtl.Text    = dt_.Rows[0]["grntttl"].ToString();
                    POSID.Value   = dt_.Rows[0]["Mposid"].ToString();

                    GV_POS.DataSource = dt_;
                    GV_POS.DataBind();

                    ViewState["dt_adItm"] = dt_;
                }
                else
                {
                    ddl_custtyp.SelectedValue = "0";
                    TBCust.Text   = "";
                    lblbilno.Text = "";
                    DataTable d = new DataTable();
                    GV_POS.DataSource = d;
                    GV_POS.DataBind();
                }
            }catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #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
                        TextBox     TBItms     = (TextBox)GV_POS.Rows[rowIndex].Cells[0].FindControl("TBItms");
                        Label       lblItmpris = (Label)GV_POS.Rows[rowIndex].Cells[1].FindControl("lblItmpris");
                        TextBox     TBItmQty   = (TextBox)GV_POS.Rows[rowIndex].Cells[2].FindControl("TBItmQty");
                        Label       lblcat     = (Label)GV_POS.Rows[rowIndex].Cells[3].FindControl("lblcat");
                        Label       lblttl     = (Label)GV_POS.Rows[rowIndex].Cells[4].FindControl("lblttl");
                        HiddenField HFDSal     = (HiddenField)GV_POS.Rows[rowIndex].Cells[5].FindControl("HFDSal");
                        HiddenField HFPROID    = (HiddenField)GV_POS.Rows[rowIndex].Cells[0].FindControl("PROID");
                        HiddenField HFPROCATID = (HiddenField)GV_POS.Rows[rowIndex].Cells[3].FindControl("PROCATID");

                        drRow = dt.NewRow();

                        dt.Rows[i - 1]["Items"]         = TBItms.Text;
                        dt.Rows[i - 1]["Itempric"]      = lblItmpris.Text;
                        dt.Rows[i - 1]["QTY"]           = TBItmQty.Text;
                        dt.Rows[i - 1]["Itemcat"]       = lblcat.Text;
                        dt.Rows[i - 1]["TTL"]           = lblttl.Text;
                        dt.Rows[i - 1]["Dposid"]        = HFDSal.Value;
                        dt.Rows[i - 1]["ProductID"]     = HFPROID.Value;
                        dt.Rows[i - 1]["ProductTypeID"] = HFPROCATID.Value;

                        rowIndex++;

                        float GTotal = 0, CRAmt = 0, DBAmt = 0;
                        for (int j = 0; j < GV_POS.Rows.Count; j++)
                        {
                            Label total = (Label)GV_POS.Rows[j].FindControl("lblttl");
                            //TextBox CRAmtttl = (TextBox)GV_POS.Rows[j].FindControl("Tbcramt");
                            //TextBox DBAmtttl = (TextBox)GV_POS.Rows[j].FindControl("Tbdbamt");

                            GTotal += Convert.ToSingle(total.Text);

                            /*if (CRAmtttl.Text != "0.00" || DBAmtttl.Text != "0.00")
                             * {
                             *  CRAmt += Convert.ToSingle(CRAmtttl.Text);
                             *  DBAmt += Convert.ToSingle(DBAmtttl.Text);
                             * }*/
                            TBTtl.Text = GTotal.ToString();
                        }

                        //TBGrssTotal.Text = GTotal.ToString();
                        //TBTtl.Text = GTotal.ToString();

                        //if (DDL_Paytyp.SelectedValue == "2")
                        //{
                        //    TB_ChqAmt.Text = TBTtl.Text;
                        //    TB_ChqAmt.Enabled = false;
                        //}
                        //else
                        //{
                        //    TB_CshAmt.Text = TBTtl.Text;
                        //    TB_CshAmt.Enabled = false;
                        //}
                        //TBCRAmtttl.Text = CRAmt.ToString();
                        //Customersttl.Text = DBAmt.ToString();


                        //ddlPurItm.Focus();
                    }

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

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

            //Set Previous Data on Postbacks
            SetPreRowitm();
        }
        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 value
                        TextBox      TBItms       = (TextBox)GV_POS.Rows[rowIndex].Cells[0].FindControl("TBItms");
                        HiddenField  HFPROID      = (HiddenField)GV_POS.Rows[rowIndex].Cells[0].FindControl("PROID");
                        Label        PROTYPID     = (Label)GV_POS.Rows[rowIndex].Cells[1].FindControl("PROTYPID");
                        DropDownList DDL_PROTYPID = (DropDownList)GV_POS.Rows[rowIndex].Cells[1].FindControl("DDL_PROTYPID");
                        TextBox      tbfitpric    = (TextBox)GV_POS.Rows[rowIndex].Cells[2].FindControl("tbfitpric");
                        TextBox      tbItmpris    = (TextBox)GV_POS.Rows[rowIndex].Cells[3].FindControl("tbItmpris");
                        TextBox      tbsalpris    = (TextBox)GV_POS.Rows[rowIndex].Cells[4].FindControl("tbsalpris");
                        TextBox      TBItmQty     = (TextBox)GV_POS.Rows[rowIndex].Cells[5].FindControl("TBItmQty");
                        Label        lblttl       = (Label)GV_POS.Rows[rowIndex].Cells[6].FindControl("lblttl");
                        HiddenField  HFDSal       = (HiddenField)GV_POS.Rows[rowIndex].Cells[7].FindControl("HFDSal");

                        drRow = dt.NewRow();

                        dt.Rows[i - 1]["Items"]     = TBItms.Text;
                        dt.Rows[i - 1]["ProductID"] = HFPROID.Value;
                        dt.Rows[i - 1]["PROTYPID"]  = DDL_PROTYPID.SelectedValue;
                        dt.Rows[i - 1]["fitpric"]   = tbfitpric.Text;
                        dt.Rows[i - 1]["Itempric"]  = tbItmpris.Text;
                        dt.Rows[i - 1]["salpric"]   = tbsalpris.Text;
                        dt.Rows[i - 1]["QTY"]       = TBItmQty.Text;
                        dt.Rows[i - 1]["TTL"]       = lblttl.Text;
                        dt.Rows[i - 1]["Dposid"]    = HFDSal.Value;

                        rowIndex++;

                        float GTotal = 0, CRAmt = 0, DBAmt = 0;
                        for (int j = 0; j < GV_POS.Rows.Count; j++)
                        {
                            Label total = (Label)GV_POS.Rows[j].FindControl("lblttl");
                            GTotal    += Convert.ToSingle(total.Text);
                            TBTtl.Text = GTotal.ToString();
                        }
                    }

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

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

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