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

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