コード例 #1
0
ファイル: ProjectBLL.cs プロジェクト: xuxb2008/ProjectManage
        /// <summary>
        /// 项目 新增和修改
        /// Created:20170324(ChengMengjia)
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="no"></param>
        /// <returns></returns>
        public JsonResult SaveProject(string id, string name, string no)
        {
            JsonResult jsonreslut = new JsonResult();

            try
            {
                #region 检查重名
                if (!UniqueName(name))
                {
                    jsonreslut.result = false;
                    jsonreslut.msg    = "项目重名,请更改!";
                    return(jsonreslut);
                }
                #endregion
                Project project = new Project()
                {
                    ID = id, Name = name, No = no
                };
                string _id;
                if (string.IsNullOrEmpty(project.ID))
                {
                    project.ID                = Guid.NewGuid().ToString();
                    project.Status            = 1;
                    project.CREATED           = DateTime.Now;
                    project.ProjectLastUpdate = DateTime.Now;
                    dao.Add(project, null, null, out _id);
                }
                else
                {
                    Project old = new Repository <Project>().Get(id);
                    old.Name = name;
                    old.No   = no;
                    dao.Update(old, out _id);
                }
                jsonreslut.data   = _id;
                jsonreslut.result = true;
                jsonreslut.msg    = "保存成功!";
            }
            catch (Exception ex)
            {
                LogHelper.WriteException(ex, LogType.BussinessDLL);
                jsonreslut.result = false;
                jsonreslut.msg    = ex.Message;
            }
            return(jsonreslut);
        }
コード例 #2
0
ファイル: frmProfile.cs プロジェクト: xiexiaojun/HPMS
        private bool SaveProfile(Project pnProject, bool replace, ref string msg)
        {
            bool ret = false;

            msg = "保存料号档案到数据库成功";
            if (replace)
            {
                ret = ProjectDao.Update(pnProject, ref msg);
            }
            else
            {
                ret = ProjectDao.Add(pnProject, ref msg);
            }



            return(ret);
        }
コード例 #3
0
ファイル: ProjectBLL.cs プロジェクト: franknew/RiskMgr
        public string Save(Project project, List <Asset> assets, List <Customer> buyers, List <Customer> sellers, List <Customer> thirdpart,
                           List <Guarantor> Guarantor, List <CreditReceiverInfo> creditInfo, string userid)
        {
            #region 初始化变量
            ISqlMapper            mapper      = Common.GetMapperFromSession();
            ProjectDao            projectdao  = new ProjectDao(mapper);
            AssetDao              assetdao    = new AssetDao(mapper);
            Asset_ProjectDao      apdao       = new Asset_ProjectDao(mapper);
            Customer_ProjectDao   cpdao       = new Customer_ProjectDao(mapper);
            CustomerDao           customerdao = new CustomerDao(mapper);
            Customer_AssetDao     cadao       = new Customer_AssetDao(mapper);
            CreditReceiverInfoDao cridao      = new CreditReceiverInfoDao(mapper);
            AssetBLL              assetbll    = new AssetBLL();
            CustomerBLL           customerbll = new CustomerBLL();
            #endregion

            #region 处理项目信息
            DateTime createstart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
            DateTime createend   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
            if (string.IsNullOrEmpty(project.Name))
            {
                int index = projectdao.QueryMaxProjectIndex(new ProjectQueryForm {
                    CreateTime_Start = createstart, CreateTime_End = createend
                });
                string code = DateTime.Now.ToString("yyMMdd") + (index + 1).ToString();
                project.Name  = code;
                project.Index = index + 1;
            }
            project.Creator   = project.LastUpdator = userid;
            project.IsDeleted = 0;
            var projecttemp = projectdao.Query(new ProjectQueryForm {
                ID = project.ID
            }).FirstOrDefault();
            if (projecttemp == null)
            {
                projectdao.Add(project);
            }
            else
            {
                projectdao.Update(new ProjectUpdateForm
                {
                    Entity           = project,
                    ProjectQueryForm = new ProjectQueryForm {
                        ID = project.ID
                    },
                });
            }
            cpdao.Delete(new Customer_ProjectQueryForm {
                ProjectID = project.ID
            });
            cadao.Delete(new Customer_AssetQueryForm {
                ProjectID = project.ID
            });
            apdao.Delete(new Asset_ProjectQueryForm {
                ProjectID = project.ID
            });
            #endregion

            #region 处理房产信息
            if (assets != null)
            {
                foreach (var asset in assets)
                {
                    asset.Creator = userid;
                    var a = assetbll.Save(asset);
                    //处理房产和公权人
                    foreach (var j in asset.Joint)
                    {
                        var c = customerbll.Save(new Customer {
                            Creator      = userid,
                            Name         = j.Name,
                            IdentityCode = j.IdentityCode,
                            Phone        = j.Phone,
                        });
                        cadao.Add(new Customer_Asset
                        {
                            AssetID    = a.ID,
                            CustomerID = c.ID,
                            ProjectID  = project.ID,
                            Type       = j.JointType,
                        });
                    }
                    //处理房产和项目关系
                    Asset_Project ap = new Asset_Project
                    {
                        AssetID   = a.ID,
                        ProjectID = project.ID,
                    };
                    apdao.Add(ap);
                }
            }
            #endregion

            #region 处理客户信息
            ProcessCustomer(buyers, customerdao, cpdao, project.ID, userid, CustomerType.Buyer);
            ProcessCustomer(sellers, customerdao, cpdao, project.ID, userid, CustomerType.Seller);
            ProcessCustomer(thirdpart, customerdao, cpdao, project.ID, userid, CustomerType.ThirdParty);
            #endregion

            #region 处理共权人信息
            if (Guarantor != null)
            {
                foreach (Guarantor g in Guarantor)
                {
                    g.Creator = userid;
                    var c = customerbll.Save(g);
                    Customer_Project cp = new Customer_Project
                    {
                        CustomerID = c.ID,
                        ProjectID  = project.ID,
                        Type       = (int)CustomerType.Guarantor,
                    };
                    cpdao.Add(cp);
                    foreach (var asset in g.Assets)
                    {
                        asset.Creator = userid;
                        var            a  = assetbll.Save(asset);
                        Customer_Asset ca = new Customer_Asset
                        {
                            AssetID    = a.ID,
                            CustomerID = c.ID,
                            ProjectID  = project.ID,
                            Type       = (int)CustomerAssetType.Guarantor,
                        };
                        cadao.Add(ca);
                    }
                }
            }
            #endregion

            #region 处理贷款接收账号信息
            cridao.Delete(new CreditReceiverInfoQueryForm {
                ProjectID = project.ID
            });
            if (creditInfo != null)
            {
                foreach (var c in creditInfo)
                {
                    c.ProjectID = project.ID;
                    cridao.Add(c);
                }
            }
            #endregion

            return(project.ID);
        }