Пример #1
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);
                }
            }
        }
Пример #2
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;
        }
Пример #3
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;
        }
        public bool UpdateIndicatorItem(IndicatorItem item)
        {
            bool result = true;

            try
            {
                db.IndicatorItems.Attach(item);
                db.Refresh(RefreshMode.KeepCurrentValues, item);
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                Log.EnsureInitialized();
                Log.Error(typeof(IndicatorRepository), "----------------------------------------------", ex);
                result = false;
                //  throw ex;
            }
            return(result);
        }
 public bool Update(ProjectEvent item)
 {
     bool result = true;
     try
     {
         /*var oldItem  = (from p in db.ProjectEvents
                        where p.EventID == item.EventID
                        select p).First();*/
         db.ProjectEvents.Attach(item);
         db.Refresh(RefreshMode.KeepCurrentValues,item);
         db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Log.EnsureInitialized();
         Log.Error(typeof(ProjectEventRepository), "----------------------------------------------", ex); 
         result = false;   
     }
     return result;
 }
Пример #6
0
        public bool UpdateStaffProject(int id, List <int> current)
        {
            BOTADataContext db = new BOTADataContext(connectString);

            {
                try
                {
                    var sspproj = from a in db.SSPStaffProjects
                                  where a.ProjectID == id
                                  select a;

                    foreach (var vsp in sspproj)
                    {
                        if (current != null)
                        {
                            if (current.Any(s => s == vsp.SSPStaffID))
                            {
                                vsp.Active = true;
                            }
                            else
                            {
                                vsp.Active = false;
                            }
                        }
                        else
                        {
                            vsp.Active = false;
                        }
                    }


                    // db.SSPStaffProjects.AttachAll(sspproj);
                    db.Refresh(RefreshMode.KeepCurrentValues, sspproj);
                    db.SubmitChanges();

                    return(true);
                }
                catch
                {
                    return(false);
                }
            }

            return(false);
        }
Пример #7
0
        /// <summary>
        /// Updates Report Periods.
        /// </summary>
        /// <param name="repperlist"></param>
        /// <returns></returns>
        public bool UpdateReportPeriodList(List <ReportPeriodListR> repperlist)
        {
            bool            result = true;
            BOTADataContext db     = new BOTADataContext(connectString);

            try
            {
                db.ReportPeriodListRs.AttachAll(repperlist);
                db.Refresh(RefreshMode.KeepCurrentValues, repperlist);
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                result = false;
            }

            return(result);
        }
        /// <summary>
        /// Updates All addreses of current organization.
        /// </summary>
        /// <param name="OrgAddresses"></param>
        /// <returns></returns>
        public bool UpdateOtherFunders(IEnumerable <OtherFunder> enumotherfunders)
        {
            bool            result = true;
            BOTADataContext db     = new BOTADataContext(connectString);

            try
            {
                db.OtherFunders.AttachAll(enumotherfunders);
                db.Refresh(RefreshMode.KeepCurrentValues, enumotherfunders);
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                Log.EnsureInitialized();
                Log.Error(typeof(OrganizationRepository), "----------------------------------------------", ex);
                result = false;
            }

            return(result);
        }
