tsgl.cs
上传用户:fuyouda
上传日期:2021-03-17
资源大小:8619k
文件大小:8k
源码类别:

Windows编程

开发平台:

C/C++

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7. using System.Data.OleDb;
  8. namespace WindowsApplication1
  9. {
  10. /// <summary>
  11. /// tsgl 的摘要说明。
  12. /// </summary>
  13. public class tsgl : System.Windows.Forms.Form
  14. {
  15. private System.Windows.Forms.DataGrid dataGrid1;
  16. private System.Windows.Forms.Button button3;
  17. private System.Windows.Forms.Button button4;
  18. private System.Windows.Forms.Button button5;
  19. private System.Windows.Forms.Button button6;
  20. private System.Windows.Forms.TextBox textBox1;
  21. private System.Windows.Forms.Label label3;
  22. private System.Windows.Forms.Label label1;
  23. private System.Windows.Forms.TextBox textBox2;
  24. /// <summary>
  25. /// 必需的设计器变量。
  26. /// </summary>
  27. private System.ComponentModel.Container components = null;
  28. public tsgl()
  29. {
  30. //
  31. // Windows 窗体设计器支持所必需的
  32. //
  33. InitializeComponent();
  34. //
  35. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  36. //
  37. }
  38. /// <summary>
  39. /// 清理所有正在使用的资源。
  40. /// </summary>
  41. protected override void Dispose( bool disposing )
  42. {
  43. if( disposing )
  44. {
  45. if(components != null)
  46. {
  47. components.Dispose();
  48. }
  49. }
  50. base.Dispose( disposing );
  51. }
  52. #region Windows 窗体设计器生成的代码
  53. /// <summary>
  54. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  55. /// 此方法的内容。
  56. /// </summary>
  57. private void InitializeComponent()
  58. {
  59. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(tsgl));
  60. this.dataGrid1 = new System.Windows.Forms.DataGrid();
  61. this.button3 = new System.Windows.Forms.Button();
  62. this.button4 = new System.Windows.Forms.Button();
  63. this.button5 = new System.Windows.Forms.Button();
  64. this.button6 = new System.Windows.Forms.Button();
  65. this.textBox1 = new System.Windows.Forms.TextBox();
  66. this.label3 = new System.Windows.Forms.Label();
  67. this.label1 = new System.Windows.Forms.Label();
  68. this.textBox2 = new System.Windows.Forms.TextBox();
  69. ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
  70. this.SuspendLayout();
  71. // 
  72. // dataGrid1
  73. // 
  74. this.dataGrid1.DataMember = "";
  75. this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
  76. this.dataGrid1.Location = new System.Drawing.Point(16, 104);
  77. this.dataGrid1.Name = "dataGrid1";
  78. this.dataGrid1.Size = new System.Drawing.Size(448, 232);
  79. this.dataGrid1.TabIndex = 6;
  80. // 
  81. // button3
  82. // 
  83. this.button3.BackColor = System.Drawing.Color.Transparent;
  84. this.button3.Location = new System.Drawing.Point(96, 352);
  85. this.button3.Name = "button3";
  86. this.button3.Size = new System.Drawing.Size(64, 28);
  87. this.button3.TabIndex = 7;
  88. this.button3.Text = "添加";
  89. this.button3.Click += new System.EventHandler(this.button3_Click);
  90. // 
  91. // button4
  92. // 
  93. this.button4.BackColor = System.Drawing.Color.Transparent;
  94. this.button4.Location = new System.Drawing.Point(304, 352);
  95. this.button4.Name = "button4";
  96. this.button4.Size = new System.Drawing.Size(64, 28);
  97. this.button4.TabIndex = 8;
  98. this.button4.Text = "删除";
  99. // 
  100. // button5
  101. // 
  102. this.button5.BackColor = System.Drawing.Color.Transparent;
  103. this.button5.Location = new System.Drawing.Point(200, 352);
  104. this.button5.Name = "button5";
  105. this.button5.Size = new System.Drawing.Size(64, 28);
  106. this.button5.TabIndex = 8;
  107. this.button5.Text = "修改";
  108. this.button5.Click += new System.EventHandler(this.button5_Click);
  109. // 
  110. // button6
  111. // 
  112. this.button6.BackColor = System.Drawing.Color.Transparent;
  113. this.button6.Location = new System.Drawing.Point(336, 56);
  114. this.button6.Name = "button6";
  115. this.button6.Size = new System.Drawing.Size(64, 28);
  116. this.button6.TabIndex = 9;
  117. this.button6.Text = "查询";
  118. this.button6.Click += new System.EventHandler(this.button6_Click);
  119. // 
  120. // textBox1
  121. // 
  122. this.textBox1.Location = new System.Drawing.Point(176, 64);
  123. this.textBox1.Name = "textBox1";
  124. this.textBox1.Size = new System.Drawing.Size(128, 21);
  125. this.textBox1.TabIndex = 10;
  126. this.textBox1.Text = "";
  127. // 
  128. // label3
  129. // 
  130. this.label3.BackColor = System.Drawing.Color.Transparent;
  131. this.label3.Location = new System.Drawing.Point(74, 71);
  132. this.label3.Name = "label3";
  133. this.label3.Size = new System.Drawing.Size(96, 16);
  134. this.label3.TabIndex = 11;
  135. this.label3.Text = "请填写投诉人:";
  136. // 
  137. // label1
  138. // 
  139. this.label1.BackColor = System.Drawing.Color.Transparent;
  140. this.label1.Location = new System.Drawing.Point(73, 23);
  141. this.label1.Name = "label1";
  142. this.label1.Size = new System.Drawing.Size(96, 16);
  143. this.label1.TabIndex = 13;
  144. this.label1.Text = "请填写投诉人:";
  145. // 
  146. // textBox2
  147. // 
  148. this.textBox2.Location = new System.Drawing.Point(176, 16);
  149. this.textBox2.Name = "textBox2";
  150. this.textBox2.Size = new System.Drawing.Size(128, 21);
  151. this.textBox2.TabIndex = 12;
  152. this.textBox2.Text = "Name";
  153. // 
  154. // tsgl
  155. // 
  156. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  157. this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
  158. this.ClientSize = new System.Drawing.Size(488, 384);
  159. this.Controls.Add(this.label1);
  160. this.Controls.Add(this.textBox2);
  161. this.Controls.Add(this.label3);
  162. this.Controls.Add(this.textBox1);
  163. this.Controls.Add(this.button6);
  164. this.Controls.Add(this.button4);
  165. this.Controls.Add(this.button3);
  166. this.Controls.Add(this.dataGrid1);
  167. this.Controls.Add(this.button5);
  168. this.Name = "tsgl";
  169. this.Text = "住户投诉管理";
  170. this.Load += new System.EventHandler(this.tsgl_Load);
  171. ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
  172. this.ResumeLayout(false);
  173. }
  174. #endregion
  175. private void button3_Click(object sender, System.EventArgs e)
  176. {
  177. modits myts=new modits();
  178. myts.Show();
  179. }
  180. private void button5_Click(object sender, System.EventArgs e)
  181. {
  182. modits myts=new modits();
  183. myts.Show();
  184. }
  185. private void tsgl_Load(object sender, System.EventArgs e)
  186. {
  187. string connstr,selectcmd;
  188. connstr="Provider=Microsoft.jet.oledb.4.0;data source="+Application.StartupPath+"\xqwy.mdb";
  189. selectcmd="select * from tsb";
  190. OleDbConnection conn=new OleDbConnection(connstr);
  191. conn.Open();
  192. OleDbDataAdapter da=new OleDbDataAdapter(selectcmd,conn);
  193. //OleDbDataAdapter oleDbDataAdapter1=new OleDbDataAdapter(selectcmd,conn);
  194. DataSet ds=new DataSet();
  195. //DataSet dataSet1=new DataSet();
  196. da.Fill(ds,"tsb");
  197. DataTable mytable=new DataTable();
  198. mytable=ds.Tables[0];
  199. this.dataGrid1.DataSource=mytable;
  200. }
  201. private void button6_Click(object sender, System.EventArgs e)
  202. {
  203. //查询记录
  204. try
  205. {
  206. string connstr,StrSQL;
  207. connstr="Provider=Microsoft.jet.oledb.4.0;data source="+Application.StartupPath+"\xqwy.mdb";
  208. StrSQL="SELECT * FROM tsb WHERE ";
  209. StrSQL+=this.textBox2.Text+" LIKE  '";
  210. StrSQL+=this.textBox1.Text+"'";
  211. OleDbConnection conn=new OleDbConnection(connstr);
  212. conn.Open();
  213. OleDbDataAdapter da=new OleDbDataAdapter(StrSQL,conn);
  214. DataSet ds=new DataSet();
  215. da.Fill(ds);
  216. DataTable mytable=new DataTable();
  217. mytable=ds.Tables[0];
  218. this.dataGrid1.DataSource=mytable;
  219. OleDbCommandBuilder cmdbld=new OleDbCommandBuilder(da);
  220. da.Update(mytable);
  221. }
  222. catch(Exception Err)
  223. {
  224. MessageBox.Show("查询数据集记录操作失败:"+Err.Message,"信息提示",
  225. MessageBoxButtons.OK,MessageBoxIcon.Information);
  226. }
  227. }
  228. }
  229. }