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