public DataDeleteResult Delete(int YearID)
 {
     Gnrl_FinancialYear Gnrl_FinancialYear;
     try
     {
         NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
         var financialyear = from Year in newAppsCnn.Gnrl_FinancialYear where Year.YearId == YearID select Year;
         if (financialyear.Count() > 0)
         {
             Gnrl_FinancialYear = financialyear.First();
             newAppsCnn.Gnrl_FinancialYear.Remove(Gnrl_FinancialYear);
             newAppsCnn.SaveChanges();
         }
         return new DataDeleteResult() { DeleteStatus = true };
     }
     catch (Exception ex)
     {
         return new DataDeleteResult() { DeleteStatus = false, ErrorMessage = ex.Message };
     }
 }
Beispiel #2
0
 public DataDeleteResult Delete()
 {
     Acc_Reconcilation dbReconcilation;
     try
     {
         NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
         var dbReconcilations = from u in newAppsCnn.Acc_Reconcilation where u.ReconcileId == this.ReconcileId select u;
         if (dbReconcilations.Count() > 0)
         {
             dbReconcilation = dbReconcilations.First();
             var dbReconcilationChilds = from u in newAppsCnn.Acc_ReconcilationDtl where u.ReconcileId == this.ReconcileId select u;
             if (dbReconcilationChilds.Count() == 0 )
             {
                 newAppsCnn.Acc_Reconcilation.Remove(dbReconcilation);
                 newAppsCnn.SaveChanges();
             }
             else
             {
                 return new DataDeleteResult() { DeleteStatus = false, ErrorMessage = "This Item has childs" };
             }
         }
         return new DataDeleteResult() { DeleteStatus = true };
     }
     catch (Exception ex)
     {
         return new DataDeleteResult() { DeleteStatus = false, ErrorMessage = ex.Message };
     }
 }
Beispiel #3
0
 public DataDeleteResult Delete(int BudgetID)
 {
     Acc_Budgets Acc_Budgets;
     try
     {
         NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
         var Budget = from bdgt in newAppsCnn.Acc_Budgets where bdgt.BudgetId == BudgetID select bdgt;
         if (Budget.Count() > 0)
         {
             Acc_Budgets = Budget.First();
             newAppsCnn.Acc_Budgets.Remove(Acc_Budgets);
             newAppsCnn.SaveChanges();
         }
         return new DataDeleteResult() { DeleteStatus = true };
     }
     catch (Exception ex)
     {
         return new DataDeleteResult() { DeleteStatus = false, ErrorMessage = ex.Message };
     }
 }
        public DataSaveResult Save(FinancialYear _FinancilaYear)
        {
            try
            {
                NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);

                if (_FinancilaYear.IsDefaultYear == true)
                {
                    var _Gnrl_FinancialYear = newAppsCnn.Gnrl_FinancialYear.ToList();
                    foreach (Gnrl_FinancialYear G in _Gnrl_FinancialYear)
                    {

                        G.IsDefaultYear = false;
                        //G.IsClosedYear = GnrlFinancialYear.IsClosedYear;
                        //G.YearBegin = GnrlFinancialYear.YearBegin;
                        //G.YearEnd = GnrlFinancialYear.YearEnd;
                        //G.YearId = GnrlFinancialYear.YearId;
                        //G.YearName = GnrlFinancialYear.YearName;

                    }
                }
                Gnrl_FinancialYear Gnrl_FinancialYear;
                Gnrl_FinancialYear = newAppsCnn.Gnrl_FinancialYear.Where(a => a.YearId == _FinancilaYear.YearID).FirstOrDefault();

                if (Gnrl_FinancialYear != null)
                {
                    BuildDBRecord(Gnrl_FinancialYear, _FinancilaYear);

                }

                else
                {

                    Gnrl_FinancialYear = new Gnrl_FinancialYear();
                    Gnrl_FinancialYear = BuildDBRecord(Gnrl_FinancialYear, _FinancilaYear);
                    newAppsCnn.Gnrl_FinancialYear.Add(Gnrl_FinancialYear);
                }

                newAppsCnn.SaveChanges();
                //   Audit.AddDataAudit(Audit.AuditActionTypes.AddNew, "Acc_VouchersType", this);

                return new DataSaveResult() { SaveStatus = true };
            }
            catch (Exception ex)
            {
                return new DataSaveResult() { SaveStatus = false };
            }
        }
 public DataDeleteResult Delete()
 {
     this.IsCopy = false;
     Ast_AssetCatogry dbAssetCatogry;
     try
     {
         NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
         var dbAssetCatogrys = from u in newAppsCnn.Ast_AssetCatogry where u.AstCatId == this.AstCatId select u;
         if (dbAssetCatogrys.Count() > 0)
         {
             dbAssetCatogry = dbAssetCatogrys.First();
             newAppsCnn.Ast_AssetCatogry.Remove(dbAssetCatogry);
             newAppsCnn.SaveChanges();
         }
         return new DataDeleteResult() { DeleteStatus = true };
     }
     catch (Exception ex)
     {
         return new DataDeleteResult() { DeleteStatus = false, ErrorMessage = ex.Message };
     }
 }
