public ActionResult MineCustomerSearch(string kind, string first, string end, string owner, string custom, int pid = 1) { //好友列表 Init(); pageModel.currentMenu = 2; List <t_customer> list = _bll.GetCustomsByCondition(first, end, owner, custom, pid); pageModel.currentIndex = pid; pageModel.list = list; pageModel.pageCount = _bll.GetPageCountByCondition(first, end, owner, custom); string url = "/sys/Client"; pageModel.PageUI = CreatePageUI(url, pageModel.currentIndex, pageModel.pageCount); if (first == "1990-01-01") { pageModel.search_time = ""; } else { pageModel.search_time = first + " - " + end; } if (custom != "0") { t_customer ml = _bll.GetCustomsById(custom); if (ml != null) { pageModel.search_custom = ml.Name; } } return(View("FriendManage", pageModel)); }
public bool RemoveModel(int id) { t_customer temp = new t_customer(); temp.ID = id.ToString(); bool res = Delete <t_customer>(temp); return(res); }
/// <summary> /// 根据用户名获取用户信息 /// </summary> /// <param name="cust_name"></param> public t_customer GetCustomById(string ID) { t_customer res = null; string sql = "select * from t_customer where id=@id"; List <t_customer> users = Query <t_customer>(sql, new { id = ID }); if (users.Count > 0) { res = users.First(); } return(res); }
/// <summary> /// 根据用户名获取用户信息 /// </summary> /// <param name="cust_name"></param> public t_customer GetCustomByRealName(string realName) { t_customer res = null; string sql = "select * from t_customer where Name=@Cust_Name"; List <t_customer> users = Query <t_customer>(sql, new { Cust_Name = realName }); if (users.Count > 0) { res = users.First(); } return(res); }
public JsonResult QueryUrl(string first, string end, string owner, string custom, string kind) { object obj = new { }; string res = string.Empty; res = "/sys/Client/"; if (Common.CommonFun.IsEmpty(first)) { first = "1990-01-01"; } if (Common.CommonFun.IsEmpty(end)) { end = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"); } if (!Common.CommonFun.IsEmpty(owner)) { t_user model = _user.GetUserByRealName(owner); if (model == null) { return(Json(new { state = 0, data = "", message = "该负责人不存在" })); } else { owner = model.ID; } } else { owner = "0"; } if (!Common.CommonFun.IsEmpty(custom)) { t_customer model = _bll.GetCustomByRealName(custom); if (model == null) { return(Json(new { state = 0, data = "", message = "该客户不存在" })); } else { custom = model.ID; } } else { custom = "0"; } res += "f" + first + "t" + end + "n" + owner + "p" + custom; obj = new { state = 1, data = res, message = "" }; return(Json(obj)); }
public int GetPageCountByCondition(string first, string end, string oid, string cid) { string owner = string.Empty; if (oid != "0") { t_user model = _user.GetUserById(oid); if (model != null) { owner = model.RealName; } else { owner = ""; } } else { owner = ""; } string custom = string.Empty; if (cid != "0") { t_customer model = _dal.GetCustomById(cid); if (model != null) { custom = model.Owner; } else { custom = ""; } } else { custom = ""; } int num = _dal.GetPageCountByCondition(first, end, owner, custom); if (num % pageCount == 0) { return(num / pageCount); } else { return((num / pageCount) + 1); } }
public bool SaveModel(t_customer model) { bool res = false; if (Int32.Parse(model.ID) > 0) { //修改 res = _dal.Alter(model); } else { //添加 res = _dal.Add(model); } return(res); }
public List <t_customer> GetCustomsByCondition(string first, string end, string oid, string cid, int pageIndex) { int firstIndex = (pageIndex - 1) * pageCount + 1; int endIndex = pageIndex * pageCount; string owner = string.Empty; if (oid != "0") { t_user model = _user.GetUserById(oid); if (model != null) { owner = model.RealName; } else { owner = ""; } } else { owner = ""; } string custom = string.Empty; if (cid != "0") { t_customer model = _dal.GetCustomById(cid); if (model != null) { custom = model.Name; } else { custom = ""; } } else { custom = ""; } return(_dal.GetCustomByCondition(first, end, owner, custom, firstIndex, endIndex)); }
public JsonResult Save(t_customer model) { object obj = new { }; try { model.time = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); model.state = "0"; model.Content = Common.CommonFun.IsEmpty(model.Content) ? "" : model.Content; bool res = _bll.SaveModel(model); if (res) { obj = new { state = 1, data = "", message = "保存信息成功" }; } else { obj = new { state = 0, data = "", message = "保存信息失败" }; } } catch { obj = new { state = 0, data = "", message = "保存信息失败" }; } return(Json(obj)); }
public HttpResponseMessage SaveBasCustomerForm(t_customer obj) { using (TransactionScope transaction = new TransactionScope()) { DBHelper <t_customer> dbhelp = new DBHelper <t_customer>(); DateTime dt = DateTime.Now; //事务 var result = 0; var Customer = db.t_customer.Where(w => w.Code == obj.Code && w.CorpID == userInfo.CorpID); try { string base64Data = obj.Photo; if (obj.CustID == 0) { string Code = obj.Code; if (Code == "" || Code == null) { result = AutoIncrement.AutoIncrementResult("Customer", out Code); } obj.Photo = ""; obj.CreateTime = dt; obj.CreateUserID = (int)userInfo.UserID; obj.CorpID = userInfo.CorpID; obj.Code = Code; if (Customer.ToList().Count() > 0) { throw new Exception("账号重复!"); } result = result + dbhelp.Add(obj); } else { obj.Photo = ""; obj.UpdateTime = dt; obj.UpdateUserID = (int)userInfo.UserID; if (Customer.ToList().Count() > 1) { throw new Exception("账号重复!"); } result = result + dbhelp.Update(obj); } //保存图片并修改数据库图片名称 try { //获取文件储存路径 string suffix = base64Data.Split(new char[] { ';' })[0].Substring(base64Data.IndexOf('/') + 1); //获取后缀名 string newFileName = "CUST_" + obj.CustID.ToString("000000000") + "." + suffix; string strPath = HttpContext.Current.Server.MapPath("~/" + UploadImgPath + "/" + newFileName); //获取当前项目所在目录 //获取图片并保存 BaseToImg.Base64ToImg(base64Data.Split(',')[1]).Save(strPath); obj.Photo = newFileName; } catch { obj.Photo = base64Data; } List <string> fileds = new List <string>(); fileds.Add("Photo"); result = result + dbhelp.UpdateEntityFields(obj, fileds); //提交事务 transaction.Complete(); return(Json(true, "保存成功!")); } catch (Exception ex) { return(Json(false, "保存失败!" + ex.Message)); } } }
public HttpResponseMessage FindBasCustomerForm(t_customer obj) { long CustID = obj.CustID; var CustCategoryIDList = db.view_datadict.Where(w => (w.CorpID == userInfo.CorpID || w.CorpID == 0) && w.Code == "CustomerCategory").Select(s => new { label = s.Name, value = s.DClassID }); var EmployeeIDList = db.t_bas_user.Where(w => w.IsValid != 0 && w.CorpID == userInfo.CorpID && w.UserCategoryID == 5).Select(s => new { label = s.Name, value = s.UserID }); var RegionIDList = getRegtion().children; List <long> ResultID = new List <long>(); string NullValue = null; if (CustID == 0) { var list = new { CustID = 0, CorpID = userInfo.CorpID, Address = NullValue, Name = NullValue, HelperCode = NullValue, AreaID = NullValue, City = NullValue, CloseTime = NullValue, CloseUserID = NullValue, Code = NullValue, Contact = NullValue, CreateTime = NullValue, CreateUserID = NullValue, CustCategoryID = NullValue, CustCategoryIDList = CustCategoryIDList, EmployeeID = NullValue, EmployeeIDList = EmployeeIDList, Fax = NullValue, IsValid = 1, Phone = NullValue, Photo = NullValue, PostCode = NullValue, RegionID = NullValue, ShortName = NullValue, Tel = NullValue, UpdateTime = NullValue, UpdateUserID = NullValue, }; return(Json(true, "", new { list = list, RegionIDList = RegionIDList, RegionIDArr = ResultID })); } else { var list = db.t_customer.Where(w => w.CustID == CustID && w.CorpID == userInfo.CorpID).Select(s => new { s.CorpID, s.Code, s.CustID, s.Address, s.Name, s.HelperCode, s.AreaID, s.City, s.CloseTime, s.CloseUserID, s.Contact, s.CreateTime, s.CreateUserID, s.CustCategoryID, CustCategoryIDList = CustCategoryIDList, s.EmployeeID, EmployeeIDList = EmployeeIDList, s.Fax, s.IsValid, s.Phone, s.Photo, s.PostCode, s.RegionID, s.ShortName, s.Tel, s.UpdateTime, s.UpdateUserID }).FirstOrDefault(); var tBasRegion = db.t_bas_region.Where(w => w.IsValid != 0 && w.CorpID == userInfo.CorpID && w.RegionID == list.RegionID).FirstOrDefault(); if (tBasRegion != null) { foreach (var item in tBasRegion.RegionAllID.Split(',')) { ResultID.Add(Convert.ToInt16(item)); } } return(Json(true, "", new { list = list, RegionIDList = RegionIDList, RegionIDArr = ResultID })); } }
public HttpResponseMessage DeleteBasCustomerRow(t_customer obj) { var result = new DBHelper <t_customer>().Remove(obj); return(Json(true, result == 1 ? "删除成功!" : "删除失败")); }
public bool Alter(t_customer model) { bool res = Alter <t_customer>(model); return(res); }
public bool Add(t_customer model) { bool res = Insert <t_customer>(model); return(res); }
public t_customer GetCustomsById(string id) { t_customer model = _dal.GetCustomById(id); return(model); }
public t_customer GetCustomByRealName(string name) { t_customer model = _dal.GetCustomByRealName(name); return(model); }