Exemplo n.º 1
0
 public static List<Group> GetAllGroups()
 {
     List<Group> result = new List<Group>();
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var dbGroups = from g in newAppsCnn.Sec_Groups select g;
     foreach (var dbGroup in dbGroups)
     {
         Group group = new Group();
         group.FromDbGroup(dbGroup);
         result.Add(group);
     }
     return result;
 }
Exemplo n.º 2
0
 public static List<Accounttype> GetAllAccounttype()
 {
     List<Accounttype> result = new List<Accounttype>();
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var dbAccounttypes = from g in newAppsCnn.Acc_Accountype select g;
     foreach (var dbAccounttype in dbAccounttypes)
     {
         Accounttype accounttype = new Accounttype();
         accounttype.FromDbAccounttype(dbAccounttype);
         result.Add(accounttype);
     }
     return result;
 }
Exemplo n.º 3
0
 public static List<AccountCategory> GetAllAccountCategory()
 {
     List<AccountCategory> result = new List<AccountCategory>();
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var dbAccountCategorys = from g in newAppsCnn.Acc_AccountCategory select g;
     foreach (var dbAccountCategory in dbAccountCategorys)
     {
         AccountCategory accountcategory = new AccountCategory();
         accountcategory.FromDbAccountCategory(dbAccountCategory);
         result.Add(accountcategory);
     }
     return result;
 }
Exemplo n.º 4
0
 public static List<FormFunction> GetFormFunctions()
 {
     List<FormFunction> result = new List<FormFunction>();
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var dbFormFunctions = from f in newAppsCnn.Sec_FormFunctions select f;
     foreach (var dbFormFunction in dbFormFunctions)
     {
         FormFunction formFunction = new FormFunction();
         formFunction.FromDbFormFunction(dbFormFunction);
         result.Add(formFunction);
     }
     return result;
 }
Exemplo n.º 5
0
 public static AccountCategory FindByAccountCategoryID(int _VaidationID)
 {
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var dbAccountCategorys = from u in newAppsCnn.Acc_AccountCategory where u.CategoryId == _VaidationID select u;
     if (dbAccountCategorys.Count() > 0)
     {
         Acc_AccountCategory dbAccountCategory = dbAccountCategorys.First();
         AccountCategory accountcategory = new AccountCategory();
         accountcategory.FromDbAccountCategory(dbAccountCategory);
         accountcategory.IsNew = false;
         return accountcategory;
     }
     else
         return null;
 }
Exemplo n.º 6
0
 public static Accounttype FindByAccounttypeID(int _VaidationID)
 {
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var dbAccounttypes = from u in newAppsCnn.Acc_Accountype where u.TypeID == _VaidationID select u;
     if (dbAccounttypes.Count() > 0)
     {
         Acc_Accountype dbAccounttype = dbAccounttypes.First();
         Accounttype accounttype = new Accounttype();
         accounttype.FromDbAccounttype(dbAccounttype);
         accounttype.IsNew = false;
         return accounttype;
     }
     else
         return null;
 }
Exemplo n.º 7
0
 public static CostCenter FindByCostCenterId(int? _VaidationID)
 {
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var dbCostCenters = from u in newAppsCnn.Acc_CostCenter where u.CostCenterId == _VaidationID select u;
     if (dbCostCenters.Count() > 0)
     {
         Acc_CostCenter dbCostCenter = dbCostCenters.First();
         CostCenter account = new CostCenter();
         account.FromDbCostCenter(dbCostCenter);
         account.IsNew = false;
         account.IsCopy = false;
         return account;
     }
     else
         return null;
 }
Exemplo n.º 8
0
        public static List<ChequeBook> GetAllAccounts()
        {
            List<ChequeBook> ChequeBookList = new List<ChequeBook>();
            NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
            var _BankAccounts = from Cheque in newAppsCnn.Acc_Accounts.Where(a => a.AccountCategoryId == 1) select Cheque;

            foreach (var account in _BankAccounts)
            {
                ChequeBook bankaccount = new ChequeBook();
                bankaccount.AccountName_Ar = account.AccountName_Ar;
                bankaccount.AccountName_En = account.AccountName_Eng;
                bankaccount.AccountId = account.AccountID;
                ChequeBookList.Add(bankaccount);
            }
            return ChequeBookList;
        }
Exemplo n.º 9
0
 public static AssetCatogry FindByAstCatId(int? _VaidationID)
 {
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var dbAssetCatogrys = from u in newAppsCnn.Ast_AssetCatogry where u.AstCatId == _VaidationID select u;
     if (dbAssetCatogrys.Count() > 0)
     {
         Ast_AssetCatogry dbAssetCatogry = dbAssetCatogrys.First();
         AssetCatogry account = new AssetCatogry();
         account.FromDbAssetCatogry(dbAssetCatogry);
         account.IsNew = false;
         account.IsCopy = false;
         return account;
     }
     else
         return null;
 }