Beispiel #6
0
 public DataDeleteResult Delete()
 {
     this.IsCopy = false;
     Acc_CostCenter dbCostCenter;
     try
     {
         NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
         var dbCostCenters = from u in newAppsCnn.Acc_CostCenter where u.CostCenterId == this.CostCenterId select u;
         if (dbCostCenters.Count() > 0)
         {
             dbCostCenter = dbCostCenters.First();
             var dbAccountChilds = from u in newAppsCnn.Acc_CostCenter where u.ParentId == this.CostCenterId select u;
             if (dbAccountChilds.Count() == 0 && DontHaveTransaction())//Transaction Condition
             {
                 newAppsCnn.Acc_CostCenter.Remove(dbCostCenter);
                 newAppsCnn.SaveChanges();
             }
             else
             {
                 return new DataDeleteResult() { DeleteStatus = false, ErrorMessage = "This Item has childs" };
             }
         }
         return new DataDeleteResult() { DeleteStatus = true };
     }
     catch (Exception ex)
     {
         return new DataDeleteResult() { DeleteStatus = false, ErrorMessage = ex.Message };
     }
 }
Beispiel #7
0
 public DataDeleteResult Delete()
 {
     try
     {
         NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
         var dbGroup = (from g in newAppsCnn.Sec_Groups where g.GroupID == this.GroupID select g).FirstOrDefault();
         if (dbGroup != null)
         {
             newAppsCnn.Sec_Groups.Remove(dbGroup);
             newAppsCnn.SaveChanges();
             return new DataDeleteResult() { DeleteStatus = true, ErrorMessage = "" };
         }
         else
             return new DataDeleteResult() { DeleteStatus = false, ErrorMessage = "" };
     }
     catch (Exception ex)
     {
        return new DataDeleteResult() { DeleteStatus = false, ErrorMessage = ex.Message };
     }
 }
Beispiel #8
0
 public DataDeleteResult Delete()
 {
     Sec_Users dbUser;
     try
     {
         NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
         var dbUsers = from u in newAppsCnn.Sec_Users where u.UserID == this.UserID select u;
         if (dbUsers.Count() > 0)
         {
             dbUser = dbUsers.First();
             newAppsCnn.Sec_Users.Remove(dbUser);
             newAppsCnn.SaveChanges();
         }
         return new DataDeleteResult() { DeleteStatus = true };
     }
     catch (Exception ex)
     {
         return new DataDeleteResult() { DeleteStatus = false, ErrorMessage = ex.Message };
     }
 }
 public DataDeleteResult Delete(string ID)
 {
     Acc_VouchersType AccVouchersType;
     try
     {
         NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
         var VoucherType = from voucher in newAppsCnn.Acc_VouchersType where voucher.VoucherTypeId == ID select voucher;
         if (VoucherType.Count() > 0)
         {
             AccVouchersType = VoucherType.First();
             newAppsCnn.Acc_VouchersType.Remove(AccVouchersType);
             newAppsCnn.SaveChanges();
         }
         return new DataDeleteResult() { DeleteStatus = true };
     }
     catch (Exception ex)
     {
         return new DataDeleteResult() { DeleteStatus = false, ErrorMessage = ex.Message };
     }
 }
