//查询一条地址数据 public ActionResult SelectOneDiZhi(string AddressNum) { KeHuBLL bll = new KeHuBLL(); List <customerAddressInfo> list = bll.CustomerAddressInfo(); var obj = from p in list where p.AddressNum == AddressNum select new { AddressNum = p.AddressNum, AddressXinxi = p.AddressXinxi, contacts = p.contacts, phone = p.phone }; return(Json(obj, JsonRequestBehavior.AllowGet)); }
public ActionResult SelectDiZhiUpdate(string bianhao) { KeHuBLL bll = new KeHuBLL(); List <customerAddressInfo> list = bll.CustomerAddressInfo(); var obj = from p in list where p.customerNum == bianhao && p.isDel == 1 select new { AddressNum = p.AddressNum, AddressXinxi = p.AddressXinxi, contacts = p.contacts, phone = p.phone }; return(Json(obj, JsonRequestBehavior.AllowGet)); }
//查询客户地址 public ActionResult SelectDiZhi() { KeHuBLL bll = new KeHuBLL(); 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 }; return(Json(obj, JsonRequestBehavior.AllowGet)); }
//新增客户地址 public ActionResult InsertDiZhi(string AddressXinxi, string phone, string contacts, string bianhao) { KeHuBLL bll = new KeHuBLL(); int shu = bll.CustomerAddressInfo().Count(); string zhang = shu.ToString(); string AddressNum = null; if (zhang.Length == 1) { AddressNum = "XBLY00" + (shu + 1); } else if (zhang.Length == 2) { AddressNum = "XBLY0" + (shu + 1); } else if (zhang.Length == 3) { AddressNum = "XBLY" + (shu + 1); } if (bianhao == "") { customerAddressInfo info = new customerAddressInfo(); info.AddressNum = AddressNum; info.AddressXinxi = AddressXinxi; info.contacts = contacts; info.phone = phone; info.isDel = 1; bll.AddcustomerAddressInfo(info); } else { customerAddressInfo info = new customerAddressInfo(); info.AddressNum = AddressNum; info.AddressXinxi = AddressXinxi; info.customerNum = bianhao; info.contacts = contacts; info.phone = phone; info.isDel = 1; bll.AddcustomerAddressInfo(info); } return(Json("新增地址成功!", 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)); }