Пример #1
0
        /// <summary>
        /// 先删除旧的的价格,在新增
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public static bool DeleteAndAdd(Supplier_Price list)
        {
            DbTrans trans = DbSession.Default.BeginTransaction();

            try
            {
                DbSession.Default.Delete <Supplier_Price>(trans, o =>
                                                          o.RawMaterialPriceId == list.RawMaterialPriceId &&
                                                          o.Years == list.Years &&
                                                          o.Month == list.Month &&
                                                          o.Display != 2);
                bool isok = DbSession.Default.Insert(trans, list) > 0;

                if (isok)
                {
                    trans.Commit();
                }
                else
                {
                    trans.Rollback();
                }

                return(isok);
            }
            catch (Exception)
            {
                trans.Rollback();
                throw;
            }
            finally
            {
                trans.Close();
            }
        }
        public static string AddVendorInfo(Supplier_VendorInfo model)
        {
            if (model == null)
            {
                return("供应商对象为空");
            }

            DbTrans trans = DbSession.Default.BeginTransaction();

            try
            {
                //插入供应商主表
                var result = DbSession.Default.Insert(trans, new Supplier_List
                {
                    Code = model.Code,
                    Name = model.Name,

                    Site       = model.CompanyWebsiteAddress,
                    Address    = model.AddressOfRegisteredOffice,
                    Contact1   = $"{model.MainContactor}/{model.TelephoneNumber}/{model.EmailForPO}",
                    Contact2   = $"{model.FinanceContact}/{model.FinanceContactPhone}/{model.FinanceContactEmail}",
                    AddDate    = model.AddDate,
                    AddUserId  = model.AddUserId,
                    LastDate   = model.AddDate,
                    LastUserId = model.AddUserId,
                    //LabelId = 1,
                    Display = 1
                });

                if (result < 1)
                {
                    trans.Rollback();
                    return("供应商主表插入失败");
                }

                //插入供应商副表
                model.VendorId = result;
                result         = Insert(model);
                if (result < 1)
                {
                    trans.Rollback();
                    return("供应商副表插入失败");
                }

                trans.Commit();
            }
            catch (Exception)
            {
                trans.Rollback();
                throw;
            }

            return("0");
        }
Пример #3
0
        /// <summary>
        /// 下移
        /// </summary>
        /// <param name="identify"></param>
        /// <returns></returns>
        public bool DownloadOSDown(int orgid, int identify)
        {
            //当前对象
            DownloadOS current = Gateway.Default.From <DownloadOS>().Where(DownloadOS._.Dos_Id == identify).ToFirst <DownloadOS>();
            int        tax     = (int)current.Dos_Tax;
            //下一个对象,即弟弟对象;弟弟不存则直接返回false;
            DownloadOS next = Gateway.Default.From <DownloadOS>()
                              .Where(DownloadOS._.Dos_Tax > tax && DownloadOS._.Org_Id == orgid).OrderBy(DownloadOS._.Dos_Tax.Asc).ToFirst <DownloadOS>();

            if (next == null)
            {
                return(false);
            }

            //交换排序号
            current.Dos_Tax = next.Dos_Tax;
            next.Dos_Tax    = tax;
            using (DbTrans tran = Gateway.Default.BeginTrans())
                try
                {
                    tran.Save <DownloadOS>(current);
                    tran.Save <DownloadOS>(next);
                    tran.Commit();
                    return(true);
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
                finally
                {
                    tran.Close();
                }
        }
Пример #4
0
 public void SortSave(TeacherSort entity)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Save <TeacherSort>(entity);
             tran.Update <Teacher>(new Field[] { Teacher._.Ths_Name }, new object[] { entity.Ths_Name }, Teacher._.Ths_ID == entity.Ths_ID);
             if (entity.Ths_IsDefault)
             {
                 tran.Update <TeacherSort>(new Field[] { TeacherSort._.Ths_IsDefault }, new object[] { false },
                                           TeacherSort._.Ths_ID != entity.Ths_ID && TeacherSort._.Org_ID == entity.Org_ID);
                 tran.Update <TeacherSort>(new Field[] { TeacherSort._.Ths_IsDefault }, new object[] { true },
                                           TeacherSort._.Ths_ID == entity.Ths_ID && TeacherSort._.Org_ID == entity.Org_ID);
             }
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Пример #5
0
        /// <summary>
        /// 删除充值码设置项
        /// </summary>
        /// <param name="entity">业务实体</param>
        public void RechargeSetDelete(RechargeSet entity)
        {
            int used = RechargeCodeOfCount(entity.Org_ID, entity.Rs_ID, true, true);

            if (used > 0)
            {
                throw new Exception("当前设置项中涉及的充值码已经存在消费记录,不能删除!可以选择禁用。");
            }
            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    tran.Delete <RechargeSet>(entity);
                    tran.Delete <RechargeCode>(RechargeCode._.Rs_ID == entity.Rs_ID);

                    tran.Commit();
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    throw ex;
                }
                finally
                {
                    tran.Close();
                }
            }
        }
