示例#1
0
 /// <summary>
 /// 批量插入电话
 /// </summary>
 /// <param name="custId"></param>
 /// <param name="tels"></param>
 public void Insert(string custId, string tels)
 {
     string[] telArry = tels.Split(',');
     foreach (string tel in telArry)
     {
         Entities.CustTel model = new Entities.CustTel();
         model.CreateTime   = DateTime.Now;
         model.CreateUserID = BLL.Util.GetLoginUserID();
         model.CustID       = custId;
         model.Tel          = tel;
         BLL.CustTel.Instance.Insert(model);
     }
 }
示例#2
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public int Update(Entities.CustTel model)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@CustID",       SqlDbType.VarChar,   20),
                new SqlParameter("@Tel",          SqlDbType.VarChar,   20),
                new SqlParameter("@CreateTime",   SqlDbType.DateTime),
                new SqlParameter("@CreateUserID", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.CustID;
            parameters[1].Value = model.Tel;
            parameters[2].Value = model.CreateTime;
            parameters[3].Value = model.CreateUserID;

            return(SqlHelper.ExecuteNonQuery(CONNECTIONSTRINGS, CommandType.StoredProcedure, P_CUSTTEL_UPDATE, parameters));
        }
示例#3
0
        public void Insert(SqlTransaction sqltran, Entities.CustTel model)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@CustID",       SqlDbType.VarChar,   20),
                new SqlParameter("@Tel",          SqlDbType.VarChar,   20),
                new SqlParameter("@CreateTime",   SqlDbType.DateTime),
                new SqlParameter("@CreateUserID", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.CustID;
            parameters[1].Value = model.Tel;
            parameters[2].Value = model.CreateTime;
            parameters[3].Value = model.CreateUserID;

            SqlHelper.ExecuteNonQuery(sqltran, CommandType.StoredProcedure, P_CUSTTEL_INSERT, parameters);
        }
示例#4
0
        private Entities.CustTel LoadSingleCustTel(DataRow row)
        {
            Entities.CustTel model = new Entities.CustTel();

            model.CustID = row["CustID"].ToString();
            model.Tel    = row["Tel"].ToString();
            if (row["CreateTime"].ToString() != "")
            {
                model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
            }
            if (row["CreateUserID"].ToString() != "")
            {
                model.CreateUserID = int.Parse(row["CreateUserID"].ToString());
            }
            return(model);
        }
示例#5
0
        /// <summary>
        /// 在个人基本信息表中添加一个个人信息
        /// </summary>
        /// <param name="groupordermodel"></param>
        /// <returns></returns>
        private string AddNewCustBaseInfo(Entities.GroupOrder groupordermodel)
        {
            string CustID = "";

            #region 插入客户池
            Entities.CustBasicInfo newcustmodel = new Entities.CustBasicInfo();
            newcustmodel.Status         = 0;
            newcustmodel.Sex            = groupordermodel.UserGender;
            newcustmodel.CustName       = groupordermodel.CustomerName;
            newcustmodel.CustCategoryID = 4;
            newcustmodel.ProvinceID     = groupordermodel.ProvinceID;
            newcustmodel.CityID         = groupordermodel.CityID;
            newcustmodel.AreaID         = groupordermodel.AreaID;
            newcustmodel.CreateTime     = System.DateTime.Now;
            newcustmodel.CreateUserID   = userId;
            //功能废弃 插入客户基本信息 废弃
            CustID = null;// BLL.CustBasicInfo.Instance.Insert(newcustmodel);
            Entities.CustTel custtelmodel = new Entities.CustTel();
            custtelmodel.CreateTime   = System.DateTime.Now;
            custtelmodel.CreateUserID = userId;
            custtelmodel.CustID       = CustID;
            custtelmodel.Tel          = groupordermodel.CustomerTel;
            //插入电话
            BLL.CustTel.Instance.Insert(custtelmodel);
            //插入bugcarinfo
            Entities.BuyCarInfo bugcarmodel = new Entities.BuyCarInfo();
            bugcarmodel.CustID       = CustID;
            bugcarmodel.Type         = 4;
            bugcarmodel.CarBrandId   = 0;
            bugcarmodel.CarSerialId  = 0;
            bugcarmodel.CarTypeID    = 0;
            bugcarmodel.Status       = 0;
            bugcarmodel.CreateTime   = System.DateTime.Now;
            bugcarmodel.CreateUserID = userId;
            bugcarmodel.UserName     = RequestQCTUserName;
            BLL.BuyCarInfo.Instance.Insert(bugcarmodel);
            #endregion
            return(CustID);
        }