Beispiel #10
0
        public DataSaveResult Save(VoucherType _VoucherType)
        {
            try
            {
                Acc_VouchersType AccVouchersType;
                NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);

                AccVouchersType = newAppsCnn.Acc_VouchersType.Where(a => a.VoucherTypeId == _VoucherType.VoucherTypeId).FirstOrDefault();
                if (AccVouchersType != null)
                {
                    BuildDBRecord(AccVouchersType, _VoucherType);
                }

                else
                {

                    AccVouchersType = new Acc_VouchersType();
                    AccVouchersType = BuildDBRecord(AccVouchersType, _VoucherType);
                    newAppsCnn.Acc_VouchersType.Add(AccVouchersType);
                }

                newAppsCnn.SaveChanges();
                //   Audit.AddDataAudit(Audit.AuditActionTypes.AddNew, "Acc_VouchersType", this);

                return new DataSaveResult() { SaveStatus = true };
            }
            catch (Exception ex)
            {
                return new DataSaveResult() { SaveStatus = false };
            }
        }
Beispiel #11
0
 public DataDeleteResult Delete()
 {
     Acc_Accountype dbAccounttype;
     try
     {
         NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
         var dbAccounttypes = from u in newAppsCnn.Acc_Accountype where u.TypeID == this.TypeID select u;
         if (dbAccounttypes.Count() > 0)
         {
             dbAccounttype = dbAccounttypes.First();
             newAppsCnn.Acc_Accountype.Remove(dbAccounttype);
             newAppsCnn.SaveChanges();
         }
         return new DataDeleteResult() { DeleteStatus = true };
     }
     catch (Exception ex)
     {
         return new DataDeleteResult() { DeleteStatus = false, ErrorMessage = ex.Message };
     }
 }
Beispiel #12
0
 public DataSaveResult Save()
 {
     Acc_Accountype dbAccounttype;
     try
     {
         NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
         var dbAccounttypes = from u in newAppsCnn.Acc_Accountype where u.TypeID == this.TypeID select u;
         if (dbAccounttypes.Count() > 0)
         {
             dbAccounttype = dbAccounttypes.First();
             this.ToDbAccounttype(dbAccounttype);
         }
         else
         {
             dbAccounttype = new Acc_Accountype();
             this.ToDbAccounttype(dbAccounttype);
             newAppsCnn.Acc_Accountype.Add(dbAccounttype);
         }
         newAppsCnn.SaveChanges();
         Audit.AddDataAudit(Audit.AuditActionTypes.AddNew, "Acc_Accountype", this);
         this.FromDbAccounttype(dbAccounttype);
         return new DataSaveResult() { SaveStatus = true };
     }
     catch (Exception ex)
     {
         return new DataSaveResult() { SaveStatus = false ,ErrorMessage=ex.Message};
     }
 }
Beispiel #13
0
        public DataSaveResult Save(Budget _Budget)
        {
            try
            {
                Acc_Budgets Acc_Budgets;
                NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);

                Acc_Budgets = newAppsCnn.Acc_Budgets.Where(a => a.BudgetId == _Budget.BudgetId && a.BudgetYearId == _Budget.BudgetYearId).FirstOrDefault();
                if (Acc_Budgets != null)
                {
                    BuildDBRecord(Acc_Budgets, _Budget);
                }

                else
                {

                    Acc_Budgets = new Acc_Budgets();
                    Acc_Budgets = BuildDBRecord(Acc_Budgets, _Budget);
                    newAppsCnn.Acc_Budgets.Add(Acc_Budgets);
                }
                newAppsCnn.SaveChanges();

                var BudgetDetails = newAppsCnn.Acc_BudgetsDtl.Where(a => a.BudgetDtlId == _Budget.BudgetDtlId && a.BudgetId == _Budget.BudgetId && a.BudgetYearId == _Budget.BudgetYearId).ToList();
                if (BudgetDetails.Count !=0)
                {
                    foreach (Acc_BudgetsDtl _Acc_BudgetsDtl in BudgetDetails)
                    {

                        foreach (Budget bdgt in _Budget.BudgetDetails)
                        {
                            if (_Acc_BudgetsDtl.BudgetDtlId == bdgt.BudgetDtlId)
                            {
                                BuildDBRecordForDetails(_Acc_BudgetsDtl, bdgt,Acc_Budgets);
                                newAppsCnn.SaveChanges();
                            }
                        }
                    }
                }
                else
                {
                    foreach (Budget bdgt in _Budget.BudgetDetails)
                    {
                        Acc_BudgetsDtl _Acc_BudgetsDtl = new Acc_BudgetsDtl();
                        _Acc_BudgetsDtl = BuildDBRecordForDetails(_Acc_BudgetsDtl, bdgt, Acc_Budgets);
                        newAppsCnn.Acc_BudgetsDtl.Add(_Acc_BudgetsDtl);
                        newAppsCnn.SaveChanges();
                    }

                }

                //   Audit.AddDataAudit(Audit.AuditActionTypes.AddNew, "Acc_VouchersType", this);

                return new DataSaveResult() { SaveStatus = true };
            }
            catch (Exception ex)
            {
                return new DataSaveResult() { SaveStatus = false };
            }
        }