Пример #6
0
 /// <summary>
 /// 修改学习卡设置项
 /// </summary>
 /// <param name="entity">业务实体</param>
 public void SetSave(LearningCardSet entity)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             Song.Entities.LearningCardSet rs = tran.From <LearningCardSet>().Where(LearningCardSet._.Lcs_ID == entity.Lcs_ID).ToFirst <LearningCardSet>();
             LearningCard[] cards             = CardGenerate(entity, tran);
             if (cards != null)
             {
                 foreach (LearningCard c in cards)
                 {
                     Gateway.Default.Save <LearningCard>(c);
                 }
             }
             tran.Update <LearningCard>(new Field[] { LearningCard._.Lc_Price, LearningCard._.Lc_LimitStart, LearningCard._.Lc_LimitEnd },
                                        new object[] { entity.Lcs_Price, entity.Lcs_LimitStart, entity.Lcs_LimitEnd },
                                        LearningCard._.Lcs_ID == entity.Lcs_ID && LearningCard._.Lc_IsUsed == false);
             tran.Save <LearningCardSet>(entity);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Пример #7
0
        public void OrganSetDefault(int identify)
        {
            using (DbTrans trans = Gateway.Default.BeginTrans())
            {
                try
                {
                    trans.Update <Organization>(new Field[] { Organization._.Org_IsDefault },
                                                new object[] { true }, Organization._.Org_ID == identify);
                    trans.Update <Organization>(new Field[] { Organization._.Org_IsDefault },
                                                new object[] { false }, Organization._.Org_ID != identify);
                    trans.Commit();
                    this.OrganBuildCache();

                    IDictionaryEnumerator cache = HttpRuntime.Cache.GetEnumerator();
                    while (cache.MoveNext())
                    {
                        HttpRuntime.Cache.Remove(cache.Key.ToString());
                    }
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw ex;
                }
                finally
                {
                    trans.Close();
                }
            }
            this.OrganBuildCache();  //重新构建缓存
        }
Пример #8
0
 public void OrganSetDefault(int identify)
 {
     using (DbTrans trans = Gateway.Default.BeginTrans())
     {
         try
         {
             trans.Update <Organization>(new Field[] { Organization._.Org_IsDefault },
                                         new object[] { true }, Organization._.Org_ID == identify);
             trans.Update <Organization>(new Field[] { Organization._.Org_IsDefault },
                                         new object[] { false }, Organization._.Org_ID != identify);
             trans.Commit();
             this.OrganBuildCache();
         }
         catch (Exception ex)
         {
             trans.Rollback();
             throw ex;
         }
         finally
         {
             trans.Close();
         }
     }
     this.OrganBuildCache();  //重新构建缓存
 }