示例#6
0
        /// <summary>
        /// ordertype 1是保存,2是提交
        /// </summary>
        /// <param name="ordertype"></param>
        public void DealOrder(int ordertype, out string msg)
        {
            msg = "";
            long taskid = 0;

            if (long.TryParse(RequestTaskID, out taskid))
            {
                Entities.GroupOrderTask model = BLL.GroupOrderTask.Instance.GetGroupOrderTask(taskid);
                if (model != null)
                {
                    if (model.TaskStatus != (int)Entities.GroupTaskStatus.NoAllocation && model.TaskStatus != (int)Entities.GroupTaskStatus.Processing && model.TaskStatus != (int)Entities.GroupTaskStatus.NoProcess)
                    {
                        //msg = "{\"Result\":false,\"Msg\":\"任务ID"+ taskid +"不处于处理状态\"}";
                        string s = "";
                        s   = BitAuto.ISDC.CC2012.BLL.Util.GetEnumOptText(typeof(BitAuto.ISDC.CC2012.Entities.GroupTaskStatus), Convert.ToInt32(model.TaskStatus));
                        msg = "任务状态为:" + s + ",不处于处理状态";
                    }
                    else
                    {
                        //本地保存订单信息,修改订单状态
                        Entities.GroupOrder groupordermodel = BLL.GroupOrder.Instance.GetGroupOrder(taskid);
                        if (groupordermodel != null)
                        {
                            #region 保存或提交订单信息,修改任务状态,插入任务操作状态
                            //保存
                            if (ordertype == 1)
                            {
                                model.LastUpdateTime   = System.DateTime.Now;
                                model.LastUpdateUserID = userId;
                                model.TaskStatus       = (int)Entities.GroupTaskStatus.Processing;
                            }
                            //提交
                            else if (ordertype == 2)
                            {
                                model.LastUpdateTime   = System.DateTime.Now;
                                model.LastUpdateUserID = userId;

                                //如果 是否为回访值为:是,则更新任务状态,调回写接口
                                //否则 不更新,也不调回写接口
                                if (this.RequestIsReturnVisit == ((int)Entities.IsReturnVisit.Yes).ToString())
                                {
                                    model.TaskStatus = (int)Entities.GroupTaskStatus.Processed;
                                }

                                model.SubmitTime = System.DateTime.Now;
                            }
                            int IsReturnVisit = 0;
                            if (int.TryParse(RequestIsReturnVisit, out IsReturnVisit))
                            {
                                groupordermodel.IsReturnVisit = IsReturnVisit;
                            }

                            groupordermodel.LastUpdateTime   = System.DateTime.Now;
                            groupordermodel.LastUpdateUserID = userId;

                            //更新任务状态
                            BLL.GroupOrderTask.Instance.Update(model);
                            //对于保存不用匹配客户池客户所以在此处更新订单信息,提交要在匹配客户池客户后拿到custid后更新
                            //处理结果为:否的,不提交,所以在些更新订单
                            //if (ordertype == 1)
                            if (this.RequestIsReturnVisit == ((int)Entities.IsReturnVisit.No).ToString())
                            {
                                BLL.GroupOrder.Instance.Update(groupordermodel);
                            }
                            //插入或合并任务操作日志
                            //如果 是否为回访值为:是,则更新任务状态,调回写接口
                            //否则 不更新,也不调回写接口
                            if (this.RequestIsReturnVisit == ((int)Entities.IsReturnVisit.Yes).ToString())
                            {
                                DealLog(ordertype);
                            }
                            #endregion

                            //如果 是否为回访值为:是,则更新任务状态,调回写接口
                            //否则 不更新,也不调回写接口
                            #region 提交处理
                            if (ordertype == 2 && this.RequestIsReturnVisit == ((int)Entities.IsReturnVisit.Yes).ToString())
                            {
                                if (!string.IsNullOrEmpty(groupordermodel.CustomerTel))
                                {
                                    #region 根据电话号码判断 客户池是否存在,存在不更新客户,不存在插入
                                    string CustID = string.Empty;
                                    //根据电话找客户,如果有多个去匹配那个名称一致的
                                    DataTable dtcust = BLL.CustBasicInfo.Instance.GetCustBasicInfosByTel(groupordermodel.CustomerTel);
                                    if (dtcust != null && dtcust.Rows.Count > 0)
                                    {
                                        for (int i = 0; i < dtcust.Rows.Count; i++)
                                        {
                                            if (dtcust.Rows[i]["CustName"].ToString() == groupordermodel.CustomerName)
                                            {
                                                CustID = dtcust.Rows[i]["CustID"].ToString();
                                                break;
                                            }
                                        }
                                    }
                                    //如果CustID不为空说明找到了,否则没找到
                                    if (!string.IsNullOrEmpty(CustID))
                                    {
                                    }
                                    else
                                    {
                                        #region 插入客户池
                                        Entities.CustBasicInfo newcustmodel = new Entities.CustBasicInfo();
                                        newcustmodel.Status         = 0;
                                        newcustmodel.Sex            = groupordermodel.UserGender;
                                        newcustmodel.CustName       = groupordermodel.CustomerName;
                                        newcustmodel.CustCategoryID = 4;
                                        newcustmodel.ProvinceID     = groupordermodel.ProvinceID;
                                        newcustmodel.CityID         = groupordermodel.CityID;
                                        newcustmodel.AreaID         = groupordermodel.AreaID;
                                        newcustmodel.CreateTime     = System.DateTime.Now;
                                        newcustmodel.CreateUserID   = userId;
                                        //功能废弃 插入客户基本信息
                                        CustID = null;// BLL.CustBasicInfo.Instance.Insert(newcustmodel);
                                        Entities.CustTel custtelmodel = new Entities.CustTel();
                                        custtelmodel.CreateTime   = System.DateTime.Now;
                                        custtelmodel.CreateUserID = userId;
                                        custtelmodel.CustID       = CustID;
                                        custtelmodel.Tel          = groupordermodel.CustomerTel;
                                        //插入电话
                                        BLL.CustTel.Instance.Insert(custtelmodel);
                                        //插入bugcarinfo
                                        Entities.BuyCarInfo bugcarmodel = new Entities.BuyCarInfo();
                                        bugcarmodel.CustID       = CustID;
                                        bugcarmodel.Type         = 4;
                                        bugcarmodel.CarBrandId   = 0;
                                        bugcarmodel.CarSerialId  = 0;
                                        bugcarmodel.CarTypeID    = 0;
                                        bugcarmodel.Status       = 0;
                                        bugcarmodel.CreateTime   = System.DateTime.Now;
                                        bugcarmodel.CreateUserID = userId;
                                        //bugcarmodel.UserName = RequestQCTUserName;
                                        BLL.BuyCarInfo.Instance.Insert(bugcarmodel);
                                        #endregion
                                    }
                                    #endregion

                                    #region 提交要匹配客户池客户所以在匹配客户池客户后拿到custid后更新订单
                                    groupordermodel.CustID = CustID;
                                    BLL.GroupOrder.Instance.Update(groupordermodel);
                                    #endregion

                                    #region 在客户历史记录里加入团购订单联系记录
                                    Entities.CustHistoryInfo custhistroyinfomodel = new Entities.CustHistoryInfo();
                                    custhistroyinfomodel.TaskID = RequestTaskID;
                                    //业务类型,2为团购订单
                                    custhistroyinfomodel.BusinessType = 2;
                                    //录音
                                    //if (!string.IsNullOrEmpty(RequestCallRecordID))
                                    //{
                                    //    long callrecordid = 0;
                                    //    if (long.TryParse(RequestCallRecordID, out callrecordid))
                                    //    {
                                    //        custhistroyinfomodel.CallRecordID = callrecordid;

                                    //    }
                                    //}
                                    //呼出
                                    custhistroyinfomodel.RecordType   = 2;
                                    custhistroyinfomodel.CustID       = CustID;
                                    custhistroyinfomodel.CreateTime   = System.DateTime.Now;
                                    custhistroyinfomodel.CreateUserID = userId;
                                    //功能废弃
                                    BLL.CustHistoryInfo.Instance.Insert(custhistroyinfomodel);
                                    #endregion

                                    #region 回写易湃
                                    ReWriteOrderData(taskid);
                                    #endregion
                                }
                            }
                            #endregion
                        }
                        else
                        {
                            //msg = "{\"Result\":false,\"Msg\":\"任务ID" + taskid + "对应订单不存在!\"}";
                            msg = "对应订单不存在!";
                        }
                    }
                }
                else
                {
                    //msg = "{\"Result\":false,\"Msg\":\"任务ID" + taskid + "不存在!\"}";
                    msg = "任务ID不存在";
                }
            }
        }
        /// <summary>
        /// 校验
        /// </summary>
        private bool Valid(int rowNum, IDataReader reader, out StringBuilder ex, int userid, out StringBuilder exportstr)
        {
            ex        = new StringBuilder();
            exportstr = new StringBuilder();

            string UserName = string.Empty;

            UserName = reader[0].ToString().Trim();

            string Sex = string.Empty;

            Sex = reader[1].ToString().Trim();

            string Tel1 = string.Empty;

            Tel1 = reader[2].ToString().Trim();

            string CustCategory = string.Empty;

            CustCategory = reader[3].ToString().Trim();

            string Tel2 = string.Empty;

            Tel2 = reader[4].ToString().Trim();

            string Email = string.Empty;

            Email = reader[5].ToString().Trim();

            string Province = string.Empty;

            Province = reader[6].ToString().Trim();

            string City = string.Empty;

            City = reader[7].ToString().Trim();

            string County = string.Empty;

            County = reader[8].ToString().Trim();

            string Address = string.Empty;

            Address = reader[9].ToString().Trim();

            string DataSource = string.Empty;

            DataSource = reader[10].ToString().Trim();
            //咨询类型
            string EnquiryType = string.Empty;

            EnquiryType = reader[11].ToString().Trim();


            string Brand = string.Empty;

            Brand = reader[12].ToString().Trim();

            string Models = string.Empty;

            Models = reader[13].ToString().Trim();

            //推荐经销商名称
            string DealerName = string.Empty;

            DealerName = reader[14].ToString().Trim();

            //来电记录
            string PhoneRecord = string.Empty;

            PhoneRecord = reader[15].ToString().Trim();

            bool insertflag = true;



            //会员ID号验证
            if (string.IsNullOrEmpty(UserName) || UserName.Length == 0)
            {
                ex.Append("[姓名]不可为空。");
                insertflag = false;
            }
            else
            {
                if (BLL.Util.GetLength(UserName) > 50)
                {
                    ex.Append("[姓名]超长。");
                    insertflag = false;
                }
            }
            if (string.IsNullOrEmpty(Sex) || Sex.Length == 0)
            {
                ex.Append("[性别]不可为空。");
                insertflag = false;
            }
            else
            {
                if (Sex != "男" && Sex != "女")
                {
                    ex.Append("[性别]输入错误。");
                    insertflag = false;
                }
            }
            if (string.IsNullOrEmpty(Tel1) || Tel1.Length == 0)
            {
                ex.Append("[电话1]不可为空。");
                insertflag = false;
            }
            else
            {
                if (BLL.Util.IsTelephone(Tel1) == false && BLL.Util.IsHandset(Tel1) == false)
                {
                    ex.Append("[电话]输入错误。");
                    insertflag = false;
                }
            }

            if (string.IsNullOrEmpty(CustCategory) || CustCategory.Length == 0)
            {
                ex.Append("[客户分类]不可为空。");
                insertflag = false;
            }
            else
            {
                if (CustCategory != "已购车" && CustCategory != "未购车" && CustCategory != "经销商")
                {
                    ex.Append("[客户分类]输入错误。");
                    insertflag = false;
                }
            }
            if (!string.IsNullOrEmpty(Tel2))
            {
                if (BLL.Util.IsTelephone(Tel2) == false && BLL.Util.IsHandset(Tel2) == false)
                {
                    ex.Append("[电话2]输入错误。");
                    insertflag = false;
                }
            }
            if (!string.IsNullOrEmpty(Email))
            {
                if (BLL.Util.IsEmail(Email) == false)
                {
                    ex.Append("[邮箱]输入错误。");
                    insertflag = false;
                }
            }
            if (!string.IsNullOrEmpty(Address))
            {
                if (BLL.Util.GetLength(Address) > 200)
                {
                    ex.Append("[地址]超长。");
                    insertflag = false;
                }
            }

            if (!string.IsNullOrEmpty(DataSource))
            {
                if (DataSource != "呼叫中心" && DataSource != "在线" && DataSource != "汽车通" && DataSource != "车易通")
                {
                    ex.Append("[数据来源]输入错误。");
                    insertflag = false;
                }
            }

            if (!string.IsNullOrEmpty(EnquiryType))
            {
                if (EnquiryType != "新车" && EnquiryType != "二手车" && EnquiryType != "个人反馈" && EnquiryType != "活动" && EnquiryType != "个人用车" && EnquiryType != "个人其他" && EnquiryType != "经销商合作" && EnquiryType != "经销商反馈" && EnquiryType != "经销商其他")
                {
                    ex.Append("[咨询类型]输入错误。");
                    insertflag = false;
                }
            }
            if (!string.IsNullOrEmpty(DealerName))
            {
                if (BLL.Util.GetLength(DealerName) > 200)
                {
                    ex.Append("[推荐经销商]超长。");
                    insertflag = false;
                }
            }
            if (!string.IsNullOrEmpty(PhoneRecord))
            {
                if (BLL.Util.GetLength(PhoneRecord) > 2000)
                {
                    ex.Append("[来电记录]超长。");
                    insertflag = false;
                }
            }
            string provinceID = "0";

            //验证省份城市
            if (!string.IsNullOrEmpty(Province))
            {
                provinceID = BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaIdByName(Province, 1);
                if (provinceID == "0")
                {
                    ex.Append("[地区(省)]输入错误。");
                    insertflag = false;
                }
            }
            string CityID = "0";

            //验证省份城市
            if (!string.IsNullOrEmpty(City))
            {
                CityID = BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaIdByName(City, 2);
                if (CityID == "0")
                {
                    ex.Append("[地区(市)]输入错误。");
                    insertflag = false;
                }
            }
            string CountryID = "0";

            //验证区县
            if (!string.IsNullOrEmpty(County))
            {
                CountryID = BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaIdByName(County, 3);
                if (CountryID == "0")
                {
                    ex.Append("[地区(区县)]输入错误。");
                    insertflag = false;
                }
            }
            //验证车型
            string BrandID = "0";

            if (!string.IsNullOrEmpty(Brand))
            {
                DataTable dt = BLL.BuyCarInfo.Instance.GetCarBrandByName(Brand);
                if (dt != null && dt.Rows.Count > 0)
                {
                    BrandID = dt.Rows[0]["Brandid"].ToString();
                }
                else
                {
                    ex.Append("[品牌]输入错误。");
                    insertflag = false;
                }
            }

            //验证车系
            string CarModelsID = "0";

            if (!string.IsNullOrEmpty(Models))
            {
                DataTable dt = BLL.BuyCarInfo.Instance.GetCarSerialByName(Models);
                if (dt != null && dt.Rows.Count > 0)
                {
                    CarModelsID = dt.Rows[0]["serialid"].ToString();
                }
                else
                {
                    ex.Append("[车系]输入错误。");
                    insertflag = false;
                }
            }

            //如果验证通过,插入
            if (insertflag)
            {
                bool flag = false;
                flag = BLL.CustBasicInfo.Instance.IsExistsByCustNameAndTel(UserName, Tel1);

                if (flag)
                {
                    ex.Append("记录[姓名],[电话1]已存在。");
                    insertflag = false;
                }
                else
                {
                    Entities.CustBasicInfo CustBasicInfoModel = new Entities.CustBasicInfo();
                    CustBasicInfoModel.Status       = 0;
                    CustBasicInfoModel.CustName     = UserName;
                    CustBasicInfoModel.Sex          = (Sex == "男" ? 1 : 2);
                    CustBasicInfoModel.CreateTime   = System.DateTime.Now;
                    CustBasicInfoModel.CreateUserID = userid;
                    if (CustCategory == "已购车")
                    {
                        CustBasicInfoModel.CustCategoryID = 1;
                    }
                    else if (CustCategory == "未购车")
                    {
                        CustBasicInfoModel.CustCategoryID = 2;
                    }
                    else
                    {
                        CustBasicInfoModel.CustCategoryID = 3;
                    }
                    if (provinceID != "0")
                    {
                        CustBasicInfoModel.ProvinceID = Convert.ToInt32(provinceID);
                    }
                    if (CityID != "0")
                    {
                        CustBasicInfoModel.CityID = Convert.ToInt32(CityID);
                    }
                    if (CountryID != "0")
                    {
                        CustBasicInfoModel.CountyID = Convert.ToInt32(CountryID);
                    }

                    if (!string.IsNullOrEmpty(Address))
                    {
                        CustBasicInfoModel.Address = Address;
                    }

                    if (!string.IsNullOrEmpty(DataSource))
                    {
                        if (DataSource == "呼叫中心")
                        {
                            CustBasicInfoModel.DataSource = 180001;
                        }
                        else if (DataSource == "在线")
                        {
                            CustBasicInfoModel.DataSource = 180002;
                        }
                        else if (DataSource == "汽车通")
                        {
                            CustBasicInfoModel.DataSource = 180003;
                        }
                        else if (DataSource == "车易通")
                        {
                            CustBasicInfoModel.DataSource = 180004;
                        }
                    }
                    string CustID = string.Empty;
                    int    rerVal = 0;
                    //客户历史记录信息主键
                    int custhistoryVal = 0;
                    try
                    {
                        //功能废弃
                        CustID = null;// BLL.CustBasicInfo.Instance.Insert(CustBasicInfoModel);
                        Entities.CustTel custTel1 = new Entities.CustTel();
                        //电话去掉‘-’

                        if (Tel1.IndexOf('-') > 0)
                        {
                            custTel1.Tel = Tel1.Remove(Tel1.IndexOf('-'), 1);
                        }
                        else
                        {
                            custTel1.Tel = Tel1;
                        }


                        custTel1.CustID       = CustID;
                        custTel1.CreateTime   = System.DateTime.Now;
                        custTel1.CreateUserID = userid;
                        BLL.CustTel.Instance.Insert(custTel1);
                        Entities.CustTel custTel2 = null;
                        if (!string.IsNullOrEmpty(Tel2))
                        {
                            custTel2 = new Entities.CustTel();
                            if (Tel2.IndexOf('-') > 0)
                            {
                                custTel2.Tel = Tel2.Remove(Tel2.IndexOf('-'), 1);
                            }
                            else
                            {
                                custTel2.Tel = Tel2;
                            }
                            custTel2.CustID       = CustID;
                            custTel2.CreateTime   = System.DateTime.Now;
                            custTel2.CreateUserID = userid;
                            BLL.CustTel.Instance.Insert(custTel2);
                        }
                        Entities.CustEmail custemail = null;
                        if (!string.IsNullOrEmpty(Email))
                        {
                            custemail              = new Entities.CustEmail();
                            custemail.Email        = Email;
                            custemail.CustID       = CustID;
                            custemail.CreateTime   = System.DateTime.Now;
                            custemail.CreateUserID = userid;
                            BLL.CustEmail.Instance.Insert(custemail);
                        }

                        //if (EnquiryType != "新车" && EnquiryType != "二手车" && EnquiryType != "个人反馈" && EnquiryType != "活动" && EnquiryType != "个人用车" && EnquiryType != "个人其他" && EnquiryType != "经销商合作" && EnquiryType != "经销商反馈" && EnquiryType != "经销商其他")

                        Entities.CustHistoryInfo CustHistoryInfoModel = null;

                        if (EnquiryType == "新车")
                        {
                            Entities.ConsultNewCar ConsultNewCarModel = new Entities.ConsultNewCar();
                            ConsultNewCarModel.CustID = CustID;
                            if (BrandID != "0")
                            {
                                ConsultNewCarModel.CarBrandId = Convert.ToInt32(BrandID);
                            }
                            if (CarModelsID != "0")
                            {
                                ConsultNewCarModel.CarSerialId = Convert.ToInt32(CarModelsID);
                            }
                            if (!string.IsNullOrEmpty(DealerName))
                            {
                                ConsultNewCarModel.DealerName = DealerName;
                            }
                            if (!string.IsNullOrEmpty(PhoneRecord))
                            {
                                ConsultNewCarModel.CallRecord = PhoneRecord;
                            }
                            ConsultNewCarModel.CreateTime   = System.DateTime.Now;
                            ConsultNewCarModel.CreateUserID = userid;
                            rerVal = BLL.ConsultNewCar.Instance.Insert(ConsultNewCarModel);

                            CustHistoryInfoModel = new CustHistoryInfo();

                            GetCustHistoryInfoModel(CustHistoryInfoModel, CustID, (int)ConsultType.NewCar, rerVal, userid);
                        }
                        else if (EnquiryType == "二手车")
                        {
                            Entities.ConsultSecondCar ConsultSecondCarModel = new Entities.ConsultSecondCar();
                            ConsultSecondCarModel.CustID = CustID;
                            if (BrandID != "0")
                            {
                                ConsultSecondCarModel.CarBrandId = Convert.ToInt32(BrandID);
                            }
                            if (CarModelsID != "0")
                            {
                                ConsultSecondCarModel.CarSerialId = Convert.ToInt32(CarModelsID);
                            }

                            if (!string.IsNullOrEmpty(PhoneRecord))
                            {
                                ConsultSecondCarModel.CallRecord = PhoneRecord;
                            }
                            ConsultSecondCarModel.CreateTime   = System.DateTime.Now;
                            ConsultSecondCarModel.CreateUserID = userid;
                            rerVal = BLL.ConsultSecondCar.Instance.Insert(ConsultSecondCarModel);

                            CustHistoryInfoModel = new CustHistoryInfo();

                            GetCustHistoryInfoModel(CustHistoryInfoModel, CustID, (int)ConsultType.SecondCar, rerVal, userid);
                        }
                        else if (EnquiryType == "个人反馈")
                        {
                            Entities.ConsultPFeedback ConsultPFeedbackModel = new Entities.ConsultPFeedback();
                            ConsultPFeedbackModel.CustID = CustID;


                            if (!string.IsNullOrEmpty(PhoneRecord))
                            {
                                ConsultPFeedbackModel.CallRecord = PhoneRecord;
                            }
                            ConsultPFeedbackModel.CreateTime   = System.DateTime.Now;
                            ConsultPFeedbackModel.CreateUserID = userid;
                            rerVal = BLL.ConsultPFeedback.Instance.Insert(ConsultPFeedbackModel);

                            CustHistoryInfoModel = new CustHistoryInfo();

                            GetCustHistoryInfoModel(CustHistoryInfoModel, CustID, (int)ConsultType.PFeedback, rerVal, userid);
                        }
                        //else if (EnquiryType == "活动")
                        //{
                        //    Entities.ConsultActivity ConsultActivityModel = new Entities.ConsultActivity();
                        //    ConsultActivityModel.CustID = CustID;

                        //    if (!string.IsNullOrEmpty(Brand))
                        //    {
                        //        ConsultActivityModel.BrandName = Brand;
                        //    }

                        //    if (!string.IsNullOrEmpty(PhoneRecord))
                        //    {
                        //        ConsultActivityModel.CallRecord = PhoneRecord;
                        //    }
                        //    ConsultActivityModel.CreateTime = System.DateTime.Now;
                        //    ConsultActivityModel.CreateUserID = userid;
                        //    rerVal = BLL.ConsultActivity.Instance.Insert(ConsultActivityModel);

                        //    CustHistoryInfoModel = new CustHistoryInfo();

                        //    GetCustHistoryInfoModel(CustHistoryInfoModel, CustID, (int)ConsultType.Activity, rerVal, userid);
                        //}
                        else if (EnquiryType == "个人其他")
                        {
                            Entities.ConsultPOther ConsultPOtherModel = new Entities.ConsultPOther();
                            ConsultPOtherModel.CustID = CustID;

                            ConsultPOtherModel.CreateTime   = System.DateTime.Now;
                            ConsultPOtherModel.CreateUserID = userid;

                            if (!string.IsNullOrEmpty(PhoneRecord))
                            {
                                ConsultPOtherModel.CallRecord = PhoneRecord;
                            }
                            rerVal = BLL.ConsultPOther.Instance.Insert(ConsultPOtherModel);


                            CustHistoryInfoModel = new CustHistoryInfo();

                            GetCustHistoryInfoModel(CustHistoryInfoModel, CustID, (int)ConsultType.POther, rerVal, userid);
                        }

                        else if (EnquiryType == "个人用车")
                        {
                            Entities.ConsultPUseCar ConsultPUseCarModel = new Entities.ConsultPUseCar();
                            ConsultPUseCarModel.CustID = CustID;

                            ConsultPUseCarModel.CreateTime   = System.DateTime.Now;
                            ConsultPUseCarModel.CreateUserID = userid;

                            if (!string.IsNullOrEmpty(PhoneRecord))
                            {
                                ConsultPUseCarModel.CallRecord = PhoneRecord;
                            }
                            rerVal = BLL.ConsultPUseCar.Instance.Insert(ConsultPUseCarModel);


                            CustHistoryInfoModel = new CustHistoryInfo();

                            GetCustHistoryInfoModel(CustHistoryInfoModel, CustID, (int)ConsultType.PUseCar, rerVal, userid);
                        }

                        else if (EnquiryType == "经销商合作")
                        {
                            Entities.ConsultDCoop ConsultDCoopCarModel = new Entities.ConsultDCoop();
                            ConsultDCoopCarModel.CustID       = CustID;
                            ConsultDCoopCarModel.Type         = 1;
                            ConsultDCoopCarModel.CreateTime   = System.DateTime.Now;
                            ConsultDCoopCarModel.CreateUserID = userid;

                            if (!string.IsNullOrEmpty(PhoneRecord))
                            {
                                ConsultDCoopCarModel.CallRecord = PhoneRecord;
                            }
                            rerVal = BLL.ConsultDCoop.Instance.Insert(ConsultDCoopCarModel);

                            CustHistoryInfoModel = new CustHistoryInfo();

                            GetCustHistoryInfoModel(CustHistoryInfoModel, CustID, (int)ConsultType.DCoop, rerVal, userid);
                        }
                        else if (EnquiryType == "经销商反馈")
                        {
                            Entities.ConsultDCoop ConsultDCoopCarModel = new Entities.ConsultDCoop();
                            ConsultDCoopCarModel.CustID       = CustID;
                            ConsultDCoopCarModel.Type         = 2;
                            ConsultDCoopCarModel.CreateTime   = System.DateTime.Now;
                            ConsultDCoopCarModel.CreateUserID = userid;

                            if (!string.IsNullOrEmpty(PhoneRecord))
                            {
                                ConsultDCoopCarModel.CallRecord = PhoneRecord;
                            }
                            rerVal = BLL.ConsultDCoop.Instance.Insert(ConsultDCoopCarModel);

                            CustHistoryInfoModel = new CustHistoryInfo();

                            GetCustHistoryInfoModel(CustHistoryInfoModel, CustID, (int)ConsultType.DCoopFeedback, rerVal, userid);
                        }
                        else if (EnquiryType == "经销商其他")
                        {
                            Entities.ConsultDCoop ConsultDCoopCarModel = new Entities.ConsultDCoop();
                            ConsultDCoopCarModel.CustID       = CustID;
                            ConsultDCoopCarModel.Type         = 3;
                            ConsultDCoopCarModel.CreateTime   = System.DateTime.Now;
                            ConsultDCoopCarModel.CreateUserID = userid;

                            if (!string.IsNullOrEmpty(PhoneRecord))
                            {
                                ConsultDCoopCarModel.CallRecord = PhoneRecord;
                            }
                            rerVal = BLL.ConsultDCoop.Instance.Insert(ConsultDCoopCarModel);

                            CustHistoryInfoModel = new CustHistoryInfo();

                            GetCustHistoryInfoModel(CustHistoryInfoModel, CustID, (int)ConsultType.DCoopOther, rerVal, userid);
                        }
                        //插入客户历史记录
                        if (CustHistoryInfoModel != null)
                        {
                            //功能废弃
                            custhistoryVal = BLL.CustHistoryInfo.Instance.Insert(CustHistoryInfoModel);
                        }
                    }
                    catch (Exception ex1)
                    {
                        ex.Append("数据插入报错。");
                        insertflag = false;
                        if (CustID != string.Empty)
                        {
                            //回滚数据
                            BLL.CustBasicInfo.Instance.Delete(CustID);
                            BLL.CustTel.Instance.Delete(CustID);
                            BLL.CustEmail.Instance.Delete(CustID);
                            if (EnquiryType == "新车")
                            {
                                BLL.ConsultNewCar.Instance.Delete(rerVal);
                            }
                            else if (EnquiryType == "二手车")
                            {
                                BLL.ConsultSecondCar.Instance.Delete(rerVal);
                            }
                            else if (EnquiryType == "个人反馈")
                            {
                                BLL.ConsultPFeedback.Instance.Delete(rerVal);
                            }
                            else if (EnquiryType == "活动")
                            {
                                BLL.ConsultActivity.Instance.Delete(rerVal);
                            }
                            else if (EnquiryType == "个人其他")
                            {
                                BLL.ConsultPOther.Instance.Delete(rerVal);
                            }

                            else if (EnquiryType == "个人用车")
                            {
                                BLL.ConsultPUseCar.Instance.Delete(rerVal);
                            }

                            else if (EnquiryType == "经销商合作")
                            {
                                BLL.ConsultDCoop.Instance.Delete(rerVal);
                            }
                            else if (EnquiryType == "经销商反馈")
                            {
                                BLL.ConsultDCoop.Instance.Delete(rerVal);
                            }
                            else if (EnquiryType == "经销商其他")
                            {
                                BLL.ConsultDCoop.Instance.Delete(rerVal);
                            }
                            if (custhistoryVal != 0)
                            {
                                BLL.CustHistoryInfo.Instance.Delete(custhistoryVal);
                            }
                        }
                    }
                }
            }
            if (insertflag == false)
            {
                //导出内容
                exportstr.Append(UserName + "|");
                exportstr.Append(Sex + "|");
                exportstr.Append(Tel1 + "|");
                exportstr.Append(CustCategory + "|");
                exportstr.Append(Tel2 + "|");
                exportstr.Append(Email + "|");

                exportstr.Append(Province + "|");

                exportstr.Append(City + "|");
                exportstr.Append(County + "|");

                exportstr.Append(Address + "|");
                exportstr.Append(DataSource + "|");

                exportstr.Append(EnquiryType + "|");
                exportstr.Append(Brand + "|");

                exportstr.Append(Models + "|");
                exportstr.Append(DealerName + "|");

                exportstr.Append(PhoneRecord + "|");
                exportstr.Append(ex.ToString());
            }
            return(insertflag);
        }
        private void Submit(out string msg, int userID)
        {
            //此方法内的逻辑可参考文档:$/A5信息系统研发/销售业务管理平台/客户关系管理/doc/Call Center/无主订单处理页面保存和提交逻辑.docx  ---- Add By Chybin At 2013-07-19

            msg = "";

            //System.Threading.Thread.Sleep(5000);

            #region 准备数据

            NewCarConsultInfo              newInfo        = null;                       //新车订单信息
            ReplaceCarConsultInfo          replaceInfo    = null;                       //置换订单信息
            Entities.OrderTask             orderTaskModel = null;                       //无主订单任务信息
            Entities.OrderTaskOperationLog orderLog       = null;                       //任务操作日志
            List <StringBuilder>           listLogStr     = new List <StringBuilder>(); //用户操作日志
            StringBuilder sblogstr = new StringBuilder();
            string        logstr   = "";

            #region 取得新车/置换无主订单信息更新后Model(此时不保存到数据库)

            Entities.OrderNewCar     newModel     = null; //新车订单实体类
            Entities.OrderRelpaceCar replaceModel = null; //置换订单实体类

            if (Source == "1" || Source == "3")
            {
                newInfo = (NewCarConsultInfo)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(NewCarConsultInfoStr, typeof(NewCarConsultInfo));

                newModel = OrderNewSave.Save(newInfo, out msg, userID, int.Parse(TaskID));
                if (msg != "")
                {
                    return;
                }
            }
            else if (Source == "2")
            {
                replaceInfo  = (ReplaceCarConsultInfo)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(ReplaceCarConsultInfoStr, typeof(ReplaceCarConsultInfo));
                replaceModel = OrderReplaceSave.Save(replaceInfo, out msg, userID, long.Parse(TaskID));
                if (msg != "")
                {
                    return;
                }
            }

            #endregion

            #region 取得任务的更新后信息

            orderTaskModel = BLL.OrderTask.Instance.GetOrderTask(long.Parse(TaskID));
            if (orderTaskModel == null)
            {
                msg += "没有找到相关的任务信息";
                return;
            }

            if (orderTaskModel.TaskStatus != 2 && orderTaskModel.TaskStatus != 3)
            {
                msg += "当前任务状态不能保存和提交";
                return;
            }

            if (orderTaskModel.AssignUserID != userID)
            {
                msg += "此订单没有分配给你";
                return;
            }


            //修改状态
            if (Action == "save")
            {
                orderTaskModel.TaskStatus = (int)TaskStatus.Processing;
            }
            else if (Action == "sub")
            {
                orderTaskModel.TaskStatus = (int)TaskStatus.Processed;
                orderTaskModel.SubmitTime = DateTime.Now;
            }

            //是否已选择经销商 只有在提交时,才会改动该属性 -是否已选择经销商 lxw
            if (Action == "sub")
            {
                if (((Source == "1" || Source == "3") && newModel.DMSMemberCode != "") || (Source == "2" && replaceModel.DMSMemberCode != ""))
                {
                    orderTaskModel.IsSelectDMSMember = true;
                }
                else
                {
                    orderTaskModel.IsSelectDMSMember = false;
                }
            }

            if (Source == "1" || Source == "3")
            {
                orderTaskModel.UserName = newModel.UserName;
            }
            else if (Source == "2")
            {
                orderTaskModel.UserName = replaceModel.UserName;
            }

            if (NoDealerReasonID != "")
            {
                orderTaskModel.NoDealerReasonID = int.Parse(NoDealerReasonID);
            }
            orderTaskModel.NoDealerReason = NoDealerReason;


            #endregion

            #region 任务操作日志

            orderLog = new OrderTaskOperationLog();

            //modify by qizq 2013-1-4首先判断是否是通话中
            if (IsCalling == "1")
            {
                if (HistoryLogID == "")
                {
                    //通话中提交把本地录音主键付给实体
                    long CallRecordReCID = 0;
                    if (CallRecordID != "")
                    {
                        if (long.TryParse(CallRecordID, out CallRecordReCID))
                        {
                            orderLog.CallRecordID = CallRecordReCID;
                        }
                    }
                }
            }
            //


            orderLog.TaskID = int.Parse(TaskID);

            if (Action == "save")
            {
                orderLog.OperationStatus = (int)OperationStatus.Save;
            }
            else if (Action == "sub")
            {
                orderLog.OperationStatus = (int)OperationStatus.Submit;
            }
            orderLog.TaskStatus   = orderTaskModel.TaskStatus;
            orderLog.CreateTime   = DateTime.Now;
            orderLog.CreateUserID = userID;

            #endregion

            #region 如果是提交操作,更新客户信息、插入咨询类型、添加客户联系记录

            Entities.CustBasicInfo          custmodel     = null;       //客户信息实体类
            Entities.CustTel                telPhoneMode  = null;       //电话实体类
            Entities.CustTel                telMobileMode = null;       //电话实体类
            Entities.CustEmail              emailMode     = null;       //邮件实体类
            Entities.ConsultOrderNewCar     cNewCar       = null;       //新车咨询类型
            Entities.ConsultOrderRelpaceCar cReplaceCar   = null;       //置换车咨询类型
            Entities.CustHistoryInfo        custHistInfo  = null;       //客户联系记录

            Entities.BuyCarInfo buyCarInfo = new Entities.BuyCarInfo(); //已购车或未购车信息 lxw

            if (Action == "sub")
            {
                #region 更新或插入客户信息
                //代码失效,功能废弃,需求重新实现
                #endregion

                #region 插入咨询类型

                if (Source == "1" || Source == "3")
                {
                    cNewCar = new ConsultOrderNewCar();

                    #region 赋值

                    cNewCar.CarBrandId   = newModel.CarMasterID;
                    cNewCar.CarSerialId  = newModel.CarSerialID;
                    cNewCar.CarNameID    = newModel.CarTypeID;
                    cNewCar.CarColor     = newModel.CarColor;
                    cNewCar.DealerCode   = newModel.DMSMemberCode;
                    cNewCar.DealerName   = newModel.DMSMemberName;
                    cNewCar.OrderRemark  = newModel.OrderRemark;
                    cNewCar.CallRecord   = newModel.CallRecord;
                    cNewCar.CreateTime   = DateTime.Now;
                    cNewCar.CreateUserID = userID;

                    #endregion
                }
                else if (Source == "2")
                {
                    cReplaceCar = new ConsultOrderRelpaceCar();

                    #region 赋值

                    cReplaceCar.WantBrandId        = replaceModel.RepCarMasterID;
                    cReplaceCar.WantSerialId       = replaceModel.RepCarSerialID;
                    cReplaceCar.WantNameID         = replaceModel.RepCarTypeId;
                    cReplaceCar.WantCarColor       = replaceModel.ReplacementCarColor;
                    cReplaceCar.WantDealerName     = replaceModel.DMSMemberName;
                    cReplaceCar.WantDealerCode     = replaceModel.DMSMemberCode;
                    cReplaceCar.CallRecord         = replaceModel.CallRecord;
                    cReplaceCar.OldBrandId         = replaceModel.CarMasterID;
                    cReplaceCar.OldSerialId        = replaceModel.CarSerialID;
                    cReplaceCar.OldNameID          = replaceModel.CarTypeID;
                    cReplaceCar.OldCarColor        = replaceModel.CarColor;
                    cReplaceCar.RegisterDateYear   = replaceModel.ReplacementCarBuyYear.ToString();
                    cReplaceCar.RegisterDateMonth  = replaceModel.ReplacementCarBuyMonth.ToString();
                    cReplaceCar.RegisterProvinceID = replaceModel.RepCarProvinceID;
                    cReplaceCar.RegisterCityID     = replaceModel.RepCarCityID;
                    cReplaceCar.RegisterCountyID   = replaceModel.RepCarCountyID;
                    cReplaceCar.Mileage            = (decimal)replaceModel.ReplacementCarUsedMiles;
                    cReplaceCar.PresellPrice       = replaceModel.SalePrice;
                    cReplaceCar.OrderRemark        = replaceModel.OrderRemark;
                    cReplaceCar.CreateTime         = DateTime.Now;
                    cReplaceCar.CreateUserID       = userID;

                    #endregion
                }

                #endregion

                #region 插入客户历史记录

                custHistInfo = new CustHistoryInfo();

                #region 赋值

                custHistInfo.TaskID = TaskID;
                if (Source == "1" || Source == "3")
                {
                    custHistInfo.ConsultID = 60010;//新车咨询类型
                }
                else
                {
                    custHistInfo.ConsultID = 60011;//置换咨询类型
                }
                custHistInfo.RecordType        = 2;
                custHistInfo.QuestionQuality   = (int)QuestionNature.NatureCommon;
                custHistInfo.ProcessStatus     = (int)EnumTaskStatus.TaskStatusOver;
                custHistInfo.CreateTime        = DateTime.Now;
                custHistInfo.CreateUserID      = userID;
                custHistInfo.LastTreatmentTime = DateTime.Now;

                #endregion

                #endregion
            }

            #endregion

            #endregion

            #region 事务提交

            string        connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC");
            SqlConnection connection        = new SqlConnection(connectionstrings);
            connection.Open();
            SqlTransaction tran = connection.BeginTransaction(IsolationLevel.ReadUncommitted, "SampleTransaction");

            try
            {
                #region 保存新车/置换无主订单信息

                if (Source == "1" || Source == "3")
                {
                    BLL.OrderNewCar.Instance.Update(tran, newModel);
                }
                else if (Source == "2")
                {
                    BLL.OrderRelpaceCar.Instance.Update(tran, replaceModel);
                }

                #endregion

                #region 修改任务信息

                BLL.OrderTask.Instance.Update(tran, orderTaskModel);

                #endregion

                #region 任务操作日志

                //modify by qizq 2013-1-4不是在通话中,处理记录已存在更新处理记录
                if (IsCalling != "1" && HistoryLogID != "")
                {
                    //通话中提交把本地录音主键付给实体
                    long CallRecordReCID = 0;
                    if (CallRecordID != "")
                    {
                        if (long.TryParse(CallRecordID, out CallRecordReCID))
                        {
                            orderLog.CallRecordID = CallRecordReCID;
                        }
                    }
                    long HistoryLogIDLog = 0;
                    if (long.TryParse(HistoryLogID, out HistoryLogIDLog))
                    {
                        orderLog.RecID = HistoryLogIDLog;
                    }
                    BLL.OrderTaskOperationLog.Instance.Update(tran, orderLog);
                }
                else
                {
                    BLL.OrderTaskOperationLog.Instance.Insert(tran, orderLog);
                }
                //



                #endregion

                if (Action == "sub")
                {
                    string retCustID = "";

                    #region 更新或插入客户信息

                    if (custmodel.RecID == -2)
                    {
                        //新加的客户

                        retCustID = BLL.CustBasicInfo.Instance.Insert(tran, custmodel);

                        #region 记日志

                        sblogstr = new StringBuilder();
                        logstr   = "";
                        logstr  += "新加了客户‘" + custmodel.CustName + "’的信息【ID:" + retCustID + "】";

                        if (logstr != "")
                        {
                            sblogstr.Append(logstr);
                            listLogStr.Add(sblogstr);
                        }

                        #endregion
                    }
                    else
                    {
                        //编辑客户信息
                        BLL.CustBasicInfo.Instance.Update(tran, custmodel);
                        retCustID = custmodel.CustID;
                    }
                    #endregion

                    #region 插入电话

                    if (telPhoneMode != null)
                    {
                        telPhoneMode.CustID = retCustID;
                        BLL.CustTel.Instance.Insert(tran, telPhoneMode);
                    }

                    if (telMobileMode != null)
                    {
                        telMobileMode.CustID = retCustID;
                        BLL.CustTel.Instance.Insert(tran, telMobileMode);
                    }

                    #endregion

                    #region 插入邮箱

                    if (emailMode != null)
                    {
                        emailMode.CustID = retCustID;
                        BLL.CustEmail.Instance.Insert(tran, emailMode);
                    }

                    #endregion

                    #region 插入咨询类型

                    int retDataID = 0;

                    if (cNewCar != null)
                    {
                        cNewCar.CustID = retCustID;
                        retDataID      = BLL.ConsultOrderNewCar.Instance.Insert(tran, cNewCar);

                        #region 记日志

                        sblogstr = new StringBuilder();
                        logstr   = "";
                        logstr  += "新加了无主订单新车联系咨询记录【ID:" + retDataID + "】";

                        if (logstr != "")
                        {
                            sblogstr.Append(logstr);
                            listLogStr.Add(sblogstr);
                        }

                        #endregion
                    }
                    if (cReplaceCar != null)
                    {
                        cReplaceCar.CustID = retCustID;
                        retDataID          = BLL.ConsultOrderRelpaceCar.Instance.Insert(tran, cReplaceCar);

                        #region 记日志

                        sblogstr = new StringBuilder();
                        logstr   = "";
                        logstr  += "新加了无主订单置换联系咨询记录【ID:" + retDataID + "】";

                        if (logstr != "")
                        {
                            sblogstr.Append(logstr);
                            listLogStr.Add(sblogstr);
                        }

                        #endregion
                    }

                    #endregion

                    #region 插入未购车或已购车记录 BuyCarInfo lxw

                    if (buyCarInfo != null && buyCarInfo.RecID == -2)
                    {
                        buyCarInfo.CustID = retCustID;
                        int recID = BLL.BuyCarInfo.Instance.Insert(tran, buyCarInfo);

                        #region 记日志

                        sblogstr = new StringBuilder();
                        logstr   = "";
                        logstr  += "新加了未购车已购车BuyCarInfo表的记录【ID:" + recID + "】";

                        if (logstr != "")
                        {
                            sblogstr.Append(logstr);
                            listLogStr.Add(sblogstr);
                        }

                        #endregion
                    }

                    if (buyCarInfo != null && buyCarInfo.RecID != -2)
                    {
                        BLL.BuyCarInfo.Instance.Update(tran, buyCarInfo);

                        #region 记日志

                        sblogstr = new StringBuilder();
                        logstr   = "";
                        logstr  += "修改了未购车已购车BuyCarInfo表的记录【ID:" + buyCarInfo.RecID + "】";

                        if (logstr != "")
                        {
                            sblogstr.Append(logstr);
                            listLogStr.Add(sblogstr);
                        }

                        #endregion
                    }

                    #endregion

                    #region 插入客户联系记录

                    if (custHistInfo != null)
                    {
                        custHistInfo.CustID        = retCustID;
                        custHistInfo.ConsultDataID = retDataID;
                        BLL.CustHistoryInfo.Instance.Insert(tran, custHistInfo);
                    }

                    #endregion

                    #region 插入已购车或未购车信息

                    #endregion

                    #region 保存用户操作日志

                    foreach (StringBuilder sbStr in listLogStr)
                    {
                        BLL.Util.InsertUserLog(tran, sbStr.ToString());
                    }
                    #endregion
                }

                if (msg == "")
                {
                    tran.Commit();
                    if (Action == "sub")
                    {
                        #region 调用易湃接口,传回数据

                        string errorMsg    = "";
                        int    retService  = 0;
                        short  isSelectDMS = 0;

                        #region 调用接口

                        BitAuto.ISDC.CC2012.WebService.NoDealerOrderHelper OrderHelper = new BitAuto.ISDC.CC2012.WebService.NoDealerOrderHelper();
                        if (Source == "1")                                                    //新车
                        {
                            isSelectDMS = newModel.DMSMemberCode == "" ? (short)2 : (short)1; //1 选择了经销商  2 未选择经销商
                            retService  = OrderHelper.SetNewCarOrder(newModel, isSelectDMS, NoDealerReason, ref errorMsg);
                        }
                        else if (Source == "2")                                                   //置换
                        {
                            isSelectDMS = replaceModel.DMSMemberCode == "" ? (short)2 : (short)1; //1 选择了经销商  2 未选择经销商
                            retService  = OrderHelper.SetReplacementOrder(replaceModel, isSelectDMS, NoDealerReason, ref errorMsg);
                        }
                        else if (Source == "3")
                        {
                            isSelectDMS = newModel.DMSMemberCode == "" ? (short)2 : (short)1; //1 选择了经销商  2 未选择经销商
                            retService  = OrderHelper.SetTestDriveOrder(newModel, isSelectDMS, NoDealerReason, ref errorMsg);
                        }

                        #endregion

                        #region 插入更新无主订单数据日志表

                        Entities.UpdateOrderData updateDateMode = new UpdateOrderData();
                        updateDateMode.TaskID = TaskID;

                        if (Source == "1" || Source == "3")
                        {
                            updateDateMode.YPOrderID = newModel.YPOrderID;
                        }
                        else if (Source == "2")
                        {
                            updateDateMode.YPOrderID = replaceModel.YPOrderID;
                        }

                        updateDateMode.UpdateType = retService;
                        updateDateMode.IsUpdate   = retService; // 1 成功了,不用处理,-1 需要重新处理
                        if (retService == 1)
                        {
                            updateDateMode.UpdateDateTime = DateTime.Now;
                        }
                        updateDateMode.UpdateErrorMsg = errorMsg;
                        updateDateMode.CreateTime     = DateTime.Now;
                        updateDateMode.CreateUserID   = userID;
                        updateDateMode.APIType        = 1;

                        BLL.UpdateOrderData.Instance.Insert(updateDateMode);

                        #endregion

                        if (retService == -1)
                        {
                            msg = "InterfaceErr|" + errorMsg;
                        }

                        #endregion
                    }
                }
                else
                {
                    tran.Rollback();
                }
            }
            catch (Exception ex)
            {
                if (tran.Connection != null)
                {
                    tran.Rollback();
                }
                msg = ex.Message.ToString();
            }
            finally
            {
                connection.Close();
            }



            #endregion
        }