Beispiel #14
0
 public DataSaveResult Save()
 {
     Acc_Reconcilation dbReconcilation;
     try
     {
         NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
         var dbReconcilations = from u in newAppsCnn.Acc_Reconcilation where u.ReconcileId == this.ReconcileId select u;
         if (dbReconcilations.Count() > 0)
         {
             dbReconcilation = dbReconcilations.First();
             this.ToDbReconcilation(dbReconcilation);
             List<Acc_ReconcilationDtl> DltLst = (from u in newAppsCnn.Acc_ReconcilationDtl where u.ReconcileId == this.ReconcileId select u).ToList();
             foreach (var itm in DltLst)
             {
                 newAppsCnn.Acc_ReconcilationDtl.Remove(itm);
                 newAppsCnn.SaveChanges();
             }
             foreach (var itm in this.ReconcilationDtlLst)
             {
                 Acc_ReconcilationDtl Obj = new Acc_ReconcilationDtl()
                 {
                     ReconcileId = dbReconcilation.ReconcileId,
                     VoucherId = itm.VoucherId,
                     VoucherNo = (from u in newAppsCnn.Acc_Voucher where u.VoucherId == itm.VoucherId select u).ToList().FirstOrDefault().VoucherRefno,
                     ReconcileDtlid = (from u in newAppsCnn.Acc_ReconcilationDtl select u.ReconcileDtlid).ToList().LastOrDefault() == null ? 1 : (1 + (from u in newAppsCnn.Acc_ReconcilationDtl select u.ReconcileDtlid).ToList().LastOrDefault())
                 };
                 newAppsCnn.Acc_ReconcilationDtl.Add(Obj);
                 newAppsCnn.SaveChanges();
             }
         }
         else
         {
             dbReconcilation = new Acc_Reconcilation();
             this.ToDbReconcilation(dbReconcilation);
             newAppsCnn.Acc_Reconcilation.Add(dbReconcilation);
             newAppsCnn.SaveChanges();
             foreach (var itm in this.ReconcilationDtlLst)
             {
                 Acc_ReconcilationDtl Obj = new Acc_ReconcilationDtl() {
                     ReconcileId = dbReconcilation.ReconcileId,
                     VoucherId=itm.VoucherId,
                     VoucherNo = (from u in newAppsCnn.Acc_Voucher where u.VoucherId == itm.VoucherId select u).ToList().FirstOrDefault().VoucherRefno,
                     ReconcileDtlid = (from u in newAppsCnn.Acc_ReconcilationDtl select u.ReconcileDtlid).ToList().LastOrDefault() == null ? 1 : (from u in newAppsCnn.Acc_ReconcilationDtl select u.ReconcileDtlid).ToList().LastOrDefault()
                 };
                 newAppsCnn.Acc_ReconcilationDtl.Add(Obj);
                 newAppsCnn.SaveChanges();
             }
         }
         newAppsCnn.SaveChanges();
         Audit.AddDataAudit(Audit.AuditActionTypes.AddNew, "Acc_Reconcilation", this);
         this.FromDbReconcilation(dbReconcilation);
         return new DataSaveResult() { SaveStatus = true };
     }
     catch (Exception ex)
     {
         return new DataSaveResult() { SaveStatus = false, ErrorMessage = ex.Message };
     }
 }
Beispiel #15
0
 public DataSaveResult Save()
 {
     Sec_Groups dbGroup;
     try
     {
         NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
         dbGroup = (from g in newAppsCnn.Sec_Groups where g.GroupID == this.GroupID select g).FirstOrDefault();
         if (dbGroup == null)
         {
             dbGroup = new Sec_Groups();
             this.ToDbGroup(dbGroup);
             newAppsCnn.Sec_Groups.Add(dbGroup);
             SaveGroupUsers(dbGroup, newAppsCnn);
             newAppsCnn.SaveChanges();
         }
         else
         {
             this.ToDbGroup(dbGroup);
             SaveGroupUsers(dbGroup, newAppsCnn);
             newAppsCnn.SaveChanges();
             Audit.AddDataAudit(Audit.AuditActionTypes.AddNew, "Sec_Groups", this);
         }
         this.FromDbGroup(dbGroup);
         return new DataSaveResult() { SaveStatus = true, ErrorMessage = "", Data = this };
     }
     catch (Exception ex)
     {
         return new DataSaveResult() { SaveStatus = false, ErrorMessage = ex.Message };
     }
 }
Beispiel #16
0
 public DataSaveResult Save()
 {
     this.IsCopy = false;
     Acc_Accounts dbAccount;
     try
     {
         NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
         var dbAccounts = from u in newAppsCnn.Acc_Accounts where u.AccountID == this.AccountID select u;
         if (dbAccounts.Count() > 0)
         {
             dbAccount = dbAccounts.First();
             if (this.AccountTypeId != dbAccount.AccountTypeId && (dbAccount.ParentId==null||dbAccount.ParentId==""))
             {
                 var dbAccountChilds = from u in newAppsCnn.Acc_Accounts where u.ParentId == this.AccountID select u;
                 foreach (var itm in dbAccountChilds)
                 {
                     itm.AccountTypeId = this.AccountTypeId;
                 }
             }
             this.ToDbAccount(dbAccount);
             dbAccount.AccountLevel = getNodeLevel(0, dbAccount.ParentId);
         }
         else
         {
             dbAccount = new Acc_Accounts();
             this.ToDbAccount(dbAccount);
             dbAccount.AccountLevel = getNodeLevel(0, dbAccount.ParentId);
             newAppsCnn.Acc_Accounts.Add(dbAccount);
         }
         newAppsCnn.SaveChanges();
         Audit.AddDataAudit(Audit.AuditActionTypes.AddNew, "Acc_Accounts", this);
         this.FromDbAccount(dbAccount);
         return new DataSaveResult() { SaveStatus = true };
     }
     catch (Exception ex)
     {
         return new DataSaveResult() { SaveStatus = false,ErrorMessage=ex.Message };
     }
 }
Beispiel #17
0
        public DataSaveResult SaveGroupRights()
        {
            NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);

            // Add And Update Group Rights
            foreach (var groupRight in GroupRights)
            {
                Sec_GroupRights dbGroupRight;
                var dbGroupRights = from g in newAppsCnn.Sec_GroupRights where g.MenuID == groupRight.MenuID && g.GroupID == groupRight.GroupID select g;
                if (dbGroupRights.Count() > 0)
                {
                    // Update Group Rights
                    dbGroupRight = dbGroupRights.First();
                    dbGroupRight.AllowedFunctions = groupRight.AllowedFunctions;
                }
                else
                {
                    // Add New Group Rights
                    dbGroupRight = new Sec_GroupRights();
                    dbGroupRight.GroupID = groupRight.GroupID;
                    dbGroupRight.MenuID = groupRight.MenuID;
                    dbGroupRight.AllowedFunctions = groupRight.AllowedFunctions;
                    newAppsCnn.Sec_GroupRights.Add(dbGroupRight);
                }
            }
            var dbAllGroupRights = from g in newAppsCnn.Sec_GroupRights where  g.GroupID == this.GroupID select g;
            foreach (var dbGroupRight in dbAllGroupRights.ToList())
            {
                GroupRight groupRights = GroupRights.Find(g => g.MenuID == dbGroupRight.MenuID);
                if (groupRights == null)
                {
                    newAppsCnn.Sec_GroupRights.Remove(dbGroupRight);
                }
            }
            try
            {
                newAppsCnn.SaveChanges();
                return new DataSaveResult() { SaveStatus = true, ErrorMessage = "", Data = this };
            }
            catch (Exception ex)
            {
                return new DataSaveResult() { SaveStatus = false, ErrorMessage = ex.Message, Data = this };
            }
        }