Пример #9
0
 public void PagerDelete(int identify)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             Examination exam = Gateway.Default.From <Examination>().Where(Examination._.Tp_Id == identify).ToFirst <Examination>();
             if (exam != null)
             {
                 throw new WeiSha.Common.ExceptionForPrompt("该试卷已被考试采用,不能删除");
             }
             tran.Delete <TestPaper>(TestPaper._.Tp_Id == identify);
             tran.Delete <TestResults>(TestResults._.Tp_Id == identify);
             tran.Commit();
         }
         catch
         {
             tran.Rollback();
             throw;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Пример #10
0
 public void TeamSave(Team entity)
 {
     //
     Song.Entities.Depart dep = Gateway.Default.From <Depart>().Where(Depart._.Dep_Id == entity.Dep_ID).ToFirst <Depart>();
     if (dep != null)
     {
         entity.Dep_Name = dep.Dep_CnName;
     }
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Save <Team>(entity);
             tran.Update <EmpAccount>(new Field[] { EmpAccount._.Team_Name }, new object[] { entity.Team_Name }, EmpAccount._.Team_ID == entity.Team_ID);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Пример #11
0
        /// <summary>
        /// 删除回复信息
        /// </summary>
        /// <param name="identify"></param>
        public void AnswerDelete(int identify)
        {
            MessageBoard mb = Gateway.Default.From <MessageBoard>().Where(MessageBoard._.Mb_Id == identify).ToFirst <MessageBoard>();

            if (mb.Mb_IsTheme)
            {
                this.ThemeDelete(mb);
            }
            else
            {
                Song.Entities.MessageBoard theme = Gateway.Default.From <MessageBoard>().Where(MessageBoard._.Mb_IsTheme == true && MessageBoard._.Mb_UID == mb.Mb_UID).ToFirst <MessageBoard>();
                using (DbTrans tran = Gateway.Default.BeginTrans())
                    try
                    {
                        theme.Mb_AnsTime      = DateTime.Now;
                        theme.Mb_ReplyNumber -= 1;
                        tran.Save <MessageBoard>(theme);
                        //
                        tran.Delete <MessageBoard>(MessageBoard._.Mb_Id == identify);
                        tran.Commit();
                    }
                    catch (Exception ex)
                    {
                        tran.Rollback();
                        throw ex;
                    }
                finally
                {
                    tran.Close();
                }
            }
        }
Пример #12
0
 /// <summary>
 /// 添加回复留言信息
 /// </summary>
 /// <param name="entity"></param>
 public void AnswerAdd(MessageBoard entity)
 {
     //
     Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent();
     if (org != null)
     {
         entity.Org_ID   = org.Org_ID;
         entity.Org_Name = org.Org_Name;
     }
     Song.Entities.MessageBoard theme = Gateway.Default.From <MessageBoard>().Where(MessageBoard._.Mb_IsTheme == true && MessageBoard._.Mb_UID == entity.Mb_UID).ToFirst <MessageBoard>();
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             theme.Mb_AnsTime      = DateTime.Now;
             theme.Mb_ReplyNumber += 1;
             tran.Save <MessageBoard>(theme);
             //
             entity.Mb_IsTheme = false;
             entity.Mb_CrtTime = DateTime.Now;
             entity.Mb_IP      = WeiSha.Common.Request.IP.IPAddress;
             tran.Save <MessageBoard>(entity);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Пример #13
0
        /// <suPsary>
        /// 删除,按栏目名称
        /// </suPsary>
        /// <param name="name">栏目名称</param>
        public void SortDelete(string name)
        {
            LinksSort entity = Gateway.Default.From <LinksSort>().Where(LinksSort._.Ls_Name == name).ToFirst <LinksSort>();

            if (entity == null)
            {
                return;
            }
            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    tran.Delete <LinksSort>(LinksSort._.Ls_Id == entity.Ls_Id);
                    tran.Delete <Links>(Links._.Ls_Id == entity.Ls_Id);
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
                finally
                {
                    tran.Close();
                }
            }
        }
Пример #14
0
        /// <summary>
        /// 新增数据
        /// </summary>
        public AjaxResult Insert(TbShortMessageTemplate model)
        {
            if (model == null)
            {
                return(AjaxResult.Warning("参数错误"));
            }
            using (DbTrans trans = Db.Context.BeginTransaction())
            {
                try
                {
                    //添加信息及明细信息
                    Repository <TbShortMessageTemplate> .Insert(trans, model);

                    trans.Commit();
                    return(AjaxResult.Success());
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    return(AjaxResult.Error(ex.ToString()));
                }
                finally
                {
                    trans.Close();
                }
            }
        }
Пример #15
0
 public void Save(Song.Entities.Columns entity)
 {
     using (DbTrans trans = Gateway.Default.BeginTrans())
     {
         try
         {
             trans.Save <Columns>(entity);
             //新闻,产品,图片,视频,下载
             trans.Update <Article>(new Field[] { Article._.Col_Name }, new object[] { entity.Col_Name }, Article._.Col_Id == entity.Col_ID);
             trans.Update <Product>(new Field[] { Product._.Col_Name }, new object[] { entity.Col_Name }, Product._.Col_Id == entity.Col_ID);
             trans.Update <Picture>(new Field[] { Picture._.Col_Name }, new object[] { entity.Col_Name }, Picture._.Col_Id == entity.Col_ID);
             trans.Update <Video>(new Field[] { Video._.Col_Name }, new object[] { entity.Col_Name }, Video._.Col_Id == entity.Col_ID);
             trans.Update <Download>(new Field[] { Download._.Col_Name }, new object[] { entity.Col_Name }, Download._.Col_Id == entity.Col_ID);
             trans.Commit();
         }
         catch (Exception ex)
         {
             trans.Rollback();
             throw ex;
         }
         finally
         {
             trans.Close();
         }
     }
 }
Пример #16
0
        /// <summary>
        /// 删除,按栏目名称
        /// </summary>
        /// <param name="name">栏目名称</param>
        public void Delete(string name)
        {
            ManageMenu dep = Gateway.Default.From <ManageMenu>().Where(ManageMenu._.MM_Name == name).ToFirst <ManageMenu>();

            if (dep == null)
            {
                return;
            }
            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    this._Delete(dep.MM_Id, tran);
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
                finally
                {
                    tran.Close();
                }
            }
        }
Пример #17
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity">业务实体</param>
        public int RootSave(ManageMenu entity)
        {
            int id = entity.MM_Id;

            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    tran.Save <ManageMenu>(entity);
                    tran.Update <ManageMenu>(new Field[] { ManageMenu._.MM_IsUse, ManageMenu._.MM_IsShow }, new object[] { entity.MM_IsUse, entity.MM_IsShow }, ManageMenu._.MM_Root == entity.MM_Id);
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
                finally
                {
                    tran.Close();
                }
            }

            return(id);
        }
