protected void btnAddTOD_Click(object sender, EventArgs e)
    {
        DataTable dt = GetDataTempTable();

        if (dt != null)
        {
            bool      isflage = false;
            DataRow[] rows    = dt.Select("TodAmount = " + txtTODAmount.Text + " And TodPercentage = " + txtTodDis.Text);
            DataRow   dr      = null;

            if (rows.Length > 0)
            {
                dr      = rows[0];
                isflage = true;
                MessageBox("Already Add Tod Amount");
                txtTODAmount.Focus();
            }
            else
            {
                dt.DefaultView.Sort = "TodAmount ASC";
                dr = dt.NewRow();
            }
            //dr["CustCode"] = txtcustCodeTod.Text.Trim();
            dr["TodAmount"]     = Convert.ToSingle(txtTODAmount.Text.Trim());
            dr["TodPercentage"] = Convert.ToSingle(txtTodDis.Text.Trim());
            dr["IsAction"]      = Convert.ToInt32(checkAction.Checked == true ? 1 : 0);

            if (!isflage)
            {
                AddRow(dr);
                txtTODAmount.Text = "";
                txtTodDis.Text    = "";
            }
        }
        TODGridview.DataSource = dt;
        TODGridview.DataBind();
        TODGridview.Visible = true;
        txtTODAmount.Text   = "";
        txtTodDis.Text      = "";
        checkAction.Checked = true;
        txtTODAmount.Focus();
    }
 protected void TODGridview_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     try
     {
         if (Session["TempDataTable"] != null)
         {
             DataTable dt = new DataTable();
             dt = (DataTable)Session["TempDataTable"];
             dt.Rows[e.RowIndex].Delete();
             DataView dv = new DataView(dt);
             TODGridview.DataSource = dv.ToTable();
             TODGridview.DataBind();
             Session["TempDataTable"] = dv.ToTable();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 3
0
    protected void btnGetData_Click(object sender, EventArgs e)
    {
        allVisible();

        string  CustCode = txtcustomer.Text.ToString().Split(':')[0].Trim();
        DataSet ds       = new DataSet();

        ds = DCMaster.Get_Name(CustCode, "Customer!" + Session["FY"].ToString());
        DataTable dt  = new DataTable();
        DataTable dt1 = new DataTable();

        dt  = ds.Tables[0];
        dt1 = ds.Tables[1];                  //CustomerTod Table
        DataTable dtAssorted = ds.Tables[2]; //Customer Assorted Discount

        if (dt.Rows.Count != 0)
        {
            txtcustomer.Text = CustCode;
            lblCustName.Text = Convert.ToString(dt.Rows[0]["CustName"]);

            grdCustDetails.DataSource = BindGvCustDetail(CustCode);
            grdCustDetails.DataBind();

            if (dtAssorted.Rows.Count > 0)
            {
                AssortedPanel.Visible   = true;
                GridAssorted.DataSource = dtAssorted;
                GridAssorted.DataBind();
            }
            else
            {
                GridAssorted.DataSource = dtAssorted;
                GridAssorted.DataBind();
            }

            if (dt1.Rows.Count > 0)
            {
                PanelTod.Visible       = true;
                TODGridview.DataSource = dt1;
                TODGridview.DataBind();
            }
            else
            {
                TODGridview.DataSource = dt1;
                TODGridview.DataBind();
            }

            if (grdCustDetails.Rows.Count > 0)
            {
                FillForm();
            }
            if (ChkBlacklist.Checked == true)
            {
                lblblkremark.Visible = true;
                LblblkDate.Visible   = true;
                TxtblkRemark.Visible = true;
                TxtblkDate.Visible   = true;
            }
            else
            {
                lblblkremark.Visible = false;
                LblblkDate.Visible   = false;
                TxtblkRemark.Visible = false;
                TxtblkDate.Visible   = false;
            }
        }
        else
        {
            lblCustName.Text = "No such Customer code";
            txtcustomer.Focus();
            txtcustomer.Text          = "";
            grdCustDetails.DataSource = null;
            grdCustDetails.DataBind();
        }
    }