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(); } }
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()); } } }