예제 #1
0
        public void UpdateBudget(int id, string infoBox, Decimal Cancellation, Decimal Returned)
        {
            bool            result = true;
            BOTADataContext db     = new BOTADataContext(connectString);

            try
            {
                var budgetToUpdate = (from b in db.Budgets
                                      where b.BudgetID == id
                                      select b).First();

                if (budgetToUpdate != null)
                {
                    budgetToUpdate.InfoBox      = infoBox;
                    budgetToUpdate.Cancellation = Cancellation;
                    budgetToUpdate.Returned     = Returned;

                    // db.Budgets.Attach(budgetToUpdate);
                    db.Refresh(RefreshMode.KeepCurrentValues, budgetToUpdate);
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                //   result = false;
            }

            //return result;
        }
예제 #2
0
        public UserActionLogRep()
        {
            Connection conn = new Connection();

            connectString = conn.GetDirectConnString();
            db            = new BOTADataContext(connectString);
        }
        public bool DeleteOrgOtherFunders(int id)
        {
            bool result = true;

            try
            {
                BOTADataContext db = new BOTADataContext(connectString);

                //using (BOTADataContext db)
                {
                    OtherFunder item = (from o in db.OtherFunders
                                        where o.OtherFundID == id
                                        select o).FirstOrDefault();
                    if (item != null)
                    {
                        db.OtherFunders.DeleteOnSubmit(item);
                        db.SubmitChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                //Log4Net uses its dll, bin/Log4Net.config -> has C:/Logs/errors2.txt
                Log.EnsureInitialized();
                Log.Error(typeof(OrganizationRepository), "----------------------------------------------", ex);
                result = false;
            }


            return(result);
        }
예제 #4
0
        public bool CreatePageAccess(PageAccess pa)
        {
            bool            result = true;
            BOTADataContext db     = new BOTADataContext(connectString);

            try
            {
                //TODO: I should also check if such project and user exists.

                if (!db.PageAccesses.Any(l => l.Controller == pa.Controller && l.Action == pa.Action && l.RoleId == pa.RoleId)) // !if exists.
                {
                    db.PageAccesses.InsertOnSubmit(pa);
                }
                else
                {
                    return(false);
                }

                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                result = false;
            }

            return(result);
        }
        public int CreateNewOrganization(string projorganization)
        {
            BOTADataContext db = new BOTADataContext(connectString);

            try
            {
                Organization org = new Organization();
                db.Organizations.InsertOnSubmit(org);
                db.SubmitChanges();

                General gen = new General();
                gen.OrgID  = org.OrgID;
                gen.NameRu = projorganization;
                db.Generals.InsertOnSubmit(gen);
                db.SubmitChanges();

                return(org.OrgID);
            }
            catch (Exception ex)
            {
                Log.EnsureInitialized();
                Log.Error(typeof(OrganizationRepository), "----------------------------------------------", ex);
                return(-1);
            }
        }
        public IEnumerable <Address> GetOrganizationAddressByID(int id)
        {
            BOTADataContext db = new BOTADataContext(connectString);



            try
            {
                /*    result = (from org in db.Organizations
                 *            join cont in db.Addresses
                 *            on org.OrgID equals cont.OrgID
                 *            where org.OrgID == id
                 *            select org).FirstOrDefault();
                 *  return result; */
                var result = from addr in db.Addresses
                             where addr.OrgID == id
                             select addr;

                return(result);
            }
            catch (Exception ex)
            {
                Log.EnsureInitialized();
                Log.Error(typeof(OrganizationRepository), "----------------------------------------------", ex);
                return(null);
            }
        }
        public bool DeleteOrgContact(int id)
        {
            bool result = true;

            try
            {
                BOTADataContext db = new BOTADataContext(connectString);

                //using (BOTADataContext db)
                {
                    Contact item = (from conts in db.Contacts
                                    where conts.ContactID == id
                                    select conts).First();
                    if (item != null)
                    {
                        db.Contacts.DeleteOnSubmit(item);
                        db.SubmitChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.EnsureInitialized();
                Log.Error(typeof(OrganizationRepository), "----------------------------------------------", ex);
                result = false;
            }


            return(result);
        }
        public bool InsertNewOrgAddress(int id)
        {
            BOTADataContext db = new BOTADataContext(connectString);

            try
            {
                Address addr = new Address();

                if (!db.Addresses.Any(l => l.OrgID == id)) // if first address of org then it is the default.
                {
                    addr.isLegalAddress = true;
                }

                addr.OrgID = id;
                db.Addresses.InsertOnSubmit(addr);
                db.SubmitChanges();

                return(true);
            }
            catch (Exception ex)
            {
                Log.EnsureInitialized();
                Log.Error(typeof(OrganizationRepository), "----------------------------------------------", ex);
                return(false);
            }
        }
예제 #9
0
        public GrantTypeListRepository()
        {
            Connection conn = new Connection();

            connectString = conn.GetDirectConnString();
            db            = new BOTADataContext(connectString);
        }
예제 #10
0
        public List <PageAccess> GetPageAccessByRole(int roleID)
        {
            IEnumerable <PageAccess> pa = null;

            BOTADataContext db = new BOTADataContext(connectString);

            {
                try
                {
                    pa = (from a in db.PageAccesses
                          where a.RoleId == roleID
                          select a);     //.FirstOrDefault();
                }
                catch
                {
                    return(null);
                }
            }

            if (pa.Any())
            {
                return(pa.ToList());
            }
            else
            {
                return(null);
            }
        }
        public IndicatorRepository()
        {
            Connection conn = new Connection();

            connectString = conn.GetDirectConnString();
            db            = new BOTADataContext(connectString);
        }
예제 #12
0
        public bool DeletePageAccess(int?id)
        {
            BOTADataContext db = new BOTADataContext(connectString);

            bool result = true;

            try
            {
                var toDelete = (from s in db.PageAccesses
                                where s.ID == id
                                select s).FirstOrDefault();

                if (toDelete != null)
                {
                    db.PageAccesses.DeleteOnSubmit(toDelete);
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                result = false;
            }

            return(result);
        }
예제 #13
0
        /// <summary>
        /// It either updates existing account or
        /// if such account does not exist then inserts.
        /// </summary>
        /// <param name="account"></param>
        public bool SaveAccount(SSPStaff account)
        {
            BOTADataContext db = new BOTADataContext(connectString);
            {
                try
                {
                    if (account.SSPStaffID > 0)
                    {
                        db.SSPStaffs.Attach(account);
                        db.Refresh(RefreshMode.KeepCurrentValues, account);
                    }
                    else
                    {
                        db.SSPStaffs.InsertOnSubmit(account);
                    }
                    db.SubmitChanges();

                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
        }
예제 #14
0
        public bool UpdateBudgetInitialAmount(int initialamt, int budgetID)
        {
            bool            result = true;
            BOTADataContext db     = new BOTADataContext(connectString);

            try
            {
                Budget budget = (from b in db.Budgets
                                 where b.BudgetID == budgetID
                                 select b).FirstOrDefault();

                budget.ContractInitialAmt = initialamt;

                //db.Budgets.Attach();
                db.Refresh(RefreshMode.KeepCurrentValues, budget);
                db.SubmitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }

            //return result;
        }
예제 #15
0
        public bool DeleteSSPStaffFromProject(int SSPStaffID, int id)
        {
            BOTADataContext db = new BOTADataContext(connectString);

            bool result = true;

            try
            {
                var toDelete = (from s in db.SSPStaffProjects
                                where s.ProjectID == id && s.SSPStaffID == SSPStaffID
                                select s).FirstOrDefault();

                if (toDelete != null)
                {
                    db.SSPStaffProjects.DeleteOnSubmit(toDelete);
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                result = false;
            }

            return(result);
        }
예제 #16
0
        /// <summary>
        /// Inserts staff into project.
        /// </summary>
        /// <param name="SSPStaffID"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool InsertSSPStaffIntoProject(int SSPStaffID, int id)
        {
            bool            result = true;
            BOTADataContext db     = new BOTADataContext(connectString);

            try
            {
                //TODO: I should also check if such project and user exists.

                if (!db.SSPStaffProjects.Any(l => l.SSPStaffID == SSPStaffID && l.ProjectID == id)) // !if exists.
                {
                    SSPStaffProject sspproject = new SSPStaffProject();
                    sspproject.ProjectID  = id;
                    sspproject.SSPStaffID = SSPStaffID;

                    db.SSPStaffProjects.InsertOnSubmit(sspproject);
                }
                else
                {
                    return(false);
                }

                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                result = false;
            }

            return(result);
        }
예제 #17
0
        /// <summary>
        ///For Drop Down.
        /// </summary>
        /// <returns></returns>
        public IEnumerable <RolesSSPStaff> GetALLSSPRoles()
        {
            BOTADataContext db     = new BOTADataContext(connectString);
            var             result = from ls in db.RolesSSPStaffs
                                     select ls;

            return(result);
        }
        public IEnumerable <FinArtCatListR> GetCatList()
        {
            BOTADataContext db     = new BOTADataContext(connectString);
            var             result = from ls in db.FinArtCatListRs
                                     select ls;

            return(result);
        }
예제 #19
0
        /// <summary>
        /// Drop Down List.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IEnumerable <FinArtCatListR> GetCatList()
        {
            BOTADataContext db     = new BOTADataContext(connectString);
            var             result = (from ls in db.FinArtCatListRs
                                      select ls).OrderBy(c => c.FinArticleCatListID);

            return(result);
        }
        public IEnumerable <EventType> GetEventTypeList()
        {
            BOTADataContext db     = new BOTADataContext(connectString);
            var             result = from et in db.EventTypes
                                     select et;

            return(result);
        }
        static ReportPredicates()
        {
            // Connection conn = new Connection();
            //connectString = conn.GetDirectConnString();
            //db = new BOTADataContext(connectString);

            db = ReportsDataContext.GetDataContext();
        }
        public IEnumerable <LFIndicatorList> LfIndicatorList()
        {
            BOTADataContext db     = new BOTADataContext(connectString);
            var             result = from ls in db.LFIndicatorLists
                                     select ls;

            return(result);
        }
예제 #23
0
        public IEnumerable <ReportPeriodListR> GetFinPeriods(int BudgetID)
        {
            BOTADataContext db     = new BOTADataContext(connectString);
            var             result = from ls in db.ReportPeriodListRs
                                     where ls.BudgetID == BudgetID
                                     select ls;

            return(result);
        }
예제 #24
0
        /*
         * SELECT     ReportPeriodListR.PeriodStart, ReportPeriodListR.PeriodEnd, ReportPeriodListR.PeriodTitle, ReportPeriodR.Amount, FinArticleCategoryR.Price,
         *             FinArticleCategoryR.TransferAmt, FinArticleCategoryR.FinArticleCatListID, FinArticleCategoryR.FinArticleCatID, FinArticleCategoryR.BudgetID
         * FROM         FinArticleCategoryR INNER JOIN
         *             ReportPeriodR ON FinArticleCategoryR.FinArticleCatID = ReportPeriodR.FinArticleCatID INNER JOIN
         *             ReportPeriodListR ON ReportPeriodR.ReportPeriodID = ReportPeriodListR.ReportPeriodID
         * WHERE     (FinArticleCategoryR.BudgetID = 1)
         */

        public Budget GetBudget(int BudgetID)
        {
            BOTADataContext db     = new BOTADataContext(connectString);
            Budget          budget = (from b in db.Budgets
                                      where b.BudgetID == BudgetID
                                      select b).FirstOrDefault();

            return(budget);
        }
        static ReportsDataContext()
        {
            //string connString = Settings.Default.EntityConnection;
            //  Context = new BOTADBEntities1();
            Connection conn = new Connection();

            connectString = conn.GetDirectConnString();
            db            = new BOTADataContext(connectString);
        }
예제 #26
0
        /// <summary>
        /// Get the Role Name for given RoleID.
        /// </summary>
        /// <param name="RoleID"></param>
        /// <returns></returns>
        public RolesSSPStaff  GetSSPRoleByID(int RoleID)
        {
            BOTADataContext db     = new BOTADataContext(connectString);
            RolesSSPStaff   result = (from r in db.RolesSSPStaffs
                                      where r.RoleID == RoleID
                                      select r).FirstOrDefault();

            return(result);
        }
예제 #27
0
        /// <summary>
        /// Get All SSP Staff
        /// </summary>
        /// <param name="ProjectID"></param>
        /// <returns></returns>
        public IEnumerable <SSPStaff> GetSSPStaffList()
        {
            BOTADataContext        db = new BOTADataContext(connectString);
            IEnumerable <SSPStaff> result;

            result = (from s in db.SSPStaffs
                      join r in db.RolesSSPStaffs on s.RoleID equals r.RoleID
                      select s).Distinct();
            return(result);
        }
예제 #28
0
        public IEnumerable <SSPStaffProject> GetSSPStaffProjectt(int id)
        {
            BOTADataContext db = new BOTADataContext(connectString);

            var ssppr = from a in db.SSPStaffProjects
                        where a.ProjectID == id
                        select a;

            return(ssppr);
        }
        public AppDropDownsRepository()
        {
            //string connString = Settings.Default.EntityConnection;
            //  Context = new BOTADBEntities1();
            Connection conn = new Connection();

            connectString = conn.GetDirectConnString();

            db = new BOTADataContext(connectString);
        }
예제 #30
0
        public IEnumerable <FinArticleCategoryR> GetFinArticleCategory(int BudgetID)
        {
            BOTADataContext db     = new BOTADataContext(connectString);
            var             result = (from fincategs in db.FinArticleCategoryRs
                                      join r in db.ReportPeriodRs on fincategs.FinArticleCatID equals r.FinArticleCatID
                                      join rlist in db.ReportPeriodListRs on r.ReportPeriodID equals rlist.ReportPeriodID
                                      where fincategs.BudgetID == BudgetID
                                      select fincategs).Distinct().OrderBy(fcat => fcat.FinArticleCatID); //because of multip reports periods...dubplicates are returned.

            return(result);
        }