protected void Page_Load(object sender, EventArgs e) { PageMenuID = Request.QueryString["ID"]; ObjAT_VPHDR = new M_AT_Acc_Payment_Vendor_AHDRBO(); ObjAT_VPDTL = new M_AT_Acc_Payment_Vendor_BDTLBO(); SetControlType(); if (!IsPostBack) { MaheshAF18.UIControlHelper.GenricControl.GetOperatorList(ddOperator); MaheshAF18.UIControlHelper.GenricControl.GetFieldListByGrid(gvList, ddSearchBy); FillDropdown(); InitializeControls(); RefreshGrid(); MultiView1.ActiveViewIndex = 0; } }
protected void btnsave_Click(object sender, System.EventArgs e) { try { if (VP_DT.Text.Length != 11) { ErrorMessage = ErrorMessage + "Invalid Entry Date<br>"; } if (VP_No.Text.Length == 0) { ErrorMessage = ErrorMessage + "Invalid Ref No<br>"; } if (Fk_VendorID.SelectedIndex == 0) { ErrorMessage = ErrorMessage + "Pls Select Customer<br>"; } if (VP_Received_Amt.Text.Length == 0) { ErrorMessage = ErrorMessage + "Received Amount Cannot Be Zero Or Blank<br>"; } else { if (Convert.ToDecimal(VP_Received_Amt.Text) <= 0) { ErrorMessage = ErrorMessage + "Received Amount Cannot Be Zero Or Blank<br>"; } } decimal var_T_Received_Amt = Convert.ToDecimal(VP_Received_Amt.Text); decimal var_T_Adjusted_Amt = Convert.ToDecimal(VP_Adjusted_Amt.Text); decimal var_T_OnAccount_Amt = Convert.ToDecimal(VP_OnAccount_Amt.Text); decimal var_T_InvAdjust_Amt = 0; foreach (GridViewRow row in gv_VP_Inv.Rows) { TextBox gv_Inv_Adjusted_Amt = (TextBox)row.FindControl("Inv_Adjusted_Amt"); if (Convert.ToDecimal(gv_Inv_Adjusted_Amt.Text) > 0) { var_T_InvAdjust_Amt = var_T_InvAdjust_Amt + Convert.ToDecimal(gv_Inv_Adjusted_Amt.Text); } } if (var_T_Received_Amt < var_T_InvAdjust_Amt) { ErrorMessage = ErrorMessage + "Sum Of Adjust Amount In Invoice Cannot Be Greater Than Received Amount <br> Adjusted Amt Sum : " + var_T_InvAdjust_Amt; } if (ErrorMessage.Length == 0) { using (TransactionScope scope = new TransactionScope()) { if (Convert.ToInt32(AVPHDR_ID.Text) == 0) { ObjAT_VPHDR.Fk_Company_ID = SessionUserData.Company.CompanyID; ObjAT_VPHDR.Fk_Branch_ID = SessionUserData.Company.BranchID; ObjAT_VPHDR.Fk_Year_ID = SessionUserData.Company.YearID; ObjAT_VPHDR.Rec_Created_In = "Self"; ObjAT_VPHDR.Rec_CreatedBy_ID = SessionUserData.Company.BranchID; ObjAT_VPHDR.Rec_CreatedFor_ID = SessionUserData.Company.BranchID; ObjAT_VPHDR.VP_CreationType = "Manually"; ObjAT_VPHDR.PC_Type = ""; ObjAT_VPHDR.MDBSC_RowCreatedByUser_ID = SessionUserData.UserData.UserID; ObjAT_VPHDR.MDBSC_RowCreatedByUserName = SessionUserData.UserData.UserName; ObjAT_VPHDR.VP_No = MEF.GenrateRefNo(SessionUserData.Company.CompanyID, SessionUserData.Company.BranchID, SessionUserData.Company.YearID, "Vendor Payment", "VP", "VP", "No", "", "", "", 0); } SetValuesToBO(); ErrorMessage = ObjAT_VPHDR.Insert_Update(ObjAT_VPHDR); AVPHDR_ID.Text = ErrorMessage.Substring((ErrorMessage.IndexOf("|") + 1), (ErrorMessage.Length - ErrorMessage.IndexOf("|") - 1)); ErrorMessage = ErrorMessage.Substring((0), (ErrorMessage.IndexOf("|"))); foreach (GridViewRow row in gv_VP_Inv.Rows) { TextBox gv_Inv_Adjusted_Amt = (TextBox)row.FindControl("Inv_Adjusted_Amt"); if (Convert.ToDecimal(gv_Inv_Adjusted_Amt.Text) > 0) { ObjAT_VPDTL = new M_AT_Acc_Payment_Vendor_BDTLBO(); ObjAT_VPDTL.AVPDTL_ID = Convert.ToInt64(row.Cells[0].Text); ObjAT_VPDTL.Fk_AVPHDRID = Convert.ToInt64(AVPHDR_ID.Text); ObjAT_VPDTL.Fk_InvoiceID = Convert.ToInt64(row.Cells[2].Text); ObjAT_VPDTL.Inv_Adjusted_Amt = Convert.ToDecimal(gv_Inv_Adjusted_Amt.Text); ErrorMessage = ObjAT_VPDTL.Insert_Update(ObjAT_VPDTL); ErrorMessage = ErrorMessage.Substring((0), (ErrorMessage.IndexOf("|"))); } else { if (Convert.ToInt64(row.Cells[0].Text) > 0) { MaheshAF18.Application.SQLManager.DeleteSRMD("M_AT_Acc_Payment_Vendor_AHDR", "M_AT_Acc_Payment_Vendor_BDTL", "AVPHDR_ID", Convert.ToInt64(0 + row.Cells[1].Text), "AVPDTL_ID", Convert.ToInt64(0 + row.Cells[0].Text), "C", ""); } } } scope.Complete(); } MABL.SQLManager.SQLProcedureCall.USP_Update_Tbl_Payment_Vendor(Convert.ToInt32(AVPHDR_ID.Text)); SetValueToControls_Edit(Convert.ToInt64(AVPHDR_ID.Text)); DisplayCustomMessageSummary(ErrorMessage); } else { DisplayCustomMessageSummary(ErrorMessage); } } catch (Exception ex) { DisplayCustomMessageSummary("Failed Save Data"); } }