Пример #18
0
        //public AjaxResult UpdateNew(List<TbNoticeNewsSetUp> noticeNewsList)
        //{
        //    if (noticeNewsList == null)
        //        return AjaxResult.Warning("参数错误");
        //    var noticeNewsListNew = new List<TbNoticeNewsSetUp>();
        //    var ret = Db.Context.From<TbNoticeNewsSetUp>().Select(TbNoticeNewsSetUp._.All).ToList();
        //    if (noticeNewsList.Count > 0)
        //    {
        //        for (int i = 0; i < noticeNewsList.Count; i++)
        //        {
        //            var model = ret.Where(p => p.NoticeNewsCode == noticeNewsList[i].NoticeNewsCode).First();
        //            model.IsStart = noticeNewsList[i].IsStart;
        //            model.App = noticeNewsList[i].App;
        //            model.Pc = noticeNewsList[i].Pc;
        //            noticeNewsListNew.Add(model);
        //        }
        //    }
        //    try
        //    {
        //        if (noticeNewsListNew.Count > 0)
        //        {
        //            Repository<TbNoticeNewsSetUp>.Update(noticeNewsListNew);
        //        }
        //        return AjaxResult.Success();
        //    }

        //    catch (Exception)
        //    {
        //        return AjaxResult.Error("操作失败");
        //    }

        //}
        public AjaxResult InsertNew(List <TbNoticeNewsOrg> noticeNewsOrgList, string OrgType, string DeptId, string RoleId, string PersonnelSource, string PersonnelCode, string ProjectId, int NewsType)
        {
            if (noticeNewsOrgList == null)
            {
                return(AjaxResult.Warning("参数错误"));
            }
            using (DbTrans trans = Db.Context.BeginTransaction())
            {
                try
                {
                    //先删除原来的数据
                    Repository <TbNoticeNewsOrg> .Delete(trans, p => p.OrgType == OrgType && p.DeptId == DeptId && p.PersonnelCode == PersonnelCode && p.PersonnelSource == PersonnelSource && p.ProjectId == ProjectId && p.NewsType == NewsType);

                    Repository <TbNoticeNewsOrg> .Insert(trans, noticeNewsOrgList);

                    trans.Commit();
                    return(AjaxResult.Success());
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    return(AjaxResult.Error(ex.ToString()));
                }
                finally
                {
                    trans.Close();
                }
            }
        }
