| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708 |
- using CallCenter.Utility;
- using CallCenterApi.Interface.Controllers.Base;
- using CallCenterApi.Interface.Models.Input;
- using Newtonsoft.Json;
- using NPOI.HSSF.UserModel;
- using NPOI.SS.UserModel;
- using NPOI.XSSF.UserModel;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.IO;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace CallCenterApi.Interface.Controllers.customer
- {
- public class CustomerNewController : BaseController
- {
- BLL.T_Cus_CustomerBaseNew cusbll = new BLL.T_Cus_CustomerBaseNew();
- BLL.T_Cus_ContactPersonNew conbll = new BLL.T_Cus_ContactPersonNew();
- BLL.T_Sys_Department deptbll = new BLL.T_Sys_Department();
- /// <summary>
- /// 获取客户列表
- /// </summary>
- /// <param name="code">客户编号</param>
- /// <param name="cmpname">公司名称</param>
- /// <param name="cmpaddress">公司地址</param>
- /// <param name="legname">法人姓名</param>
- /// <param name="legtel">法人电话</param>
- /// <param name="subtrade">所属行业</param>
- /// <param name="layer">客户信誉等级</param>
- /// <param name="bedept">客户归属部门</param>
- /// <param name="bereladd">客户归属涉税会计</param>
- /// <param name="beaudacc">客户归属审核会计</param>
- /// <param name="bemakeacc">客户归属做账会计</param>
- /// <param name="conname">联系人姓名</param>
- /// <param name="contel">联系人电话</param>
- /// <returns></returns>
- public ActionResult GetList(string keywords, string code, string cmpname, string cmpaddress,
- string legname, string legtel, string subtrade, string layer, string bedept,
- string berelacc, string beaudacc, string bemakeacc, string conname, string contel,
- int pageindex = 1, int pagesize = 10)
- {
- string sql = "";
- DataTable dt = new DataTable();
- #region 筛选条件
- if (!string.IsNullOrWhiteSpace(keywords))//关键字搜索
- sql += $" and F_KeyWords like '%" + keywords.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(code))//客户编号
- sql += $" and F_CustomerCode like '%" + code.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(cmpname))//公司名称
- sql += $" and F_KeyWords like '%" + cmpname.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(cmpaddress))//公司地址
- sql += $" and F_CompanyAddress like '%" + cmpaddress.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(legname))//法人姓名
- sql += $" and F_LegalName like '%" + legname.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(legtel))//法人电话
- sql += $" and F_LegalTel like '%" + legtel.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(subtrade))//所属行业
- sql += $" and isnull(F_SubTrade,'') = '" + subtrade.Trim() + "'";
- if (!string.IsNullOrWhiteSpace(layer))//客户信誉等级
- sql += $" and isnull(F_Layer,'') = '" + layer.Trim() + "'";
- if (!string.IsNullOrWhiteSpace(bedept))//客户所属部门
- sql += $" and isnull(F_BeDept,'') = '" + bedept.Trim() + "'";
- if (!string.IsNullOrWhiteSpace(berelacc))//涉税会计
- sql += $" and F_BeRelatedAcc like '%" + berelacc.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(beaudacc))//审核会计
- sql += $" and F_BeAuditAcc like '%" + beaudacc.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(bemakeacc))//做账会计
- sql += $" and F_BeMakeAcc like '%" + bemakeacc.Trim() + "%'";
- if (!string.IsNullOrWhiteSpace(conname) || !string.IsNullOrWhiteSpace(contel))
- {
- var sqlcon = " where F_DeleteFlag=0 ";
- if (!string.IsNullOrWhiteSpace(conname)) // 联系人
- sqlcon += " and F_Name like '%" + conname + "%'";
- if (!string.IsNullOrWhiteSpace(contel)) //联系人电话
- sqlcon += " and F_Telephone like '%" + contel + "%'";
- sql += $" and F_CustomerId in (select F_CustomerId from T_Cus_ContactPersonNew " + sqlcon + " )";
- }
- #endregion
- int recordCount = 0;
- if (!string.IsNullOrWhiteSpace(sql))
- {
- sql += " and F_DeleteFlag=0";
- dt = BLL.PagerBLL.GetListPager(
- "T_Cus_CustomerBaseNew",
- "F_CustomerId",
- "*,dbo.GetDeptName(F_BeDept) as F_BeDeptName",
- sql,
- "ORDER BY F_CustomerId desc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- #region
- dt.Columns.Add("F_Contact");
- var dept = new BLL.T_Sys_Department().GetModelList("");
- foreach (DataRow dr in dt.Rows)
- {
- #region 绑定联系人信息
- var contact = "";
- string cusid = dr["F_CustomerId"] != null ? dr["F_CustomerId"].ToString() : "";
- if (cusid != "")
- {
- var conlist = conbll.GetModelList(" F_CustomerId=" + cusid);
- if (conlist.Count > 0)
- {
- foreach (var item in conlist)
- {
- contact += item.F_Name + "(" + item.F_Telephone + "),";
- }
- }
- dr["F_Contact"] = contact.TrimEnd(',');
- }
- #endregion
- }
- #endregion
- }
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 根据关键字搜索公司
- /// </summary>
- public ActionResult GetListByKey(string keywords)
- {
- string sql = "";
- if (!string.IsNullOrWhiteSpace(keywords))//关键字搜索
- sql += $" F_KeyWords like '%" + keywords.Trim() + "%'";
- var list = new List<Model.T_Cus_CustomerBaseNew>();
- if (!string.IsNullOrWhiteSpace(sql))
- {
- sql += " and F_DeleteFlag=0";
- list = cusbll.GetModelList(sql);
- }
- if (list.Count > 0)
- return Success("根据关键字获取公司信息", list.FirstOrDefault());
- else
- return Error("没有获取到相关公司,请重新搜索");
- }
- /// <summary>
- /// 获取客户信息
- /// </summary>
- /// <returns></returns>
- public ActionResult GetCustomer(int cusid)
- {
- if (cusid != 0)
- {
- Model.T_Cus_CustomerBaseNew userModel = cusbll.GetModel(cusid);
- if (userModel != null)
- {
- #region 绑定部门
- var deptname = "";
- var deptmodel = deptbll.GetModel(userModel.F_BeDept.Value);
- if (deptmodel != null)
- deptname = deptmodel.F_DeptName;
- #endregion
- var conlist = conbll.GetModelList(" F_DeleteFlag=0 and F_CustomerId=" + cusid);
- var obj = new
- {
- CustomerBase = userModel,
- BeDeptName = deptname,
- ContactList = conlist,
- };
- return Success("获取成功", obj);
- }
- else
- {
- return Error("获取失败");
- }
- }
- else
- {
- return Error("参数传输失败");
- }
- }
- /// <summary>
- /// 通过来电号码获取来电弹屏左侧客户信息
- /// </summary>
- /// <returns></returns>
- public ActionResult GetCustomerByTel(string tel)
- {
- if (!string.IsNullOrWhiteSpace(tel))
- {
- var sql = $" and (F_LegalTel like '%" + tel.Trim() + "%') or F_CustomerId in (select F_CustomerId from T_Cus_ContactPersonNew where F_Telephone like '%" + tel.Trim() + "%')";
- var userModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_DeleteFlag = 0 " + sql);
- if (userModel.Count() > 0)
- {
- var model = userModel.Last();
- int cusid = model.F_CustomerId;
- var conlist = conbll.GetModelList(" F_DeleteFlag=0 and F_CustomerId=" + cusid);
- #region 绑定部门
- var deptname = "";
- var deptmodel = deptbll.GetModel(model.F_BeDept.Value);
- if (deptmodel != null)
- deptname = deptmodel.F_DeptName;
- #endregion
- var obj = new
- {
- CustomerBase = model,
- BeDeptName = deptname,
- ContactList = conlist,
- };
- return Success("获取成功", obj);
- }
- else
- {
- return Success("获取成功");
- }
- }
- else
- {
- return Error("参数传输失败");
- }
- }
- /// <summary>
- /// 添加客户信息
- /// </summary>
- /// <returns></returns>
- public ActionResult Add(CustomerBaseNewInput input)
- {
- string usercode = CurrentUser.UserData.F_UserCode;
- #region 添加验证判断
- if (string.IsNullOrEmpty(input.F_CustomerCode))
- return Error("编号不能为空!");
- if (getunique(0, input.F_CustomerCode))
- return Error("编号已被占用,请重新输入!");
- #endregion
- var model = new Model.T_Cus_CustomerBaseNew();
- #region 保存客户基本信息
- model.F_CustomerCode = input.F_CustomerCode;
- model.F_CompanyName = input.F_CompanyName;
- #region 处理关键字
- var keyword = model.F_CompanyName;
- var keyconfig = Configs.GetValue("keystring");
- var keystring = keyconfig.Split(',');
- foreach (var item in keystring)
- {
- if (model.F_CompanyName.Contains(item))
- keyword = keyword.Replace(item, "");
- }
- model.F_KeyWords = keyword;
- #endregion
- //model.F_KeyWords = input.F_KeyWords;
- model.F_RegisteredAddress = input.F_RegisteredAddress;
- model.F_CompanyAddress = input.F_CompanyAddress;
- model.F_LegalName = input.F_LegalName;
- model.F_LegalIDCards = input.F_LegalIDCards;
- model.F_LegalTel = input.F_LegalTel;
- model.F_Qualification = input.F_Qualification;
- model.F_Layer = input.F_Layer;
- model.F_InvoiceRange = input.F_InvoiceRange;
- model.F_SubTrade = input.F_SubTrade;
- model.F_TaxCategory = input.F_TaxCategory;
- model.F_TaxPointDes = input.F_TaxPointDes;
- model.F_WxPassword = input.F_WxPassword;
- model.F_BeDept = input.F_BeDept;
- model.F_FinancialManager = input.F_FinancialManager;
- model.F_BusinessOwner = input.F_BusinessOwner;
- model.F_BeRelatedAcc = input.F_BeRelatedAcc;
- model.F_BeAuditAcc = input.F_BeAuditAcc;
- model.F_BeMakeAcc = input.F_BeMakeAcc;
- model.F_Remark1 = input.F_Remark1;
- model.F_Remark2 = input.F_Remark2;
- model.F_Remark3 = input.F_Remark3;
- model.F_CreateBy = usercode;
- model.F_CreatedOn = DateTime.Now;
- model.F_DeleteFlag = 0;
- #endregion
- int n = cusbll.Add(model);
- if (n > 0)
- {
- #region 添加联系人
- if (input.ContactList != null && input.ContactList.Count > 0)
- {
- var conmodel = new Model.T_Cus_ContactPersonNew();
- conmodel.F_CustomerId = n;
- conmodel.F_CreateBy = usercode;
- conmodel.F_CreateOn = DateTime.Now;
- conmodel.F_DeleteFlag = 0;
- foreach (var item in input.ContactList)
- {
- conmodel.F_IsMain = item.F_IsMain;
- conmodel.F_Name = item.F_Name;
- conmodel.F_Telephone = item.F_Telephone;
- conmodel.F_Duties = item.F_Duties;
- conmodel.F_Email = item.F_Email;
- conmodel.F_MSN = item.F_MSN;
- conmodel.F_QQ = item.F_QQ;
- conmodel.F_Remark = item.F_Remark;
- conbll.Add(conmodel);
- }
- }
- #endregion
- return Success("新增成功!");
- }
- else
- return Error("新增失败!");
- }
- /// <summary>
- /// 修改客户信息
- /// </summary>
- /// <returns></returns>
- public ActionResult Update(CustomerBaseNewInput input)
- {
- string usercode = CurrentUser.UserData.F_UserCode;
- #region 添加验证判断
- if (input.F_CustomerId <= 0)
- return Error("参数错误!");
- if (getunique(input.F_CustomerId, input.F_CustomerCode))
- return Error("编号已被占用,请重新输入!");
- #endregion
- var model = cusbll.GetModel(input.F_CustomerId);
- #region 保存客户基本信息
- //model.F_CustomerCode = input.F_CustomerCode;
- model.F_CompanyName = input.F_CompanyName;
- #region 处理关键字
- var keyword = model.F_CompanyName;
- var keyconfig = Configs.GetValue("keystring");
- var keystring = keyconfig.Split(',');
- foreach (var item in keystring)
- {
- if (model.F_CompanyName.Contains(item))
- keyword = keyword.Replace(item, "");
- }
- model.F_KeyWords = keyword;
- #endregion
- model.F_RegisteredAddress = input.F_RegisteredAddress;
- model.F_CompanyAddress = input.F_CompanyAddress;
- model.F_LegalName = input.F_LegalName;
- model.F_LegalIDCards = input.F_LegalIDCards;
- model.F_LegalTel = input.F_LegalTel;
- model.F_Qualification = input.F_Qualification;
- model.F_Layer = input.F_Layer;
- model.F_InvoiceRange = input.F_InvoiceRange;
- model.F_SubTrade = input.F_SubTrade;
- model.F_TaxCategory = input.F_TaxCategory;
- model.F_TaxPointDes = input.F_TaxPointDes;
- model.F_WxPassword = input.F_WxPassword;
- model.F_BeDept = input.F_BeDept;
- model.F_FinancialManager = input.F_FinancialManager;
- model.F_BusinessOwner = input.F_BusinessOwner;
- model.F_BeRelatedAcc = input.F_BeRelatedAcc;
- model.F_BeAuditAcc = input.F_BeAuditAcc;
- model.F_BeMakeAcc = input.F_BeMakeAcc;
- model.F_Remark1 = input.F_Remark1;
- model.F_Remark2 = input.F_Remark2;
- model.F_Remark3 = input.F_Remark3;
- #endregion
- bool n = cusbll.Update(model);
- if (n)
- {
- return Success("保存成功!");
- }
- else
- return Error("保存失败!");
- }
- /// <summary>
- /// 验证客户编号是否唯一
- /// </summary>
- private bool getunique(int id, string code)
- {
- var sql = " F_DeleteFlag=0 and F_CustomerCode='" + code + "'";
- if (id > 0)
- sql += " and F_CustomerId<>"+id;
- var count=cusbll.GetModelList(sql).Count();
-
- return count > 0;
- }
- /// <summary>
- /// 删除客户
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- public ActionResult DelCustomer(string[] ids)
- {
- if (ids != null && ids.Length > 0)
- {
- string idd = " ";
- foreach (string str in ids)
- {
- idd += str + ",";
- }
- if (!string.IsNullOrEmpty(idd.Trim()))
- {
- if (cusbll.DeleteList(idd.TrimEnd(',')))
- {
- conbll.DeleteListByCusid(idd.TrimEnd(','));
- return Success("设置成功");
- }
- else
- {
- return Error("设置失败");
- }
- }
- else
- {
- return Error("请选择用户");
- }
- }
- else
- {
- return Error("获取参数失败");
- }
- }
- /// <summary>
- /// 获取客户联系人列表
- /// </summary>
- public ActionResult GetConList(string tel, string cusid, int pageindex = 1, int pagesize = 10)
- {
- string sql = "";
- DataTable dt = new DataTable();
- #region 筛选条件
- if (!string.IsNullOrWhiteSpace(cusid))
- sql += " and F_CustomerId=" + cusid + "";
- if (!string.IsNullOrWhiteSpace(tel)) //联系人电话
- sql += " and F_Telephone like '%" + tel + "%'";
- #endregion
- int recordCount = 0;
- if (!string.IsNullOrWhiteSpace(sql))
- {
- sql += " and F_DeleteFlag=0";
- dt = BLL.PagerBLL.GetListPager(
- "T_Cus_ContactPersonNew",
- "F_ManId",
- "*",
- sql,
- "ORDER BY F_ManId desc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- }
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 添加联系人
- /// </summary>
- /// <param name="coninput"></param>
- /// <returns></returns>
- public ActionResult AddContact(ContactPersonNewInput coninput)
- {
- string usercode = CurrentUser.UserData.F_UserCode;
- #region 添加验证判断
- if (coninput.F_CustomerId <= 0)
- return Error("客户ID获取失败!");
- #endregion
- var conmodel = new Model.T_Cus_ContactPersonNew();
- conmodel.F_CustomerId = coninput.F_CustomerId;
- conmodel.F_IsMain = coninput.F_IsMain;
- conmodel.F_Name = coninput.F_Name;
- conmodel.F_Telephone = coninput.F_Telephone;
- conmodel.F_Duties = coninput.F_Duties;
- conmodel.F_Email = coninput.F_Email;
- conmodel.F_MSN = coninput.F_MSN;
- conmodel.F_QQ = coninput.F_QQ;
- conmodel.F_Remark = coninput.F_Remark;
- conmodel.F_CreateBy = usercode;
- conmodel.F_CreateOn = DateTime.Now;
- conmodel.F_DeleteFlag = 0;
- int n = conbll.Add(conmodel);
- if (n > 0)
- return Success("联系人保存成功!");
- else
- return Error("联系人保存失败!");
- }
- /// <summary>
- /// 修改联系人
- /// </summary>
- /// <param name="coninput"></param>
- /// <returns></returns>
- public ActionResult UpdateContact(ContactPersonNewInput coninput)
- {
- string usercode = CurrentUser.UserData.F_UserCode;
- #region 添加验证判断
- if (coninput.F_ManId <= 0)
- return Error("参数错误!");
- if (coninput.F_CustomerId <= 0)
- return Error("客户ID获取失败!");
- #endregion
- var conmodel = conbll.GetModel(coninput.F_ManId);
- conmodel.F_CustomerId = coninput.F_CustomerId;
- conmodel.F_IsMain = coninput.F_IsMain;
- conmodel.F_Name = coninput.F_Name;
- conmodel.F_Telephone = coninput.F_Telephone;
- conmodel.F_Duties = coninput.F_Duties;
- conmodel.F_Email = coninput.F_Email;
- conmodel.F_MSN = coninput.F_MSN;
- conmodel.F_QQ = coninput.F_QQ;
- conmodel.F_Remark = coninput.F_Remark;
- var n = conbll.Update(conmodel);
- if (n)
- return Success("联系人保存成功!");
- else
- return Error("联系人保存失败!");
- }
- /// <summary>
- /// 删除联系人
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- public ActionResult DelContact(string[] ids)
- {
- if (ids != null && ids.Length > 0)
- {
- string idd = " ";
- foreach (string str in ids)
- {
- idd += str + ",";
- }
- if (!string.IsNullOrEmpty(idd.Trim()))
- {
- if (conbll.DeleteList(idd.TrimEnd(',')))
- {
- return Success("设置成功");
- }
- else
- {
- return Error("设置失败");
- }
- }
- else
- {
- return Error("请选择联系人");
- }
- }
- else
- {
- return Error("获取参数失败");
- }
- }
- /// <summary>
- /// 导入excel
- /// </summary>
- public ActionResult ImportExcel()
- {
- string usercode = CurrentUser.UserData.F_UserCode;
- if (!string.IsNullOrWhiteSpace(usercode))
- {
- HttpPostedFile _upFile = RequestString.GetFile("upFile");
- if (_upFile != null)
- {
- int headrow = 0;
- #region 上传文件
- string filepath = "";
- string datepath = DateTime.Now.ToString("yyyyMMddHHMMss");
- string aLastName = _upFile.FileName.Substring(_upFile.FileName.LastIndexOf(".") + 1, (_upFile.FileName.Length - _upFile.FileName.LastIndexOf(".") - 1)); //扩展名
- if (aLastName != "xls" && aLastName != "xlsx")
- {
- return Error("文件类型错误,请选择Excel文件");
- }
- string newpath = datepath + "_" + _upFile.FileName;
- if (!Directory.Exists(Server.MapPath(this.Request.ApplicationPath + "\\ExcelData")))
- {
- Directory.CreateDirectory(Server.MapPath(this.Request.ApplicationPath + "\\ExcelData"));
- }
- filepath = this.Request.ApplicationPath + "/ExcelData/" + newpath;
- string PhysicalPath = Server.MapPath(filepath);
- _upFile.SaveAs(PhysicalPath);
- #endregion
- DataTable dt = new DataTable();
- #region 读取excel中内容
- IWorkbook workbook = null;
- using (FileStream file = new FileStream(PhysicalPath, FileMode.Open, FileAccess.Read))
- {
- if (aLastName == "xlsx") // 2007版本
- {
- workbook = new XSSFWorkbook(file);
- }
- else if (aLastName == "xls") // 2003版本
- {
- workbook = new HSSFWorkbook(file);
- }
- }
- ISheet sheet = workbook.GetSheetAt(0);
-
- System.Collections.IEnumerator rows = sheet.GetRowEnumerator();
- //获取sheet的第一行
- IRow headerRow = sheet.GetRow(headrow);
- int cellCount = headerRow.LastCellNum;
- if (cellCount < 1)
- return Error("文件标题没有数据");
- for (int j = 0; j < cellCount; j++)
- {
- ICell cell = headerRow.GetCell(j);
- dt.Columns.Add(cell.ToString());
- }
- #endregion
- int count = 0;
- for (int i = (sheet.FirstRowNum + headrow + 1); i <= sheet.LastRowNum; i++)
- {
- #region 数据入库
- IRow row = sheet.GetRow(i);
- DataRow dataRow = dt.NewRow();
- for (int j = row.FirstCellNum; j < cellCount; j++)
- {
- if (row.GetCell(j) != null)
- dataRow[j] = row.GetCell(j).ToString();
- }
- dt.Rows.Add(dataRow);
- if (dt.Rows.Count < 1)
- return Error("文件内容没有数据");
-
- var cusmodel = new Model.T_Cus_CustomerBaseNew();
- var conmodel = new Model.T_Cus_ContactPersonNew();
- #region 信息对应
- //报税会计 做账会计 编号 客服 公司名称 负责人电话 交接日期
- cusmodel.F_CustomerCode = dataRow["编号"].ToString();
- cusmodel.F_CompanyName = dataRow["公司名称"].ToString();
- #region 处理关键字
- var keyword = cusmodel.F_CompanyName;
- var keyconfig = Configs.GetValue("keystring");
- var keystring = keyconfig.Split(',');
- foreach (var item in keystring)
- {
- if (cusmodel.F_CompanyName.Contains(item))
- keyword = keyword.Replace(item, "");
- }
- cusmodel.F_KeyWords = keyword;
- #endregion
- cusmodel.F_BeRelatedAcc = dataRow["报税会计"].ToString();
- cusmodel.F_BeMakeAcc = dataRow["做账会计"].ToString();
- cusmodel.F_Remark1 = dataRow["交接日期"].ToString();
- cusmodel.F_Remark2 = dataRow["客服"].ToString();
- cusmodel.F_CreateBy = usercode;
- cusmodel.F_CreatedOn = DateTime.Now;
- cusmodel.F_DeleteFlag = 0;
- #endregion
- int n = cusbll.Add(cusmodel);
- if (n > 0)
- {
- #region 添加联系人
- if (dataRow["负责人电话"] != null)
- {
- conmodel.F_CustomerId = n;
- conmodel.F_CreateBy = usercode;
- conmodel.F_CreateOn = DateTime.Now;
- conmodel.F_DeleteFlag = 0;
- conmodel.F_IsMain = true;
- conmodel.F_Telephone = dataRow["负责人电话"].ToString();
- conbll.Add(conmodel);
- }
- #endregion
- count++;
- }
- #endregion
- }
- if (dt == null || dt.Rows.Count == 0)
- return Error("文件没有数据");
- else
- {
- var jstr = DataTableToJson(dt);
- if (count > 0)
- {
- return Success("导入成功 " + count + "条信息", jstr);
- }
- else
- {
- return Success("导入成功 " + count + "条信息", jstr);
- }
- }
- }
- return Error("数据源上传失败");
- }
- return Error("用户登录失败,请重新登录");
- }
- public string DataTableToJson(DataTable dt)
- {
- string JsonString = string.Empty;
- JsonString = JsonConvert.SerializeObject(dt);
- return JsonString;
- }
- }
- }
|