public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            currentContext = context;
            BitAuto.YanFa.SysRightManager.Common.UserInfo.Check();
            //添加用户信息
            if (context.Request.QueryString["add"] != null && context.Request.QueryString["add"] == "yes")
            {
                BitAuto.YanFa.Crm2009.Entities.ContactInfo model = new BitAuto.YanFa.Crm2009.Entities.ContactInfo();
                model.PID            = Convert.ToInt32(RequestPid);
                model.CustID         = RequestCustID;
                model.CName          = RequestCName;
                model.EName          = RequestEName;
                model.Sex            = RequestSex;
                model.DepartMent     = RequestDepartMent;
                model.OfficeTypeCode = int.Parse(RequestOfficeTypeCode.Trim());
                model.Title          = RequestTitle;
                model.OfficeTel      = RequestOfficeTel;
                model.Phone          = RequestPhone;
                model.Email          = RequestEmail;
                model.Fax            = RequestFax;
                model.Remark         = RequestReamrk;
                model.CreateTime     = DateTime.Now;
                model.Status         = 0;
                model.Address        = RequestAddress;
                model.ZipCode        = RequestZipCode;
                model.MSN            = RequestMsn;
                model.Birthday       = RequestBirthday;
                model.Hobby          = Hobby;
                model.Responsible    = Responsible;
                model.CreateUserID   = BLL.Util.GetLoginUserID();

                int contactID = BitAuto.YanFa.Crm2009.BLL.ContactInfo.Instance.InsertContactInfo(model);
                if (contactID > 0)
                {
                    int userid = model.CreateUserID;
                    //插入CC添加联系人记录日志
                    BLL.ProjectTask_ReturnVisit.Instance.InsertCCAddCRMContractLogForRV(contactID, userid);

                    //



                    message = "Add:'yes'";
                    AddContactUserMapping(contactID);

                    //负责会员处理(按顺序执行)
                    YesSelectMemberHandle(contactID);
                    NotSelectMemberHandle(contactID);
                    YesSelectMainHandle(contactID);
                    NotSelectMainHandle(contactID);
                    //添加日志记录 BY cheng ON 2011-08-12
                    string content = string.Format("为【{0}(ID:{1})】添加联系人【{2}】成功。", BitAuto.YanFa.Crm2009.BLL.AllCusts.Instance.GetCustName(model.CustID), model.CustID, model.CName);
                    BitAuto.YanFa.SysRightManager.Common.LogInfo.Instance.InsertLog(BitAuto.YanFa.Crm2009.BLL.LogModule.ContactInfo, (int)BitAuto.YanFa.SysRightManager.Common.LogInfo.ActionType.Add, content);
                    message = "Add:'yes',Edit:'no'";
                }
                else
                {
                    message = "Add:'no'";
                }
                context.Response.Write("{" + message + "}");
                context.Response.End();
            }
            //编辑用户信息
            else if (context.Request.QueryString["edit"] != null && context.Request.QueryString["edit"] == "yes")
            {
                BitAuto.YanFa.Crm2009.Entities.ContactInfo model = BitAuto.YanFa.Crm2009.BLL.ContactInfo.Instance.GetContactInfoByUserID(RequestID);
                if (model != null)
                {
                    model.PID        = Convert.ToInt32(RequestPid);
                    model.CName      = RequestCName;
                    model.EName      = RequestEName;
                    model.Sex        = RequestSex;
                    model.DepartMent = RequestDepartMent;
                    int typecode = 0;
                    Int32.TryParse(RequestOfficeTypeCode, out typecode);
                    model.OfficeTypeCode = typecode;
                    model.Title          = RequestTitle;
                    model.OfficeTel      = RequestOfficeTel;
                    model.Phone          = RequestPhone;
                    model.Email          = RequestEmail;
                    model.Fax            = RequestFax;
                    model.Remark         = RequestReamrk;
                    model.Address        = RequestAddress;
                    model.ZipCode        = RequestZipCode;
                    model.MSN            = RequestMsn;
                    model.Birthday       = RequestBirthday;

                    model.Hobby        = Hobby;
                    model.Responsible  = Responsible;
                    model.ModifyTime   = DateTime.Now;
                    model.ModifyUserID = BLL.Util.GetLoginUserID();

                    //添加日志记录 BY cheng ON 2011-08-12
                    string content = BitAuto.YanFa.Crm2009.BLL.ContactInfo.Instance.GetUpdateContent(model, "{0}由【{1}】修改为【{2}】", ',');

                    if (BitAuto.YanFa.Crm2009.BLL.ContactInfo.Instance.UpdateContactInfo(model) > 0)
                    {
                        message = "Add:'yes'";

                        EditContactUserMapping(model.ID);

                        //负责会员处理(按顺序执行)
                        YesSelectMemberHandle(RequestID);
                        NotSelectMemberHandle(RequestID);
                        YesSelectMainHandle(RequestID);
                        NotSelectMainHandle(RequestID);

                        try
                        {
                            content = string.Format("为【{0}(ID:{1})】修改联系人【{2}】:{3}。",
                                                    BitAuto.YanFa.Crm2009.BLL.AllCusts.Instance.GetCustName(model.CustID), model.CustID, model.CName, content);
                            BitAuto.YanFa.SysRightManager.Common.LogInfo.Instance.InsertLog(BitAuto.YanFa.Crm2009.BLL.LogModule.ContactInfo, (int)BitAuto.YanFa.SysRightManager.Common.LogInfo.ActionType.Update, content);
                            message = "Add:'yes',Edit:'yes'";
                        }
                        catch (Exception ex)
                        {
                            message = ex.Message;
                        }
                    }
                    else
                    {
                        message = "Add:'no'";
                    }
                }
                else
                {
                    message = "Add:'no'";
                }
                context.Response.Write("{" + message + "}");
                context.Response.End();
            }
            //获取一条记录
            else if (context.Request.QueryString["show"] != null && context.Request.QueryString["show"] == "yes")
            {
                BitAuto.YanFa.Crm2009.Entities.ContactInfo model = BitAuto.YanFa.Crm2009.BLL.ContactInfo.Instance.GetContactInfoByUserID(RequestID);
                if (model != null)
                {
                    model.CreateUserTrueName = GetUserInfoTrueName(model.CreateUserID);
                    model.CreateTimeFormat   = string.Format("{0:yyyy-MM-dd}", model.CreateTime);
                    model.ModifyUserTrueName = GetUserInfoTrueName(model.ModifyUserID);
                    model.ModifyTimeFormat   = string.Format("{0:yyyy-MM-dd}", model.ModifyTime);


                    string  strwhere = " ContactID = '" + model.ID.ToString() + "' and Status=0 ";
                    DataSet dstSet   = BitAuto.YanFa.Crm2009.BLL.ContactUserMapping.Instance.GetList(strwhere);
                    for (int i = 0; i < dstSet.Tables[0].Rows.Count; i++)
                    {
                        model.ContactUserS     += GetTrueName(dstSet.Tables[0].Rows[i]["UserID"].ToString()) + ",";
                        model.hid_ContactUserS += dstSet.Tables[0].Rows[i]["UserID"] + ",";
                    }
                    result  = JavaScriptConvert.SerializeObject(model);
                    message = "yes";
                }
                else
                {
                    success = false;
                    message = "no";
                }
                AJAXHelper.WrapJsonResponse(success, result, message);
            }
            //删除一条记录
            else if (context.Request["action"] != null && context.Request["action"] == "DeleteContact")
            {
                BitAuto.YanFa.Crm2009.Entities.ContactInfo contact = BitAuto.YanFa.Crm2009.BLL.ContactInfo.Instance.GetContactInfoByUserID(RequestID);
                if (contact != null)
                {
                    //删除CC添加联系人记录日志
                    BLL.ProjectTask_ReturnVisit.Instance.DeleteCCAddCRMContractLogForRV(RequestID);

                    //


                    BitAuto.YanFa.Crm2009.BLL.ContactUserMapping.Instance.DeleteByContactID(contact.ID);
                    //删除会员联系人关联关系
                    BitAuto.YanFa.Crm2009.BLL.MemberContactMapping.Instance.DeleteByContactID(contact.ID);
                    if (BitAuto.YanFa.Crm2009.BLL.ContactInfo.Instance.Delete(RequestID) > 0)
                    {
                        message = "yes";//成功
                        //添加日志记录 BY cheng ON 2011-08-12
                        string content = string.Format("为【{0}(ID:{1})】删除联系人【{2}】。", BitAuto.YanFa.Crm2009.BLL.AllCusts.Instance.GetCustName(contact.CustID), contact.CustID, contact.CName);
                        BitAuto.YanFa.SysRightManager.Common.LogInfo.Instance.InsertLog(BitAuto.YanFa.Crm2009.BLL.LogModule.ContactInfo, (int)BitAuto.YanFa.SysRightManager.Common.LogInfo.ActionType.Delete, content);
                    }
                    else
                    {
                        success = false;
                        message = "no";//失败
                    }
                }

                AJAXHelper.WrapJsonResponse(success, result, message);
            }
            //通过CustID获取获取直接上级
            else if ((context.Request["action"] + "").Trim() == "DropDownListPID")
            {
                StringBuilder sb = new StringBuilder();
                DataTable     dt = BitAuto.YanFa.Crm2009.BLL.ContactInfo.Instance.GetContactInfoPID(RequestCustID);
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        sb.Append("{'ID':'" + dr["ID"] + "','Name':'" + dr["CName"] + "'},");
                    }
                    message = sb.ToString().TrimEnd(",".ToCharArray());
                }
                else
                {
                    message = sb.ToString();
                }
                context.Response.Write("[" + message + "]");
                context.Response.End();
            }
            //通过CustID获取获取直接上级
            else if ((context.Request["action"] + "").Trim() == "BindContactDepartment")
            {
                string        strWhere   = "";
                string        filedOrder = "";
                StringBuilder sb         = new StringBuilder();
                if ((context.Request["type"] + "").Trim() == "friend")
                {
                    FriendInfo model = BitAuto.YanFa.Crm2009.BLL.FriendInfo.Instance.GetFriendInfo(context.Request["CustID"]);

                    if (context.Request["CustID"] != "0")
                    {
                        if (model != null)
                        {
                            strWhere   = "TypeID='" + model.FriendCategoryID + "'";
                            filedOrder = " sort asc";

                            if (model.FriendCategoryID.Trim() == "")
                            {
                                sb.Append("{'ID':'1','Name':'error'},");
                            }
                        }
                        else
                        {
                            strWhere = "lb='0'";
                        }
                    }
                    else
                    {
                        strWhere = "lb='0'";
                    }
                }
                else if ((context.Request["type"] + "").Trim() == "customer")
                {
                    BitAuto.YanFa.Crm2009.Entities.CustInfo model = BitAuto.YanFa.Crm2009.BLL.CustInfo.Instance.GetCustInfo(context.Request["CustID"]);
                    if (context.Request["CustID"] != "0")
                    {
                        if (model != null)
                        {
                            strWhere   = "TypeID='" + model.TypeID + "'";
                            filedOrder = " sort asc";

                            if (model.TypeID.Trim() == "")
                            {
                                sb.Append("{'ID':'0','Name':'error'},");
                            }
                        }
                        else
                        {
                            strWhere = "lb='1'";
                        }
                    }
                    else
                    {
                        strWhere = "lb='1'";
                    }
                }

                DataSet dt = BitAuto.YanFa.Crm2009.BLL.ContactUserDepartment.Instance.GetList(-1, strWhere, filedOrder);
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Tables[0].Rows)
                    {
                        sb.Append("{'ID':'" + dr["DepartmentID"] + "','Name':'" + dr["DepartmentName"] + "'},");
                    }
                    message = sb.ToString().TrimEnd(",".ToCharArray());
                }
                else
                {
                    message = sb.ToString();
                }
                context.Response.Write("[" + message + "]");
                context.Response.End();
            }
            else if ((context.Request["showContactInfo"] + "").Trim() == "yes")
            {
                StringBuilder    sb = new StringBuilder();
                QueryContactInfo queryContactInfo = new QueryContactInfo();
                queryContactInfo.CustID = RequestCustID;
                int       o;
                DataTable dt = BitAuto.YanFa.Crm2009.BLL.ContactInfo.Instance.GetContactInfo(queryContactInfo, "", 1, 10000, out o);
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        string tel = "";
                        if (dr["Phone"] != DBNull.Value)
                        {
                            tel += dr["Phone"].ToString().Trim() + ",";
                        }
                        if (dr["OfficeTel"] != DBNull.Value)
                        {
                            tel += dr["OfficeTel"].ToString().Trim() + ",";
                        }
                        sb.Append("{'ID':'" + dr["ID"] + "','Name':'" + dr["CName"] + "','Tel':'" + tel.Trim(',') + "'},");
                    }
                    message = sb.ToString().TrimEnd(",".ToCharArray());
                }
                else
                {
                    message = sb.ToString();
                }
                context.Response.Write("[" + message + "]");
                context.Response.End();
            }
            else if ((context.Request["showContactInfobycustid"] + "").Trim() == "yes")
            {
                StringBuilder sb = new StringBuilder();
                DataTable     dt = BitAuto.YanFa.Crm2009.BLL.ContactInfo.Instance.GetContactInfoByCustID(RequestCustID);
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        string tel = "";
                        if (dr["Phone"] != DBNull.Value)
                        {
                            tel += dr["Phone"].ToString().Trim() + ",";
                        }
                        if (dr["OfficeTel"] != DBNull.Value)
                        {
                            tel += dr["OfficeTel"].ToString().Trim() + ",";
                        }
                        sb.Append("{'ID':'" + dr["ID"] + "','Name':'" + dr["CName"] + "','Tel':'" + tel.Trim(',') + "','DepartMent':'" + dr["DepartMent"] + "'},");
                    }
                    message = sb.ToString().TrimEnd(",".ToCharArray());
                }
                else
                {
                    message = sb.ToString();
                }
                context.Response.Write("[" + message + "]");
                context.Response.End();
            }
            else if (context.Request["action"].Trim() == "getmember")
            {
                message = GetMappingMember();
                context.Response.Write(message);
                context.Response.End();
            }
            else if (context.Request["action"].Trim() == "ishasmanager")
            {
                message = GetManageContactInfo();
                context.Response.Write(message);
                context.Response.End();
            }
            else
            {
                success = false;
                message = "request error";
                AJAXHelper.WrapJsonResponse(success, result, message);
            }
        }
