예제 #1
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, ProjecttoolsEntity entity)
 {
     entity.PROJECTTOOLSID = keyValue;
     if (!string.IsNullOrEmpty(keyValue))
     {
         ProjecttoolsEntity se = this.BaseRepository().FindEntity(keyValue);
         if (se == null)
         {
             //设备类型编码配置未配置对应专业则不需要验收
             DataItemModel model = dataitemdetailservice.GetDataItemByDetailValue("ToolEquipmentType", entity.TOOLTYPE).FirstOrDefault();
             entity.Status = string.IsNullOrWhiteSpace(model.Description) ? "0" : "";
             entity.Create();
             this.BaseRepository().Insert(entity);
         }
         else
         {
             entity.Modify(keyValue);
             this.BaseRepository().Update(entity);
         }
     }
     else
     {
         //设备类型编码配置未配置对应专业则不需要验收
         DataItemModel model = dataitemdetailservice.GetDataItemByDetailValue("ToolEquipmentType", entity.TOOLTYPE).FirstOrDefault();
         entity.Status = string.IsNullOrWhiteSpace(model.Description) ? "" : "0";
         entity.Create();
         this.BaseRepository().Insert(entity);
     }
 }
예제 #2
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveForm(string keyValue, string type, ToolsEntity entity)
        {
            Operator curUser = ERCHTMS.Code.OperatorProvider.Provider.Current();
            var      res     = DbFactory.Base().BeginTrans();

            try
            {
                List <ProjecttoolsEntity> list   = ProjecttoolsService.GetList(" and TOOLSID='" + keyValue + "'").ToList();
                List <string>             zylist = new List <string>();
                string zystr = "";
                foreach (var item in list.Select(t => t.TOOLTYPE).ToArray().Distinct().ToList())
                {
                    zylist = zylist.AsEnumerable().Union(DataItemDetailService.GetDataItemByDetailValue("ToolEquipmentType", item).FirstOrDefault().Description.Split(',')).ToList();
                }
                zystr = string.Join(",", zylist.Distinct().ToList());
                entity.SpecialtyType = zystr;
                #region 保存
                if (type == "1")          //保存
                {
                    entity.ISSAVED = "0"; //标记当前记录处于登记阶段
                    entity.ISOVER  = "0"; //流程未完成,1表示完成
                    entity.TOOLSID = keyValue;
                    if (!string.IsNullOrEmpty(keyValue))
                    {
                        ToolsEntity se = this.BaseRepository().FindEntity(keyValue);
                        if (se == null)
                        {
                            entity.Create();
                            res.Insert <ToolsEntity>(entity);
                        }
                        else
                        {
                            entity.Modify(keyValue);
                            res.Update <ToolsEntity>(entity);
                        }
                    }
                    else
                    {
                        entity.Create();
                        res.Insert <ToolsEntity>(entity);
                    }
                }
                #endregion
                #region 提交
                if (type == "2")//提交
                {
                    string state         = string.Empty;
                    string moduleName    = entity.EQUIPTYPE == "2" ? "特种设备工器具" : "设备工器具";
                    string outengineerid = entity.OUTENGINEERID;
                    Repository <OutsouringengineerEntity> ourEngineer = new Repository <OutsouringengineerEntity>(DbFactory.Base());
                    OutsouringengineerEntity engineerEntity           = ourEngineer.FindEntity(entity.OUTENGINEERID);
                    //currUser:当前登录人,state:是否有权限审核 1:能审核 0 :不能审核,moduleName:模块名称,outengineerid:工程Id
                    ManyPowerCheckEntity mpcEntity = peopleReview.CheckAuditPower(curUser, out state, moduleName, outengineerid, false);
                    if (null != mpcEntity)
                    {
                        //保存设备工器具记录
                        entity.FLOWDEPT     = mpcEntity.CHECKDEPTID;
                        entity.FLOWDEPTNAME = mpcEntity.CHECKDEPTNAME;
                        entity.FLOWROLE     = mpcEntity.CHECKROLEID;
                        entity.FLOWROLENAME = mpcEntity.CHECKROLENAME;
                        entity.ISSAVED      = "1"; //标记已经从登记到审核阶段
                        entity.ISOVER       = "0"; //流程未完成,1表示完成
                        entity.FlowId       = mpcEntity.ID;
                        entity.FLOWNAME     = mpcEntity.FLOWNAME;
                    }
                    else  //为空则表示已经完成流程
                    {
                        entity.FLOWDEPT     = "";
                        entity.FLOWDEPTNAME = "";
                        entity.FLOWROLE     = "";
                        entity.FLOWROLENAME = "";
                        entity.ISSAVED      = "1"; //标记已经从登记到审核阶段
                        entity.ISOVER       = "1"; //流程未完成,1表示完成
                        entity.FLOWNAME     = "";
                        entity.FlowId       = "";
                        #region 更新工程流程状态
                        Repository <StartappprocessstatusEntity> proecss = new Repository <StartappprocessstatusEntity>(DbFactory.Base());
                        StartappprocessstatusEntity startProecss         = proecss.FindList(string.Format("select * from epg_startappprocessstatus t where t.outengineerid='{0}'", entity.OUTENGINEERID)).ToList().FirstOrDefault();
                        startProecss.EQUIPMENTTOOLSTATUS = "1";
                        res.Update <StartappprocessstatusEntity>(startProecss);
                        #endregion
                        #region  步设备
                        if (entity.EQUIPTYPE == "2")
                        {
                            new SpecialEquipmentService().SyncSpecificTools(entity.OUTENGINEERID, entity.OUTPROJECTID, entity.TOOLSID);
                        }
                        #endregion
                    }
                    entity.TOOLSID = keyValue;
                    if (!string.IsNullOrEmpty(keyValue))
                    {
                        ToolsEntity se = this.BaseRepository().FindEntity(keyValue);
                        if (se == null)
                        {
                            entity.Create();
                            res.Insert <ToolsEntity>(entity);
                        }
                        else
                        {
                            entity.Modify(keyValue);
                            res.Update <ToolsEntity>(entity);
                        }
                    }
                    else
                    {
                        entity.Create();
                        res.Insert <ToolsEntity>(entity);
                    }
                }
                #endregion
                res.Commit();
            }
            catch (Exception ex)
            {
                res.Rollback();
                throw ex;
            }
        }