//查询客户 public ActionResult SelectKeHu(int pageIndex, int pageSize, string customerNum, string customerName) { KeHuBLL bll = new KeHuBLL(); List <customer> list = bll.Customers(); var obj = from p in list where p.isDel == 1 && p.customerNum.Contains(customerNum) && p.customerName.Contains(customerName) select new { customerNum = p.customerNum, customerName = p.customerName, phone = p.phone, chuanzhen = p.chuanzhen, createTime = p.createTime.ToString("yyyy年MM月dd日") }; obj = obj.OrderBy(p => p.customerNum).Skip((pageIndex - 1) * pageSize).Take(pageSize); return(Json(obj, JsonRequestBehavior.AllowGet)); }
//查询一条地址 public ActionResult SelectOne(string customerNum) { KeHuBLL bll = new KeHuBLL(); List <customer> list = bll.Customers(); var obj = from p in list where p.customerNum == customerNum select new { customerNum = p.customerNum, customerName = p.customerName, phone = p.phone, chuanzhen = p.chuanzhen, email = p.email, contents = p.contents }; return(Json(obj, JsonRequestBehavior.AllowGet)); }
//客户总条数 public ActionResult SelectKeHus(string customerNum, string customerName) { KeHuBLL bll = new KeHuBLL(); List <customer> list = bll.Customers(); var obj = from p in list where p.isDel == 1 select p; if (!string.IsNullOrEmpty(customerNum)) { obj = obj.Where(p => p.customerNum.Contains(customerNum)); } if (!string.IsNullOrEmpty(customerName)) { obj = obj.Where(p => p.customerName.Contains(customerName)); } return(Json(obj.Count(), JsonRequestBehavior.AllowGet)); }
//新增客户 public ActionResult InsertKeHu(string customerName, string phone, string chuanzhen, string email, string contacts) { KeHuBLL bll = new KeHuBLL(); int shu = bll.Customers().Count(); string zhang = shu.ToString(); string customerNum = null; if (zhang.Length == 1) { customerNum = "00000" + (shu + 1); } else if (zhang.Length == 2) { customerNum = "0000" + (shu + 1); } else if (zhang.Length == 3) { customerNum = "000" + (shu + 1); } customer cu = new customer(); cu.customerNum = customerNum; cu.customerName = customerName; cu.phone = phone; cu.chuanzhen = chuanzhen; cu.email = email; cu.contents = contacts; cu.createTime = DateTime.Now; cu.isDel = 1; bll.Add(cu); List <customerAddressInfo> list = bll.CustomerAddressInfo(); var obj = from p in list where Nullable <int> .Equals(p.customerNum, null) && p.isDel == 1 select new { AddressNum = p.AddressNum, AddressXinxi = p.AddressXinxi, contacts = p.contacts, phone = p.phone }; foreach (var item in obj) { bll.UdpateBianHao(item.AddressNum, customerNum); } return(Json("新增成功!", JsonRequestBehavior.AllowGet)); }