public string GetInfo() { List <HospitalInfo> list = new List <HospitalInfo>(); string sqlhos = "select * from HospitalInfo"; using (SqlDataReader sdr = SqlHelper.ExecuteReader(sqlhos)) { if (sdr.HasRows) { while (sdr.Read()) { HospitalInfo hpf = new HospitalInfo(); hpf.Id = Convert.ToInt32(sdr["ID"]); //hpf.HospitalId = Convert.ToInt32(sdr["Hospital_ID"]); //hpf.HospitalName = sdr["HospitalName"].ToString(); //hpf.DoctorId = Convert.ToInt32(sdr["Doctor_ID"]); hpf.DoctorName = sdr["DoctorName"].ToString(); list.Add(hpf); } } } //把集合放入json中 //JavaScriptSerializer js = new JavaScriptSerializer(); //return js.Serialize(list); string jsonData = JsonConvert.SerializeObject(list); return(jsonData); }
/// <summary> /// 得到用户登录名,判断用户是否登陆成功 /// </summary> /// <param name="User_Id"></param> /// <param name="Password"></param> /// <returns>登陆成功或者失败</returns> public string GetUserInfoByLoginName(string User_Id, string Password) { string sqlsys = "select * from sys_users where User_Id=@User_Id and Password=@Password"; string res = ""; DataTable dt = SqlHelper.ExecuteTable(sqlsys, new SqlParameter("@User_Id", User_Id), new SqlParameter("@Password", Password)); if (dt.Rows.Count > 0) { HospitalInfo hpf = new HospitalInfo(); res = hpf.GetInfo(); } //sys_users temp = new sys_users(); //temp.User_ID = 1; //temp.UserName = "******"; //temp.Password = "******"; //temp.UserRole = "doctor"; //temp.HospitalName = "郑州大学第一附属医院"; //把集合放入json中 //JavaScriptSerializer js = new JavaScriptSerializer(); //string jsonData = JsonConvert.SerializeObject(lstStuModel); //return js.Serialize(res); return(res); }