示例#1
0
        public List<CustomerEntity> GetCustomers(EnumSearchType searchtype, int type, string sourceid, string stageid, int status, int mark, string activityid, string searchuserid, string searchteamid, string searchagentid,
                                                 string begintime, string endtime, string keyWords, string orderby, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string userid, string agentid, string clientid)
        {
            List<CustomerEntity> list = new List<CustomerEntity>();
            DataTable dt = GetCustomersDatable(searchtype, type, sourceid, stageid, status, mark, activityid, searchuserid, searchteamid, searchagentid, begintime, endtime, 
                                                                keyWords, orderby, pageSize, pageIndex, ref totalCount, ref pageCount, userid, agentid, clientid);
            foreach (DataRow dr in dt.Rows)
            {
                CustomerEntity model = new CustomerEntity();
                model.FillData(dr);

                model.Owner = OrganizationBusiness.GetUserByUserID(model.OwnerID, model.AgentID);
                model.Source = SystemBusiness.BaseBusiness.GetCustomSourcesByID(model.SourceID, model.AgentID, model.ClientID);
                model.StageStatusStr = CommonBusiness.GetEnumDesc<EnumCustomStageStatus>((EnumCustomStageStatus)model.StageStatus);
                model.City = CommonBusiness.GetCityByCode(model.CityCode);
                list.Add(model);
            }
            return list;
        }
示例#2
0
        public List<CustomerEntity> GetCustomersByActivityID(string activityid, int pageSize, int pageIndex, ref int totalCount, ref int pageCount)
        {
            List<CustomerEntity> list = new List<CustomerEntity>();
            string sqlWhere = " ActivityID='" + activityid + "' and status<>9";

            DataTable dt = CommonBusiness.GetPagerData("Customer", "*", sqlWhere, "CustomerID", pageSize, pageIndex, out totalCount, out pageCount);
            foreach (DataRow dr in dt.Rows)
            {
                CustomerEntity model = new CustomerEntity();
                model.FillData(dr);

                model.Owner = OrganizationBusiness.GetUserByUserID(model.OwnerID, model.AgentID);
                model.Source = SystemBusiness.BaseBusiness.GetCustomSourcesByID(model.SourceID, model.AgentID, model.ClientID);
                model.StageStatusStr = CommonBusiness.GetEnumDesc<EnumCustomStageStatus>((EnumCustomStageStatus)model.StageStatus);
                //model.Stage = SystemBusiness.BaseBusiness.GetCustomStageByID(model.StageID, model.AgentID, model.ClientID);
                list.Add(model);
            }
            return list;
        }
示例#3
0
 public List<CustomerEntity> GetCustomersByKeywords(string keywords, string userid,string agentid,string clientid)
 {
     List<CustomerEntity> list = new List<CustomerEntity>();
     DataSet ds = CustomDAL.BaseProvider.GetCustomersByKeywords(keywords, userid, agentid, clientid);
     foreach (DataRow dr in ds.Tables[0].Rows)
     {
         CustomerEntity model = new CustomerEntity();
         model.FillData(dr);
         model.Owner = OrganizationBusiness.GetUserByUserID(model.OwnerID, model.AgentID);
         model.Source = SystemBusiness.BaseBusiness.GetCustomSourcesByID(model.SourceID, model.AgentID, model.ClientID);
         model.StageStatusStr = CommonBusiness.GetEnumDesc<EnumCustomStageStatus>((EnumCustomStageStatus)model.StageStatus);
         //model.Stage = SystemBusiness.BaseBusiness.GetCustomStageByID(model.StageID, model.AgentID, model.ClientID);
         list.Add(model);
     }
     return list;
 }
示例#4
0
        public List<CustomerEntity> GetCustomerByOwneID(string ownerID, string agentid="", string clientid="")
        {
            int total = 0;
            List<CustomerEntity> list=new List<CustomerEntity>();
            string cloumns = " status<>9 and OwnerID='" + ownerID + "'";
            if (!string.IsNullOrEmpty(agentid))
            {
                cloumns += " and agentid='" +agentid+ "'";
            } 
            if (!string.IsNullOrEmpty(clientid))
            {
                cloumns += " and clientid='" + clientid + "'";
            }

           DataTable dt = CommonBusiness.GetPagerData("Customer", "*", cloumns, "CustomerID", int.MaxValue, 1, out total, out total);
           foreach (DataRow dr in dt.Rows)
           {
               CustomerEntity model = new CustomerEntity();
               model.FillData(dr); 
               list.Add(model);
           }
            return list;
        }
