/// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, Client_ChanceDescriptionEntity entity)
 {
     try
     {
         service.SaveForm(keyValue, entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
 public ActionResult SaveForm(string keyValue, Client_ChanceDescriptionEntity entity)
 {
     client_Chancedescriptionbll.SaveForm(keyValue, entity);
     return(Success("操作成功。"));
 }
Esempio n. 3
0
        public void SaveFormApi(string keyValue, ChanceEntity entity, string userid, string username)
        {
            ICodeRuleService service = new CodeRuleService();
            IRepository      db      = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    if (GetEntity(keyValue).Description != entity.Description && !string.IsNullOrEmpty(entity.Description))
                    {//备注和之前不同时,插入备注列表
                        Client_ChanceDescriptionEntity chanceDescriptionEntity = new Client_ChanceDescriptionEntity();

                        chanceDescriptionEntity.CreateDate         = DateTime.Now;
                        chanceDescriptionEntity.CreateUserId       = userid;
                        chanceDescriptionEntity.CreateUserName     = username;
                        chanceDescriptionEntity.DescriptionId      = Guid.NewGuid().ToString();
                        chanceDescriptionEntity.OrderId            = keyValue;
                        chanceDescriptionEntity.DescriptionContent = entity.Description;
                        db.Insert(chanceDescriptionEntity);
                    }

                    // entity.Modify(keyValue);
                    entity.ChanceId       = keyValue;
                    entity.ModifyDate     = DateTime.Now;
                    entity.ModifyUserId   = userid;
                    entity.ModifyUserName = username;
                    entity.CustTypeName   = entity.CustTypeId;
                    this.BaseRepository().Update(entity);
                }
                else
                {
                    entity.EnCode         = service.SetBillCodeApi(userid, "", ((int)(CodeRuleEnum.Customer_ChanceCode)).ToString());
                    entity.FullName       = entity.EnCode;
                    entity.ChanceId       = Guid.NewGuid().ToString();
                    entity.CreateDate     = DateTime.Now;
                    entity.CreateUserId   = userid;
                    entity.CreateUserName = username;
                    entity.CustTypeName   = entity.CustTypeId;

                    db.Insert(entity);
                    //占用单据号
                    coderuleService.UseRuleSeed(entity.CreateUserId, "", ((int)(CodeRuleEnum.Customer_ChanceCode)).ToString(), db);

                    if (!string.IsNullOrEmpty(entity.Description))
                    {
                        Client_ChanceDescriptionEntity chanceDescriptionEntity = new Client_ChanceDescriptionEntity();

                        chanceDescriptionEntity.CreateDate         = DateTime.Now;
                        chanceDescriptionEntity.CreateUserId       = userid;
                        chanceDescriptionEntity.CreateUserName     = username;
                        chanceDescriptionEntity.DescriptionId      = Guid.NewGuid().ToString();
                        chanceDescriptionEntity.OrderId            = entity.ChanceId;
                        chanceDescriptionEntity.DescriptionContent = entity.Description;
                        db.Insert(chanceDescriptionEntity);
                    }
                }

                ////IRepository dbc = null;
                //////dbc = new RepositoryFactory().BaseRepository() ;

                //if (Convert.ToString(entity.IsToCustom) == "1")
                //{
                //    CustomerService customerService = new CustomerService();

                //    if (customerService.GetEntityByCondation(entity.CompanyName, entity.Mobile).Count() == 0)
                //    {
                //        CustomerEntity customerEntity = new CustomerEntity();

                //        customerEntity.CreateUserId = Guid.NewGuid().ToString();
                //        customerEntity.CreateDate = DateTime.Now;
                //        customerEntity.CreateUserId = entity.CreateUserId;
                //        customerEntity.CreateUserName = entity.CreateUserName;

                //        // customerEntity.EnCode = coderuleService.SetBillCodeApi(customerEntity.CreateUserId, "", ((int)CodeRuleEnum.Customer_CustomerCode).ToString(), db);
                //        customerEntity.FullName = entity.CompanyName;
                //        customerEntity.TraceUserId = entity.TraceUserId;
                //        customerEntity.TraceUserName = entity.TraceUserName;
                //        customerEntity.CustIndustryId = entity.CompanyNatureId;
                //        //customerEntity.CompanySite = entity.CompanySite;
                //        //customerEntity.CompanyDesc = entity.CompanyDesc;
                //        customerEntity.CompanyAddress = entity.CompanyAddress;
                //        //customerEntity.Province = entity.Province;
                //        //customerEntity.City = entity.City;
                //        //customerEntity.Contact = entity.Contacts;
                //        customerEntity.Mobile = entity.Mobile;
                //        customerEntity.Tel = entity.Mobile;
                //        //customerEntity.Fax = entity.Fax;
                //        //customerEntity.QQ = entity.QQ;
                //        //customerEntity.Email = entity.Email;
                //        customerEntity.Wechat = entity.Wechat;
                //        //customerEntity.Hobby = entity.Hobby;
                //        customerEntity.Description = entity.Description;
                //        customerEntity.CustLevelId = "C";
                //        customerEntity.CustDegreeId = "往来客户";

                //        customerService.SaveFormApi("", customerEntity);
                //    }
                //}



                db.Commit();

                if (Convert.ToString(entity.IsToCustom) == "1")
                {
                    CustomerService customerService = new CustomerService();

                    if (customerService.GetEntityByCondation(entity.CompanyName, entity.Mobile).Count() == 0)
                    {
                        ToCustomerApi(entity.ChanceId);
                    }
                }
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }