protected void btn_Save_Click(object sender, EventArgs e) { btn_Save.Enabled = false; cndate = txtCNDate.Text.Split('/')[2] + "/" + txtCNDate.Text.Split('/')[1] + "/" + txtCNDate.Text.Split('/')[0]; cndt = Convert.ToDateTime(cndate); CNNo = 0; bool flag = false; CustCode = txtcustomer.Text.ToString().Split(':')[0].Trim(); int GCN; int SCN; if (Txtgcn.Text.Trim() == "") { Txtgcn.Text = "0"; } if (Txtscn.Text.Trim() == "") { Txtscn.Text = "0"; } GCN = Convert.ToInt32(Txtgcn.Text.Trim()); SCN = Convert.ToInt32(Txtscn.Text.Trim()); if (Session["UserName"] != null) { DCReturnBook _obdcrtbk1 = new DCReturnBook(); CreditNote _obcn1 = new CreditNote(); LedgerCN _oblcn1 = new LedgerCN(); CNNo = Convert.ToInt32(CreditNote.GetCNNo(Convert.ToInt32(strFY))); lblCNNo.Text = CreditNote.GetCNNo(Convert.ToInt32(strFY)); try { if (grdBookDetails.Rows.Count == 0) { MessageBox("Kindly fill Book details"); } else { //Response.Write("HERE"); foreach (GridViewRow Row in grdBookDetails.Rows) { string RQty = ((TextBox)Row.FindControl("txtretquty")).Text.Trim(); // string DfQty = ((TextBox)Row.FindControl("txtdefquty")).Text.Trim(); string CrQty = ((TextBox)Row.FindControl("txtquty")).Text.Trim(); _obdcrtbk1.DCReturnBkID = 0; _obdcrtbk1.CustCode = CustCode; _obdcrtbk1.BookCode = (((Label)Row.FindControl("lblBookCode")).Text.Trim()); _obdcrtbk1.ReturnQty = Convert.ToInt32(RQty); // _obdcrtbk1.DefectQty = Convert.ToInt32(DfQty); _obdcrtbk1.DefectQty = 0; _obdcrtbk1.Comment = ((TextBox)Row.FindControl("txtcmmt")).Text.Trim(); _obdcrtbk1.CreatedBy = Session["UserName"].ToString(); _obdcrtbk1.Flag = "Manual"; _obcn1.AutoID = 0; _obcn1.CNNo = CNNo; _obcn1.CustCode = CustCode; _obcn1.BookCode = (((Label)Row.FindControl("lblBookCode")).Text.Trim()); _obcn1.Rate = Convert.ToDecimal(((TextBox)Row.FindControl("txtrate")).Text.Trim()); _obcn1.Discount = Convert.ToDecimal(((TextBox)Row.FindControl("txtDiscount")).Text.Trim()); _obcn1.ReturnQty = Convert.ToInt32(CrQty); _obcn1.DefectQty = 0; _obcn1.TotReturnQty = Convert.ToInt32(RQty); _obcn1.Flag = "Manual"; _obcn1.Comment = ((TextBox)Row.FindControl("txtcmmt")).Text.Trim(); _obcn1.IsActive = true; _obcn1.GCN = GCN; _obcn1.SCN = SCN; _obcn1.CreatedBy = Session["UserName"].ToString(); _obcn1.strFY = Convert.ToInt32(strFY); _oblcn1.CNNo = CNNo; _oblcn1.strFY = Convert.ToInt32(strFY); _oblcn1.CNDate = cndt; _obcn1.CNDate = cndt; _obcn1.TransportName = lbltransporter.Text.ToString(); _obcn1.LrNo = txtlrno.Text.ToString(); _obcn1.Remark1 = ""; _obcn1.Remark2 = ""; _obcn1.Remark3 = ""; _obcn1.Remark4 = ""; _obcn1.Remark5 = ""; _obdcrtbk1.Save_DC_ReturnBook(); // Response.Write("Save_DC_ReturnBook"); _obcn1.Save_CN(Convert.ToInt32(strFY)); // Response.Write("Save_CN"); flag = true; } } if (flag) { _oblcn1.Ledger_CN(); // Response.Write("Ledger_CN"); //MessageBox(Constants.save); MessageBox(Constants.save + "\\r\\n CreditNote No: " + CNNo); Bindgrdcn(); //Session["tempDCData"].; Session["tempDCData"] = null; // grdBookDetails.DataSource = Session["tempDCData"]; grdBookDetails.DataBind(); quantity = 0; tamount = 0; ClearFields(); DataTable dt1 = new DataTable(); dt1 = DCReturnBook.GetCustAddress(CustCode, "CNCustlist").Tables[0]; if (dt1.Rows.Count > 0) { lblCustName1.Text = dt1.Rows[0]["CustName"].ToString(); lblCustAddress.Text = dt1.Rows[0]["Address"].ToString(); } PnlAddBook.Visible = false; btn_Save.Visible = false; PnlPrint.Visible = true; btnPrint.Visible = true; } } //catch(Exception ex) //{ // Response.Write(ex.Message.ToString()); // Response.End(); //} catch (Exception ex) { txtcustomer.Text = ex.Message.ToString(); } } }
protected void btnSave_Click(object sender, EventArgs e) { cndate = txtCNDate.Text.Split('/')[2] + "/" + txtCNDate.Text.Split('/')[1] + "/" + txtCNDate.Text.Split('/')[0]; cndt = Convert.ToDateTime(cndate); bool flag = false; int flag1 = 0; int flag2 = 0; CNNo = 0; int GCN; int SCN; if (Txtgcn.Text.Trim() == "") { Txtgcn.Text = "0"; } if (Txtscn.Text.Trim() == "") { Txtscn.Text = "0"; } GCN = Convert.ToInt32(Txtgcn.Text.Trim()); SCN = Convert.ToInt32(Txtscn.Text.Trim()); if (Session["UserName"] != null) { DCReturnBook _obdcrtbk = new DCReturnBook(); CreditNote _obcn = new CreditNote(); LedgerCN _oblcn = new LedgerCN(); try { foreach (GridViewRow Row in Grd2.Rows) { string RQty = ((TextBox)Row.FindControl("txtreturn")).Text.Trim(); int qty = (Convert.ToInt32(RQty)); string cmt = ((TextBox)Row.FindControl("txtcmmt")).Text.Trim(); if (qty > 0) { flag1 = flag1 + 1; if (cmt != "") { flag2 = flag2 + 1; } else { } } } if (flag1 == 0) { MessageBox("Please Enter Return Quantity"); Panel2.Visible = true; } if (flag1 > flag2) { MessageBox("Please Enter Comment For Respective Quantity"); Panel2.Visible = true; } if (flag1 == flag2) { CNNo = Convert.ToInt32(CreditNote.GetCNNo(Convert.ToInt32(strFY))); lblCNNo.Text = CreditNote.GetCNNo(Convert.ToInt32(strFY)); foreach (GridViewRow Row in Grd2.Rows) { _obdcrtbk.DCReturnBkID = 0; _obdcrtbk.CustCode = CustCode; _obdcrtbk.BookCode = (((Label)Row.FindControl("lblbkcode")).Text.Trim()); string RQty = ((TextBox)Row.FindControl("txtreturn")).Text.Trim(); int rqty1 = Convert.ToInt32(RQty); _obdcrtbk.ReturnQty = Convert.ToInt32(RQty); string cmt = ((TextBox)Row.FindControl("txtcmmt")).Text.Trim(); _obdcrtbk.Comment = ((TextBox)Row.FindControl("txtcmmt")).Text.Trim(); _obdcrtbk.CreatedBy = Session["UserName"].ToString(); _obdcrtbk.Flag = "DC"; string dqty = ((TextBox)Row.FindControl("txtDefect")).Text.Trim(); // _obdcrtbk.DefectQty = Convert.ToInt32(dqty); _obdcrtbk.DefectQty = 0; _obdcrtbk.strFY = Convert.ToInt32(strFY); if (RdbtnYN.SelectedValue == "1") { _obcn.AutoID = 0; _obcn.CNNo = CNNo; _obcn.CustCode = CustCode; _obcn.BookCode = (((Label)Row.FindControl("lblbkcode")).Text.Trim()); _obcn.Rate = Convert.ToDecimal(((DropDownList)Row.FindControl("DDLR")).SelectedValue); _obcn.Discount = Convert.ToDecimal(((DropDownList)Row.FindControl("DDLD")).SelectedValue); string CNqty = ((TextBox)Row.FindControl("txtCN")).Text.Trim(); _obcn.ReturnQty = Convert.ToInt32(CNqty); _obcn.DefectQty = 0; _obcn.TotReturnQty = Convert.ToInt32(RQty); _obcn.Comment = ((TextBox)Row.FindControl("txtcmmt")).Text.Trim(); _obcn.IsActive = true; _obcn.GCN = GCN; _obcn.SCN = SCN; _obcn.CreatedBy = Session["UserName"].ToString(); _obcn.Flag = "DC"; _obcn.strFY = Convert.ToInt32(strFY); _obcn.CNDate = cndt; _obcn.TransportName = lbltransporter.Text.ToString(); _obcn.LrNo = txtlrno.Text.ToString(); _obcn.Remark1 = ""; _obcn.Remark2 = ""; _obcn.Remark3 = ""; _obcn.Remark4 = ""; _obcn.Remark5 = ""; } else { } if (rqty1 > 0 && cmt != "") { _obdcrtbk.Save_DC_ReturnBook(Convert.ToInt32(strFY)); if (RdbtnYN.SelectedValue == "1") { _oblcn.CNNo = CNNo; _oblcn.strFY = Convert.ToInt32(strFY); _oblcn.CNDate = cndt; _obcn.Save_CN(Convert.ToInt32(strFY)); } else { } flag = true; //bind grid to display printdata Bindgrdcn(); } else { } } } if (flag) { try { if (RdbtnYN.SelectedValue == "1") { _oblcn.Ledger_CN(); MessageBox(Constants.save + "\\r\\n CreditNote No: " + CNNo); //BindGrd2(); PnlPrint.Visible = true; btnPrint.Visible = true; btnaddBooks.Visible = false; txtcustomer.Enabled = true; } else if (RdbtnYN.SelectedValue == "0") { MessageBox(Constants.save); } } catch (Exception ex) { MessageBox("Error : " + ex.Message.ToString()); clearall(); Txtgcn.Focus(); } Panel2.Visible = false; // RdbtnYN.SelectedIndex = 0; // txtcustomer.Text = ""; //lblCustName.Text = ""; } } catch (Exception ex) { MessageBox("Error : " + ex.Message.ToString()); } } }