Exemple #2
0
        private void BindCustomerInfo()
        {
            if (this.CustInfo != null)
            {
                this.CustID = this.CustInfo.CustID;

                spanCustName.InnerText = this.CustInfo.CustName;
                spanAbbrName.InnerText = this.CustInfo.AbbrName;
                spanAddress.InnerText  = this.CustInfo.Address;
                if (!string.IsNullOrEmpty(CustInfo.CreateTime))
                {
                    spanCreateTime.InnerText = CustInfo.CreateTime;
                }
                spanCreateUserName.InnerText = BitAuto.YanFa.SysRightManager.Common.UserInfo.GerTrueName(CustInfo.CreateUserID);
                if (!string.IsNullOrEmpty(CustInfo.LastUpdateTime))
                {
                    spanModifyTime.InnerText = CustInfo.LastUpdateTime;
                }
                spanModifyUserName.InnerText = BitAuto.YanFa.SysRightManager.Common.UserInfo.GerTrueName(CustInfo.LastUpdateUserID);

                BitAuto.YanFa.Crm2009.Entities.QueryBrandInfo queryBrandInfo = new BitAuto.YanFa.Crm2009.Entities.QueryBrandInfo();
                queryBrandInfo.CustID = this.CustInfo.CustID;
                int       o;
                string    s  = "";
                DataTable dt = BitAuto.YanFa.Crm2009.BLL.CarBrand.Instance.GetCustBrandInfo(queryBrandInfo, "", 1, 10000, out o);
                if (dt != null && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        s += dt.Rows[i]["name"] + " ";
                    }
                }
                spanBrand.InnerText        = s;
                spanCarType.InnerText      = BLL.Util.GetCustCatTypeName(this.CustInfo.CarType);
                spanContractName.InnerText = this.CustInfo.contactName;
                spanFax.InnerText          = this.CustInfo.Fax;
                if (!string.IsNullOrEmpty(this.CustInfo.IndustryID))
                {
                    spanIndustry.InnerText = BitAuto.YanFa.Crm2009.BLL.Util.GetEnumOptText(Convert.ToInt32(this.CustInfo.IndustryID));
                }
                if (!string.IsNullOrEmpty(this.CustInfo.LevelID))
                {
                    spanLevel.InnerText = BitAuto.YanFa.Crm2009.BLL.Util.GetEnumOptText(Convert.ToInt32(this.CustInfo.LevelID));
                }

                // 集团 厂商 没有 [所属集团 所属厂商]; 没有新增会员按钮
                if (this.CustInfo.TypeID == ((int)BitAuto.YanFa.Crm2009.Entities.EnumCustomType.Company).ToString() || this.CustInfo.TypeID == ((int)BitAuto.YanFa.Crm2009.Entities.EnumCustomType.Bloc).ToString())
                {
                    liPid.Visible     = false;
                    liCustPid.Visible = false;
                }
                else
                {
                    if (this.CustInfo.TypeID == ((int)BitAuto.YanFa.Crm2009.Entities.EnumCustomType.SynthesizedShop).ToString())
                    {
                        liCustPid.Visible = false;
                        //综合店 没有厂商
                    }
                    if (CustInfo.TypeID == ((int)BitAuto.YanFa.Crm2009.Entities.EnumCustomType.Licence).ToString())
                    {
                        liFourS.Visible = true;
                        if (!string.IsNullOrEmpty(CustInfo.FoursPid))
                        {
                            BitAuto.YanFa.Crm2009.Entities.CustInfo pmodel = BitAuto.YanFa.Crm2009.BLL.CustInfo.Instance.GetCustInfo(CustInfo.FoursPid);
                            if (pmodel != null)
                            {
                                spanFourPidName.InnerText = pmodel.CustName;
                            }
                        }
                    }
                }

                spanLicenseNumber.InnerText = this.CustInfo.LicenseNumber;
                //spanAS.InnerText = this.CustInfo.BLAnnualSurvey == 0 ? "未知" : (this.CustInfo.BLAnnualSurvey == 1 ? "通过" : "未通过");
                this.BLAnnualSurvey = this.CustInfo.BLAnnualSurvey.ToString();
                //信用等级
                this.StarLevel = this.CustInfo.StarLevel;


                spanNotes.InnerText     = this.CustInfo.Notes;
                spanOfficeTel.InnerText = this.CustInfo.Officetel;
                if (!string.IsNullOrEmpty(this.CustInfo.Pid))
                {
                    BitAuto.YanFa.Crm2009.Entities.CustInfo pmodel = BitAuto.YanFa.Crm2009.BLL.CustInfo.Instance.GetCustInfo(this.CustInfo.Pid);
                    if (pmodel != null)
                    {
                        spanPid.InnerText = pmodel.CustName;
                    }
                }
                if (!string.IsNullOrEmpty(this.CustInfo.CustPid))
                {
                    BitAuto.YanFa.Crm2009.Entities.CustInfo pmodel = BitAuto.YanFa.Crm2009.BLL.CustInfo.Instance.GetCustInfo(this.CustInfo.CustPid);
                    if (pmodel != null)
                    {
                        spanCustPid.InnerText = pmodel.CustName;
                    }
                }
                //if (!string.IsNullOrEmpty(model.ProducerID) && model.ProducerID != "-1")
                //{
                //    Entities.ProducerInfo producerInfo = BLL.ProducerInfo.Instance.GetProducerInfo(model.ProducerID);
                //    if (model != null)
                //    {
                //        spanProducer.InnerText = producerInfo.ChinaName;
                //    }
                //}
                string provinceCity = "";
                if (!string.IsNullOrEmpty(this.CustInfo.ProvinceID))
                {
                    provinceCity += BitAuto.YanFa.Crm2009.BLL.MainBrand.Instance.GetAreaName(this.CustInfo.ProvinceID);
                }
                if (!string.IsNullOrEmpty(this.CustInfo.CityID))
                {
                    provinceCity += " " + BitAuto.YanFa.Crm2009.BLL.MainBrand.Instance.GetAreaName(this.CustInfo.CityID);
                }
                if (!string.IsNullOrEmpty(this.CustInfo.CountyID))
                {
                    provinceCity += " " + BitAuto.YanFa.Crm2009.BLL.MainBrand.Instance.GetAreaName(this.CustInfo.CountyID);
                }
                spanProvinceCity.InnerText = provinceCity;
                //if (!string.IsNullOrEmpty(model.SaleOrgID) && model.SaleOrgID != "-1")
                //{
                //    Entities.SalesNetwork salesNetwork = BLL.SalesNetwork.Instance.GetSalesNetwork(model.SaleOrgID);
                //    if (model != null)
                //    {
                //        spanSaleNetwork.InnerText = salesNetwork.SnName;
                //    }
                //}
                if (!string.IsNullOrEmpty(this.CustInfo.ShopLevel))
                {
                    spanShopLevel.InnerText = BitAuto.YanFa.Crm2009.BLL.Util.GetEnumOptText(Convert.ToInt32(this.CustInfo.ShopLevel));
                }
                if (!string.IsNullOrEmpty(this.CustInfo.TypeID))
                {
                    spanType.InnerText = BitAuto.YanFa.Crm2009.BLL.Util.GetEnumOptText(Convert.ToInt32(this.CustInfo.TypeID));
                }
                spanZipCode.InnerText = this.CustInfo.zipcode;

                if (this.CustInfo.Lock == 1)
                {
                    //spanLock.InnerText = "是";
                    spanLock.Style["display"] = "block";
                }
                else
                {
                    //spanLock.InnerText = "否";
                    spanLock.Style["display"] = "none";
                }
                if (this.CustInfo.Status == 0)
                {
                    //spanStatus.InnerText = "在用";
                    spanStatus.Style["display"] = "none";
                }
                else
                {
                    //spanStatus.InnerText = "停用";
                    spanStatus.Style["display"] = "block";
                }
                //二手车经营类型 置换型:1;零售型:2
                if (custInfo.UsedCarBusinessType == "1")
                {
                    spanUsedCarBusiness.InnerText = "置换型";
                }
                else if (custInfo.UsedCarBusinessType == "2")
                {
                    spanUsedCarBusiness.InnerText = "零售型";
                }

                //所属交易市场
                if (!string.IsNullOrEmpty(custInfo.TradeMarketID))
                {
                    BitAuto.YanFa.Crm2009.Entities.CustInfo custinfo = BitAuto.YanFa.Crm2009.BLL.CustInfo.Instance.GetCustInfo(custInfo.TradeMarketID.ToString());
                    if (custinfo != null)
                    {
                        spanTradeMarketID.InnerText = custinfo.CustName;
                    }
                }

                #region Modify=masj,Date=2012-04-13 注释掉
                ////车商通会员ID
                //Crm2009.Entities.QueryCstMember queryCstMember = new Crm2009.Entities.QueryCstMember();
                //queryCstMember.CustID = custInfo.CustID;
                //queryCstMember.Status = 0;

                //DataTable dtCstMember = Crm2009.BLL.CstMember.Instance.GetTable(queryCstMember);
                //string[] strCstMemberID = new string[dtCstMember.Rows.Count];
                ////ArrayList arr_cstMember = new ArrayList();

                //for (int k = 0; k < dtCstMember.Rows.Count; k++)
                //{
                //    strCstMemberID[k]=dtCstMember.Rows[k]["CstMemberID"].ToString();
                //}
                //if (strCstMemberID != null)
                //{
                //    spanCstMemberID.InnerHtml = "";
                //    for (int k = 0; k < strCstMemberID.Length; k++)
                //    {
                //        spanCstMemberID.InnerHtml += "<a href='/CustCheck/CSTMember/CSTMemberInfo.aspx?CSTMemberID=" + strCstMemberID[k] + "' target='_blank'>" + strCstMemberID[k] + "</a>";
                //        if (k != strCstMemberID.Length - 1)
                //        {
                //            spanCstMemberID.InnerHtml += ",";
                //        }
                //    }
                //}
                #endregion
            }
        }
        private bool CheckDataImported(string fileName, string filePath, out string msg)
        {
            bool checkData = true;//验证数据正确性

            msg = "导入出错,请重新导入!";
            //(1)连接EXCEL文件
            string ext     = Path.GetExtension(fileName);
            string connStr = string.Empty;

            if (ext.ToLower() == ".xls")
            {
                connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @fileName + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";
            }
            else
            {
                throw new Exception("上传文件应为xls格式的文件");
            }
            //(2)读取校验数据
            Dictionary <string, ReturnVisitData> dictCust = new Dictionary <string, ReturnVisitData>(); //key 为客户ID, value为(客服ID,客户ID,工号)
            bool isExistYYKF        = false;                                                            //数据中存在运营客服 默认没有
            bool isExistsCustMember = false;                                                            //客户存在新车负责客服  默认没有

            DataSet ds = new DataSet();

            try
            {
                using (OleDbConnection conn = new OleDbConnection(connStr))
                {
                    conn.Open();

                    //返回Excel的架构,包括各个sheet表的名称,类型,创建时间和修改时间等
                    DataTable dtSheetName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "Table" });
                    //包含excel中表名的字符串数组
                    string firstSheetName = dtSheetName.Rows[0]["TABLE_NAME"].ToString();
                    //读取第一个sheet填充数据sheetConfig.Name.Replace(".", "#") + "$"
                    OleDbCommand     command = new OleDbCommand("select * from [" + firstSheetName.Replace(".", "#") + "]", conn);
                    OleDbDataAdapter odda    = new OleDbDataAdapter(command);
                    odda.Fill(ds);
                }
                if (ds.Tables[0].Rows.Count > 1000 || ds.Tables[0].Rows.Count == 0)
                {
                    msg = "数据行数必须大于0小于1000!";
                    return(false);
                }
                int rowNum       = 1;
                int startReadRow = 0;

                foreach (DataRow idr in ds.Tables[0].Rows)
                {
                    if (idr[0].ToString().Trim().Contains("客户ID"))
                    {
                        startReadRow = rowNum;
                    }
                    if (rowNum > startReadRow)
                    {
                        ++rowNum;
                        string agentNum = idr[1].ToString(); //工号
                        string custid   = idr[0].ToString(); //客户id
                        custid = Regex.Replace(custid, @"\D*", "");
                        if (string.IsNullOrEmpty(custid) || string.IsNullOrEmpty(agentNum))
                        {
                            msg       = "导入失败,第" + rowNum + "行客户ID或工号不可为空!";
                            checkData = false;
                            break;
                        }
                        BitAuto.YanFa.Crm2009.Entities.CustInfo custModel = BitAuto.YanFa.Crm2009.BLL.CustInfo.Instance.GetCustInfo(custid);

                        if (custModel == null)
                        {
                            msg       = "导入失败,第" + rowNum + "行数据的客户ID不存在!";
                            checkData = false;
                            break;
                        }
                        if (!dictCust.ContainsKey(custid))
                        {
                            DataTable dt = BLL.EmployeeAgent.Instance.GetEmployeeAgentsByAgentNum(agentNum);//根据工号获得userid
                            if (dt.Rows.Count == 0)
                            {
                                msg       = "导入失败,第" + rowNum + "行数据的客服工号不存在!";
                                checkData = false;
                                break;
                            }
                            else
                            {
                                dictCust.Add(custid, new ReturnVisitData()
                                {
                                    crmCustID = custid, AgentNum = agentNum, UserID = BitAuto.ISDC.CC2012.Entities.CommonFunction.ObjectToInteger(dt.Rows[0][0])
                                });
                            }
                        }
                        else
                        {
                            msg       = "导入失败,第" + rowNum + "数据中存在相同客户ID!";
                            checkData = false;
                            break;
                        }
                    }
                }
                if (checkData)
                {
                    int row = 0;

                    foreach (KeyValuePair <string, ReturnVisitData> item in dictCust)
                    {
                        row++;
                        bool isYYKF = BLL.ProjectTask_ReturnVisit.Instance.IsYYKF(item.Value.UserID);//是运行客服
                        if (isYYKF)
                        {
                            isExistYYKF = true;
                            // bool existFlag = BLL.EmployeeAgent.Instance.GetEmployeeAgentsByAgentNumBussniess(item.Key);
                            bool ExistsCustMember = BLL.ProjectTask_ReturnVisit.Instance.IsExistsCustMember(item.Value.UserID, "'" + item.Key + "'");
                            if (ExistsCustMember)//客户已存在新车负责客服
                            {
                                isExistsCustMember = true;
                                msg       = "custidexists";
                                checkData = false;
                                break;
                            }
                        }
                    }
                    if (!isExistYYKF)//不存在运营客服 直接导入 FF浏览器CC使用直接导入有问题
                    {
                        msg       = "onlyupload";
                        checkData = false;
                        //  DealDataImported(fileName, false);
                    }
                    else if (isExistYYKF && !isExistsCustMember)//存在运营客服,切不存在新车负责客服 即修改
                    {
                        msg       = "editupload";
                        checkData = false;
                        //DealDataImported(fileName, true);
                    }
                }
                else//文件校验失败 直接删除
                {
                    Directory.Delete(filePath, true);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                msg = "分配失败!";
                Directory.Delete(filePath, true);
                checkData = false;
            }
            return(checkData);
        }