示例#9
0
        /// 保存个人信息:弹屏,老版工单
        /// <summary>
        /// 保存个人信息:弹屏,老版工单
        /// </summary>
        /// <param name="info"></param>
        /// <param name="msg"></param>
        public void InsertCustInfo(CustBasicInfo info, out string msg)
        {
            msg = string.Empty;
            try
            {
                if (info.CustName == string.Empty || info.Tel == string.Empty)
                {
                    msg = "'result':'false','errorMsg':'数据格式错误!'";
                    return;
                }
                validateData(info.CustName, info.Sex, info.Tel, info.CustCategoryID, out msg);
                if (msg != "")
                {
                    msg = "'result':'false','errorMsg':'" + msg + "'";
                    return;
                }
                //获取个人用户ID
                ccCustID = BLL.CustBasicInfo.Instance.GetMaxNewCustBasicInfoByTel(info.Tel);
                if (!string.IsNullOrEmpty(ccCustID))
                {
                    # region 更新操作
                    Entities.CustBasicInfo model = BLL.CustBasicInfo.Instance.GetCustBasicInfo(ccCustID);
                    model.CustName = info.CustName;

                    int _sex      = CommonFunction.ObjectToInteger(info.Sex, -1);            //1男 2女
                    int _category = CommonFunction.ObjectToInteger(info.CustCategoryID, -1); //3经销商 4个人
                    if (_sex > 0)
                    {
                        model.Sex = _sex;
                    }
                    if (_category > 0)
                    {
                        model.CustCategoryID = _category;//3-经销商;4-个人;
                    }
                    int pID = 0, cID = 0;
                    BLL.PhoneNumDataDict.GetAreaId(info.Tel, out pID, out cID);
                    model.ProvinceID   = pID == 0 ? -2 : pID;
                    model.CityID       = cID == 0 ? -2 : cID;
                    model.CountyID     = -1;
                    model.AreaID       = "";//新增 更新时 自动计算
                    model.CallTime     = 0;
                    model.Status       = 0;
                    model.ModifyUserID = info.OperID;
                    model.ModifyTime   = info.OperTime;
                    BLL.CustBasicInfo.Instance.Update(model);
                    #endregion
                    BLL.Util.InsertUserLog("个人用户表【修改记录】【修改电话信息】成功【电话】" + info.Tel + "【姓名】" + info.CustName + "【客户分类】" + info.CustCategoryID + "【省份ID】" + pID + "【城市ID】" + cID + "【大区】" + model.AreaID + "【操作人】" + info.OperID + "【操作时间】" + info.OperTime);
                    msg = "'result':'true','CustID':'" + ccCustID + "'";
                    return;
                }
                else
                {
                    int _sex      = CommonFunction.ObjectToInteger(info.Sex, 1);            //1男 2女
                    int _category = CommonFunction.ObjectToInteger(info.CustCategoryID, 4); //3经销商 4个人

                    if (_sex <= 0 || _category <= 0)
                    {
                        msg = "'result':'false','errorMsg':'Sex:" + info.Sex + ",CustCategoryID:" + info.CustCategoryID + ",数据格式出现错误,无法操作!'";
                        return;
                    }

                    #region 插入个人信息表CustBasicInfo
                    Entities.CustBasicInfo model = new Entities.CustBasicInfo();
                    model.CustName       = info.CustName;
                    model.Sex            = _sex;
                    model.CustCategoryID = _category;//3-经销商;4-个人;
                    int pID = 0, cID = 0;
                    BLL.PhoneNumDataDict.GetAreaId(info.Tel, out pID, out cID);
                    model.ProvinceID   = pID == 0 ? -2 : pID;
                    model.CityID       = cID == 0 ? -2 : cID;
                    model.CountyID     = -1;
                    model.AreaID       = "";//新增 更新时 自动计算
                    model.CallTime     = 0;
                    model.Status       = 0;
                    model.CreateUserID = model.ModifyUserID = info.OperID;
                    model.CreateTime   = model.ModifyTime = info.OperTime;
                    //插入个人用户库
                    ccCustID = BLL.CustBasicInfo.Instance.Insert(model);
                    #endregion

                    #region 插入电话信息CustTel
                    Entities.CustTel model_Tel = new Entities.CustTel();
                    model_Tel.CustID       = ccCustID;
                    model_Tel.CreateTime   = info.OperTime;
                    model_Tel.CreateUserID = info.OperID;
                    model_Tel.Tel          = info.Tel;
                    BLL.CustTel.Instance.Insert(model_Tel);
                    #endregion

                    #region 如果客户分类为3-经销商,且经销商ID存在,则插入客户与经销商关联表
                    if (info.CustCategoryID == "3" && !string.IsNullOrEmpty(info.MemberID) && !string.IsNullOrEmpty(info.MemberName))
                    {
                        Entities.DealerInfo model_Dealer = new Entities.DealerInfo();
                        model_Dealer.CustID       = ccCustID;
                        model_Dealer.MemberCode   = info.MemberID;
                        model_Dealer.Name         = info.MemberName;
                        model_Dealer.Status       = 0;
                        model_Dealer.CreateTime   = info.OperTime;
                        model_Dealer.CreateUserID = info.OperID;
                        BLL.DealerInfo.Instance.Insert(model_Dealer);
                    }
                    #endregion

                    msg = "'result':'true','CustID':'" + ccCustID + "'";
                    BLL.Util.InsertUserLog("个人用户表【新增记录】【插入电话信息】成功【电话】" + info.Tel + "【姓名】" + info.CustName + "【客户分类】" + info.CustCategoryID + "【省份ID】" + pID + "【城市ID】" + cID + "【大区】" + model.AreaID + "【操作人】" + info.OperID + "【操作时间】" + info.OperTime);
                }
            }
        /// 保存信息到个人用户库:接口,服务
        /// <summary>
        /// 保存信息到个人用户库:接口,服务
        /// </summary>
        /// <param name="CustName">客户名称</param>
        /// <param name="Tels">电话号码,允许多个</param>
        /// <param name="Sex">姓别 男:1,女:2</param>
        /// <param name="CreateUserID">创建人</param>
        /// <param name="msg">返回调用结果信息</param>
        /// <param name="CustID">客户号返回值</param>
        public bool InsertCustInfo(string CustName, string[] Tels, int Sex, int CreateUserID, int custCategory, int?update_provinceid, int?update_cityid, out string msg, out string CustID)
        {
            CustID = string.Empty;
            msg    = string.Empty;

            try
            {
                #region 验证参数
                if (CustName == string.Empty)
                {
                    msg = "'result':'false','errorMsg':'数据格式错误,姓名不能为空!'";
                    return(false);
                }
                else if (Tels.Length == 0)
                {
                    msg = "'result':'false','errorMsg':'数据格式错误,电话不能为空!'";
                    return(false);
                }
                else if (Tels.Length > 0)
                {
                    foreach (string tel in Tels)
                    {
                        if (string.IsNullOrEmpty(tel))
                        {
                            msg = "'result':'false','errorMsg':'数据格式错误,电话不能为空!'";
                            return(false);
                        }
                    }
                }
                //校验客户类型参数,只能传入3,4类型
                if (custCategory == (int)CustTypeEnum.T01_个人)
                {
                    custCategory = (int)CustTypeEnum.T01_个人;
                }
                else
                {
                    custCategory = (int)CustTypeEnum.T02_经销商;
                }
                #endregion

                CustID = GetMaxNewCustBasicInfoByTel(Tels);
                Entities.CustBasicInfo model = null;
                if (!string.IsNullOrEmpty(CustID))
                {
                    #region 修改操作
                    //更新客户
                    model = BLL.CustBasicInfo.Instance.GetCustBasicInfo(CustID);
                    if (update_provinceid.HasValue)
                    {
                        model.ProvinceID = update_provinceid;
                    }
                    if (update_cityid.HasValue)
                    {
                        model.CityID = update_cityid;
                    }
                    model.CustCategoryID = custCategory;
                    model.ModifyTime     = DateTime.Now;
                    model.Sex            = Sex;
                    BLL.CustBasicInfo.Instance.Update(model);
                    //更新电话
                    foreach (string tel in Tels)
                    {
                        if (!BLL.CustTel.Instance.IsExistsByCustIDAndTel(CustID, tel))
                        {
                            Entities.CustTel modeltel = new Entities.CustTel();
                            modeltel.CreateTime   = DateTime.Now;
                            modeltel.CreateUserID = CreateUserID;
                            modeltel.CustID       = CustID;
                            modeltel.Tel          = tel;
                            try
                            {
                                BLL.CustTel.Instance.Insert(modeltel);
                            }
                            catch (Exception ex)
                            {
                                msg = "'result':'false','errorMsg':'插入【电话】" + modeltel + "失败!'";
                                Loger.Log4Net.Error("【保存信息到个人用户库:接口】", ex);
                                return(false);
                            }
                        }
                    }
                    #endregion
                    msg = "'result':'true','CustID':'" + CustID + "'";
                }
                else
                {
                    #region 新增操作
                    model                = new Entities.CustBasicInfo();
                    model.CustName       = CustName;
                    model.Sex            = Sex;
                    model.CustCategoryID = custCategory;//3-经销商;4-个人;
                    int pID = 0, cID = 0;
                    BLL.PhoneNumDataDict.GetAreaId(Tels[0], out pID, out cID);
                    model.ProvinceID   = pID == 0 ? -2 : pID;
                    model.CityID       = cID == 0 ? -2 : cID;
                    model.CountyID     = -1;
                    model.AreaID       = "";//新增和更新时自动计算
                    model.CallTime     = 0;
                    model.Status       = 0;
                    model.CreateUserID = model.ModifyUserID = CreateUserID;
                    model.CreateTime   = model.ModifyTime = DateTime.Now;
                    CustID             = BLL.CustBasicInfo.Instance.Insert(model);

                    foreach (string tel in Tels)
                    {
                        Entities.CustTel model_Tel = new Entities.CustTel();
                        model_Tel.CustID       = CustID;
                        model_Tel.CreateTime   = DateTime.Now;
                        model_Tel.CreateUserID = CreateUserID;
                        model_Tel.Tel          = tel;
                        try
                        {
                            BLL.CustTel.Instance.Insert(model_Tel);
                        }
                        catch (Exception ex)
                        {
                            msg = "'result':'false','errorMsg':'插入【电话】" + model_Tel + "失败!";
                            Loger.Log4Net.Error("【保存信息到个人用户库:接口】", ex);
                            return(false);
                        }
                    }
                    #endregion
                    msg = "'result':'true','CustID':'" + CustID + "'";
                }
            }
            catch (Exception ex)
            {
                Loger.Log4Net.Error("【保存信息到个人用户库:接口】", ex);
                msg = "'result':'false','errorMsg':'" + ex.Message + "'";
                return(false);
            }
            return(true);
        }
示例#11
0
        /// 保存个人信息
        /// <summary>
        /// 保存个人信息
        /// </summary>
        /// <param name="jsondata"></param>
        public void SaveCustBasicInfo(WOrderJsonData jsondata, int loginuserid)
        {
            //构造个人主表数据
            Entities.CustBasicInfo model = new Entities.CustBasicInfo();
            model.CustName       = jsondata.CustBaseInfo.CBName_Out;
            model.Sex            = jsondata.CustBaseInfo.CBSex_Out;
            model.CustCategoryID = (int)jsondata.CustBaseInfo.CustTypeID_Out;
            model.ProvinceID     = jsondata.CustBaseInfo.ProvinceID_Out;
            model.CityID         = jsondata.CustBaseInfo.CityID_Out;
            model.CountyID       = jsondata.CustBaseInfo.CountyID_Out;
            //废弃字段
            model.Address    = null;
            model.DataSource = null;
            model.CallTime   = null;
            model.Status     = 0;

            //查询数据库
            string cbid = BLL.CustBasicInfo.Instance.GetMaxNewCustBasicInfoByTel(jsondata.CustBaseInfo.Phone_Out);

            if (!string.IsNullOrEmpty(cbid))
            {
                //更新
                model.CustID       = cbid;
                model.ModifyTime   = DateTime.Now;
                model.ModifyUserID = loginuserid;
                BLL.CustBasicInfo.Instance.Update(model);
            }
            else
            {
                //新增
                model.CreateTime   = DateTime.Now;
                model.CreateUserID = loginuserid;
                model.ModifyTime   = null;
                model.ModifyUserID = null;
                cbid = BLL.CustBasicInfo.Instance.Insert(model);

                //插入电话信息
                Entities.CustTel model_Tel = new Entities.CustTel();
                model_Tel.CustID       = cbid;
                model_Tel.Tel          = jsondata.CustBaseInfo.Phone_Out;
                model_Tel.CreateTime   = DateTime.Now;
                model_Tel.CreateUserID = loginuserid;
                BLL.CustTel.Instance.Insert(model_Tel);
            }
            //存储
            jsondata.CBID = cbid;
            //删除经销商信息
            BLL.DealerInfo.Instance.Delete(cbid);
            //存储经销商信息
            if (jsondata.CustBaseInfo.CustTypeID_Out == CustTypeEnum.T02_经销商)
            {
                //插入经销商信息
                Entities.DealerInfo model_Dealer = new Entities.DealerInfo();
                model_Dealer.CustID       = cbid;
                model_Dealer.MemberCode   = jsondata.CustBaseInfo.MemberCode_Out;
                model_Dealer.Name         = jsondata.CustBaseInfo.MemberName_Out;
                model_Dealer.Status       = 0;
                model_Dealer.CreateTime   = DateTime.Now;
                model_Dealer.CreateUserID = loginuserid;
                BLL.DealerInfo.Instance.Insert(model_Dealer);
            }
        }
示例#12
0
        /// <summary>
        /// 校验
        /// </summary>
        private bool Valid(int rowNum, IDataReader reader, out StringBuilder ex, int userid, DataTable dtExport)
        {
            ex = new StringBuilder();

            string UserName = string.Empty;

            UserName = reader[0].ToString().Trim();

            string Sex = string.Empty;

            Sex = reader[1].ToString().Trim();

            string Tel1 = string.Empty;

            Tel1 = reader[2].ToString().Trim();

            string CustCategory = string.Empty;

            CustCategory = reader[3].ToString().Trim();

            string Tel2 = string.Empty;

            Tel2 = reader[4].ToString().Trim();

            string Email = string.Empty;

            Email = reader[5].ToString().Trim();

            string Province = string.Empty;

            Province = reader[6].ToString().Trim();

            string City = string.Empty;

            City = reader[7].ToString().Trim();

            string County = string.Empty;

            County = reader[8].ToString().Trim();

            string Address = string.Empty;

            Address = reader[9].ToString().Trim();

            string DataSource = string.Empty;

            DataSource = reader[10].ToString().Trim();
            //咨询类型
            string EnquiryType = string.Empty;

            EnquiryType = reader[11].ToString().Trim();


            string Brand = string.Empty;

            Brand = reader[12].ToString().Trim();

            string Models = string.Empty;

            Models = reader[13].ToString().Trim();

            //推荐经销商名称
            string DealerName = string.Empty;

            DealerName = reader[14].ToString().Trim();

            //来电记录
            string PhoneRecord = string.Empty;

            PhoneRecord = reader[15].ToString().Trim();

            bool insertflag = true;

            //会员ID号验证
            if (string.IsNullOrEmpty(UserName) || UserName.Length == 0)
            {
                ex.Append("第" + rowNum + "行[姓名]不可为空。");
                insertflag = false;
            }
            else
            {
                if (BLL.Util.GetLength(UserName) > 50)
                {
                    ex.Append("第" + rowNum + "行[姓名]超长。");
                    insertflag = false;
                }
            }
            if (string.IsNullOrEmpty(Sex) || Sex.Length == 0)
            {
                ex.Append("第" + rowNum + "行[性别]不可为空。");
                insertflag = false;
            }
            else
            {
                if (Sex != "男" && Sex != "女")
                {
                    ex.Append("第" + rowNum + "行[性别]输入错误。");
                    insertflag = false;
                }
            }
            if (string.IsNullOrEmpty(Tel1) || Tel1.Length == 0)
            {
                ex.Append("第" + rowNum + "行[电话1]不可为空。");
                insertflag = false;
            }
            else
            {
                if (BLL.Util.IsTelephone(Tel1) == false && BLL.Util.IsHandset(Tel1) == false)
                {
                    ex.Append("第" + rowNum + "行[电话]输入错误。");
                    insertflag = false;
                }
            }

            if (string.IsNullOrEmpty(CustCategory) || CustCategory.Length == 0)
            {
                ex.Append("第" + rowNum + "行[客户分类]不可为空。");
                insertflag = false;
            }
            else
            {
                if (CustCategory != "已购车" && CustCategory != "未购车" && CustCategory != "经销商")
                {
                    ex.Append("第" + rowNum + "行[客户分类]输入错误。");
                    insertflag = false;
                }
            }
            if (!string.IsNullOrEmpty(Tel2))
            {
                if (BLL.Util.IsTelephone(Tel2) == false && BLL.Util.IsHandset(Tel2) == false)
                {
                    ex.Append("第" + rowNum + "行[电话2]输入错误。");
                    insertflag = false;
                }
            }
            if (!string.IsNullOrEmpty(Email))
            {
                if (BLL.Util.IsEmail(Email) == false)
                {
                    ex.Append("第" + rowNum + "行[邮箱]输入错误。");
                    insertflag = false;
                }
            }
            if (!string.IsNullOrEmpty(Address))
            {
                if (BLL.Util.GetLength(Address) > 200)
                {
                    ex.Append("第" + rowNum + "行[地址]超长。");
                    insertflag = false;
                }
            }

            if (!string.IsNullOrEmpty(DataSource))
            {
                if (DataSource != "呼叫中心" && DataSource != "在线" && DataSource != "汽车通" && DataSource != "车易通")
                {
                    ex.Append("第" + rowNum + "行[数据来源]输入错误。");
                    insertflag = false;
                }
            }

            if (!string.IsNullOrEmpty(EnquiryType))
            {
                if (EnquiryType != "新车" && EnquiryType != "二手车" && EnquiryType != "个人反馈" && EnquiryType != "活动" && EnquiryType != "个人用车" && EnquiryType != "个人其他" && EnquiryType != "经销商合作" && EnquiryType != "经销商反馈" && EnquiryType != "经销商其他")
                {
                    ex.Append("第" + rowNum + "行[咨询类型]输入错误。");
                    insertflag = false;
                }
            }
            if (!string.IsNullOrEmpty(DealerName))
            {
                if (BLL.Util.GetLength(DealerName) > 200)
                {
                    ex.Append("第" + rowNum + "行[推荐经销商]超长。");
                    insertflag = false;
                }
            }
            if (!string.IsNullOrEmpty(PhoneRecord))
            {
                if (BLL.Util.GetLength(PhoneRecord) > 2000)
                {
                    ex.Append("第" + rowNum + "行[来电记录]超长。");
                    insertflag = false;
                }
            }
            string provinceID = "0";

            //验证省份城市
            if (!string.IsNullOrEmpty(Province))
            {
                provinceID = BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaIdByName(Province, 1);
                if (provinceID == "0")
                {
                    ex.Append("第" + rowNum + "行[地区(省)]输入错误。");
                    insertflag = false;
                }
            }
            string CityID = "0";

            //验证省份城市
            if (!string.IsNullOrEmpty(City))
            {
                CityID = BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaIdByName(City, 2);
                if (CityID == "0")
                {
                    ex.Append("第" + rowNum + "行[地区(市)]输入错误。");
                    insertflag = false;
                }
            }
            string CountryID = "0";

            //验证区县
            if (!string.IsNullOrEmpty(County))
            {
                CountryID = BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaIdByName(County, 3);
                if (CountryID == "0")
                {
                    ex.Append("第" + rowNum + "行[地区(区县)]输入错误。");
                    insertflag = false;
                }
            }
            //验证车型
            string BrandID = "0";

            if (!string.IsNullOrEmpty(Brand))
            {
                DataTable dt = BLL.BuyCarInfo.Instance.GetCarBrandByName(Brand);
                if (dt != null && dt.Rows.Count > 0)
                {
                    BrandID = dt.Rows[0]["Brandid"].ToString();
                }
                else
                {
                    ex.Append("第" + rowNum + "行[品牌]输入错误。");
                    insertflag = false;
                }
            }

            //验证车系
            string CarModelsID = "0";

            if (!string.IsNullOrEmpty(Models))
            {
                DataTable dt = BLL.BuyCarInfo.Instance.GetCarSerialByName(Models);
                if (dt != null && dt.Rows.Count > 0)
                {
                    CarModelsID = dt.Rows[0]["serialid"].ToString();
                }
                else
                {
                    ex.Append("第" + rowNum + "行[车系]输入错误。");
                    insertflag = false;
                }
            }

            //如果验证通过,插入
            if (insertflag)
            {
                bool flag = false;
                flag = BLL.CustBasicInfo.Instance.IsExistsByCustNameAndTel(UserName, Tel1);

                if (flag)
                {
                    ex.Append("第" + rowNum + "行记录[姓名],[电话1]已存在。");
                    insertflag = false;
                }
                else
                {
                    Entities.CustBasicInfo CustBasicInfoModel = new Entities.CustBasicInfo();
                    CustBasicInfoModel.Status   = 0;
                    CustBasicInfoModel.CustName = UserName;
                    CustBasicInfoModel.Sex      = (Sex == "男" ? 1 : 2);
                    if (CustCategory == "已购车")
                    {
                        CustBasicInfoModel.CustCategoryID = 1;
                    }
                    else if (CustCategory == "未购车")
                    {
                        CustBasicInfoModel.CustCategoryID = 2;
                    }
                    else
                    {
                        CustBasicInfoModel.CustCategoryID = 3;
                    }
                    if (provinceID != "0")
                    {
                        CustBasicInfoModel.ProvinceID = Convert.ToInt32(provinceID);
                    }
                    if (CityID != "0")
                    {
                        CustBasicInfoModel.CityID = Convert.ToInt32(CityID);
                    }
                    if (CountryID != "0")
                    {
                        CustBasicInfoModel.CountyID = Convert.ToInt32(CountryID);
                    }

                    if (!string.IsNullOrEmpty(Address))
                    {
                        CustBasicInfoModel.Address = Address;
                    }

                    if (!string.IsNullOrEmpty(DataSource))
                    {
                        if (DataSource == "呼叫中心")
                        {
                            CustBasicInfoModel.DataSource = 180001;
                        }
                        else if (DataSource == "在线")
                        {
                            CustBasicInfoModel.DataSource = 180002;
                        }
                        else if (DataSource == "汽车通")
                        {
                            CustBasicInfoModel.DataSource = 180003;
                        }
                        else if (DataSource == "车易通")
                        {
                            CustBasicInfoModel.DataSource = 180004;
                        }
                    }
                    string CustID = string.Empty;
                    int    rerVal = 0;
                    try
                    {
                        //功能废弃
                        CustID = null;// BLL.CustBasicInfo.Instance.Insert(CustBasicInfoModel);
                        Entities.CustTel custTel1 = new Entities.CustTel();
                        custTel1.Tel    = Tel1;
                        custTel1.CustID = CustID;
                        BLL.CustTel.Instance.Insert(custTel1);
                        Entities.CustTel custTel2 = null;
                        if (!string.IsNullOrEmpty(Tel2))
                        {
                            custTel2        = new Entities.CustTel();
                            custTel2.Tel    = Tel2;
                            custTel2.CustID = CustID;
                            BLL.CustTel.Instance.Insert(custTel2);
                        }
                        Entities.CustEmail custemail = null;
                        if (!string.IsNullOrEmpty(Email))
                        {
                            custemail        = new Entities.CustEmail();
                            custemail.Email  = Email;
                            custemail.CustID = CustID;
                            BLL.CustEmail.Instance.Insert(custemail);
                        }

                        //if (EnquiryType != "新车" && EnquiryType != "二手车" && EnquiryType != "个人反馈" && EnquiryType != "活动" && EnquiryType != "个人用车" && EnquiryType != "个人其他" && EnquiryType != "经销商合作" && EnquiryType != "经销商反馈" && EnquiryType != "经销商其他")
                        if (EnquiryType == "新车")
                        {
                            Entities.ConsultNewCar ConsultNewCarModel = new Entities.ConsultNewCar();
                            ConsultNewCarModel.CustID = CustID;
                            if (BrandID != "0")
                            {
                                ConsultNewCarModel.CarBrandId = Convert.ToInt32(BrandID);
                            }
                            if (CarModelsID != "0")
                            {
                                ConsultNewCarModel.CarSerialId = Convert.ToInt32(CarModelsID);
                            }
                            if (!string.IsNullOrEmpty(DealerName))
                            {
                                ConsultNewCarModel.DealerName = DealerName;
                            }
                            if (!string.IsNullOrEmpty(PhoneRecord))
                            {
                                ConsultNewCarModel.CallRecord = PhoneRecord;
                            }
                            ConsultNewCarModel.CreateTime   = System.DateTime.Now;
                            ConsultNewCarModel.CreateUserID = userid;
                            rerVal = BLL.ConsultNewCar.Instance.Insert(ConsultNewCarModel);
                        }
                        else if (EnquiryType == "二手车")
                        {
                            Entities.ConsultSecondCar ConsultSecondCarModel = new Entities.ConsultSecondCar();
                            ConsultSecondCarModel.CustID = CustID;
                            if (BrandID != "0")
                            {
                                ConsultSecondCarModel.CarBrandId = Convert.ToInt32(BrandID);
                            }
                            if (CarModelsID != "0")
                            {
                                ConsultSecondCarModel.CarSerialId = Convert.ToInt32(CarModelsID);
                            }

                            if (!string.IsNullOrEmpty(PhoneRecord))
                            {
                                ConsultSecondCarModel.CallRecord = PhoneRecord;
                            }
                            ConsultSecondCarModel.CreateTime   = System.DateTime.Now;
                            ConsultSecondCarModel.CreateUserID = userid;
                            rerVal = BLL.ConsultSecondCar.Instance.Insert(ConsultSecondCarModel);
                        }
                        else if (EnquiryType == "个人反馈")
                        {
                            Entities.ConsultPFeedback ConsultPFeedbackModel = new Entities.ConsultPFeedback();
                            ConsultPFeedbackModel.CustID = CustID;


                            if (!string.IsNullOrEmpty(PhoneRecord))
                            {
                                ConsultPFeedbackModel.CallRecord = PhoneRecord;
                            }
                            ConsultPFeedbackModel.CreateTime   = System.DateTime.Now;
                            ConsultPFeedbackModel.CreateUserID = userid;
                            rerVal = BLL.ConsultPFeedback.Instance.Insert(ConsultPFeedbackModel);
                        }
                        else if (EnquiryType == "活动")
                        {
                            Entities.ConsultActivity ConsultActivityModel = new Entities.ConsultActivity();
                            ConsultActivityModel.CustID = CustID;

                            if (!string.IsNullOrEmpty(Brand))
                            {
                                ConsultActivityModel.BrandName = Brand;
                            }

                            if (!string.IsNullOrEmpty(PhoneRecord))
                            {
                                ConsultActivityModel.CallRecord = PhoneRecord;
                            }
                            ConsultActivityModel.CreateTime   = System.DateTime.Now;
                            ConsultActivityModel.CreateUserID = userid;
                            rerVal = BLL.ConsultActivity.Instance.Insert(ConsultActivityModel);
                        }
                        else if (EnquiryType == "个人其他")
                        {
                            Entities.ConsultPOther ConsultPOtherModel = new Entities.ConsultPOther();
                            ConsultPOtherModel.CustID = CustID;

                            ConsultPOtherModel.CreateTime   = System.DateTime.Now;
                            ConsultPOtherModel.CreateUserID = userid;

                            if (!string.IsNullOrEmpty(PhoneRecord))
                            {
                                ConsultPOtherModel.CallRecord = PhoneRecord;
                            }
                            rerVal = BLL.ConsultPOther.Instance.Insert(ConsultPOtherModel);
                        }

                        else if (EnquiryType == "个人用车")
                        {
                            Entities.ConsultPUseCar ConsultPUseCarModel = new Entities.ConsultPUseCar();
                            ConsultPUseCarModel.CustID = CustID;

                            ConsultPUseCarModel.CreateTime   = System.DateTime.Now;
                            ConsultPUseCarModel.CreateUserID = userid;

                            if (!string.IsNullOrEmpty(PhoneRecord))
                            {
                                ConsultPUseCarModel.CallRecord = PhoneRecord;
                            }
                            rerVal = BLL.ConsultPUseCar.Instance.Insert(ConsultPUseCarModel);
                        }

                        else if (EnquiryType == "经销商合作")
                        {
                            Entities.ConsultDCoop ConsultDCoopCarModel = new Entities.ConsultDCoop();
                            ConsultDCoopCarModel.CustID       = CustID;
                            ConsultDCoopCarModel.Type         = 1;
                            ConsultDCoopCarModel.CreateTime   = System.DateTime.Now;
                            ConsultDCoopCarModel.CreateUserID = userid;

                            if (!string.IsNullOrEmpty(PhoneRecord))
                            {
                                ConsultDCoopCarModel.CallRecord = PhoneRecord;
                            }
                            rerVal = BLL.ConsultDCoop.Instance.Insert(ConsultDCoopCarModel);
                        }
                        else if (EnquiryType == "经销商反馈")
                        {
                            Entities.ConsultDCoop ConsultDCoopCarModel = new Entities.ConsultDCoop();
                            ConsultDCoopCarModel.CustID       = CustID;
                            ConsultDCoopCarModel.Type         = 2;
                            ConsultDCoopCarModel.CreateTime   = System.DateTime.Now;
                            ConsultDCoopCarModel.CreateUserID = userid;

                            if (!string.IsNullOrEmpty(PhoneRecord))
                            {
                                ConsultDCoopCarModel.CallRecord = PhoneRecord;
                            }
                            rerVal = BLL.ConsultDCoop.Instance.Insert(ConsultDCoopCarModel);
                        }
                        else if (EnquiryType == "经销商其他")
                        {
                            Entities.ConsultDCoop ConsultDCoopCarModel = new Entities.ConsultDCoop();
                            ConsultDCoopCarModel.CustID       = CustID;
                            ConsultDCoopCarModel.Type         = 3;
                            ConsultDCoopCarModel.CreateTime   = System.DateTime.Now;
                            ConsultDCoopCarModel.CreateUserID = userid;

                            if (!string.IsNullOrEmpty(PhoneRecord))
                            {
                                ConsultDCoopCarModel.CallRecord = PhoneRecord;
                            }
                            rerVal = BLL.ConsultDCoop.Instance.Insert(ConsultDCoopCarModel);
                        }
                    }
                    catch (Exception ex1)
                    {
                        ex.Append("第" + rowNum + "行数据插入报错。");
                        insertflag = false;
                        if (CustID != string.Empty)
                        {
                            //回滚数据
                            BLL.CustBasicInfo.Instance.Delete(CustID);
                            BLL.CustTel.Instance.Delete(CustID);
                            BLL.CustEmail.Instance.Delete(CustID);
                            if (EnquiryType == "新车")
                            {
                                BLL.ConsultNewCar.Instance.Delete(rerVal);
                            }
                            else if (EnquiryType == "二手车")
                            {
                                BLL.ConsultSecondCar.Instance.Delete(rerVal);
                            }
                            else if (EnquiryType == "个人反馈")
                            {
                                BLL.ConsultPFeedback.Instance.Delete(rerVal);
                            }
                            else if (EnquiryType == "活动")
                            {
                                BLL.ConsultActivity.Instance.Delete(rerVal);
                            }
                            else if (EnquiryType == "个人其他")
                            {
                                BLL.ConsultPOther.Instance.Delete(rerVal);
                            }

                            else if (EnquiryType == "个人用车")
                            {
                                BLL.ConsultPUseCar.Instance.Delete(rerVal);
                            }

                            else if (EnquiryType == "经销商合作")
                            {
                                BLL.ConsultDCoop.Instance.Delete(rerVal);
                            }
                            else if (EnquiryType == "经销商反馈")
                            {
                                BLL.ConsultDCoop.Instance.Delete(rerVal);
                            }
                            else if (EnquiryType == "经销商其他")
                            {
                                BLL.ConsultDCoop.Instance.Delete(rerVal);
                            }
                        }
                    }
                }
            }
            if (insertflag == false)
            {
                DataRow newRow = dtExport.NewRow();
                newRow["username"]     = UserName;
                newRow["sex"]          = Sex;
                newRow["tel1"]         = Tel1;
                newRow["custcategory"] = CustCategory;
                newRow["tel2"]         = Tel2;
                newRow["email"]        = Email;

                newRow["province"] = Province;
                newRow["city"]     = City;
                newRow["county"]   = County;

                newRow["address"]    = Address;
                newRow["datasource"] = DataSource;

                newRow["EnquiryType"] = EnquiryType;
                newRow["brand"]       = Brand;

                newRow["carmodel"]   = Models;
                newRow["Dealer"]     = DealerName;
                newRow["callrecord"] = PhoneRecord;
                newRow["failinfo"]   = ex.ToString();
                dtExport.Rows.Add(newRow);
            }
            return(insertflag);
        }
        /// 保存个人信息
        /// <summary>
        /// 保存个人信息
        /// </summary>
        /// <param name="jsondata"></param>
        /// <param name="loginuserid"></param>
        public string SaveCustBasicInfo(string phone, PageDataInfo pagedata, int loginuserid)
        {
            //查询数据库
            string cbid = BLL.CustBasicInfo.Instance.GetMaxNewCustBasicInfoByTel(phone);

            if (string.IsNullOrEmpty(cbid))
            {
                //新增
                Entities.CustBasicInfo model = new Entities.CustBasicInfo();
                model.CustName       = pagedata.CBName_Out != "" ? pagedata.CBName_Out : "未知";
                model.Sex            = pagedata.CBSex_Out > 0 ? pagedata.CBSex_Out : 1;
                model.CustCategoryID = (int)pagedata.CustType_Out;
                int pID = 0, cID = 0;
                BLL.PhoneNumDataDict.GetAreaId(phone, out pID, out cID);
                model.ProvinceID = pID == 0 ? -2 : pID;
                model.CityID     = cID == 0 ? -2 : cID;
                model.CountyID   = -1;
                //废弃字段
                model.Address    = null;
                model.DataSource = null;
                model.CallTime   = null;
                model.Status     = 0;
                //基础字段
                model.CreateTime   = DateTime.Now;
                model.CreateUserID = loginuserid;
                model.ModifyTime   = null;
                model.ModifyUserID = null;
                cbid = BLL.CustBasicInfo.Instance.Insert(model);

                //插入电话信息
                Entities.CustTel model_Tel = new Entities.CustTel();
                model_Tel.CustID       = cbid;
                model_Tel.Tel          = phone;
                model_Tel.CreateTime   = DateTime.Now;
                model_Tel.CreateUserID = loginuserid;
                BLL.CustTel.Instance.Insert(model_Tel);
            }
            else
            {
                //修改( 值有效才更新 )
                Entities.CustBasicInfo model = BLL.CustBasicInfo.Instance.GetCustBasicInfo(cbid);
                if (!string.IsNullOrEmpty(pagedata.CBName_Out))
                {
                    model.CustName = pagedata.CBName_Out;
                }
                if (pagedata.CBSex_Out > 0)
                {
                    model.Sex = pagedata.CBSex_Out;
                }
                model.CustCategoryID = (int)pagedata.CustType_Out;
                //废弃字段
                model.Address    = null;
                model.DataSource = null;
                model.CallTime   = null;
                model.Status     = 0;
                //基础字段
                model.ModifyTime   = DateTime.Now;
                model.ModifyUserID = loginuserid;
                BLL.CustBasicInfo.Instance.Update(model);
            }
            //删除经销商信息(个人类型 或者 有值)
            if (!string.IsNullOrEmpty(pagedata.CBMemberName_Out) ||
                pagedata.CustType_Out == Entities.CustTypeEnum.T01_个人)
            {
                BLL.DealerInfo.Instance.Delete(cbid);
            }
            //更新经销商(经销商类型 且 有值)
            if (!string.IsNullOrEmpty(pagedata.CBMemberName_Out) &&
                pagedata.CustType_Out == Entities.CustTypeEnum.T02_经销商)
            {
                //插入经销商信息
                Entities.DealerInfo model_Dealer = new Entities.DealerInfo();
                model_Dealer.CustID       = cbid;
                model_Dealer.MemberCode   = pagedata.CBMemberCode_Out;
                model_Dealer.Name         = pagedata.CBMemberName_Out;
                model_Dealer.Status       = 0;
                model_Dealer.CreateTime   = DateTime.Now;
                model_Dealer.CreateUserID = loginuserid;
                BLL.DealerInfo.Instance.Insert(model_Dealer);
            }
            return(cbid);
        }
示例#14
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(Entities.CustTel model)
 {
     return(Dal.CustTel.Instance.Update(model));
 }
示例#15
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Insert(SqlTransaction sqltran, Entities.CustTel model)
 {
     Dal.CustTel.Instance.Insert(sqltran, model);
 }
示例#16
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Insert(Entities.CustTel model)
 {
     Dal.CustTel.Instance.Insert(model);
 }