当前位置: 首页>>代码示例>>C#>>正文


C# SessionFactory.Update方法代码示例

本文整理汇总了C#中SessionFactory.Update方法的典型用法代码示例。如果您正苦于以下问题:C# SessionFactory.Update方法的具体用法?C# SessionFactory.Update怎么用?C# SessionFactory.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SessionFactory的用法示例。


在下文中一共展示了SessionFactory.Update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Approve

        public ActionResult Approve(FormCollection collection, long[] ids, long id = 0)
        {
            if (ids.Length == 0)
            {
                FlashWarn("请选择要批阅的记录。");
                return Close();
            }
            using (var session = new SessionFactory().OpenSession())
            {
                var model = session.Load<TrainRecordFile>(m => m.Id.In(ids));
                if (model == null)
                {
                    FlashInfo("你没有选择任何可以批阅的记录。");
                    return Close();
                }
                TryUpdateModel(model, collection.ToValueProvider());
                model.UpdatedAt = DateTime.Now;
                model.UpdatedBy = CurrentAccountNo;
                if (session.Update(model))
                {
                    FlashSuccess("批阅记录成功");
                    return Close();
                }
                FlashFailure("批阅记录失败,请联系管理员!");
                return View();

            }
        }
开发者ID:dalinhuang,项目名称:info_platform_i,代码行数:28,代码来源:TrainRecordFilesController.cs

示例2: Edit

 public ActionResult Edit(FormCollection collection, long[] ids)
 {
     if (ids.Length == 0)
     {
         FlashWarn("请选择要修改的记录。");
         return Close();
     }
     using (var session = new SessionFactory().OpenSession())
     {
         var model = session.Load<School>(m => m.Id.In(ids));
         if (model == null)
         {
             FlashInfo("你没有选择任何可以修改的学校。");
             return Close();
         }
         TryUpdateModel(model, collection.ToValueProvider());
         if (!ModelState.IsValid)
         {
             return View(model);
         }
         model.UpdatedAt = DateTime.Now;
         model.UpdatedBy = CurrentAccountNo;
         if (session.Update(model))
         {
             FlashSuccess("学校更改成功");
             return Close();
         }
         return View();
     }
 }
开发者ID:dalinhuang,项目名称:info_platform,代码行数:30,代码来源:SchoolController.cs

示例3: Approve

 public ActionResult Approve(FormCollection collection, long[] ids)
 {
     if (ids.Length == 0)
     {
         FlashWarn("请选择要修改的记录。");
         return Close();
     }
     using (var session = new SessionFactory().OpenSession())
     {
         var model = session.Load<TrainManagement>(m => m.Id.In(ids));
         if (model == null)
         {
             FlashInfo("你没有选择任何可以审核的记录。");
             return Close();
         }
         if (!CanApprove(model))
         {
             FlashWarn("无法审核,请检查所选记录状态!");
             return Close();
         }
         model.Status = TrainManStateConst.法规部门负责人已审核;
         model.UpdatedAt = DateTime.Now;
         model.UpdatedBy = CurrentAccountNo;
         if (session.Update(model))
             FlashSuccess("记录审核成功");
         else
             FlashError("记录审核失败,请联系管理员!");
         return Close();
     }
 }
开发者ID:dalinhuang,项目名称:info_platform_i,代码行数:30,代码来源:TrainManagementController.cs

示例4: Create

        public ActionResult Create(FormCollection collection)
        {
            var model = new TrainNeed();
            TryUpdateModel(model, collection.ToValueProvider());
            if (!ModelState.IsValid)
            {
                return View(model);
            }
            using (var session = new SessionFactory().OpenSession())
            {

                session.BeginTransaction();
                var dept = new Criteria<Department>(session)
                  .AndIn<User>(m => m.Id, n => n.DepartmentId, m => m.Code.Equals(CurrentAccountNo)).Load();
                var models = session.Find<TrainNeed>(m => !m.IsCollected && m.Status.Equals(TrainNeedStatus.已提交部门负责人) && m.DeptId == dept.Id && m.Type.Equals(TrainNeedType.员工));
                if (models == null || !models.Any())
                {
                    FlashWarn("没有未汇总的需求!");
                    return Close();
                }
                foreach (var trainNeed in models)
                {
                    trainNeed.IsCollected = true;
                }
                model.DeptId = dept != null ? dept.Id : 0;
                model.Dept = dept != null ? dept.Name : null;
                model.IsCollected = false;
                model.CreatedAt = DateTime.Now;
                model.CreatedBy = CurrentAccountNo;
                model.Type = TrainNeedType.部门;
                ViewData.Model = model;
                ViewData["StaffNeeds"] = models;
                var exist = session.Load<TrainNeed>(m => m.Type.Equals(TrainNeedType.部门) && m.DeptId.Equals(model.DeptId) && m.Year.Equals(model.Year));
                if (exist != null)
                {
                    ModelState.AddModelError("Year", "本部门该年度部门培训需求已经存在!");
                    return View(model);
                }
                if (session.Create(model) && session.Update(models))
                {
                    session.Commit();
                    FlashSuccess("创建记录成功!");
                    return Close();
                }
                session.Rollback();
                FlashFailure("创建记录失败!");
                return View();
            }
        }
开发者ID:dalinhuang,项目名称:info_platform_i,代码行数:49,代码来源:TrainNeedDepartmentController.cs

示例5: Create

        public ActionResult Create(FormCollection collection)
        {
            var model = new TrainNeed();
            TryUpdateModel(model, collection.ToValueProvider());
            if (!ModelState.IsValid)
            {
                return View(model);
            }
            using (var session = new SessionFactory().OpenSession())
            {

                session.BeginTransaction();
                var models = session.Find<TrainNeed>(m =>
                        !m.IsCollected && m.Status.Equals(TrainNeedStatus.已提交培训部门) && m.Type.Equals(TrainNeedType.部门));
                if (models == null || !models.Any())
                {
                    FlashWarn("没有未汇总的需求!");
                    return Close();
                }
                foreach (var trainNeed in models)
                {
                    trainNeed.IsCollected = true;
                }
                model.IsCollected = false;
                model.CreatedAt = DateTime.Now;
                model.CreatedBy = CurrentAccountNo;
                model.Type = TrainNeedType.公司;
                ViewData["StaffNeeds"] = models;
                ViewData.Model = model;
                var exist = session.Load<TrainNeed>(m => m.Type.Equals(TrainNeedType.公司) && m.Year.Equals(model.Year));
                if (exist != null)
                {
                    ModelState.AddModelError("Year", "该年度公司培训需求已经存在!");
                    return View(model);
                }
                if (session.Create(model) && session.Update(models))
                {
                    session.Commit();
                    FlashSuccess("创建记录成功!");
                    return Close();
                }
                session.Rollback();
                FlashFailure("创建记录失败!");
                return View();
            }
        }
开发者ID:dalinhuang,项目名称:info_platform_i,代码行数:46,代码来源:TrainNeedCompanyController.cs

示例6: Approve

        public ActionResult Approve(FormCollection collection, long[] ids)
        {
            if (ids == null || ids.Length == 0)
            {
                FlashWarn("请选择要审核的记录。");
                return Close();
            }
            using (var session = new SessionFactory().OpenSession())
            {
                session.BeginTransaction();
                var model = session.Load<PunishmentDossier>(m => m.Id.In(ids));
                if (model == null)
                {
                    FlashInfo("你没有选择任何可以审核的记录。");
                    session.Rollback();
                    return Close();
                }
                if (!CanApprove(model))
                {
                    FlashWarn("无法审核,请检查所选记录状态!");
                    session.Rollback();
                    return Close();
                }
                TryUpdateModel(model, collection.ToValueProvider());
                if (!ModelState.IsValid)
                {
                    return View("Edit", model);
                }
                model.ApproveState = ApproveStateConst.已审核;
                model.ApprovePerson3 = CurrentAccountNo.GetName();
                model.UpdatedAt = DateTime.Now;
                model.UpdatedBy = CurrentAccountNo;

                if (session.Update(model))
                {
                    FlashSuccess("记录审核成功");
                    session.Commit();
                    return Close();
                }
                FlashFailure("审核失败,请联系管理员!");
                session.Rollback();
                return Close();
            }
        }
开发者ID:dalinhuang,项目名称:info_platform_i,代码行数:44,代码来源:PunishmentDossierLawController.cs

示例7: Approve

        public ActionResult Approve(FormCollection collection, long[] ids)
        {
            if (ids == null || ids.Length == 0)
            {
                FlashWarn("请选择要审核的记录。");
                return Close();
            }
            using (var session = new SessionFactory().OpenSession())
            {
                session.BeginTransaction();
                var models = session.Find<Contract>(m => m.Id.In(ids));
                if (models.Count == 0)
                {
                    FlashInfo("你没有选择任何可以审核的记录。");
                    session.Rollback();
                    return Close();
                }
                if (models.Any(m => !CanApprove(m)))
                {
                    FlashWarn("无法审核,请检查所选记录状态!");
                    session.Rollback();
                    return Close();
                }
                foreach (var model in models)
                {
                    model.State = ContractStateConst.承办部门审核;
                    model.ApproveState = ApproveStateConst.已审核;
                    model.ApprovePerson1 = CurrentAccountNo.GetName();
                    model.UpdatedAt = DateTime.Now;
                    model.UpdatedBy = CurrentAccountNo;
                }

                if (session.Update(models))
                {
                    FlashSuccess("记录审核成功");
                    session.Commit();
                    return Close();
                }
                FlashFailure("审核失败,请联系管理员!");
                session.Rollback();
                return Close();
            }
        }
开发者ID:dalinhuang,项目名称:info_platform_i,代码行数:43,代码来源:ContractUndertakeController.cs

示例8: Approve

        public ActionResult Approve(FormCollection collection, long[] ids)
        {
            if (ids.Length == 0)
            {
                FlashWarn("请选择要审核的记录。");
                return Close();
            }
            using (var session = new SessionFactory().OpenSession())
            {
                session.BeginTransaction();
                var models = session.Find<StandardFile>(m => m.Id.In(ids));
                if (models.Count == 0)
                {
                    FlashInfo("你没有选择任何可以审核的记录。");
                    return Close();
                }

                if (!models.All(CanApprove))
                {
                    FlashInfo("所选文件状态有误,请检查!");
                    return Close();
                }
                var displays = string.Join(", ", models.Select(m => m.FileName));

                foreach (var model in models)
                {
                    model.ApproveState = ApproveStateConst.已审核;
                    model.UpdatedAt = DateTime.Now;
                    model.UpdatedBy = CurrentAccountNo;
                }
                if (!session.Update(models))
                {
                    session.Rollback();
                    FlashError("审核记录{0}失败!", displays);
                    return View(models);
                }
                session.Commit();
                FlashSuccess("审核记录{0}成功!", displays);
                return Close();

            }
        }
开发者ID:dalinhuang,项目名称:info_platform_i,代码行数:42,代码来源:StandardFileApproveController.cs

示例9: Approve

        public ActionResult Approve(FormCollection collection, long[] ids)
        {
            if (ids.Length == 0)
            {
                FlashWarn("请选择要审核的记录。");
                return Close();
            }
            using (var session = new SessionFactory().OpenSession())
            {
                session.BeginTransaction();
                var models = session.Find<TrainExperience>(m => m.Id.In(ids));
                if (models.Count == 0)
                {
                    FlashInfo("你没有选择任何可以审核的记录。");
                    return Close();
                }
                if (!models.All(CanApprove))
                {
                    FlashWarn("所选记录不能审核,请检查记录状态!");
                    return Close();
                }
                foreach (var item in models)
                {
                    item.ApproveStatus = ApproveStateConst.已审核;
                    item.UpdatedAt = DateTime.Now;
                    item.UpdatedBy = CurrentAccountNo;
                }

                if (session.Update(models))
                {
                    session.Commit();
                    FlashSuccess("审核成功");
                    return Close();
                }
                session.Rollback();
                FlashError("审核失败,请联系管理员!");
                return Close();
            }
        }
开发者ID:dalinhuang,项目名称:info_platform_i,代码行数:39,代码来源:TrainExperienceDeptController.cs

示例10: Submit

        public ActionResult Submit(FormCollection collection, long[] ids)
        {
            if (ids.Length == 0)
            {
                FlashWarn("请选择要操作的记录。");
                return Close();
            }
            using (var session = new SessionFactory().OpenSession())
            {
                var model = session.Load<TrainNeed>(m => m.Id.In(ids));
                if (model == null)
                {
                    FlashInfo("你没有选择任何可以操作的记录。");
                    return Close();
                }

                model.UpdatedAt = DateTime.Now;
                model.UpdatedBy = CurrentAccountNo;
                model.Status = TrainNeedStatus.提交部门负责人;
                if (session.Update(model))
                {
                    FlashSuccess("提交成功");
                    return Close();
                }
                FlashWarn("提交失败,请联系管理呗!");
                return View();
            }
        }
开发者ID:dalinhuang,项目名称:info_platform,代码行数:28,代码来源:TrainNeedController.cs

示例11: Edit

        public ActionResult Edit(FormCollection collection, long[] ids)
        {
            if (ids.Length == 0)
            {
                FlashWarn("请选择要修改的记录。");
                return Close();
            }
            using (var session = new SessionFactory().OpenSession())
            {
                var model = session.Load<StandardFile>(m => m.Id.In(ids));
                if (model == null)
                {
                    FlashInfo("你没有选择任何可以修改的记录。");
                    return Close();
                }
                if (!model.CreatedBy.Equals(CurrentAccountNo))
                {
                    FlashInfo("你不是创建人,不能修改!");
                    return Close();
                }
                if (!CanSubmit(model))
                {
                    FlashInfo("已经提交审核,不能修改!");
                    return Close();
                }
                TryUpdateModel(model, collection.ToValueProvider());
                model.UpdatedAt = DateTime.Now;
                model.UpdatedBy = CurrentAccountNo;
                if (session.Update(model))
                {
                    FlashSuccess("记录修改成功");
                    return Close();
                }
                FlashFailure("记录修改失败,请联系管理员!");
                return View();

            }
        }
开发者ID:dalinhuang,项目名称:info_platform_i,代码行数:38,代码来源:StandardFileApproveController.cs

示例12: Back

        public ActionResult Back(FormCollection collection, long[] ids)
        {
            if (ids == null || ids.Length == 0)
            {
                FlashWarn("请选择要返回的记录。");
                return Close();
            }
            using (var session = new SessionFactory().OpenSession())
            {
                session.BeginTransaction();
                var models = session.Find<Record>(m => m.Id.In(ids));
                if (models.Count == 0)
                {
                    FlashInfo("你没有选择任何可以返回的记录。");
                    session.Rollback();
                    return Close();
                }
                if (models.Any(m => !CanBack(m)))
                {
                    FlashWarn("无法返回,请检查所选记录状态!");
                    session.Rollback();
                    return Close();
                }
                foreach (var model in models)
                {
                    model.State = RecordStateConst.修改制度;
                    model.ApproveState = "";
                    model.UpdatedAt = DateTime.Now;
                    model.UpdatedBy = CurrentAccountNo;
                }

                if (session.Update(models))
                {
                    FlashSuccess("返回成功");
                    session.Commit();
                    return Close();
                }
                FlashFailure("返回失败,请联系管理员!");
                session.Rollback();
                return Close();
            }
        }
