Exemple #1
0
        /// <summary>
        /// 将实体信息转换成视图
        /// </summary>
        /// <param name="model">合同实体</param>
        /// <returns></returns>
        public static ContractView EntityToView(Epm_Contract model)
        {
            ContractView view = new ContractView();

            if (model != null)
            {
                view.id              = model.Id;
                view.projectId       = model.ProjectId ?? 0;
                view.projectName     = model.ProjectName ?? "";
                view.code            = model.Code ?? "";
                view.name            = model.Name ?? "";
                view.firstPartyId    = model.FirstPartyId ?? 0;
                view.firstPartyName  = model.FirstPartyName ?? "";
                view.secondPartyId   = model.SecondPartyId ?? 0;
                view.secondPartyName = model.SecondPartyName ?? "";
                view.buildDays       = model.BuildDays ?? 0;
                view.startTime       = string.Format("{0:yyyy-MM-dd}", model.StartTime);
                view.endDate         = string.Format("{0:yyyy-MM-dd}", model.EndTime);
                view.amount          = model.Amount ?? 0;
                view.signTime        = string.Format("{0:yyyy-MM-dd}", model.SignTime);
                view.state           = model.State ?? 0;
                view.remark          = model.Remark ?? "";
                view.createTime      = string.Format("{0:yyyy-MM-dd}", model.CreateTime);
            }
            return(view);
        }
Exemple #2
0
        //[AuthCheck(Module = WebModule.Contract, Right = SystemRight.Modify)]
        public ActionResult Edit(Epm_Contract model)
        {
            ResultView <int> view = new ResultView <int>();

            //合同附件集合
            string            fileDataJson = Request.Form["fileDataJsonFile"];                                 //获取上传文件json字符串
            List <Base_Files> fileList     = JsonConvert.DeserializeObject <List <Base_Files> >(fileDataJson); //将文件信息json字符

            string contractTypeName = Request.Form["ContractTypeName"];

            if (contractTypeName == ContractType.Contract.ToString())
            {
                model.ContractType = 1;
            }
            else if (contractTypeName == ContractType.FrameContract.ToString())
            {
                model.ContractType = 2;
            }

            //表单校验
            if (string.IsNullOrEmpty(model.Name))
            {
                view.Flag    = false;
                view.Message = "名称不能为空";
                return(Json(view));
            }
            if (string.IsNullOrEmpty(model.Code))
            {
                view.Flag    = false;
                view.Message = "编码不能为空";
                return(Json(view));
            }
            Result <int> result = new Result <int>();

            using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(Request)))
            {
                result = proxy.UpdateContract(model, fileList);
            }
            return(Json(result.ToResultView()));
        }
Exemple #3
0
        ///<summary>
        ///添加:
        ///</summary>
        /// <param name="model">要添加的model</param>
        /// <returns>受影响的行数</returns>
        public Result <int> AddContract(Epm_Contract model, List <Base_Files> fileList = null)
        {
            Result <int> result = new Result <int>();

            try
            {
                base.SetCurrentUser(model);
                model.CrtCompanyId   = CurrentCompanyID.ToLongReq();
                model.CrtCompanyName = CurrentCompanyName;
                model.ProjectId      = model.ProjectId ?? 0;

                //bool dConfig = DataOperateBusiness<Epm_Contract>.Get().Count(i => i.Name == model.Name) > 0;
                //if (dConfig)
                //{
                //    throw new Exception("该合同名称已经存在");
                //}
                //dConfig = DataOperateBusiness<Epm_Contract>.Get().Count(i => i.Code == model.Code) > 0;
                //if (dConfig)
                //{
                //    throw new Exception("该合同编码已经存在");
                //}

                var rows = DataOperateBusiness <Epm_Contract> .Get().Add(model);

                //新增附件
                AddFilesByTable(model, fileList);

                result.Data = rows;
                result.Flag = EResultFlag.Success;
                WriteLog(BusinessType.Contract.GetText(), SystemRight.Add.GetText(), "新增: " + model.Id);

                if ((ApprovalState)Enum.ToObject(typeof(ApprovalState), model.State) == ApprovalState.WaitAppr)
                {
                    bool isApprSuccess = false;
                    //判断是否工程处提交,如果是直接通过
                    if (IsAgencyUser(CurrentUserID.ToLongReq()))
                    {
                        isApprSuccess = true;
                        model.State   = (int)ApprovalState.ApprSuccess;
                        DataOperateBusiness <Epm_Contract> .Get().Update(model);
                    }

                    if (!isApprSuccess && model.ProjectId.Value != 0)
                    {
                        #region 生成待办
                        var project = DataOperateBusiness <Epm_Project> .Get().GetModel(model.ProjectId.Value);

                        List <Epm_Approver> list = new List <Epm_Approver>();
                        Epm_Approver        app  = new Epm_Approver();
                        app.Title            = CurrentUserName + "上传了项目合同,待审核";
                        app.Content          = CurrentUserName + "上传了项目合同,待审核";
                        app.SendUserId       = CurrentUserID.ToLongReq();
                        app.SendUserName     = CurrentUserName;
                        app.SendTime         = DateTime.Now;
                        app.LinkURL          = string.Empty;
                        app.BusinessTypeNo   = BusinessType.Contract.ToString();
                        app.Action           = SystemRight.Add.ToString();
                        app.BusinessTypeName = BusinessType.Contract.GetText();
                        app.BusinessState    = (int)(ApprovalState.WaitAppr);
                        app.BusinessId       = model.Id;
                        app.ApproverId       = project.PMId;
                        app.ApproverName     = project.PMName;
                        app.ProjectId        = model.ProjectId;
                        app.ProjectName      = project.Name;
                        list.Add(app);
                        AddApproverBatch(list);
                        WriteLog(BusinessType.Contract.GetText(), SystemRight.Add.GetText(), "提交合同生成待办: " + model.Id);
                        #endregion

                        #region 消息
                        var waitSend = GetWaitSendMessageList(model.ProjectId.Value);
                        foreach (var send in waitSend)
                        {
                            Epm_Massage modelMsg = new Epm_Massage();
                            modelMsg.ReadTime     = null;
                            modelMsg.RecId        = send.Key;
                            modelMsg.RecName      = send.Value;
                            modelMsg.RecTime      = DateTime.Now;
                            modelMsg.SendId       = CurrentUserID.ToLongReq();
                            modelMsg.SendName     = CurrentUserName;
                            modelMsg.SendTime     = DateTime.Now;
                            modelMsg.Title        = CurrentUserName + "上传了项目合同,待审核";
                            modelMsg.Content      = CurrentUserName + "上传了项目合同,待审核";
                            modelMsg.Type         = 2;
                            modelMsg.IsRead       = false;
                            modelMsg.BussinessId  = model.Id;
                            modelMsg.BussinesType = BusinessType.Contract.ToString();
                            modelMsg.ProjectId    = model.ProjectId.Value;
                            modelMsg.ProjectName  = model.ProjectName;
                            modelMsg = base.SetCurrentUser(modelMsg);
                            modelMsg = base.SetCreateUser(modelMsg);
                            DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg);
                        }
                        #endregion

                        #region 发送短信
                        //Dictionary<string, string> parameterSms = new Dictionary<string, string>();
                        //parameterSms.Add("UserName", CurrentUserName);
                        //WriteSMS(project.PMId.Value, 0, MessageStep.ContractAdd, parameterSms);
                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                result.Data      = -1;
                result.Flag      = EResultFlag.Failure;
                result.Exception = new ExceptionEx(ex, "AddContract");
            }
            return(result);
        }