public void Import_Client() { if (!B_ARoleAuth.AuthCheckEx(ZLEnum.Auth.office, "crm")) { return; } var file = Request.Files["file_up"]; if (file == null) { function.WriteErrMsg("未指定文件"); return; } if (file.ContentLength < 100) { function.WriteErrMsg("文件为空"); return; } string ext = Path.GetExtension(file.FileName).ToLower(); if (ext != ".xlsx") { function.WriteErrMsg("只允许上传xlsx文件"); return; } DataTable excelDT = Import_Logical.Excel_ToDT(XMLPath_Client, file.InputStream); DataTable typeDT = attrBll.Sel("ctype"); //将数据直接写入数据库,或将其转换为模型再写入 foreach (DataRow dr in excelDT.Rows) { M_CRMS_Client model = new M_CRMS_Client().GetModelFromReader(dr); //clientType统一让用户填中文,转化为中文 //model.ClientType = StrHelper.IdsFormat(model.ClientType); #region ClientType if (!string.IsNullOrEmpty(model.ClientType)) { model.ClientType = model.ClientType.Replace(" ", ""); string[] ctypeArr = model.ClientType.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); foreach (string ctype in ctypeArr) { typeDT.DefaultView.RowFilter = "Value='" + ctype + "'"; if (typeDT.DefaultView.ToTable().Rows.Count < 1) { //新增ClientType M_CRMS_Attr attrMod = new M_CRMS_Attr(); attrMod.ZType = "ctype"; attrMod.Value = ctype; attrBll.Insert(attrMod); typeDT = attrBll.Sel("ctype"); } } } #endregion clientBll.Insert(model); } function.WriteSuccessMsg("客户信息导入成功", "ClientImport"); }
public IActionResult CTypeAdd() { if (!B_ARoleAuth.AuthCheckEx(ZLEnum.Auth.office, "crm")) { return(null); } M_CRMS_Attr attrMod = new M_CRMS_Attr(); if (Mid > 0) { attrMod = attrBll.SelReturnModel(Mid); } return(View(attrMod)); }
public IActionResult CType_Add() { M_CRMS_Attr attrMod = new M_CRMS_Attr(); if (Mid > 0) { attrMod = attrBll.SelReturnModel(Mid); } attrMod.Value = Request.Form["value"]; attrMod.Remark = Request.Form["remark"]; if (attrMod.ID > 0) { attrBll.UpdateByID(attrMod); } else { attrMod.ZType = "ctype"; attrBll.Insert(attrMod); } return(WriteOK("操作成功", "CType")); }
public void CType_Add() { M_CRMS_Attr attrMod = new M_CRMS_Attr(); if (Mid > 0) { attrMod = attrBll.SelReturnModel(Mid); } attrMod.Value = Request.Form["value"]; attrMod.Remark = Request.Form["remark"]; if (attrMod.ID > 0) { attrBll.UpdateByID(attrMod); } else { attrMod.ZType = "ctype"; attrBll.Insert(attrMod); } function.WriteSuccessMsg("操作成功", "CType"); }
public bool UpdateByID(M_CRMS_Attr model) { return(DBCenter.UpdateByID(model, model.ID)); }
public int Insert(M_CRMS_Attr model) { return(DBCenter.Insert(model)); }