protected void btn_Save_Click(object sender, EventArgs e) { cndate = txtCNDate.Text.Split('/')[2] + "/" + txtCNDate.Text.Split('/')[1] + "/" + txtCNDate.Text.Split('/')[0]; cndt = Convert.ToDateTime(cndate); int r1 = grdBookDetails.Rows.Count; int cntr1 = 0; if (Session["UserName"] != null) { CNNo = Convert.ToInt32(txtCnno.Text.Trim()); CreditNote _obedtcn = new CreditNote(); LedgerCN _obedtld = new LedgerCN(); try { foreach (GridViewRow Row in grdBookDetails.Rows) { CheckBox chkBxSelect = (CheckBox)Row.FindControl("chkBxSelect"); if (chkBxSelect != null) { if (chkBxSelect.Checked == true) { // bool chkbx = ((CheckBox)Row.FindControl("chkBxSelect")).; string RQty = (((TextBox)Row.FindControl("txtretquty")).Text.Trim()); //string DfQty = ((TextBox)Row.FindControl("txtdefquty")).Text; string CrQty = (((TextBox)Row.FindControl("txtquty")).Text.Trim()); string AtID = (((Label)Row.FindControl("lblDAutoID")).Text.Trim()); _obedtcn.AutoID = Convert.ToInt32(AtID); _obedtcn.CNNo = CNNo; //_obedtcn.CustCode = (DDLCustomer.SelectedValue); _obedtcn.CustCode = CustCode; //txtcustomer.Text.Trim().ToString(); _obedtcn.BookCode = (((Label)Row.FindControl("lblBookCode")).Text.Trim()); _obedtcn.Rate = Convert.ToDecimal(((TextBox)Row.FindControl("txtrate")).Text.Trim()); _obedtcn.Discount = Convert.ToDecimal(((TextBox)Row.FindControl("txtDiscount")).Text.Trim()); _obedtcn.ReturnQty = Convert.ToInt32(CrQty); _obedtcn.Comment = (((TextBox)Row.FindControl("txtcmmt")).Text.Trim()); _obedtcn.IsActive = true; _obedtcn.UpdatedBy = Session["UserName"].ToString(); _obedtcn.Flag = (((Label)Row.FindControl("lblflag")).Text.Trim()); _obedtcn.TotReturnQty = Convert.ToInt32(RQty); _obedtcn.DefectQty = 0; _obedtcn.IsDeleted = false; _obedtcn.strFY = Convert.ToInt32(strFY); _obedtcn.CNDate = cndt; _obedtld.CNDate = cndt; if (txtGCN.Text != "") { _obedtcn.GCN = Convert.ToInt32(txtGCN.Text); } else { _obedtcn.GCN = 0; } if (txtSCN.Text != "") { _obedtcn.SCN = Convert.ToInt32(txtSCN.Text); } else { _obedtcn.SCN = 0; } _obedtcn.LrNo = txtlRNO.Text.Trim().ToString(); _obedtcn.TransportName = lbltransporter.Text.Trim().ToString(); _obedtcn.Update_CN(Convert.ToInt32(strFY)); cntr1 = cntr1 + 1; } } } //_obedtcn.AutoID = Convert.ToInt32(AtID); //_obedtcn.CNNo = CNNo; //_obedtcn.CustCode = (DDLCustomer.SelectedValue); //_obedtcn.BookCode = ((Label)grdBookDetails.Rows[e.NewEditIndex].FindControl("lblBookCode")).Text; //_obedtcn.Rate = Convert.ToDecimal(((TextBox)grdBookDetails.Rows[e.NewEditIndex].FindControl("txtrate")).Text.Trim()); //_obedtcn.Discount = Convert.ToDecimal(((TextBox)grdBookDetails.Rows[e.NewEditIndex].FindControl("txtDiscount")).Text.Trim()); //_obedtcn.ReturnQty = Convert.ToInt32(CrQty); //_obedtcn.Comment = ((TextBox)grdBookDetails.Rows[e.NewEditIndex].FindControl("txtcmmt")).Text; //_obedtcn.IsActive = true; //_obedtcn.UpdatedBy = Session["UserName"].ToString(); //_obedtcn.Flag = ((Label)grdBookDetails.Rows[e.NewEditIndex].FindControl("lblflag")).Text; //_obedtcn.TotReturnQty = Convert.ToInt32(RQty); //_obedtcn.DefectQty = 0; //_obedtcn.IsDeleted = false; //_obedtcn.Update_CN(); if (cntr1 == 0) { MessageBox("Select Record To Update"); } if (cntr1 > 0) { _obedtld.CNNo = CNNo; _obedtld.strFY = Convert.ToInt32(Convert.ToInt32(strFY)); _obedtld.CNDate = cndt; if (ISExcise.Checked == true) { _obedtld.IsExciseApplicable = "1"; } else { _obedtld.IsExciseApplicable = "0"; } _obedtld.Ledger_CN("ExiseApply"); MessageBox("Record Updated Successfully"); CustCode = null; txtcustomer.Text = ""; lblCustName.Text = ""; Bindgrdcn(); quantity = 0; tamount = 0; DataTable dt1 = new DataTable(); dt1 = DCReturnBook.GetCustAddress(cust, "CNCustlist").Tables[0]; if (dt1.Rows.Count > 0) { lblCNNo.Text = (txtCnno.Text.Trim()); lblCustName1.Text = dt1.Rows[0]["CustName"].ToString(); lblCustAddress.Text = dt1.Rows[0]["Address"].ToString(); } PnlAddbk.Visible = false; btn_Save.Visible = false; PnlPrint.Visible = true; btnPrint.Visible = true; } } catch { } btnPrint.Focus(); } }