예제 #1
0
        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);
        }
예제 #2
0
        private void ProcessCustomer(List <Customer> customers, CustomerDao customerdao, Customer_ProjectDao cpdao, string projectid, string userid,
                                     CustomerType type)
        {
            if (customers == null || customers.Count == 0)
            {
                return;
            }
            CustomerBLL customerbll = new CustomerBLL();

            foreach (var customer in customers)
            {
                Customer c = null;
                if (string.IsNullOrEmpty(customer.ID))
                {
                    customer.IsDeleted = 0;
                    customer.Enabled   = 1;
                    customer.Creator   = userid;
                    customerdao.Add(customer);
                    c = customer;
                }
                else
                {
                    c = customerdao.Query(new CustomerQueryForm {
                        ID = customer.ID
                    }).FirstOrDefault();
                    if (c == null)
                    {
                        customer.IsDeleted = 0;
                        customer.Enabled   = 1;
                        customer.Creator   = userid;
                        customerdao.Add(customer);
                        c = customer;
                    }
                    else
                    {
                        customerdao.Update(new CustomerUpdateForm
                        {
                            Entity = new Customer
                            {
                                Name                = customer.Name,
                                IdentityCode        = customer.IdentityCode,
                                CardType            = customer.CardType,
                                Phone               = customer.Phone,
                                Gender              = customer.Gender,
                                Marrage             = customer.Marrage,
                                Address             = customer.Address,
                                OrignalName         = customer.OrignalName,
                                OrignalIdentityCode = customer.OrignalIdentityCode,
                                BankCode            = customer.BankCode,
                                BankType            = customer.BankType,
                                WorkUnit            = customer.WorkUnit,
                                Remark              = customer.Remark,
                            },
                            CustomerQueryForm = new CustomerQueryForm {
                                ID = customer.ID
                            }
                        });
                    }
                }
                cpdao.Add(new Customer_Project {
                    CustomerID = c.ID, ProjectID = projectid, Type = (int)type
                });
            }
        }
예제 #3
0
파일: Index.cs 프로젝트: franknew/RiskMgr
 private void button16_Click(object sender, EventArgs e)
 {
     Workflow workflow = new Workflow();
     RoleBLL rolebll = new RoleBLL();
     CustomerBLL customerbll = new CustomerBLL();
     List<string> ids = rolebll.GetUserSubUserIDs("13");
     CustomerQueryForm form = new CustomerQueryForm();
     form.Creators = ids;
     var list = customerbll.Query(form);
     PagingEntity<Customer> paggingList = new PagingEntity<Customer>();
     paggingList.Record = list;
     paggingList.PageCount = form.PageCount;
     paggingList.RecordCount = form.RecordCount;
 }