Exemplo n.º 10
0
        public static List<FinancialYear> GetAllFinancialYears()
        {
            NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
            List<FinancialYear> FinancialYearsList = new List<FinancialYear>();
            var financialyear = newAppsCnn.Gnrl_FinancialYear.ToList();
            foreach (var financial in financialyear)
            {
                FinancialYear year = new FinancialYear();
                year.YearID = financial.YearId;
                year.YearName = financial.YearName;
                year.YearBegin = financial.YearBegin;
                year.YearEnd = financial.YearEnd;
                year.IsDefaultYear = financial.IsDefaultYear;
                year.IsClosedYear = financial.IsClosedYear;
                year.prefix = financial.prefix;

                FinancialYearsList.Add(year);
            }

            return FinancialYearsList;
        }
Exemplo n.º 11
0
        public static User CheckUser(string _userName, string _password)
        {
            try
            {
                NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
                var dbUsers = from u in newAppsCnn.Sec_Users where u.UserLogin == _userName && u.Password == _password select u;
                if (dbUsers.Count() > 0)
                {
                    Sec_Users dbUser = dbUsers.First();
                    User user = new User();
                    user.FromDbUser(dbUser);
                    user.LoadUserMenu(dbUser);
                    return user;
                }
                else
                    return null;
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Exemplo n.º 12
0
 private void LoadUserMenuForAdminUser(Sec_Users _dbUser)
 {
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var dbMenuItems = from m in newAppsCnn.Sec_MainMenu select m;
     foreach (var dbMenuItem in dbMenuItems)
     {
         MenuItem menuItem = new MenuItem();
         menuItem.FromDbMenuItem(dbMenuItem);
         this.UserMenuItems.Add(menuItem);
     }
 }
Exemplo n.º 13
0
 public static List<Account> GetAllAccountTree()
 {
     List<Account> result = new List<Account>();
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var dbAccounts = from g in newAppsCnn.Acc_Accounts where g.AccountID != null || g.AccountID != "" select g;
     foreach (var dbAccount in dbAccounts)
     {
         Account account = new Account();
         account.FromDbAccount(dbAccount);
         result.Add(account);
     }
     return result;
 }
Exemplo n.º 14
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 };
     }
 }
Exemplo n.º 15
0
 public void SaveDbUserGroups(Sec_Users _dbUser, NewAppsCnn newAppsCnn)
 {
     // Add New User Groups
     foreach (var group in this.Groups)
     {
         var dbUserGroups = _dbUser.Sec_Groups.Where(g => g.GroupID == group.GroupID);
         if (dbUserGroups.Count() == 0)
         {
             var dbGroup = newAppsCnn.Sec_Groups.First(g => g.GroupID == group.GroupID);
             _dbUser.Sec_Groups.Add(dbGroup);
         }
     }
     // Delete User Groups
     foreach (var dbGroup in _dbUser.Sec_Groups.ToList())
     {
         var group = this.Groups.Find(g => g.GroupID == dbGroup.GroupID);
         if (group == null)
             _dbUser.Sec_Groups.Remove(dbGroup);
     }
 }
Exemplo n.º 16
0
 public static User GetPrev(User _user)
 {
     if (_user == null)
         return GetFirst();
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var dbUsers = from u in newAppsCnn.Sec_Users where u.UserID < _user.UserID orderby u.UserID descending select u;
     if (dbUsers.Count() > 0)
     {
         var dbUser = dbUsers.FirstOrDefault();
         User user = new User();
         user.FromDbUser(dbUser);
         user.LoadDbUserGroups(dbUser);
         return user;
     }
     else
         return null;
 }
Exemplo n.º 17
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 };
     }
 }
Exemplo n.º 18
0
 public void ToDbReconcilation(Acc_Reconcilation _dbReconcilation)
 {
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var RId = 1 + ((from u in newAppsCnn.Acc_Reconcilation select u.ReconcileId).ToList().LastOrDefault() == null ? 1 : (int.Parse((from u in newAppsCnn.Acc_Reconcilation select u.ReconcileId).ToList().LastOrDefault())));
     _dbReconcilation.ReconcileId = this.ReconcileId ?? RId.ToString();
     _dbReconcilation.ReconcileAccountId = this.ReconcileAccountId;
     _dbReconcilation.ReconcileYear = AppInfo.CurrentYear.YearId;
     _dbReconcilation.CurrentStatemantAmount = this.CurrentStatemantAmount;
     _dbReconcilation.CurrentStatementDate = this.CurrentStatementDate;
     _dbReconcilation.ReconciledLastBal = this.ReconciledLastBal;
     _dbReconcilation.ReconciledLastDate = this.ReconciledLastDate;
     _dbReconcilation.ReconcilationValue = this.ReconcilationValue;
     _dbReconcilation.AccountBalance = this.AccountBalance;
     _dbReconcilation.DiffreneceInBook = this.DiffreneceInBook;
 }
