protected void GridAssorted_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     try
     {
         if (Session["TempAssorted"] != null)
         {
             DataTable dt = new DataTable();
             dt = (DataTable)Session["TempAssorted"];
             dt.Rows[e.RowIndex].Delete();
             DataView dv = new DataView(dt);
             GridAssorted.DataSource = dv.ToTable();
             GridAssorted.DataBind();
             Session["TempAssorted"] = dv.ToTable();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
    protected void btnAddAccess_Click(object sender, EventArgs e)
    {
        Other_Z.OtherBAL ObjBAL   = new Other_Z.OtherBAL();
        string           BookCode = txtBookType.Text.Split(':')[0].Trim();
        DataSet          ds       = ObjBAL.GetBookIdWithBookType(BookCode, Convert.ToInt32(Session["FY"]), "booktype");

        if (ds.Tables[0].Rows.Count > 0)
        {
            DataTable dt = GetDataTempTableAssorted();
            if (dt != null)
            {
                if (Convert.ToInt32(txtDiscount.Text) <= 0 || Convert.ToInt32(txtDiscount.Text) >= 100)
                {
                    MessageBox("Discount greater then 0 and less then 100");
                    txtDiscount.Focus();
                    return;
                }
                if (Convert.ToInt32(txtFromQty.Text) >= Convert.ToInt32(txtToQty.Text))
                {
                    MessageBox("From quantity shold be less than To quantity");
                    txtFromQty.Focus();
                    return;
                }
                else
                {
                    //
                    //DataRow[] rows1 = dt.Select("BookType = '" + BookCode + "' And ToQty > " + txtFromQty.Text);
                    //if (rows1.Length > 0)
                    //{
                    //    MessageBox("Wrong from quantity and to quantity");
                    //    txtFromQty.Focus();
                    //    return;
                    //}

                    bool      isflage = false;
                    DataRow[] rows    = dt.Select("BookType = '" + BookCode + "' And FromQty =" + txtFromQty.Text + " And ToQty = " + txtToQty.Text + "And Discount=" + txtDiscount.Text + "");

                    DataRow dr = null;
                    if (rows.Length > 0)
                    {
                        dr      = rows[0];
                        isflage = true;
                        MessageBox("Already Add Assorted Discount");
                        txtTODAmount.Focus();
                        return;
                    }
                    else
                    {
                        dt.DefaultView.Sort = "BookType ASC";
                        dr = dt.NewRow();
                    }
                    dr["BookType"] = BookCode;
                    dr["Bookid"]   = ds.Tables[0].Rows[0][0].ToString();
                    dr["FromQty"]  = Convert.ToInt32(txtFromQty.Text.Trim());
                    dr["ToQty"]    = Convert.ToInt32(txtToQty.Text.Trim());
                    dr["Discount"] = Convert.ToInt32(txtDiscount.Text.Trim());

                    if (!isflage)
                    {
                        AddRowAssorted(dr);
                        txtTODAmount.Text = "";
                        txtTodDis.Text    = "";
                    }
                }
                GridAssorted.DataSource = dt;
                GridAssorted.DataBind();
                GridAssorted.Visible = true;
                txtBookType.Text     = "";
                txtFromQty.Text      = "";
                txtToQty.Text        = "";
                txtDiscount.Text     = "";
                txtBookType.Focus();
            }
        }
        else
        {
            MessageBox("Invalid book name please try again");
            txtBookType.Text = "";
            txtBookType.Focus();
            return;
        }
    }
示例#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();
        }
    }