Пример #9
0
        public bool UpdatePageAccess(PageAccess pa)
        {
            BOTADataContext db = new BOTADataContext(connectString);
            {
                try
                {
                    if (pa.ID > 0)
                    {
                        db.PageAccesses.Attach(pa);
                        db.Refresh(RefreshMode.KeepCurrentValues, pa);
                    }

                    db.SubmitChanges();
                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
        }
Пример #10
0
        public void UpdateCategoriesValues(List <FinArticleCategoryR> FinArticleCategory)
        {
            bool            result = true;
            BOTADataContext db     = new BOTADataContext(connectString);

            try
            {
                /*var oldItem  = (from p in db.ProjectEvents
                 *             where p.EventID == item.EventID
                 *             select p).First();*/
                db.FinArticleCategoryRs.AttachAll(FinArticleCategory);
                db.Refresh(RefreshMode.KeepCurrentValues, FinArticleCategory);
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                //   result = false;
            }

            //return result;
        }
Пример #11
0
        public void UpdateReportPeriodTrans(List <ReportPeriodR> ReportPeriods)
        {
            bool            result = true;
            BOTADataContext db     = new BOTADataContext(connectString);

            try
            {
                /*var oldItem  = (from p in db.ProjectEvents
                 *             where p.EventID == item.EventID
                 *             select p).First();*/
                db.ReportPeriodRs.AttachAll(ReportPeriods);
                db.Refresh(RefreshMode.KeepCurrentValues, ReportPeriods);
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                //   result = false;
            }

            //return result;
        }
        /// <summary>
        /// Updates Organization General.
        /// LegalStatus: If exists then update, if no then insert.
        /// </summary>
        /// <param name="gen"></param>
        /// <returns></returns>
        public bool UpdateOrganizationGeneral(General gen)
        {
            bool            result = true;
            BOTADataContext db     = new BOTADataContext(connectString);

            try
            {
                db.Generals.Attach(gen);
                db.Refresh(RefreshMode.KeepCurrentValues, gen);

                //db.ExecuteCommand("DELETE FROM addresses WHERE ContactID={0} and AddressTypeID={1}", contactID, addressTypeID);
                // gen.Organization.LegalStatus.Detach();

                //check if legalstaus exists.

                /* var legstat = (from l in db.LegalStatus
                 *              where l.OrgID == gen.OrgID
                 *              select l).FirstOrDefault(); */


                //if (legstat == null) //if it does not exist.
                if (!db.LegalStatus.Any(l => l.OrgID == gen.OrgID)) // !if exists.
                {
                    //Insert
                    LegalStatus lstat = new LegalStatus();
                    lstat.OrgID        = gen.OrgID;
                    lstat.LegSListID   = gen.Organization.LegalStatus.LegSListID;
                    lstat.SelectedDate = gen.Organization.LegalStatus.SelectedDate;
                    db.LegalStatus.InsertOnSubmit(lstat);
                }
                else
                {  //try to update.
                   // legstat.Detach();
                   // legstat.LegSListID = gen.Organization.LegalStatus.LegSListID;
                   // db.LegalStatus.Attach(legstat);
                    db.Refresh(RefreshMode.KeepCurrentValues, gen.Organization.LegalStatus);
                }

                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                Log.EnsureInitialized();
                Log.Error(typeof(OrganizationRepository), "----------------------------------------------", ex);
                result = false;
            }

            return(result);

/*
 *         try
 *         {
 *
 *             BOTADataContext db = new BOTADataContext(connectString);
 *
 *             { General genitem = (from organization in db.Organizations
 *                                    join general in db.Generals
 *                                    on organization.OrgID equals general.OrgID
 *                                    where general.OrgID == gen.Organization.OrgID
 *                                    select general).First();
 *
 *                 genitem.Name = gen.Name;
 *                 genitem.Organization.LegalStatus.LegSListID = gen.Organization.LegalStatus.LegSListID;
 *                 genitem.FiscalYearEnd = gen.FiscalYearEnd;
 *                 genitem.Notes = gen.Notes;
 *                 db.SubmitChanges();
 *
 *             }
 *         }
 *         catch (Exception ex)
 *         {
 *             result = false;
 *         }
 *
 *         return result; */
        }
        public bool ArticleCatListEdit(List <FinArtCatListR> FinArtCatListR)
        {
            bool result = true;

            try
            {
                if (FinArtCatListR.Count() > 0)
                {
                    db.FinArtCatListRs.AttachAll(FinArtCatListR);
                    db.Refresh(RefreshMode.KeepCurrentValues, FinArtCatListR);
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                result = false;
            }

            return(result);
        }