开发者ID:dalinhuang,项目名称:info_platform_i,代码行数:42,代码来源:RecordController.cs

示例13: SubmitToLeader

        public ActionResult SubmitToLeader(FormCollection collection, long[] ids)
        {
            if (ids == null || ids.Length == 0)
            {
                FlashWarn("请选择要提交的记录。");
                return Close();
            }
            using (var session = new SessionFactory().OpenSession())
            {
                session.BeginTransaction();
                var models = session.Find<Dossier>(m => m.Id.In(ids));
                if (models.Count == 0)
                {
                    FlashInfo("你没有选择任何可以提交的记录。");
                    session.Rollback();
                    return Close();
                }
                if (models.Any(m => !CanSubmitToLeader(m)))
                {
                    FlashWarn("无法提交,请检查所选记录状态!");
                    session.Rollback();
                    return Close();
                }
                foreach (var model in models)
                {
                    model.State = DossierStateConst.专卖科审核;
                    model.ApproveState = ApproveStateConst.待审核;
                    model.UpdatedAt = DateTime.Now;
                    model.UpdatedBy = CurrentAccountNo;
                }

                if (session.Update(models))
                {
                    FlashSuccess("提交成功");
                    session.Commit();
                    return Close();
                }
                FlashFailure("提交失败,请联系管理员!");
                session.Rollback();
                return Close();
            }
        }
开发者ID:dalinhuang,项目名称:info_platform_i,代码行数:42,代码来源:DossierController.cs

示例14: Back

        public ActionResult Back(FormCollection collection, long[] ids)
        {
            if (ids.Length == 0)
            {
                FlashWarn("请选择要退回的记录。");
                return Close();
            }
            using (var session = new SessionFactory().OpenSession())
            {
                var model = session.Load<Contract>(m => m.Id.In(ids));
                if (model == null)
                {
                    FlashInfo("你没有选择任何可以退回的记录。");
                    return Close();
                }

                TryUpdateModel(model, collection.ToValueProvider());
                if (!ModelState.IsValid)
                {
                    return View(model);
                }
                model.ApprovePerson2 = CurrentAccountNo.GetName();
                model.ApproveTime1 = DateTime.Now;
                model.ApproveState = ApproveStateConst.审核不通过;
                model.UpdatedAt = DateTime.Now;
                model.UpdatedBy = CurrentAccountNo;
                if (session.Update(model))
                {
                    FlashSuccess("记录退回成功");
                    return Close();
                }
                return View();
            }
        }
开发者ID:dalinhuang,项目名称:info_platform_i,代码行数:34,代码来源:ContractFinancialController.cs

示例15: Submit

 public ActionResult Submit(FormCollection collection, long[] ids)
 {
     if (ids.Length == 0)
     {
         FlashWarn("请选择要操作的记录。");
         return Close();
     }
     using (var session = new SessionFactory().OpenSession())
     {
         var model = session.Load<TrainNeed>(m => m.Id.In(ids));
         if (model == null)
         {
             FlashInfo("你没有选择任何可以操作的记录。");
             return Close();
         }
         if (!model.Type.Equals(TrainNeedType.部门))
         {
             FlashInfo("只能提交类型为\"部门\"的记录!");
             return Close();
         }
         if (!CanSubmit(model))
         {
             FlashWarn("该记录已经提交。");
             return Close();
         }
         model.UpdatedAt = DateTime.Now;
         model.UpdatedBy = CurrentAccountNo;
         model.Status = TrainNeedStatus.已提交培训部门;
         if (session.Update(model))
         {
             FlashSuccess("提交成功");
             return Close();
         }
         FlashWarn("提交失败,请联系管理员!");
         return View();
     }
 }
开发者ID:dalinhuang,项目名称:info_platform_i,代码行数:37,代码来源:TrainNeedDepartmentController.cs


注:本文中的SessionFactory.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。