Пример #19
0
        public void PagerSave(TestPaper entity)
        {
            entity.Tp_Lasttime = DateTime.Now;
            //相关联的课程名称
            Course cou = Gateway.Default.From <Course>().Where(Course._.Cou_ID == entity.Cou_ID).ToFirst <Course>();

            if (cou != null)
            {
                entity.Cou_Name = cou.Cou_Name;
            }
            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    tran.Save <TestPaper>(entity);
                    tran.Update <Examination>(new Field[] { Examination._.Exam_PassScore, Examination._.Exam_Total },
                                              new object[] { entity.Tp_PassScore, entity.Tp_Total }, Examination._.Tp_Id == entity.Tp_Id);
                    tran.Commit();
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    throw ex;
                }
                finally
                {
                    tran.Close();
                }
            }
        }
Пример #20
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="entity">业务实体</param>
 public void Delete(Position entity)
 {
     if (entity.Posi_IsAdmin)
     {
         return;
     }
     //删除权限关联
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Delete <Purview>(Purview._.Posi_Id == entity.Posi_Id);
             //修改员工信息中的岗位名称
             tran.Update <EmpAccount>(new Field[] { EmpAccount._.Posi_Name }, new object[] { "" }, EmpAccount._.Posi_Id == entity.Posi_Id);
             tran.Delete <Position>(entity);
             tran.Commit();
         }
         catch
         {
             tran.Rollback();
             throw;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Пример #21
0
 public void ArticleDelete(Article entity, DbTrans tran)
 {
     if (tran == null)
     {
         tran = Gateway.Default.BeginTrans();
     }
     try
     {
         //删除附件
         Business.Do <IAccessory>().Delete(entity.Art_Uid);
         tran.Delete <Article>(Article._.Art_Id == entity.Art_Id);
         //删除图片文件
         string img = WeiSha.Common.Upload.Get[_artUppath].Physics + entity.Art_Logo;
         if (System.IO.File.Exists(img))
         {
             System.IO.File.Delete(img);
         }
         //删除文章
         tran.Delete <Article>(Article._.Art_Id == entity.Art_Id);
         tran.Commit();
     }
     catch (Exception ex)
     {
         tran.Rollback();
         throw ex;
     }
     finally
     {
         tran.Close();
     }
 }
Пример #22
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="entity">业务实体</param>
 public void ColumnsSave(GuideColumns entity)
 {
     Song.Entities.GuideColumns old = this.ColumnsSingle(entity.Gc_ID);
     if (old.Gc_PID != entity.Gc_PID)
     {
         object obj = Gateway.Default.Max <GuideColumns>(GuideColumns._.Gc_Tax, GuideColumns._.Cou_ID == entity.Cou_ID && GuideColumns._.Gc_PID == entity.Gc_PID);
         entity.Gc_Tax = obj is int?(int)obj + 1 : 0;
     }
     using (DbTrans trans = Gateway.Default.BeginTrans())
     {
         try
         {
             trans.Save <GuideColumns>(entity);
             trans.Update <GuideColumns>(new Field[] { Guide._.Gc_Title }, new object[] { entity.Gc_Title, }, GuideColumns._.Gc_ID == entity.Gc_ID);
             trans.Commit();
         }
         catch (Exception ex)
         {
             trans.Rollback();
             throw ex;
         }
         finally
         {
             trans.Close();
         }
     }
 }
Пример #23
0
 /// <summary>
 /// 回滚事务
 /// </summary>
 public void Rollback()
 {
     if (_trans != null)
     {
         _trans.Rollback();
     }
 }
Пример #24
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="entity">业务实体</param>
 public void GuideDelete(Guide entity)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             if (!string.IsNullOrWhiteSpace(entity.Gu_Uid))
             {
                 //删除附件
                 Business.Do <IAccessory>().Delete(entity.Gu_Uid);
                 //删除图片文件
                 string img = WeiSha.Common.Upload.Get[_artUppath].Physics + entity.Gu_Logo;
                 if (System.IO.File.Exists(img))
                 {
                     System.IO.File.Delete(img);
                 }
             }
             tran.Delete <Guide>(Guide._.Gu_Id == entity.Gu_Id);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Пример #25
0
        /// <summary>
        /// 删除学习卡设置项
        /// </summary>
        /// <param name="entity">业务实体</param>
        public void SetDelete(LearningCardSet entity)
        {
            int used = CardOfCount(entity.Org_ID, entity.Lcs_ID, true, true);

            if (used > 0)
            {
                throw new Exception("当前设置项中涉及的学习卡已经存在使用记录,不能删除!可以选择禁用。");
            }
            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    tran.Delete <LearningCardSet>(entity);
                    tran.Delete <LearningCard>(LearningCard._.Lcs_ID == entity.Lcs_ID);

                    tran.Commit();
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    throw ex;
                }
                finally
                {
                    tran.Close();
                }
            }
        }
