//获取销售员详细信息
 public ActionResult SaleMessage()
 {
     int id = Convert.ToInt32(Request["id"]);
     SqlParameter[] saleMessageParam = { new SqlParameter("@id", id) };
     var saleMessageds = SQLHelper.ExecuteDataset(connStr, System.Data.CommandType.StoredProcedure, "sale_message", saleMessageParam);
     //如果有数据返回
     if (saleMessageds.Tables[0].Rows.Count > 0)
     {
         List<UserLogin> saleMessage = new List<UserLogin>();
         for (int i = 0; i < saleMessageds.Tables[0].Rows.Count; i++)
         {
             UserLogin sale = new UserLogin();
             sale.username = saleMessageds.Tables[0].Rows[i]["username"].ToString();
             sale.phone = saleMessageds.Tables[0].Rows[i]["phone"].ToString();
             sale.tel = saleMessageds.Tables[0].Rows[i]["tel"].ToString();
             sale.depart = saleMessageds.Tables[0].Rows[i]["depart"].ToString();
             saleMessage.Add(sale);
         }
         var result = new { code = "0", rows = saleMessage };
         return Json(result, JsonRequestBehavior.AllowGet);
     }
     else
     {
         var result = new { code = "1" };
         return Json(result, JsonRequestBehavior.AllowGet);
     }
 }
 //根据用户名查询
 public ActionResult SearchByName()
 {
     int parentId = Convert.ToInt32(Request["parentId"]);
     string searchName = Request["searchname"].ToString();
     //根据用户名模糊查询出子销售员
     SqlParameter[] searchParm = { new SqlParameter("@parentId", parentId), new SqlParameter("@username", "%" + searchName + "%") };
     var searchds = SQLHelper.ExecuteDataset(connStr, System.Data.CommandType.StoredProcedure, "name_likesearch", searchParm);
     //如果查询的子销售员存在
     if (searchds.Tables[0].Rows.Count > 0)
     {
         List<UserLogin> searchSaleList = new List<UserLogin>();
         for (int i = 0; i < searchds.Tables[0].Rows.Count; i++)
         {
             UserLogin sale = new UserLogin();
             sale.username = searchds.Tables[0].Rows[i]["username"].ToString();
             sale.phone = searchds.Tables[0].Rows[i]["phone"].ToString();
             sale.tel = searchds.Tables[0].Rows[i]["tel"].ToString();
             sale.depart = searchds.Tables[0].Rows[i]["depart"].ToString();
             sale.logintime = searchds.Tables[0].Rows[i]["logintime"].ToString();
             searchSaleList.Add(sale);
         }
         //成功返回返回码0和子销售员列表
         var result = new { code = "0", rows = searchSaleList };
         return Json(result, JsonRequestBehavior.AllowGet);
     }
     else
     {
         //返回返回码1,没有子销售员
         var result = new { code = "1" };
         return Json(result, JsonRequestBehavior.AllowGet);
     }
 }
 public ActionResult GetSaleList()
 {
     //获取当前用户的id
     int id = Convert.ToInt32(Request["id"]);
     SqlParameter[] saleparm = { new SqlParameter("@id", id) };
     var saleds = SQLHelper.ExecuteDataset(connStr, System.Data.CommandType.StoredProcedure, "getsalelist", saleparm);
     //如果存在子销售员
     //ds.Tables[0].Rows[i]["ID"]
     if (saleds.Tables[0].Rows.Count > 0)
     {
         List<UserLogin> saleList = new List<UserLogin>();
         for (int i = 0; i < saleds.Tables[0].Rows.Count; i++)
         {
             UserLogin sale = new UserLogin();
             sale.id = Convert.ToInt32(saleds.Tables[0].Rows[i]["id"]);
             sale.username = saleds.Tables[0].Rows[i]["username"].ToString();
             sale.phone = saleds.Tables[0].Rows[i]["phone"].ToString();
             sale.tel = saleds.Tables[0].Rows[i]["tel"].ToString();
             sale.depart = saleds.Tables[0].Rows[i]["depart"].ToString();
             sale.logintime = saleds.Tables[0].Rows[i]["logintime"].ToString();
             saleList.Add(sale);
         }
         //返回返回码0,子销售员列表
         var result = new { code = "0", rows = saleList };
         return Json(result, JsonRequestBehavior.AllowGet);
     }
     else
     {
         //返回返回码1,没有子销售员
         var result = new { code = "1" };
         return Json(result, JsonRequestBehavior.AllowGet);
     }
 }