protected void lblBookType_TextChanged(object sender, EventArgs e) { TextBox txtbooktype = (TextBox)sender; GridViewRow gvRow = (GridViewRow)txtbooktype.Parent.Parent; Label lblTotalRs = (Label)gvRow.FindControl("bookId"); TextBox txtFromQty = (TextBox)gvRow.FindControl("lblFromQty"); string BookCode = txtbooktype.Text.Split(':')[0].Trim(); txtbooktype.Text = BookCode; if (txtbooktype.Text != "") { Other_Z.OtherBAL ObjBAL = new Other_Z.OtherBAL(); DataSet ds = ObjBAL.GetBookIdWithBookType(BookCode, Convert.ToInt32(Session["FY"]), "booktype"); if (ds.Tables[0].Rows.Count > 0) { lblTotalRs.Text = ds.Tables[0].Rows[0][0].ToString(); txtFromQty.Focus(); } else { MessageBox("Invalid book name please try again"); txtbooktype.Text = ""; txtbooktype.Focus(); return; } } else { MessageBox("Please enter book code"); txtbooktype.Text = ""; txtbooktype.Focus(); return; } }
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; } }