Beispiel #18
0
 public DataSaveResult Save()
 {
     Sec_Users dbUser;
     try
     {
         NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
         var dbUsers = from u in newAppsCnn.Sec_Users where u.UserID == this.UserID select u;
         if (dbUsers.Count() > 0)
         {
             dbUser = dbUsers.First();
             this.ToDbUser(dbUser);
             this.SaveDbUserGroups(dbUser, newAppsCnn);
         }
         else
         {
             dbUser = new Sec_Users();
             this.ToDbUser(dbUser);
             this.SaveDbUserGroups(dbUser, newAppsCnn);
             newAppsCnn.Sec_Users.Add(dbUser);
         }
         newAppsCnn.SaveChanges();
         Audit.AddDataAudit(Audit.AuditActionTypes.AddNew, "Sec_Users", this);
         this.FromDbUser(dbUser);
         return new DataSaveResult() { SaveStatus = true };
     }
     catch (Exception ex)
     {
         return new DataSaveResult() { SaveStatus = false, ErrorMessage = ex.Message };
     }
 }
Beispiel #19
0
 public DataDeleteResult Delete(int ChequeID)
 {
     Acc_ChequeBook Acc_Cheque;
     try
     {
         NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
         var ChequeBook = from Cheque in newAppsCnn.Acc_ChequeBook where Cheque.ChequeBookID == ChequeID select Cheque;
         if (ChequeBook.Count() > 0)
         {
             Acc_Cheque = ChequeBook.First();
             newAppsCnn.Acc_ChequeBook.Remove(Acc_Cheque);
             newAppsCnn.SaveChanges();
         }
         return new DataDeleteResult() { DeleteStatus = true };
     }
     catch (Exception ex)
     {
         return new DataDeleteResult() { DeleteStatus = false, ErrorMessage = ex.Message };
     }
 }
 public DataSaveResult Save()
 {
     this.IsCopy = false;
     Ast_AssetCatogry dbAssetCatogry;
     try
     {
         NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
         var dbAssetCatogrys = from u in newAppsCnn.Ast_AssetCatogry where u.AstCatId == this.AstCatId select u;
         if (dbAssetCatogrys.Count() > 0)
         {
             dbAssetCatogry = dbAssetCatogrys.First();
             this.ToDbAssetCatogry(dbAssetCatogry);
         }
         else
         {
             dbAssetCatogry = new Ast_AssetCatogry();
             this.ToDbAssetCatogry(dbAssetCatogry);
             newAppsCnn.Ast_AssetCatogry.Add(dbAssetCatogry);
         }
         newAppsCnn.SaveChanges();
         Audit.AddDataAudit(Audit.AuditActionTypes.AddNew, "Ast_AssetCatogry", this);
         this.FromDbAssetCatogry(dbAssetCatogry);
         return new DataSaveResult() { SaveStatus = true };
     }
     catch (Exception ex)
     {
         return new DataSaveResult() { SaveStatus = false,ErrorMessage=ex.Message };
     }
 }
Beispiel #21
0
        public DataSaveResult Save(ChequeBook _ChequeBook)
        {
            try
            {
                Acc_ChequeBook Acc_ChequeBook;
                NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);

                Acc_ChequeBook = newAppsCnn.Acc_ChequeBook.Where(a => a.ChequeBookID == _ChequeBook.ChequeBookID).FirstOrDefault();
                if (Acc_ChequeBook != null)
                {
                    BuildDBRecord(Acc_ChequeBook, _ChequeBook);
                }

                else
                {

                    Acc_ChequeBook = new Acc_ChequeBook();
                    Acc_ChequeBook = BuildDBRecord(Acc_ChequeBook, _ChequeBook);
                    newAppsCnn.Acc_ChequeBook.Add(Acc_ChequeBook);
                }

                newAppsCnn.SaveChanges();
                //   Audit.AddDataAudit(Audit.AuditActionTypes.AddNew, "Acc_VouchersType", this);

                return new DataSaveResult() { SaveStatus = true };
            }
            catch (Exception ex)
            {
                return new DataSaveResult() { SaveStatus = false };
            }
        }
