//查询个人信息 public IHttpActionResult GetUserInfoList() { var db = DBhelp.GetInstance(); try { int UserID = ((Useridentity)User.Identity).UserId; var list = db.Queryable <UserInfo, Department, Role>((a, b, c) => new JoinQueryInfos( JoinType.Left, a.DepartmentID == b.DepartmentID, JoinType.Left, a.RoleID == c.RoleID )).Select <ViewModelUserInfo>().ToList(); var json = new { msg = "ok", data = list }; return(Json(json)); } catch (Exception e) { var json = new { msg = "错误信息:" + e.Message }; return(Json(json)); } }
public IHttpActionResult GetUserInfoList(int page, int limit) { var db = DBhelp.GetInstance(); try { int offset = (page - 1) * limit; var list = db.Queryable <UserInfo, Department>((a, b) => new JoinQueryInfos( JoinType.Left, a.DepartmentID == b.DepartmentID )).Where((a, b) => a.isDel == 0).Select <ViewModelUserInfo>().ToList(); var data = list.OrderBy(r => r.UserID).Skip(offset).Take(limit); var json = new { code = 0, msg = "ok", data, count = list.Count() }; return(Json(json)); } catch (Exception e) { var json = new { code = 0, msg = e.Message }; return(Json(json)); } }
void wykres2() { List <KeyValuePair <string, double> > valueList = new List <KeyValuePair <string, double> >(); List <Uzytkownik> users = DBhelp.Uczniowie(); Dictionary <string, double> tt = new Dictionary <string, double>(); foreach (Uzytkownik temp in users) { double srednia = DBhelp.OcenyUczniaSrednia(temp.id); if (srednia == 0) { continue; } if (temp.id != MainWindow.user.id) { tt.Add(temp.Nazwisko, srednia); } else { tt.Add("JA", srednia); } } System.Windows.Controls.DataVisualization.Charting.ColumnSeries ColumnSeries = new System.Windows.Controls.DataVisualization.Charting.ColumnSeries(); //columnChart.DataContext = tt; //Setting data for line chart // pieChart.Visibility = Visibility.Hidden; mcCharobec.Visibility = Visibility.Hidden; mcChartpie.Visibility = Visibility.Hidden; mcChart.Visibility = Visibility.Visible; ((BarSeries)mcChart.Series[0]).ItemsSource = tt; //columnChart.Visibility = Visibility.Visible; }
//更新用户信息 public string UserInfoUpdate(UserInfo userInfo) { var db = DBhelp.GetInstance(); try { //查询账号给传过来的实体赋值 UserInfo NamePwd = db.Queryable <UserInfo>().First(r => r.UserID == userInfo.UserID); //查询是否有重复手机号 UserInfo phone = db.Queryable <UserInfo>().First(r => r.UserTel == userInfo.UserTel && r.UserID != userInfo.UserID); if (phone != null) { return("手机号不能重复"); } if (userInfo.UserID != 1 && userInfo.RoleID == 1) { return("你不能当总经理"); } userInfo.UserIphone = filePath; userInfo.LoginName = NamePwd.LoginName; userInfo.LoginPwd = NamePwd.LoginPwd; userInfo.UserStatr = 1; int count = db.Updateable(userInfo).ExecuteCommand(); if (count > 0) { return("ok"); } else { return("no"); } } catch (Exception e) { return("错误信息:" + e.Message); } }
private void Init_gridview() { SqlDataReader normr = DBhelp.ExecuteReader("select count(*) from config where Meter_malfunc=1"); while (normr.Read()) { normal.Text = Convert.ToString(normr.GetInt32(0)); } normr.Close(); SqlDataReader accr = DBhelp.ExecuteReader("select count(*) from config"); while (accr.Read()) { account.Text = Convert.ToString(accr.GetInt32(0)); } accr.Close(); SqlDataReader fixr = DBhelp.ExecuteReader("select count(*) from config where Meter_malfunc = 0 and 开始维护时间 is not null"); while (fixr.Read()) { fixing.Text = Convert.ToString(fixr.GetInt32(0)); } fixr.Close(); SqlDataReader badr = DBhelp.ExecuteReader("select count(*) from config where Meter_malfunc=0"); while (badr.Read()) { error.Text = Convert.ToString(badr.GetInt32(0)); } badr.Close(); percent.Text = Convert.ToString((Convert.ToDecimal(error.Text) / Convert.ToDecimal(account.Text)) * 100) + "%"; }
private void OnLoadTable(object sender, RoutedEventArgs e) { dziennik.ItemsSource = DBhelp.ObecnosciKlasa(1); }
private void Button_Click_1(object sender, RoutedEventArgs e) { dziennik.ItemsSource = DBhelp.ObecnosciKlasa(2); }
private void OnLoadTable(object sender, RoutedEventArgs e) { oceny.ItemsSource = DBhelp.OcenyPrzedmioty(1); obecnosci.ItemsSource = DBhelp.ObecnosciKlasa(1); }
private void Button_Click_1(object sender, RoutedEventArgs e) { oceny.ItemsSource = DBhelp.OcenyPrzedmioty(2); obecnosci.ItemsSource = DBhelp.ObecnosciKlasa(2); }
public static string getDeviceInfoCommon(int userid) { //http://localhost:59519/Service/rilservlet.ashx?action=getDevice&userid=1 DeviceManager device = new DeviceManager(); string data = ""; string json = ""; JavaScriptSerializer js = new JavaScriptSerializer(); List <DeviceModel> lstoutinfo = new List <DeviceModel>(); DeviceModel outinfo = null; using (SqlConnection con = DBhelp.conn()) { con.Open(); string sql = "select* from device_tb where userid = @userid"; SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.AddWithValue(@"userid", userid); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { outinfo = new DeviceModel(); outinfo.Deviceid = int.Parse(dr["deviceid"].ToString()); outinfo.Userid = int.Parse(dr["userid"].ToString()); outinfo.Devicecode = dr["devicecode"].ToString(); outinfo.Devicename = dr["devicename"].ToString(); outinfo.Deviceaddre = dr["deviceaddre"].ToString(); outinfo.Devicetime = dr["devicetime"].ToString(); outinfo.Deviceonline = int.Parse(dr["deviceonline"].ToString()); outinfo.Deviceinfo = dr["deviceinfo"].ToString(); lstoutinfo.Add(outinfo); } dr.Close(); con.Close(); } using (SqlConnection con = DBhelp.conn()) { con.Open(); for (int i = 0; i < lstoutinfo.Count; i++) { lstoutinfo[i].Plist = new List <ProbeModel>(); outinfo.Plist = new List <ProbeModel>(); ProbeModel pb = null; string sql = "select * from probe_tb where deviceid='" + lstoutinfo[i].Deviceid + "'"; SqlCommand cmd = new SqlCommand(sql, con); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { pb = new ProbeModel(); pb.Probename = dr["probename"].ToString(); pb.Probeid = int.Parse(dr["probeid"].ToString()); pb.Deviceid = int.Parse(dr["deviceid"].ToString()); pb.Probetemp = dr["probetemp"].ToString(); lstoutinfo[i].Plist.Add(pb); } dr.Close(); } con.Close(); } data = js.Serialize(lstoutinfo); if (data != null && data != "") { json = "{" + "\"code\"" + ":" + 200 + "," + "\"message\"" + ":" + "\"success\"" + "," + "\"device\"" + ":" + data + "}"; } else { json = "{" + "\"code\"" + ":" + 0 + "," + "\"message\"" + ":" + "\"error\"" + "}"; } return(json); }
private void Init_gridview() { dataGridView1.DataSource = DBhelp.GetDataTable("select * from supplier_info"); }
public string UserInfoIsDel(string[] number) { string[] messageOK = new string[number.Length]; string[] messageNO = new string[number.Length]; int okindex = 0; int noindex = 0; string ok = string.Empty; string no = string.Empty; var db = DBhelp.GetInstance(); try { foreach (var item in number) { UserInfo userInfo = db.Queryable <UserInfo>().First(r => r.UserNumber == item); if (userInfo != null) { userInfo.isDel = 1; int count = db.Updateable(userInfo).ExecuteCommand(); if (count > 0) { messageOK[okindex] = item; okindex++; } else { messageNO[noindex] = item; noindex++; } } } if (okindex != 0) { for (int i = 0; i < messageOK.Length; i++) { if (messageOK[i] != null) { ok = ok + messageOK[i].ToString() + " "; } else { break; } } } if (noindex != 0) { for (int i = 0; i < messageOK.Length; i++) { if (messageNO[i] != null) { no = no + messageNO[i].ToString() + " "; } else { break; } } } if (ok != "" && no != "") { return("编号为 " + ok + "的员工删除成功" + "ID为" + no + "的员工删除失败"); } else if (ok != "" && no == "") { return("编号为 " + ok + "的员工删除成功"); } else if (ok == "" && no != "") { return("编号为" + no + "的员工删除失败"); } else { return("未找到此员工"); } } catch (Exception e) { return("错误信息:" + e.Message); } }
public void DodajObecnoscTest() { int test_reader = 2; Assert.IsTrue(test_reader == DBhelp.DodajObecnosc(3, 1, "2019-02-10") + DBhelp.DodajObecnosc(3, 1, "2019-02-09")); }
public void DodajoceneTest() { int test_reader = 3; Assert.IsTrue(test_reader == DBhelp.Dodajocene(2, 8, 5, "2019-02-10") + DBhelp.Dodajocene(4, 6, 4, "2019-02-10") + DBhelp.Dodajocene(7, 3, 5, "2019-02-09")); }