private void LoadYijian() { JObject jo; YouGeWebApi yg = new YouGeWebApi(); try { if (yg.GetYijian(out jo)) { int i = 0; gdt.Rows.Clear(); while (!string.IsNullOrEmpty(jo["data"][i]["id"].ToString())) { DataRow dr = gdt.NewRow(); dr["id"] = Convert.ToInt32(jo["data"][i]["id"].ToString()); dr["content"] = jo["data"][i]["content"].ToString(); dr["time"] = MyOperation.Unix2Datetime(jo["data"][i]["time"].ToString()); dr["status"] = jo["data"][i]["status"].ToString(); dr["staff"] = jo["data"][i]["staff"].ToString(); if (string.IsNullOrEmpty(jo["data"][i]["stime"].ToString())) { dr["stime"] = jo["data"][i]["stime"].ToString(); } else { dr["stime"] = MyOperation.Unix2Datetime(jo["data"][i]["stime"].ToString()); } dr["mark"] = jo["data"][i]["mark"].ToString(); gdt.Rows.Add(dr); i++; } } else { MessageBox.Show("初始化意见列表失败"); } } catch (Exception e) { MyOperation.DebugPrint("LoadYijian出现catch异常:" + e.Message); } finally { dataGridView1.DataSource = gdt.DefaultView; } }
/// <summary> /// 增删改操作 /// </summary> /// <param name="sql">sql语句</param> /// <returns>执行后的条数</returns> public int AddDelUpdate(string sql) { MySqlConnection conn = null; MySqlCommand cmd = null; try { conn = this.GetConn(); conn.Open(); cmd = new MySqlCommand(sql, conn); int i = cmd.ExecuteNonQuery(); conn.Close(); return(i); } catch (Exception ex) { MyOperation.DebugPrint(ex.Message); throw; } }
/// <summary> /// 查询操作 /// </summary> /// <param name="sql"></param> /// <returns></returns> public DataTable Selectinfo(string sql) { MySqlConnection mysqlconn = null; MySqlDataAdapter sda = null; DataTable dt = null; try { mysqlconn = this.GetConn(); mysqlconn.Open(); sda = new MySqlDataAdapter(sql, mysqlconn); dt = new DataTable(); sda.Fill(dt); mysqlconn.Close(); return(dt); } catch (Exception ex) { MyOperation.DebugPrint(ex.Message); throw; } }