Beispiel #22
0
 public DataSaveResult Save()
 {
     this.IsCopy = false;
     Acc_CostCenter dbCostCenter;
     try
     {
         NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
         var dbCostCenters = from u in newAppsCnn.Acc_CostCenter where u.CostCenterId == this.CostCenterId select u;
         if (dbCostCenters.Count() > 0)
         {
             dbCostCenter = dbCostCenters.First();
             this.ToDbCostCenter(dbCostCenter);
         }
         else
         {
             dbCostCenter = new Acc_CostCenter();
             this.ToDbCostCenter(dbCostCenter);
             newAppsCnn.Acc_CostCenter.Add(dbCostCenter);
         }
         newAppsCnn.SaveChanges();
         Audit.AddDataAudit(Audit.AuditActionTypes.AddNew, "Acc_CostCenter", this);
         this.FromDbCostCenter(dbCostCenter);
         return new DataSaveResult() { SaveStatus = true};
     }
     catch (Exception ex)
     {
         return new DataSaveResult() { SaveStatus = false ,ErrorMessage= ex.Message };
     }
 }
Beispiel #23
0
        private static void AddDataAuditAsync(List<DbEntityEntry> _auditData)
        {
            NewAppsCnn cnn = new NewAppsCnn(NewAppsConnectionString);
            foreach (DbEntityEntry entity in _auditData)
            {
                string tableName = entity.Entity.GetType().BaseType.Name;
                if (!(entity.Entity is Grnl_Audit) && !(entity.Entity is Grnl_AuditDtl) && !(entity.Entity is Gnrl_AuditActions))
                {
                    Grnl_Audit audit = new Grnl_Audit();
                    audit.TableName = tableName;
                    audit.UserId = CrUserID;
                    audit.AuditActionId = (int)entity.State;
                    audit.ActionDate = DateTime.Now;
                    string[] propertyNames;
                    switch (entity.State)
                    {
                        case System.Data.EntityState.Added:
                            propertyNames = entity.CurrentValues.PropertyNames.ToArray();
                            break;
                        case System.Data.EntityState.Deleted:
                            propertyNames = entity.OriginalValues.PropertyNames.ToArray();
                            break;
                        case System.Data.EntityState.Detached:
                            propertyNames = entity.OriginalValues.PropertyNames.ToArray();
                            break;
                        default:
                            propertyNames = entity.CurrentValues.PropertyNames.ToArray();
                            break;
                    }

                    foreach (var propertyName in propertyNames)
                    {
                        Grnl_AuditDtl auditDtl = new Grnl_AuditDtl();
                        auditDtl.PropertyName = propertyName;
                        switch (entity.State)
                        {
                            case System.Data.EntityState.Added:
                                if (entity.CurrentValues[propertyName] != null)
                                    auditDtl.PropertyCurrentValues = entity.CurrentValues[propertyName].ToString();
                                break;
                            case System.Data.EntityState.Modified:
                                if (entity.CurrentValues[propertyName] != null)
                                    auditDtl.PropertyCurrentValues = entity.CurrentValues[propertyName].ToString();
                                if (entity.OriginalValues[propertyName] != null)
                                    auditDtl.PropertyOriginalValues = entity.OriginalValues[propertyName].ToString();
                                break;
                            case System.Data.EntityState.Deleted:
                                if (entity.OriginalValues[propertyName] != null)
                                auditDtl.PropertyOriginalValues = entity.OriginalValues[propertyName].ToString();
                                break;
                            default:
                                if (entity.CurrentValues[propertyName] != null)
                                    auditDtl.PropertyCurrentValues = entity.CurrentValues[propertyName].ToString();
                                break;
                        }
                        if(!string.IsNullOrEmpty(auditDtl.PropertyCurrentValues))
                        audit.Grnl_AuditDtl.Add(auditDtl);
                    }
                    cnn.Grnl_Audit.Add(audit);
                    cnn.SaveChanges();
                }
            }
        }