Пример #26
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="entity">业务实体</param>
 public void Save(Depart entity)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Save <Depart>(entity);
             tran.Update <EmpAccount>(new Field[] { EmpAccount._.Dep_CnName }, new object[] { entity.Dep_CnName }, EmpAccount._.Dep_Id == entity.Dep_Id);
             tran.Update <Subject>(new Field[] { Subject._.Dep_CnName }, new object[] { entity.Dep_CnName }, Subject._.Dep_Id == entity.Dep_Id);
             tran.Update <Course>(new Field[] { Course._.Dep_CnName }, new object[] { entity.Dep_CnName }, Course._.Dep_Id == entity.Dep_Id);
             //tran.Update<Teacher>(new Field[] { Teacher._.Dep_CnName }, new object[] { entity.Dep_CnName }, Teacher._.Dep_Id == entity.Dep_Id);
             tran.Update <StudentSort>(new Field[] { StudentSort._.Dep_CnName }, new object[] { entity.Dep_CnName }, StudentSort._.Dep_Id == entity.Dep_Id);
             tran.Commit();
         }
         catch
         {
             tran.Rollback();
             throw;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Пример #27
0
 public void TeacherDelete(Teacher entity, DbTrans tran)
 {
     if (tran == null)
     {
         tran = Gateway.Default.BeginTrans();
     }
     try
     {
         tran.Delete <Teacher>(Teacher._.Th_ID == entity.Th_ID);
         tran.Delete <TeacherHistory>(TeacherHistory._.Th_ID == entity.Th_ID);
         tran.Update <Accounts>(new Field[] { Accounts._.Ac_IsTeacher }, new object[] { false }, Accounts._.Ac_ID == entity.Ac_ID);
         tran.Commit();
         if (!string.IsNullOrWhiteSpace(entity.Th_Photo))
         {
             WeiSha.WebControl.FileUpload.Delete("Teacher", entity.Th_Photo);
         }
     }
     catch (Exception ex)
     {
         tran.Rollback();
         throw ex;
     }
     finally
     {
         tran.Close();
         tran.Dispose();
     }
     Extend.LoginState.Accounts.Refresh(entity.Ac_ID);
 }
Пример #28
0
        /// <summary>
        /// 删除章节
        /// </summary>
        /// <param name="entity">业务实体</param>
        public void OutlineDelete(Outline entity)
        {
            if (entity == null)
            {
                return;
            }
            List <Song.Entities.Accessory> acs = Business.Do <IAccessory>().GetAll(entity.Ol_UID);

            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    //删除附件
                    foreach (Song.Entities.Accessory ac in acs)
                    {
                        Business.Do <IAccessory>().Delete(ac.As_Id);
                    }
                    //先清理试题
                    tran.Delete <Questions>(Questions._.Ol_ID == entity.Ol_ID);
                    tran.Delete <Outline>(Outline._.Ol_ID == entity.Ol_ID);
                    tran.Commit();
                    this.OnDelete(entity, null);
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    throw ex;
                }
                finally
                {
                    tran.Close();
                }
            }
        }
