Example #1
0
 /// <summary>
 /// 客户下拉列表
 /// </summary>
 /// <param name="roleNum"></param>
 /// <returns></returns>
 public static string GetCustomerList(string cusNum)
 {
     CustomerProvider provider = new CustomerProvider();
     List<CustomerEntity> list = provider.GetList();
     StringBuilder sb = new StringBuilder();
     string CusTemplate = "<option value='{0}' {1}>{2}</option>";
     sb.AppendFormat(CusTemplate, "", "", "请选择客户");
     if (!list.IsNullOrEmpty())
     {
         foreach (CustomerEntity cus in list)
         {
             sb.AppendFormat(CusTemplate, cus.CusNum, cus.CusNum == cusNum ? "selected='selected'" : string.Empty, cus.CusName);
         }
     }
     return sb.ToString();
 }
        public ActionResult Auto(string cusName)
        {
            CustomerProvider provider = new CustomerProvider();
            List<CustomerEntity> list = provider.GetList();
            if (!list.IsNullOrEmpty() && !cusName.IsEmpty())
            {
                list = list.Where(a => a.CusNum.Contains(cusName) || a.CusName.Contains(cusName)).ToList();
            }
            list = list.IsNull() ? new List<CustomerEntity>() : list;
            StringBuilder sb = new StringBuilder();
            JsonObject jsonObject = null;
            foreach (CustomerEntity t in list)
            {
                jsonObject = new JsonObject();
                jsonObject.AddProperty("CusNum", t.CusNum);
                jsonObject.AddProperty("CusName", t.CusName);
                //jsonObject.AddProperty("Phone", t.Phone);
                sb.Append(jsonObject.ToString() + "\n");

            }
            if (sb.Length == 0)
            {
                sb.Append("\n");
            }
            return Content(sb.ToString());
        }