Пример #1
0
        //public ActionResult Search(string ps_AllLoc, string ps_Location)
        //{
        //    DALVoucherEntry objDal = new DALVoucherEntry();
        //    int li_AllLocation = -1;//, li_AllVoucherType = -1, li_AllDate = -1;
        //    try
        //    {
        //        if (ps_Location == null || ps_Location == "" || ps_Location == "0")
        //        {
        //            li_AllLocation = 1;
        //        }
        //        else
        //        {
        //            li_AllLocation = 0;
        //        }
        //        //if (ps_VoucherType == null || ps_VoucherType == "" || ps_VoucherType == "0")
        //        //{
        //        //    li_AllVoucherType = 1;
        //        //}
        //        //else
        //        //{
        //        //    li_AllVoucherType = 0;
        //        //}
        //        //if (ps_DateFrom == null || ps_DateFrom == "" || ps_DateTo == null || ps_DateTo == "")
        //        //{
        //        //    li_AllDate = 1;
        //        //}
        //        //else
        //        //{
        //        //    li_AllDate = 0;
        //        //}
        //        //objDal.GetVoucherEntryConsoleData(li_AllLocation, ps_Location, li_AllVoucherType, ps_VoucherType, li_AllDate, ps_DateFrom, ps_DateTo, false);
        //        objDal.GetVoucherEntryConsoleData(li_AllLocation, ps_Location, 1, "", 1, "", "", true);
        //        return PartialView("GridData");
        //    }
        //    catch
        //    {
        //        return PartialView("GridData");
        //    }
        //}
        public ActionResult DeleteRecordById(String ps_Id)
        {
            DALVoucherEntry objDal = new DALVoucherEntry();
            String ls_Action = "Cancel", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[7], ls_Data = new String[7];
            Int32 li_ReturnValue = 0;

            try
            {
                GL_VchrMaster VoucherMasterRow = objDal.GetAllMasterRecords().Where(c => c.VchMas_Id.Equals(ps_Id)).SingleOrDefault();
                List<GL_VchrDetail> VoucherDetailList = objDal.GetAllDetailRecords().Where(c => c.VchMas_Id.Equals(ps_Id)).ToList();

                li_ReturnValue = objDal.DeleteRecordById(ps_Id);
                ViewData["result"] = li_ReturnValue;

                IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues("IsAuditTrail")[0];

                // Delete 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_Lable[6] = "Entered By";

                    ls_Data[0] = VoucherMasterRow.VchMas_Code;
                    ls_Data[1] = Convert.ToString(VoucherMasterRow.VchMas_Date);
                    ls_Data[2] = VoucherMasterRow.Loc_Id;
                    ls_Data[3] = VoucherMasterRow.VchrType_Id;
                    ls_Data[4] = VoucherMasterRow.VchMas_Remarks;
                    ls_Data[5] = VoucherMasterRow.VchMas_Status;
                    ls_Data[6] = VoucherMasterRow.VchMas_EnteredBy;

                    objAuditLog.SaveRecord(16, ls_UserId, ls_Action, ls_Lable, ls_Data);
                }
                // Audit Trail Section End
                ViewData["ddl_Location"] = new SelectList(new DALLocation().PopulateData(), "Loc_Id", "Loc_Title");
                ViewData["ddl_VoucherType"] = new SelectList(new DALVoucherType().PopulateData(), "VchrType_Id", "VchrType_Title");
                ViewData["AllLoc"] = 1;
                ViewData["LocationId"] = "";
                ViewData["AllVchrType"] = 1;
                ViewData["VoucherTypeId"] = "";

                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
Пример #2
0
        public ActionResult DeleteCompany(String companyId)
        {
            String ls_Action = "Delete", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[7], ls_Data = new String[7];
            Int32 li_ReturnValue = 0;

            try
            {
                SETUP_Company CompanyRow = objDalCompany.GetCmpByCode(companyId).SingleOrDefault();

                li_ReturnValue = objDalCompany.DeleteCompanyByCompanyId(companyId);
                ViewData["SaveResult"] = li_ReturnValue;

                IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues("IsAuditTrail")[0];

                // Delete 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] = "Title";
                    ls_Lable[2] = "Address";
                    ls_Lable[3] = "       ";
                    ls_Lable[4] = "Email";
                    ls_Lable[5] = "Phone";
                    ls_Lable[6] = "Fax";

                    ls_Data[0] = CompanyRow.Cmp_Code;
                    ls_Data[1] = CompanyRow.Cmp_Title;
                    ls_Data[2] = CompanyRow.Cmp_Address1;
                    ls_Data[3] = CompanyRow.Cmp_Address2;
                    ls_Data[4] = CompanyRow.Cmp_Email;
                    ls_Data[5] = CompanyRow.Cmp_Phone;
                    ls_Data[6] = CompanyRow.Cmp_Fax;

                    objAuditLog.SaveRecord(1, ls_UserId, ls_Action, ls_Lable, ls_Data);
                }
                // Audit Trail Section End

                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
Пример #3
0
        public ActionResult DeleteRecord(String CusID)
        {
            String ls_Action = "Delete", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[7], ls_Data = new String[7];
            Int32 li_ReturnValue = 0;

            try
            {
                SETUP_Customer SupplierRow = objDALCustomer.GetAllCustomer().Where(c => c.Cust_Id.Equals(CusID)).SingleOrDefault();

                li_ReturnValue = objDALCustomer.DeleteRecordById(CusID);
                ViewData["SaveResult"] = li_ReturnValue;

                IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues("IsAuditTrail")[0];

                // Delete 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] = "Title";
                    ls_Lable[2] = "Address";
                    ls_Lable[3] = "Customer Type";
                    ls_Lable[4] = "Email";
                    ls_Lable[5] = "Phone";
                    ls_Lable[6] = "Fax";

                    ls_Data[0] = SupplierRow.Cust_Code;
                    ls_Data[1] = SupplierRow.Cust_Title;
                    ls_Data[2] = SupplierRow.Cust_Address1;
                    ls_Data[3] = SupplierRow.CustType_Id;
                    ls_Data[4] = SupplierRow.Cust_Email;
                    ls_Data[5] = SupplierRow.Cust_Phone;
                    ls_Data[6] = SupplierRow.Cust_Fax;

                    objAuditLog.SaveRecord(7, ls_UserId, ls_Action, ls_Lable, ls_Data);
                }
                // Audit Trail Section End
                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
Пример #4
0
        public ActionResult DeleteRecord(String _pId)
        {
            String ls_Action = "Delete", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[6], ls_Data = new String[6];
            Int32 li_ReturnValue = 0;

            try
            {
                SETUP_ChartOfAccount ChartOfAccountRow = objDalChartOfAccount.GetAllRecords().Where(c => c.ChrtAcc_Id.Equals(_pId)).SingleOrDefault();

                li_ReturnValue = objDalChartOfAccount.DeleteRecordById(_pId);
                ViewData["SaveResult"] = li_ReturnValue;

                IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues("IsAuditTrail")[0];

                // Delete 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] = "Title";
                    ls_Lable[2] = "Level";
                    ls_Lable[3] = "Budget Level";
                    ls_Lable[4] = "Type";
                    ls_Lable[5] = "Nature";

                    ls_Data[0] = ChartOfAccountRow.ChrtAcc_CodeDisplay;
                    ls_Data[1] = ChartOfAccountRow.ChrtAcc_Title;
                    ls_Data[2] = ChartOfAccountRow.ChrtAcc_Level.ToString();
                    ls_Data[3] = ChartOfAccountRow.ChrtAcc_BudgetLevel.ToString();
                    ls_Data[4] = ChartOfAccountRow.ChrtAcc_Type.ToString();
                    ls_Data[5] = ChartOfAccountRow.AccNatr_Id;

                    objAuditLog.SaveRecord(10, ls_UserId, ls_Action, ls_Lable, ls_Data);
                }

                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
Пример #5
0
        public ActionResult DeleteRecord(String _pId)
        {
            String ls_Action = "Delete", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[6], ls_Data = new String[6];
            Int32 li_ReturnValue = 0;

            try
            {
                SETUP_Calendar CalendarRow = objDalCalendar.GetAllRecords().Where(c => c.Cldr_Id.Equals(_pId)).SingleOrDefault();

                li_ReturnValue = objDalCalendar.DeleteRecordById(_pId);
                ViewData["SaveResult"] = li_ReturnValue;

                IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues("IsAuditTrail")[0];

                // Delete 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] = "Title";
                    ls_Lable[2] = "Prefix";
                    ls_Lable[3] = "Calendar Type";
                    ls_Lable[4] = "Start Date";
                    ls_Lable[5] = "End Date";

                    ls_Data[0] = CalendarRow.Cldr_Code;
                    ls_Data[1] = CalendarRow.Cldr_Title;
                    ls_Data[2] = CalendarRow.Cldr_Prefix;
                    ls_Data[3] = CalendarRow.CldrType_Id;
                    ls_Data[4] = Convert.ToString(CalendarRow.Cldr_DateStart);
                    ls_Data[5] = Convert.ToString(CalendarRow.Cldr_DateEnd);

                    objAuditLog.SaveRecord(14, ls_UserId, ls_Action, ls_Lable, ls_Data);
                }
                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
Пример #6
0
        public ActionResult DeleteRecord(String _pId)
        {
            DALBankAccount objDalBankAccount = new DALBankAccount();
            String ls_Action = "Delete", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[5], ls_Data = new String[5];
            Int32 li_ReturnValue = 0;

            try
            {
                SETUP_BankAccount BankRow = objDalBankAccount.GetAllRecords().Where(c => c.BankAcc_Id.Equals(_pId)).SingleOrDefault();
                li_ReturnValue = objDalBankAccount.DeleteRecordById(_pId);
                ViewData["SaveResult"] = li_ReturnValue;

                IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues("IsAuditTrail")[0];

                // Delete 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] = "Location";
                    ls_Lable[2] = "Bank";
                    ls_Lable[3] = "Title";
                    ls_Lable[4] = "Account Code";

                    ls_Data[0] = BankRow.BankAcc_Code;
                    ls_Data[1] = BankRow.Loc_Id;
                    ls_Data[2] = BankRow.Bank_Id;
                    ls_Data[3] = BankRow.BankAcc_Title;
                    ls_Data[4] = BankRow.ChrtAcc_Id;

                    objAuditLog.SaveRecord(12, ls_UserId, ls_Action, ls_Lable, ls_Data);
                }
                // Audit Trail Section End

                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
Пример #7
0
        public ActionResult DeleteVoucherType(String VoucherTypeId)
        {
            String ls_Action = "Delete", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[4], ls_Data = new String[4];
            Int32 li_ReturnValue = 0;

            try
            {
                sp_PopulateVoucherTypeListResult VoucherTypeRow = objDALVoucherType.PopulateData().Where(c => c.VchrType_Id.Equals(VoucherTypeId)).SingleOrDefault();

                li_ReturnValue = objDALVoucherType.DeleteVoucherTypeById(VoucherTypeId);
                ViewData["SaveResult"] = li_ReturnValue;

                IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues("IsAuditTrail")[0];

                // Delete 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] = "Title";
                    ls_Lable[2] = "Prefix";
                    ls_Lable[3] = "Code Initialization";

                    ls_Data[0] = VoucherTypeRow.VchrType_Code;
                    ls_Data[1] = VoucherTypeRow.VchrType_Title;
                    ls_Data[2] = VoucherTypeRow.VchrType_Prefix;
                    ls_Data[3] = VoucherTypeRow.VchrType_CodeInitialization.ToString();

                    objAuditLog.SaveRecord(8, ls_UserId, ls_Action, ls_Lable, ls_Data);
                }
                // Audit Trail Section End

                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
Пример #8
0
        public ActionResult DeleteRecord(String _pId)
        {
            DALVoucherTypeNarration objDal = new DALVoucherTypeNarration();
            String ls_Action = "Delete", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[3], ls_Data = new String[3];
            Int32 li_ReturnValue = 0;

            try
            {
                sp_GetVoucherTypeNarrationListResult VoucherTypeNarrationRow = objDal.GetAllData().Where(c => c.VchrTypeNarr_Id.Equals(_pId)).SingleOrDefault();

                li_ReturnValue = objDal.DeleteRecordById(_pId);
                ViewData["SaveResult"] = li_ReturnValue;

                IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues("IsAuditTrail")[0];

                // Delete 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] = "Title";
                    ls_Lable[2] = "Voucher Type";

                    ls_Data[0] = VoucherTypeNarrationRow.VchrTypeNarr_Code;
                    ls_Data[1] = VoucherTypeNarrationRow.VchrTypeNarr_Title;
                    ls_Data[2] = VoucherTypeNarrationRow.VchrType_Id;

                    objAuditLog.SaveRecord(9, ls_UserId, ls_Action, ls_Lable, ls_Data);
                }
                // Audit Trail Section End

                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
Пример #9
0
        public ActionResult SaveRecord(String ps_Code, String ps_Title, String ps_CmpId)
        {
            SETUP_Location lrow_Location = new SETUP_Location();
            String ls_Action = "Edit", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[3], ls_Data = new String[3];
            Int32 li_ReturnValue = 0;

            try
            {
                if (String.IsNullOrEmpty(ps_Code))
                {
                    if (DALCommon.AutoCodeGeneration("SETUP_Location") == 1)
                    {
                        ps_Code = DALCommon.GetMaximumCode("SETUP_Location");
                        ls_Action = "Add";
                    }
                }

                if (!String.IsNullOrEmpty(ps_Code))
                {
                    lrow_Location.Loc_Id = ps_Code;
                    lrow_Location.Loc_Code = ps_Code;
                    lrow_Location.Loc_Title = ps_Title;
                    lrow_Location.Cmp_Id = ps_CmpId;
                    lrow_Location.Loc_Active = 1;

                    li_ReturnValue = objDalLocation.SaveRecord(lrow_Location);
                    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] = "Title";
                        ls_Lable[2] = "Company";

                        ls_Data[0] = ps_Code;
                        ls_Data[1] = ps_Title;
                        ls_Data[2] = ps_CmpId;

                        objAuditLog.SaveRecord(2, ls_UserId, ls_Action, ls_Lable, ls_Data);
                    }
                    // Audit Trail Section End
                }

                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
Пример #10
0
        public ActionResult SaveCompany(String Code, String Name, String Address1, String Address2, String Email, String Phone, String Fax)
        {
            SETUP_Company setupCompanyRow = new SETUP_Company();
            String ls_Action = "Edit", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[7], ls_Data = new String[7];
            Int32 li_ReturnValue = 0;

            try
            {
                if (String.IsNullOrEmpty(Code))
                {
                    if (DALCommon.AutoCodeGeneration("SETUP_Company") == 1)
                    {
                        Code = DALCommon.GetMaximumCode("SETUP_Company");
                        ls_Action = "Add";
                    }
                }

                if (!String.IsNullOrEmpty(Code))
                {
                    setupCompanyRow.Cmp_Id = Code;
                    setupCompanyRow.Cmp_Code = Code;
                    setupCompanyRow.Cmp_Title = Name;
                    setupCompanyRow.Cmp_Address1 = Address1;
                    setupCompanyRow.Cmp_Address2 = Address2;
                    setupCompanyRow.Cmp_Email = Email;
                    setupCompanyRow.Cmp_Phone = Phone;
                    setupCompanyRow.Cmp_Fax = Fax;
                    setupCompanyRow.Cmp_Active = 1;
                    li_ReturnValue = objDalCompany.SaveCompany(setupCompanyRow);
                    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] = "Title";
                        ls_Lable[2] = "Address";
                        ls_Lable[3] = "       ";
                        ls_Lable[4] = "Email";
                        ls_Lable[5] = "Phone";
                        ls_Lable[6] = "Fax";

                        ls_Data[0] = Code;
                        ls_Data[1] = Name;
                        ls_Data[2] = Address1;
                        ls_Data[3] = Address2;
                        ls_Data[4] = Email;
                        ls_Data[5] = Phone;
                        ls_Data[6] = Fax;

                        objAuditLog.SaveRecord(1, ls_UserId, ls_Action, ls_Lable, ls_Data);
                    }
                }
                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
Пример #11
0
        public ActionResult SaveRecord(String ps_Code, String ps_Title)
        {
            SETUP_City lrow_City = new SETUP_City();
            String ls_Action = "Edit", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[3], ls_Data = new String[3];
            Int32 li_ReturnValue = 0;

            try
            {
                if (String.IsNullOrEmpty(ps_Code))
                {
                    if (DALCommon.AutoCodeGeneration("SETUP_City") == 1)
                    {
                        ps_Code = DALCommon.GetMaximumCode("SETUP_City");
                        ls_Action = "Add";
                    }
                }

                if (!String.IsNullOrEmpty(ps_Code))
                {
                    lrow_City.City_Id = ps_Code;
                    lrow_City.City_Code = ps_Code;
                    lrow_City.City_Title = ps_Title;
                    lrow_City.Cnty_Id = "00001";
                    lrow_City.City_Active = 1;

                    li_ReturnValue = objDalCity.SaveRecord(lrow_City);
                    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] = "Title";
                        ls_Lable[2] = "Country";

                        ls_Data[0] = ps_Code;
                        ls_Data[1] = ps_Title;
                        ls_Data[2] = "00001";

                        objAuditLog.SaveRecord(3, ls_UserId, ls_Action, ls_Lable, ls_Data);
                    }
                }

                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
Пример #12
0
        public string SaveRecord(IEnumerable<string> dataString)
        {
            String[] Row = dataString.Last().Split('║');
            string ps_Id = Row[0];
            string ps_Code = Row[1];
            string ps_Title = Row[2];
            int pi_Level = Row[3] != null ? Convert.ToInt32(Row[3]) : 0;
            int pi_BudgetLevel = Row[4] != null ? Convert.ToInt32(Row[4]) : 0;
            int pi_Active = Row[5] != null ? Convert.ToInt32(Row[5]) : 0;
            int pi_Type = Row[6] != null ? Convert.ToInt32(Row[6]) : 0;
            string ps_Nature = Row[7];
            string ps_AccountNature = Row[8];
            string ps_CodeBeforeEdit = Row[9];
            string ps_TitleBeforeEdit = Row[10];

            SETUP_ChartOfAccount lrow_ChartOfAccount = new SETUP_ChartOfAccount();
            String ls_Action = "Edit", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[6], ls_Data = new String[6];
            Int32 li_ReturnValue = 0;

            try
            {
                if (String.IsNullOrEmpty(ps_Id))
                {
                    if (DALCommon.AutoCodeGeneration("SETUP_ChartOfAccount") == 1)
                    {
                        ps_Id = DALCommon.GetMaximumCode("SETUP_ChartOfAccount");
                        ls_Action = "Add";
                    }
                }

                if (!String.IsNullOrEmpty(ps_Id))
                {
                    lrow_ChartOfAccount.ChrtAcc_Id = ps_Id;
                    lrow_ChartOfAccount.ChrtAcc_Code = ps_Code.Replace("-", "").Replace("_", "");
                    string[] AccCodeArr = ps_Code.Replace("_", "").Split('-');
                    string AccountCodeForDisplay = "";
                    foreach (string code in AccCodeArr)
                    {
                        AccountCodeForDisplay += (!string.IsNullOrEmpty(AccountCodeForDisplay) ? (!string.IsNullOrEmpty(code) ? "-" + code : code) : code);
                    }
                    lrow_ChartOfAccount.ChrtAcc_CodeDisplay = AccountCodeForDisplay.Trim();
                    lrow_ChartOfAccount.ChrtAcc_Title = ps_Title;
                    lrow_ChartOfAccount.ChrtAcc_Level = pi_Level;
                    lrow_ChartOfAccount.ChrtAcc_BudgetLevel = pi_BudgetLevel;
                    lrow_ChartOfAccount.ChrtAcc_Type = pi_Type;
                    lrow_ChartOfAccount.Natr_Id = ps_Nature;
                    lrow_ChartOfAccount.ChrtAcc_Active = 1;

                    var ChartOfAccountCode = objDalChartOfAccount.GetAllRecords().Where(c => c.ChrtAcc_Code.Equals(lrow_ChartOfAccount.ChrtAcc_Code) && c.ChrtAcc_Id != lrow_ChartOfAccount.ChrtAcc_Id ).ToList();
                    var ChartOfAccountTitle = objDalChartOfAccount.GetAllRecords().Where(c => c.ChrtAcc_Title.Trim().ToLower().Equals(lrow_ChartOfAccount.ChrtAcc_Title.Trim().ToLower()) && c.ChrtAcc_Id != lrow_ChartOfAccount.ChrtAcc_Id ).ToList();

                    if ((ls_Action == "Add" || ls_Action == "Edit"  ) && ( ChartOfAccountCode != null && ChartOfAccountCode.Count > 0))
                    {
                        ViewData["SaveResult"] = -1;
                    }
                    //else if (ls_Action == "Edit" && ps_Code.Replace("-", "").Replace("_", "") != ps_CodeBeforeEdit.Replace("-", "").Replace("_", "") && ChartOfAccountCode != null && ChartOfAccountCode.Count > 0)
                    //{
                    //    ViewData["SaveResult"] = -1;
                    //}
                    else if ((ls_Action == "Add" || ls_Action == "Edit"  ) && (ChartOfAccountTitle != null && ChartOfAccountTitle.Count > 0))
                    {
                        ViewData["SaveResult"] = -2;
                    }
                    //else if (ls_Action == "Edit" && ps_Title != ps_TitleBeforeEdit && ChartOfAccountTitle != null && ChartOfAccountTitle.Count > 0)
                    //{
                    //    ViewData["SaveResult"] = -2;
                    //}
                    else
                    {
                        li_ReturnValue = objDalChartOfAccount.SaveRecord(lrow_ChartOfAccount);
                        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] = "Title";
                            ls_Lable[2] = "Level";
                            ls_Lable[3] = "Budget Level";
                            ls_Lable[4] = "Type";
                            ls_Lable[5] = "Nature";

                            ls_Data[0] = AccountCodeForDisplay;
                            ls_Data[1] = ps_Title;
                            ls_Data[2] = pi_Level.ToString();
                            ls_Data[3] = pi_BudgetLevel.ToString();
                            ls_Data[4] = pi_Type.ToString();
                            ls_Data[5] = ps_Nature;

                            objAuditLog.SaveRecord(10, ls_UserId, ls_Action, ls_Lable, ls_Data);
                        }
                    }
                }
                string[] rList = new string[1];
                rList[0] = "";

                rList[0] += "<style type='text/css'>";
                rList[0] += "select";
                rList[0] += "{";
                rList[0] += "background: none;";
                rList[0] += "width: auto;";
                rList[0] += "padding: 0;";
                rList[0] += "margin: 0;";
                rList[0] += "border-radius: 0px;";
                rList[0] += "}";
                rList[0] += "input[type='text']";
                rList[0] += "{";
                rList[0] += "margin-bottom: 0;";
                rList[0] += "}";
                rList[0] += "</style>";
                rList[0] += "<table id='ChartOfAccountGrid' class='data display datatable'>";
                rList[0] += "<thead>";
                rList[0] += "<tr>";
                rList[0] += "<th style='width: 5%; display: none;'>";
                rList[0] += "Sr No.";
                rList[0] += "</th>";
                rList[0] += "<th style='width: 6%;'>";
                rList[0] += "Action";
                rList[0] += "</th>";
                rList[0] += "<th style='width: 20%;'>";
                rList[0] += "Code";
                rList[0] += "</th>";
                rList[0] += "<th style='width: 23%;'>";
                rList[0] += "Title";
                rList[0] += "</th>";
                rList[0] += "<th style='width: 10%;'>";
                rList[0] += "Level";
                rList[0] += "</th>";
                rList[0] += "<th style='width: 12%;'>";
                rList[0] += "Budget Level";
                rList[0] += "</th>";
                rList[0] += "<th style='width: 12%;'>";
                rList[0] += "Type";
                rList[0] += "</th>";
                rList[0] += "<th style='width: 12%;'>";
                rList[0] += "Nature";
                rList[0] += "</th>";
                rList[0] += "</tr>";
                rList[0] += "</thead>";
                rList[0] += "<tbody>";

                var lList_Data = new SCMSDataLayer.DALChartOfAccount().GetAllRecords();
                var IList_AccountNature = new SCMSDataLayer.DALAccountNature().GetAllRecords();
                var IList_Nature = new SCMSDataLayer.DALNature().GetAllRecords();
                if (lList_Data != null && lList_Data.Count > 0)
                {
                    int count = 0;
                    foreach (SCMSDataLayer.DB.SETUP_ChartOfAccount lRow_Data in lList_Data)
                    {
                        string tempValue = "";
                        string Title = lRow_Data.ChrtAcc_Title.Replace("'", "&#39");
                        for (int index = 0; index < lRow_Data.ChrtAcc_Code.Length; index++)
                        {
                            if (index == 2 || index == 5 || index == 9 || index == 14 || index == 19 || index == 24)
                            {
                                tempValue += "-" + lRow_Data.ChrtAcc_Code[index];
                            }
                            else
                            {
                                tempValue += lRow_Data.ChrtAcc_Code[index];
                            }
                        }
                        lRow_Data.ChrtAcc_Code = tempValue;
                        count++;
                        rList[0] += "<tr class='odd' style='line-height: 15px;'>";
                        rList[0] += "<td style='display: none;'>";
                        rList[0] += count;
                        rList[0] += "</td>";
                        rList[0] += "<td>";
                        rList[0] += " <div onclick=\"javascript:return EditRecord('" + lRow_Data.ChrtAcc_Id + "', '" + lRow_Data.ChrtAcc_Code + "')\" ";
                        rList[0] += " style='width: 22px; padding-right: 5px; float: left; cursor: pointer;'>";
                        rList[0] += "<img alt='Edit' src='../../img/edit.png' style='width: 22px; vertical-align: middle' />";
                        rList[0] += "</div>";
                        rList[0] += "<div onclick=\"javascript:return DeleteRecord('" + lRow_Data.ChrtAcc_Id + "')\" style='width: 22px;";
                        rList[0] += "float: left; cursor: pointer;'>";
                        rList[0] += "<img alt='Delete' src='../../img/delete.png' style='width: 22px; vertical-align: middle' />";
                        rList[0] += "</div>";
                        rList[0] += "</td>";
                        rList[0] += "<td id='txt_Code" + lRow_Data.ChrtAcc_Id + "' style='vertical-align: middle;'>";
                        if (lRow_Data.ChrtAcc_Level == 2)
                        {
                            lRow_Data.ChrtAcc_Code = "&nbsp; " + lRow_Data.ChrtAcc_Code;
                        }

                        else if (lRow_Data.ChrtAcc_Level == 3)
                        {
                            lRow_Data.ChrtAcc_Code = "&nbsp; &nbsp; " + lRow_Data.ChrtAcc_Code;
                        }

                        else if (lRow_Data.ChrtAcc_Level == 4)
                        {
                            lRow_Data.ChrtAcc_Code = "&nbsp; &nbsp; &nbsp; " + lRow_Data.ChrtAcc_Code;
                        }

                        else if (lRow_Data.ChrtAcc_Level == 5)
                        {
                            lRow_Data.ChrtAcc_Code = "&nbsp; &nbsp; &nbsp; &nbsp; " + lRow_Data.ChrtAcc_Code;
                        }

                        else if (lRow_Data.ChrtAcc_Level == 6)
                        {
                            lRow_Data.ChrtAcc_Code = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;" + lRow_Data.ChrtAcc_Code;
                        }

                        rList[0] += lRow_Data.ChrtAcc_Code;
                        rList[0] += "</td>";
                        rList[0] += "<td id='txt_Title" + lRow_Data.ChrtAcc_Id + "' style='vertical-align: middle;'>";
                        if (lRow_Data.ChrtAcc_Level == 2)
                        {
                            lRow_Data.ChrtAcc_Title = "&nbsp; " + lRow_Data.ChrtAcc_Title;
                        }

                        else if (lRow_Data.ChrtAcc_Level == 3)
                        {
                            lRow_Data.ChrtAcc_Title = "&nbsp; &nbsp; " + lRow_Data.ChrtAcc_Title;
                        }

                        else if (lRow_Data.ChrtAcc_Level == 4)
                        {
                            lRow_Data.ChrtAcc_Title = "&nbsp; &nbsp; &nbsp; " + lRow_Data.ChrtAcc_Title;
                        }

                        else if (lRow_Data.ChrtAcc_Level == 5)
                        {
                            lRow_Data.ChrtAcc_Title = "&nbsp; &nbsp; &nbsp; &nbsp; " + lRow_Data.ChrtAcc_Title;
                        }

                        else if (lRow_Data.ChrtAcc_Level == 6)
                        {
                            lRow_Data.ChrtAcc_Title = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;" + lRow_Data.ChrtAcc_Title;
                        }

                        rList[0] += Title;
                        rList[0] += "</td>";
                        rList[0] += "<td id='txt_AccountLevel" + lRow_Data.ChrtAcc_Id + "' style='vertical-align: middle;'>";
                        rList[0] += lRow_Data.ChrtAcc_Level;
                        rList[0] += "<input type='hidden' id='ChrtAcc_Level" + lRow_Data.ChrtAcc_Id + "' value='" + lRow_Data.ChrtAcc_Level + "' />";
                        rList[0] += "</td>";
                        rList[0] += "<td id='txt_AccountBudgetLevel'" + lRow_Data.ChrtAcc_Id + "' style='vertical-align: middle;'>";
                        rList[0] += lRow_Data.ChrtAcc_BudgetLevel;
                        rList[0] += "<input type='hidden' id='ChrtAcc_BudgetLevel" + lRow_Data.ChrtAcc_Id + "' value='" + lRow_Data.ChrtAcc_BudgetLevel + "' />";
                        rList[0] += "</td>";
                        rList[0] += "<td id='txt_AccountType" + lRow_Data.ChrtAcc_Id + "' style='vertical-align: middle;'>";
                        if (lRow_Data.ChrtAcc_Type == 1)
                        {
                            rList[0] += "Group";
                        }
                        else
                        {
                            rList[0] += "Detail";
                        }
                        rList[0] += "<input type='hidden' id='ChrtAcc_Type" + lRow_Data.ChrtAcc_Id + "' value='" + lRow_Data.ChrtAcc_Type + "' />";
                        rList[0] += "</td>";
                        rList[0] += "<td id='txt_NatureId" + lRow_Data.ChrtAcc_Id + "' style='vertical-align: middle;'>";
                        String Nature = IList_Nature.Where(c => c.Natr_Id.Equals(lRow_Data.Natr_Id)).SingleOrDefault().Natr_Title;
                        if (Nature == "None")
                        {
                            Nature = "";
                        }
                        rList[0] += Nature;

                        rList[0] += "<input type='hidden' id='Natr_Id" + lRow_Data.ChrtAcc_Id + "' value='" + lRow_Data.Natr_Id + "' />";
                        rList[0] += "</td>";
                        rList[0] += "</tr>";
                    }
                }

                rList[0] += "</tbody>";
                rList[0] += "</table>";
                rList[0] += "<input type='hidden' id='SaveResult' value='" + ViewData["SaveResult"] + "' />";

                System.Web.Script.Serialization.JavaScriptSerializer se = new System.Web.Script.Serialization.JavaScriptSerializer();
                string result = se.Serialize(rList);
                return result;
            }
            catch
            {
                return "";
            }
        }
Пример #13
0
        public ActionResult SaveSupplierRecord(String Code, String location, String SupplierType, String Title, String Address, String Email, String Phone, String Fax)
        {
            SETUP_Supplier row_Supplier = new SETUP_Supplier();
            String ls_Action = "Edit", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[7], ls_Data = new String[7];
            Int32 li_ReturnValue = 0;

            try
            {
                if (String.IsNullOrEmpty(Code))
                {
                    if (DALCommon.AutoCodeGeneration("SETUP_Supplier") == 1)
                    {
                        Code = DALCommon.GetMaximumCode("SETUP_Supplier");
                        ls_Action = "Add";
                    }
                }

                if (!String.IsNullOrEmpty(Code))
                {
                    row_Supplier.Supp_Id = Code;
                    row_Supplier.Supp_Code = Code;
                    row_Supplier.Loc_Id = location;
                    row_Supplier.SuppType_Id = SupplierType;
                    row_Supplier.Supp_Title = Title;
                    row_Supplier.Supp_Address1 = Address;
                    row_Supplier.Supp_Email = Email;
                    row_Supplier.Supp_Phone = Phone;
                    row_Supplier.Supp_Fax = Fax;
                    row_Supplier.Supp_Active = 1;
                    row_Supplier.City_Id = "00001";
                    li_ReturnValue = objDalSupplier.SaveRecord(row_Supplier);
                    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] = "Title";
                        ls_Lable[2] = "Address";
                        ls_Lable[3] = "Supplier Type";
                        ls_Lable[4] = "Email";
                        ls_Lable[5] = "Phone";
                        ls_Lable[6] = "Fax";

                        ls_Data[0] = Code;
                        ls_Data[1] = Title;
                        ls_Data[2] = Address;
                        ls_Data[3] = SupplierType;
                        ls_Data[4] = Email;
                        ls_Data[5] = Phone;
                        ls_Data[6] = Fax;

                        objAuditLog.SaveRecord(5, ls_UserId, ls_Action, ls_Lable, ls_Data);
                    }
                }
                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
Пример #14
0
        public ActionResult Save(String Code, String Title, String Prefix)
        {
            SYSTEM_BudgetType SystemBudgetTypeRow = new SYSTEM_BudgetType();
            String ls_Action = "Delete", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[3], ls_Data = new String[3];
            Int32 li_ReturnValue = 0;

            try
            {
                if (String.IsNullOrEmpty(Code))
                {
                    if (DALCommon.AutoCodeGeneration("SYSTEM_BudgetType") == 1)
                    {
                        Code = DALCommon.GetMaximumCode("SYSTEM_BudgetType");
                        ls_Action = "Add";
                    }
                }

                if (!String.IsNullOrEmpty(Code))
                {
                    SystemBudgetTypeRow.BgdtType_Id = Code;
                    SystemBudgetTypeRow.BgdtType_Code = Code;
                    SystemBudgetTypeRow.BgdtType_Title = Title;
                    SystemBudgetTypeRow.BgdtType_Prefix = Prefix;
                    SystemBudgetTypeRow.BgdtType_SortOrder = 1;
                    SystemBudgetTypeRow.BgdtType_Active = 1;
                    li_ReturnValue = objDALBudgetType.Save(SystemBudgetTypeRow);

                    ViewData["SaveResult"] = li_ReturnValue;

                    IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues("IsAuditTrail")[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] = "Title";
                        ls_Lable[2] = "Prefix";

                        ls_Data[0] = Code;
                        ls_Data[1] = Title;
                        ls_Data[2] = Prefix;

                        objAuditLog.SaveRecord(18, ls_UserId, ls_Action, ls_Lable, ls_Data);
                    }
                    // Audit Trail Section End
                }
                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
Пример #15
0
        // Insertion
        public ActionResult SaveRecord(String ps_Code, String CalenderType, String Prefix, String Title, DateTime SratrtDate, DateTime EndDate)
        {
            SETUP_Calendar lrow_Calendar = new SETUP_Calendar();
            String ls_Action = "Delete", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[6], ls_Data = new String[6];
            Int32 li_ReturnValue = 0;

            // Get Company name show in list
            List<SCMSDataLayer.DB.SETUP_CalendarType> ListCalendarType = new List<SCMSDataLayer.DB.SETUP_CalendarType>();
            ListCalendarType = new SCMSDataLayer.DALCalendarType().GetAllRecords().ToList();
            SCMSDataLayer.DB.SETUP_CalendarType CalendarTypeRow = ListCalendarType.Where(c => c.CldrType_Id.Equals(CalenderType)).SingleOrDefault();

            try
            {
                if (String.IsNullOrEmpty(ps_Code))
                {
                    if (DALCommon.AutoCodeGeneration("SETUP_Calendar") == 1)
                    {
                        ps_Code = DALCommon.GetMaximumCode("SETUP_Calendar");
                        ls_Action = "Add";
                    }
                }

                if (!String.IsNullOrEmpty(ps_Code))
                {
                    lrow_Calendar.Cldr_Id = ps_Code;
                    lrow_Calendar.Cldr_Code = ps_Code;
                    lrow_Calendar.CldrType_Id = CalenderType;
                    lrow_Calendar.Cldr_Prefix = Prefix;
                    lrow_Calendar.Cldr_Title = Title;
                    lrow_Calendar.Cldr_DateStart = SratrtDate;
                    lrow_Calendar.Cldr_DateEnd = EndDate;
                    lrow_Calendar.CldrType_Level = CalendarTypeRow.CldrType_Level;
                    lrow_Calendar.Cldr_Active = 1;

                    li_ReturnValue = objDalCalendar.SaveRecord(lrow_Calendar);
                    ViewData["SaveResult"] = li_ReturnValue;

                    IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues("IsAuditTrail")[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] = "Title";
                        ls_Lable[2] = "Prefix";
                        ls_Lable[3] = "Calendar Type";
                        ls_Lable[4] = "Start Date";
                        ls_Lable[5] = "End Date";

                        ls_Data[0] = ps_Code;
                        ls_Data[1] = Title;
                        ls_Data[2] = Prefix;
                        ls_Data[3] = CalenderType;
                        ls_Data[4] = SratrtDate.ToString("dd/MM/yyyy");
                        ls_Data[5] = EndDate.ToString("dd/MM/yyyy");

                        objAuditLog.SaveRecord(14, ls_UserId, ls_Action, ls_Lable, ls_Data);
                    }
                    // Audit Trail Section End
                }
                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
Пример #16
0
        public ActionResult SaveRecord(String ps_Code, String Location, String Bank, String Title, String AccountCode)
        {
            DALBankAccount objDalBankAccount = new DALBankAccount();
            SETUP_BankAccount lrow_BankAccount = new SETUP_BankAccount();
            String ls_Action = "Edit", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[5], ls_Data = new String[5];
            Int32 li_ReturnValue = 0;

            try
            {
                if (String.IsNullOrEmpty(ps_Code))
                {
                    if (DALCommon.AutoCodeGeneration("SETUP_BankAccount") == 1)
                    {
                        ps_Code = DALCommon.GetMaximumCode("SETUP_BankAccount");
                        ls_Action = "Add";
                    }
                }

                if (!String.IsNullOrEmpty(ps_Code))
                {
                    lrow_BankAccount.BankAcc_Id = ps_Code;
                    lrow_BankAccount.BankAcc_Id = ps_Code;
                    lrow_BankAccount.BankAcc_Title = Title;
                    lrow_BankAccount.Loc_Id = Location;
                    lrow_BankAccount.Bank_Id = Bank;
                    lrow_BankAccount.ChrtAcc_Id = AccountCode;
                    lrow_BankAccount.BankAcc_Active = 1;

                    li_ReturnValue = objDalBankAccount.SaveRecord(lrow_BankAccount);
                    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] = "Location";
                        ls_Lable[2] = "Bank";
                        ls_Lable[3] = "Title";
                        ls_Lable[4] = "Account Code";

                        ls_Data[0] = ps_Code;
                        ls_Data[1] = Location;
                        ls_Data[2] = Bank;
                        ls_Data[3] = Title;
                        ls_Data[4] = AccountCode;

                        objAuditLog.SaveRecord(12, ls_UserId, ls_Action, ls_Lable, ls_Data);
                    }
                }
                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
Пример #17
0
        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";
            }
        }