Пример #29
0
 public void TeacherSave(Teacher entity)
 {
     //如果密码不为空
     //if (string.IsNullOrWhiteSpace(entity.Th_Pw))
     //    entity.Th_Pw = new WeiSha.Common.Param.Method.ConvertToAnyValue(entity.Th_Pw).MD5;
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Save <Teacher>(entity);
             //同步课程表中的教师名称
             tran.Update <Course>(new Field[] { Course._.Th_Name }, new object[] { entity.Th_Name }, Course._.Th_ID == entity.Th_ID);
             //同步教师评价中的名称
             tran.Update <TeacherComment>(new Field[] { TeacherComment._.Th_Name }, new object[] { entity.Th_Name }, TeacherComment._.Th_ID == entity.Th_ID);
             tran.Update <Accounts>(new Field[] { Accounts._.Ac_Sex, Accounts._.Ac_Birthday, Accounts._.Ac_IDCardNumber, Accounts._.Ac_Nation, Accounts._.Ac_Native },
                                    new object[] { entity.Th_Sex, entity.Th_Birthday, entity.Th_IDCardNumber, entity.Th_Nation, entity.Th_Native }, Accounts._.Ac_ID == entity.Ac_ID);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Пример #30
0
        /// <summary>
        /// 上移
        /// </summary>
        /// <param name="identify"></param>
        /// <returns></returns>
        public bool DownloadTypeUp(int orgid, int identify)
        {
            //当前对象
            DownloadType current = Gateway.Default.From <DownloadType>().Where(DownloadType._.Dty_Id == identify).ToFirst <DownloadType>();
            int          tax     = (int)current.Dty_Tax;
            //上一个对象,即兄长对象;兄长不存则直接返回false;
            DownloadType prev = Gateway.Default.From <DownloadType>()
                                .Where(DownloadType._.Dty_Tax < tax && DownloadType._.Org_Id == orgid).OrderBy(DownloadType._.Dty_Tax.Desc).ToFirst <DownloadType>();

            if (prev == null)
            {
                return(false);
            }

            //交换排序号
            current.Dty_Tax = prev.Dty_Tax;
            prev.Dty_Tax    = tax;
            using (DbTrans tran = Gateway.Default.BeginTrans())
                try
                {
                    tran.Save <DownloadType>(current);
                    tran.Save <DownloadType>(prev);
                    tran.Commit();
                    return(true);
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
                finally
                {
                    tran.Close();
                }
        }