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; } }
private void button2_Click(object sender, EventArgs e) { int index = dataGridView1.CurrentRow.Index; //获取选中行的行号 IDictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("id", dataGridView1.Rows[index].Cells[0].Value.ToString()); parameters.Add("staff", GlobalVar.name); parameters.Add("status", "处理中"); parameters.Add("stime", MyOperation.Datetime2Unix(DateTime.Now.ToString())); YouGeWebApi yg = new YouGeWebApi(); if (yg.UpdateYijian(parameters)) { MessageBox.Show("接单成功!"); LoadYijian(); } else { MessageBox.Show("接单失败!"); } }
/// <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; } }