Exemplo n.º 19
0
 public NewAppsCnn(string _connectionString)
 {
     Database.Connection.ConnectionString = _connectionString;
     NewAppsCnn newAppsCnn = new NewAppsCnn();
 }
Exemplo n.º 20
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 };
     }
 }
Exemplo n.º 21
0
 public static Account FindByAccountID(string _VaidationID)
 {
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var dbAccounts = from u in newAppsCnn.Acc_Accounts where u.AccountID == _VaidationID select u;
     if (dbAccounts.Count() > 0)
     {
         Acc_Accounts dbAccount = dbAccounts.First();
         Account account = new Account();
         account.FromDbAccount(dbAccount);
         account.IsNew = false;
         account.IsCopy = false;
         return account;
     }
     else
         return null;
 }
Exemplo n.º 22
0
 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 };
     }
 }
Exemplo n.º 23
0
 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 };
     }
 }
Exemplo n.º 24
0
        public static string getNewId(string ParentId, bool IsSubAccount)
        {
            string AccountId = "";
            NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
            var dbAccounts = from g in newAppsCnn.Acc_Accounts where g.AccountID != null || g.AccountID != "" select g;
            if (ParentId == null || ParentId == "")
            {
                var PChild = (from ac in dbAccounts where ac.ParentId == "" || ac.ParentId == null select ac).ToList();
                AccountId = string.Format("{0}", PChild.Count + 1);
            }
            else if (IsSubAccount)
            {
                char[] array = new char[6];
                var PrntVal = FindByAccountID(ParentId);
                var PChild = (from ac in dbAccounts where ac.ParentId == ParentId && ac.IsSubAccount == IsSubAccount select ac).ToList();

                int ArrCount = 0;
                string NwId = (PChild.Count + 1).ToString();
                for (int idx = array.Length - 1; idx > -1; idx--)
                {
                    if (ArrCount < NwId.Length)
                    {
                        array[idx] = NwId[ArrCount];
                        ArrCount++;
                    }
                    else
                    {
                        array[idx] = '0';
                    }
                }
                AccountId = string.Format("{0}{1}", ParentId, (new string(array)));
            }
            else
            {
                char[] array = new char[2];
                var PrntVal = FindByAccountID(ParentId);
                var PChild = (from ac in dbAccounts where ac.ParentId == ParentId select ac).ToList();
                int ArrCount = 0;
                string NwId=(PChild.Count + 1).ToString();
                for (int idx = array.Length - 1; idx > -1; idx--)
                {
                    if (ArrCount < NwId.Length)
                    {
                        array[idx] = NwId[ArrCount];
                        ArrCount++;
                    }
                    else
                    {
                        array[idx] = '0';
                    }
                }
                AccountId = string.Format("{0}{1}", ParentId, (new string(array)));
            }
            return AccountId;
        }
Exemplo n.º 25
0
 public static List<AssetCatogry> GetAllAssetCatogryTree()
 {
     List<AssetCatogry> result = new List<AssetCatogry>();
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var dbAssetCatogrys = from g in newAppsCnn.Ast_AssetCatogry select g;
     foreach (var dbAssetCatogry in dbAssetCatogrys)
     {
         AssetCatogry account = new AssetCatogry();
         account.FromDbAssetCatogry(dbAssetCatogry);
         result.Add(account);
     }
     return result;
 }
Exemplo n.º 26
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 };
     }
 }
Exemplo n.º 27
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 };
     }
 }
Exemplo n.º 28
0
 public static User FindByUserID(int _userID)
 {
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var dbUsers = from u in newAppsCnn.Sec_Users where u.UserID == _userID select u;
     if (dbUsers.Count() > 0)
     {
         Sec_Users dbUser = dbUsers.First();
         User user = new User();
         user.FromDbUser(dbUser);
         user.LoadDbUserGroups(dbUser);
         return user;
     }
     else
         return null;
 }
Exemplo n.º 29
0
 public static List<CostCenter> GetAllCmbCostCenter()
 {
     List<CostCenter> result = new List<CostCenter>();
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var dbCostCenters = from g in newAppsCnn.Acc_CostCenter where g.IsDisable==false select g;
     foreach (var dbCostCenter in dbCostCenters)
     {
         CostCenter account = new CostCenter();
         account.FromDbCostCenter(dbCostCenter);
         result.Add(account);
     }
     return result;
 }
Exemplo n.º 30
0
 public static User GetFirst()
 {
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var dbUser = newAppsCnn.Sec_Users.FirstOrDefault();
     if (dbUser != null)
     {
         User user = new User();
         user.FromDbUser(dbUser);
         user.LoadDbUserGroups(dbUser);
         return user;
     }
     else
         return null;
 }