public int SaveRecord(GL_VchrMaster newVoucherMaster) { try { SCMSDataContext dbSCMS = Connection.Create(); GL_VchrMaster existingVoucherMaster = dbSCMS.GL_VchrMasters.Where(c => c.VchMas_Id.Equals(newVoucherMaster.VchMas_Id)).SingleOrDefault(); if (existingVoucherMaster != null) { existingVoucherMaster.VchMas_Code = newVoucherMaster.VchMas_Code; existingVoucherMaster.VchMas_Date = newVoucherMaster.VchMas_Date; existingVoucherMaster.VchMas_Status = newVoucherMaster.VchMas_Status; existingVoucherMaster.VchrType_Id = newVoucherMaster.VchrType_Id; existingVoucherMaster.VchMas_Remarks = newVoucherMaster.VchMas_Remarks; existingVoucherMaster.Loc_Id = newVoucherMaster.Loc_Id; existingVoucherMaster.SyncStatus = false; } else { dbSCMS.GL_VchrMasters.InsertOnSubmit(newVoucherMaster); } dbSCMS.SubmitChanges(); return Convert.ToInt32(newVoucherMaster.VchMas_Id); } catch { return 0; } }
public int SaveRecord(GL_VchrMaster lrow_VchrMaster) { int li_ReturnValue = 0; try { SCMSDataContext dbSCMS = Connection.Create(); GL_VchrMaster lRow_ExistingData = dbSCMS.GL_VchrMasters.Where(c => c.VchMas_Id.Equals(lrow_VchrMaster.VchMas_Id)).SingleOrDefault(); if (lRow_ExistingData != null) { lRow_ExistingData.VchMas_Reconciliation = lrow_VchrMaster.VchMas_Reconciliation; lRow_ExistingData.VchMas_ReconciliationDate = lrow_VchrMaster.VchMas_ReconciliationDate; } else { //dbSCMS.SETUP_BankAccounts.InsertOnSubmit(lrow_BankAccount); } dbSCMS.SubmitChanges(); li_ReturnValue = Convert.ToInt32(lrow_VchrMaster.VchMas_Id); } catch { return 0; } return li_ReturnValue; }
public ActionResult SaveRecord(String ps_Code, String ps_Reconciled, String ps_ReconciliationDate) { DALBankReconciliation objDalBankReconciliation = new DALBankReconciliation(); GL_VchrMaster lrow_BankReconciliation = new GL_VchrMaster(); String IsAuditTrail = ""; // ls_Action = "Edit", String[] ls_Lable = new String[5], ls_Data = new String[5]; Int32 li_ReturnValue = 0; try { if (!String.IsNullOrEmpty(ps_Code)) { lrow_BankReconciliation.VchMas_Id = ps_Code; if (ps_Reconciled.ToLower() == "On".ToLower()) { lrow_BankReconciliation.VchMas_Reconciliation = 1; } else { lrow_BankReconciliation.VchMas_Reconciliation = 0; } lrow_BankReconciliation.VchMas_ReconciliationDate = Convert.ToDateTime(ps_ReconciliationDate); li_ReturnValue = objDalBankReconciliation.SaveRecord(lrow_BankReconciliation); ViewData["SaveResult"] = li_ReturnValue; IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues(3)[0]; //// Audit Trail Entry Section //if (li_ReturnValue > 0 && IsAuditTrail == "1") //{ // DALAuditLog objAuditLog = new DALAuditLog(); // ls_UserId = ((SECURITY_User)Session["user"]).User_Id; // ls_Lable[0] = "Code"; // ls_Lable[1] = "Reconciliation"; // ls_Lable[2] = "Reconciliation Date"; // ls_Data[0] = ps_Code; // ls_Data[1] = ps_Reconciled; // ls_Data[2] = ps_ReconciliationDate; // objAuditLog.SaveRecord(12, ls_UserId, ls_Action, ls_Lable, ls_Data); //} } return PartialView("GridData"); } catch { return PartialView("GridData"); } }
public string SaveVoucher(IEnumerable<string> VoucherDetailRows) { String[] MasterRow = VoucherDetailRows.Last().Split('║'); String VoucherMasterId = MasterRow[0]; String VoucherMasterCode = MasterRow[6].Replace("[Auto]", null); DateTime VoucherDate = MasterRow[1] != null ? Convert.ToDateTime(MasterRow[1]) : DateTime.Now; string Status = MasterRow[2]; String VoucherType = MasterRow[3]; String LocationId = MasterRow[4]; String Remarks = MasterRow[5]; string ls_VchrTypId = "", ls_YearPrefix = ""; Session["VoucherTypeForVoucherEntry"] = VoucherType; Session["LocationIdForVoucherEntry"] = LocationId; DALVoucherEntry objDalVoucherEntry = new DALVoucherEntry(); DALCalendar objDalCalendar = new DALCalendar(); int flag = 0; String ls_Action = "Edit", IsAuditTrail = "", ls_UserId = ""; String[] ls_Lable = new String[7], ls_Data = new String[7]; Int32 li_ReturnValue = 0, Increment = 5; try { GL_VchrMaster GL_Master = new GL_VchrMaster(); GL_VchrDetail GL_Detail = new GL_VchrDetail(); String Prefix = new DALVoucherType().GetAllData().Where(c => c.VchrType_Id.Equals(VoucherType)).SingleOrDefault().VchrType_Prefix; ls_VchrTypId = Convert.ToString(Convert.ToInt32(VoucherType)); if (String.IsNullOrEmpty(VoucherMasterId)) { if (DALCommon.AutoCodeGeneration("GL_VchrMaster") == 1) { ls_YearPrefix = objDalCalendar.GetCalendarPrefix_ByCurrentDate(VoucherDate); if (ls_YearPrefix == null && ls_YearPrefix == "") { return ""; } VoucherMasterId = DALCommon.GetMaxVoucherId(ls_YearPrefix); VoucherMasterCode = DALCommon.GetMaxVoucherCode("GL_VchrMaster", VoucherType, Prefix, LocationId, ls_YearPrefix); ls_Action = "Add"; } } else { flag = 1; } List<GL_VchrDetail> VoucherDetailList = new List<GL_VchrDetail>(); if (!String.IsNullOrEmpty(VoucherMasterId) && !String.IsNullOrEmpty(VoucherMasterCode)) { GL_Master.VchMas_Id = VoucherMasterId; ViewData["VoucherId"] = VoucherMasterId; GL_Master.VchMas_Code = VoucherMasterCode; ViewData["VoucherCode"] = VoucherMasterCode; GL_Master.VchMas_Date = VoucherDate; GL_Master.Loc_Id = LocationId; GL_Master.VchrType_Id = VoucherType; GL_Master.VchMas_Remarks = Remarks; GL_Master.VchMas_Status = Status; GL_Master.VchMas_EnteredBy = ((SECURITY_User)Session["user"]).User_Title; GL_Master.VchMas_EnteredDate = DateTime.Now; li_ReturnValue = objDalVoucherEntry.SaveVoucherMaster(GL_Master); if (li_ReturnValue > 0) { if (flag == 1) { objDalVoucherEntry.DeleteDetailRecordByMasterId(VoucherMasterId); } for (int index = 0; index < VoucherDetailRows.ToList().Count - 1; index++) { string Row = VoucherDetailRows.ToList()[index]; String[] Columns = Row.Split('║'); String VoucherDetailCode = ""; if (String.IsNullOrEmpty(VoucherDetailCode)) { if (DALCommon.AutoCodeGeneration("GL_VchrDetail") == 1) { VoucherDetailCode = DALCommon.GetMaximumCode("GL_VchrDetail"); //VoucherDetailCode = VoucherMasterCode; } } if (!String.IsNullOrEmpty(VoucherDetailCode) && Columns[0] != null && Columns[0] != "" && Columns[0] != "0" && ((Columns[1] != null && Columns[1] != "") || (Columns[2] != null && Columns[2] != ""))) { GL_Detail = new GL_VchrDetail(); GL_Detail.VchDet_Id = VoucherDetailCode; GL_Detail.VchMas_Id = VoucherMasterId; GL_Detail.ChrtAcc_Id = Columns[0].ToString(); //Columns[0] has AccountId from Account Title drop down; GL_Detail.VchMas_DrAmount = (Columns[1] != null && Columns[1] != "") ? Convert.ToDecimal(Columns[1].Replace(",", "")) : 0; // Columns[1] has Debit Amount GL_Detail.VchMas_CrAmount = (Columns[2] != null && Columns[2] != "") ? Convert.ToDecimal(Columns[2].Replace(",", "")) : 0; // Columns[2] has Debit Amount GL_Detail.VchDet_Remarks = (Columns[3] != null && Columns[3] != "") ? Columns[3].ToString() : ""; // Columns[3] has Remarks objDalVoucherEntry.SaveVoucherDetail(GL_Detail); VoucherDetailList.Add(GL_Detail); } } } } ViewData["SaveResult"] = li_ReturnValue; IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues("IsAuditTrail")[0]; // Save Audit Log if (li_ReturnValue > 0 && IsAuditTrail == "1") { DALAuditLog objAuditLog = new DALAuditLog(); ls_UserId = ((SECURITY_User)Session["user"]).User_Id; ls_Lable[0] = "Code"; ls_Lable[1] = "Date"; ls_Lable[2] = "Location"; ls_Lable[3] = "Voucher Type"; ls_Lable[4] = "Remarks"; ls_Lable[5] = "Status"; ls_Data[0] = VoucherMasterCode; ls_Data[1] = VoucherDate.ToString("dd/MM/yyyy"); ls_Data[2] = LocationId; ls_Data[3] = VoucherType; ls_Data[4] = Remarks; ls_Data[5] = Status; foreach (GL_VchrDetail voucherDetail in VoucherDetailList) { Increment++; ls_Lable[Increment] = "Account Code"; ls_Data[Increment] = voucherDetail.ChrtAcc_Id; Increment++; ls_Lable[Increment] = "Debit"; ls_Data[Increment] = Convert.ToString(voucherDetail.VchMas_DrAmount); Increment++; ls_Lable[Increment] = "Credit"; ls_Data[Increment] = Convert.ToString(voucherDetail.VchMas_CrAmount); Increment++; ls_Lable[Increment] = "Narration"; ls_Data[Increment] = voucherDetail.VchDet_Remarks; } objAuditLog.SaveRecord(7, ls_UserId, ls_Action, ls_Lable, ls_Data); } //// Audit Trail Entry Section //if (li_ReturnValue > 0) //{ // string IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues(3)[0]; // if (IsAuditTrail == "1") // { // SYSTEM_AuditTrail systemAuditTrail = new SYSTEM_AuditTrail(); // DALAuditLog objAuditTrail = new DALAuditLog(); // systemAuditTrail.Scr_Id = flag == 0 ? 17 : 16; // systemAuditTrail.User_Id = ((SECURITY_User)Session["user"]).User_Id; // systemAuditTrail.Loc_Id = GL_Master.Loc_Id; // systemAuditTrail.VchrType_Id = GL_Master.VchrType_Id; // systemAuditTrail.AdtTrl_Action = flag == 0 ? "Add" : "Edit"; // systemAuditTrail.AdtTrl_EntryId = VoucherMasterId; // systemAuditTrail.AdtTrl_DataDump = "VchMas_Id = " + GL_Master.VchMas_Id + ";"; // systemAuditTrail.AdtTrl_DataDump += "VchMas_Code = " + GL_Master.VchMas_Code + ";"; // systemAuditTrail.AdtTrl_DataDump += "VchMas_Date = " + GL_Master.VchMas_Date + ";"; // systemAuditTrail.AdtTrl_DataDump += "Cmp_Id = " + GL_Master.Cmp_Id + ";"; // systemAuditTrail.AdtTrl_DataDump += "Loc_Id = " + GL_Master.Loc_Id + ";"; // systemAuditTrail.AdtTrl_DataDump += "VchrType_Id = " + GL_Master.VchrType_Id + ";"; // systemAuditTrail.AdtTrl_DataDump += "VchMas_Remarks = " + GL_Master.VchMas_Remarks + ";"; // systemAuditTrail.AdtTrl_DataDump += "VchMas_Status = " + GL_Master.VchMas_Status + ";"; // systemAuditTrail.AdtTrl_DataDump += "VchMas_EnteredBy = " + GL_Master.VchMas_EnteredBy + ";"; // systemAuditTrail.AdtTrl_DataDump += "VchMas_EnteredDate = " + GL_Master.VchMas_EnteredDate + ";"; // systemAuditTrail.AdtTrl_DataDump += "VchMas_ApprovedBy = " + GL_Master.VchMas_ApprovedBy + ";"; // systemAuditTrail.AdtTrl_DataDump += "VchMas_ApprovedDate = " + GL_Master.VchMas_ApprovedDate + ";"; // systemAuditTrail.AdtTrl_DataDump += "SyncStatus = " + GL_Master.SyncStatus + ";"; // foreach (GL_VchrDetail voucherDetail in VoucherDetailList) // { // systemAuditTrail.AdtTrl_DataDump += "║ VchDet_Id = " + voucherDetail.VchDet_Id + ";"; // systemAuditTrail.AdtTrl_DataDump += "VchMas_Id = " + voucherDetail.VchMas_Id + ";"; // systemAuditTrail.AdtTrl_DataDump += "ChrtAcc_Id = " + voucherDetail.ChrtAcc_Id + ";"; // systemAuditTrail.AdtTrl_DataDump += "VchMas_DrAmount = " + voucherDetail.VchMas_DrAmount + ";"; // systemAuditTrail.AdtTrl_DataDump += "VchMas_CrAmount = " + voucherDetail.VchMas_CrAmount + ";"; // systemAuditTrail.AdtTrl_DataDump += "VchDet_Remarks = " + voucherDetail.VchDet_Remarks + ";"; // } // systemAuditTrail.AdtTrl_Date = DateTime.Now; // objAuditTrail.SaveRecord(systemAuditTrail); // } //} //// Audit Trail Section End //return PartialView("GridData"); //string result = ViewData["VoucherId"].ToString(); //+ "|" + ViewData["VoucherCode"].ToString() + "|" + ViewData["SaveResult"].ToString(); string[] rList = new string[3]; rList[0] = ViewData["VoucherId"].ToString(); rList[1] = ViewData["VoucherCode"].ToString(); rList[2] = ViewData["SaveResult"].ToString(); System.Web.Script.Serialization.JavaScriptSerializer se = new System.Web.Script.Serialization.JavaScriptSerializer(); string result = se.Serialize(rList); return result; } catch { //ViewData["SaveResult"] = 0; //return PartialView("GridData"); return "0"; } }