示例#5
0
        public CustomerEntity GetCustomerByID(string customerid, string agentid, string clientid)
        {
            DataSet ds = CustomDAL.BaseProvider.GetCustomerByID(customerid, agentid, clientid);
            CustomerEntity model = new CustomerEntity();
            if (ds.Tables["Customer"].Rows.Count > 0)
            {
                model.FillData(ds.Tables["Customer"].Rows[0]);
                model.Owner = OrganizationBusiness.GetUserByUserID(model.OwnerID, model.AgentID);
                model.Source = SystemBusiness.BaseBusiness.GetCustomSourcesByID(model.SourceID, model.AgentID, model.ClientID);
                model.StageStatusStr = CommonBusiness.GetEnumDesc<EnumCustomStageStatus>((EnumCustomStageStatus)model.StageStatus);

                if (model.Extent > 0)
                {
                    model.ExtentStr = GetExtents().Where(m => m.ExtentID == model.Extent.ToString()).FirstOrDefault().ExtentName;
                }

                model.City = CommonBusiness.Citys.Where(m => m.CityCode == model.CityCode).FirstOrDefault();

                model.CreateUser = OrganizationBusiness.GetUserByUserID(model.CreateUserID, model.AgentID);

                if (!string.IsNullOrEmpty(model.IndustryID))
                {
                    model.Industry = SystemBusiness.BaseBusiness.GetClientIndustryByID(model.IndustryID, model.AgentID, model.ClientID);
                }
                if (ds.Tables["Activity"].Rows.Count > 0)
                {
                    model.Activity = new ActivityEntity();
                    model.Activity.FillData(ds.Tables["Activity"].Rows[0]);
                }

                //if (ds.Tables["Contact"].Rows.Count > 0)
                //{
                //    model.Contacts = new List<ContactEntity>();
                //    foreach (DataRow dr in ds.Tables["Contact"].Rows)
                //    {
                //        ContactEntity con = new ContactEntity();
                //        con.FillData(dr);
                //        model.Contacts.Add(con);
                //    }
                    
                //}
            }
            return model;
        }
 public CustomerEntity GetCustomerByDataRow(DataRow dr ,bool isQiYe=false)
 {
     CustomerEntity customers = new CustomerEntity();
     customers.Address = dr["详细地址"].ToString();
     customers.Description = dr["描述"].ToString();
     customers.Email = dr["邮箱"].ToString();
     customers.MobilePhone = dr["联系电话"].ToString();
     customers.Jobs = dr["职位"].ToString();
     customers.ClientID = CurrentUser.ClientID;
     customers.AgentID = CurrentUser.AgentID;
     customers.CreateUserID = CurrentUser.UserID;
     customers.OwnerID = dr["是否属于我的客户"].ToString() == "是" ? CurrentUser.UserID : "";
     customers.CreateTime = DateTime.Now;
     customers.Type = dr["是否企业客户"].ToString() == "是" ? 1 : 0;
     customers.ContactName = dr["联系人"].ToString();
     customers.CustomerID = Guid.NewGuid().ToString();
     customers.CityCode = GetCityCode(dr);
     customers.Name = dr["客户名称"].ToString(); 
     ClientsIndustry industry = SystemBusiness.BaseBusiness.GetClientIndustryByName(dr["行业"].ToString(),CurrentUser.AgentID,CurrentUser.ClientID);
     customers.IndustryID = industry != null ? industry.ClientIndustryID : "";
     customers.Extent =
         (int)CommonBusiness.GetEnumindexByDesc<EnumCustomerExtend>(EnumCustomerExtend.Huge, dr["公司规模"].ToString());
     return customers;
 }
 public ActionResult CustomerImport(HttpPostedFileBase file, int overType = 0, int type=0)
 {
     if (file == null) { return Content("请选择要导入的文件"); }
     if (file.ContentLength > 2097152)
     {
         return Content("导入文件超过规定(2M )大小,请修改后再操作."); 
     }
     if (!file.FileName.Contains(".xls") && !file.FileName.Contains(".xlsx")) { return Content("文件格式类型不正确"); }
     string mes = "";
     try
     {
         DataTable dt = ImportExcelToDataTable(file);
         if (dt.Columns.Count > 0)
         {
             ///1.获取系统模版列
             var checkColumn = dt.Columns.Contains("是否企业客户");
             Dictionary<string, ExcelFormatter> dic = new Dictionary<string, ExcelFormatter>();
             Dictionary<string, ExcelModel> listColumn = GetColumnForJson("customer", ref dic, checkColumn ? "Item" : "OwnItem", "import", CurrentUser.ClientID);
             ///2.上传Excel 与模板中列是否一致 不一致返回提示
             foreach (DataColumn dc in dt.Columns)
             {
                 if (default(KeyValuePair<string, ExcelModel>).Equals(listColumn.FirstOrDefault(x => x.Value.Title == dc.ColumnName)))
                 {
                     mes += dc.ColumnName + ",";
                 }
             }
             if (!string.IsNullOrEmpty(mes))
             {
                 return Content("Excel模版与系统模版不一致,请重新下载模板,编辑后再上传.错误:缺少列 " + mes);
             } 
             ///3.开始处理
             int k = 1;
             List<CustomerEntity> list = new List<CustomerEntity>();
             List<ContactEntity> contactList = new List<ContactEntity>();
             var excelWriter = new ExcelWriter();
             foreach (DataRow dr in dt.Rows)
             {
                 try
                 {
                     if (checkColumn)
                     {
                         CustomerEntity customer = new CustomerEntity();
                         excelWriter.GetProductByDataRow(dr, listColumn, customer, dic, CurrentUser.ClientID);
                         customer.ClientID = CurrentUser.ClientID;
                         customer.AgentID = CurrentUser.AgentID;
                         customer.CreateUserID = CurrentUser.UserID;
                         customer.CreateTime = DateTime.Now;
                         customer.CustomerID = Guid.NewGuid().ToString();
                         customer.CityCode = GetCityCode(dr);
                         customer.OwnerID = customer.OwnerID.Trim() == "是" ? CurrentUser.UserID : "";
                         list.Add(customer);
                         //上面出问题的话请注释以上 使用下面
                         //list.Add(GetCustomerByDataRow(dr));
                     }
                     else
                     {
                         ContactEntity contact = new ContactEntity();
                         excelWriter.GetProductByDataRow(dr, listColumn, contact, dic, CurrentUser.ClientID);
                         contact.CityCode = GetCityCode(dr);
                         contact.ClientID = CurrentUser.ClientID;
                         contact.AgentID = CurrentUser.AgentID;
                         contact.CreateUserID = CurrentUser.UserID;
                         contact.OwnerID = CurrentUser.UserID;
                         contact.CustomerID = ""; 
                         contact.CreateTime = DateTime.Now;
                         contact.Type = 0;
                         contact.ContactID = Guid.NewGuid().ToString();
                         contactList.Add(contact);
                         //contactList.Add( GetContactByDataRow(dr, checkColumn));
                     }
                 }
                 catch (Exception ex)
                 {
                     mes += k +" 原因:"+ex.Message+ ",";
                 }
             }
             try
             {
                 if (list.Count > 0) ExcelImportBusiness.InsertCustomer(list, type, overType);
                 if (contactList.Count > 0) ExcelImportBusiness.InsertContact(contactList, type, overType);
             }
             catch (Exception ex)
             {
                 return Content("系统异常:请联系管理员,错误原因" + ex.Message);
             }
         }
         if (!string.IsNullOrEmpty(mes))
         {
             return Content("部分数据未导入成功,Excel行位置" + mes);
         }
     }
     catch (Exception ex)
     {
         return Content("系统异常:请联系管理员,错误原因:" + ex.Message.ToString());
     }
     return Content("操作成功");
 }
示例#8
0
        public List<CustomerEntity> GetCustomers(EnumSearchType searchtype, int type, string sourceid, string stageid, int status, int mark, string activityid, string searchuserid, string searchteamid, string searchagentid,
                                                 string begintime, string endtime, string keyWords, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string userid, string agentid, string clientid)
        {
            List<CustomerEntity> list = new List<CustomerEntity>();
            DataSet ds = CustomDAL.BaseProvider.GetCustomers((int)searchtype, type, sourceid, stageid, status, mark, activityid, searchuserid, searchteamid, searchagentid, begintime, endtime, keyWords, pageSize, pageIndex, ref totalCount, ref pageCount, userid, agentid, clientid);
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                CustomerEntity model = new CustomerEntity();
                model.FillData(dr);

                model.Owner = OrganizationBusiness.GetUserByUserID(model.OwnerID, model.AgentID);
                model.Source = SystemBusiness.BaseBusiness.GetCustomSourcesByID(model.SourceID, model.AgentID, model.ClientID);
                model.Stage = SystemBusiness.BaseBusiness.GetCustomStageByID(model.StageID, model.AgentID, model.ClientID);
                list.Add(model);
            }
            return list;
        }