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

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. /// modisf 的摘要说明。
  12. /// </summary>
  13. public class modisf : 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.TextBox textBox3;
  21. private System.Windows.Forms.Label label4;
  22. private System.Windows.Forms.TextBox textBox4;
  23. private System.Windows.Forms.Label label5;
  24. private System.Windows.Forms.TextBox textBox5;
  25. private System.Windows.Forms.Label label6;
  26. private System.Windows.Forms.TextBox textBox6;
  27. private System.Windows.Forms.Label label7;
  28. private System.Windows.Forms.TextBox textBox7;
  29. private System.Windows.Forms.Label label8;
  30. private System.Windows.Forms.Button button1;
  31. private System.Windows.Forms.Button button2;
  32. private System.Windows.Forms.DateTimePicker dateTimePicker1;
  33. private System.Windows.Forms.Button button3;
  34. /// <summary>
  35. /// 必需的设计器变量。
  36. /// </summary>
  37. private System.ComponentModel.Container components = null;
  38. public modisf()
  39. {
  40. //
  41. // Windows 窗体设计器支持所必需的
  42. //
  43. InitializeComponent();
  44. //
  45. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  46. //
  47. }
  48. /// <summary>
  49. /// 清理所有正在使用的资源。
  50. /// </summary>
  51. protected override void Dispose( bool disposing )
  52. {
  53. if( disposing )
  54. {
  55. if(components != null)
  56. {
  57. components.Dispose();
  58. }
  59. }
  60. base.Dispose( disposing );
  61. }
  62. #region Windows 窗体设计器生成的代码
  63. /// <summary>
  64. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  65. /// 此方法的内容。
  66. /// </summary>
  67. private void InitializeComponent()
  68. {
  69. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(modisf));
  70. this.label1 = new System.Windows.Forms.Label();
  71. this.textBox1 = new System.Windows.Forms.TextBox();
  72. this.label2 = new System.Windows.Forms.Label();
  73. this.textBox2 = new System.Windows.Forms.TextBox();
  74. this.label3 = new System.Windows.Forms.Label();
  75. this.textBox3 = new System.Windows.Forms.TextBox();
  76. this.label4 = new System.Windows.Forms.Label();
  77. this.textBox4 = new System.Windows.Forms.TextBox();
  78. this.label5 = new System.Windows.Forms.Label();
  79. this.textBox5 = new System.Windows.Forms.TextBox();
  80. this.label6 = new System.Windows.Forms.Label();
  81. this.textBox6 = new System.Windows.Forms.TextBox();
  82. this.label7 = new System.Windows.Forms.Label();
  83. this.textBox7 = new System.Windows.Forms.TextBox();
  84. this.label8 = new System.Windows.Forms.Label();
  85. this.button1 = new System.Windows.Forms.Button();
  86. this.button2 = new System.Windows.Forms.Button();
  87. this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
  88. this.button3 = new System.Windows.Forms.Button();
  89. this.SuspendLayout();
  90. // 
  91. // label1
  92. // 
  93. this.label1.BackColor = System.Drawing.Color.Transparent;
  94. this.label1.Location = new System.Drawing.Point(224, 32);
  95. this.label1.Name = "label1";
  96. this.label1.Size = new System.Drawing.Size(48, 16);
  97. this.label1.TabIndex = 0;
  98. this.label1.Text = "编号:";
  99. // 
  100. // textBox1
  101. // 
  102. this.textBox1.Location = new System.Drawing.Point(224, 56);
  103. this.textBox1.Name = "textBox1";
  104. this.textBox1.Size = new System.Drawing.Size(144, 21);
  105. this.textBox1.TabIndex = 1;
  106. this.textBox1.Text = "";
  107. // 
  108. // label2
  109. // 
  110. this.label2.BackColor = System.Drawing.Color.Transparent;
  111. this.label2.Location = new System.Drawing.Point(24, 96);
  112. this.label2.Name = "label2";
  113. this.label2.Size = new System.Drawing.Size(48, 16);
  114. this.label2.TabIndex = 2;
  115. this.label2.Text = "水费:";
  116. // 
  117. // textBox2
  118. // 
  119. this.textBox2.Location = new System.Drawing.Point(24, 120);
  120. this.textBox2.Name = "textBox2";
  121. this.textBox2.Size = new System.Drawing.Size(144, 21);
  122. this.textBox2.TabIndex = 3;
  123. this.textBox2.Text = "";
  124. // 
  125. // label3
  126. // 
  127. this.label3.BackColor = System.Drawing.Color.Transparent;
  128. this.label3.Location = new System.Drawing.Point(24, 160);
  129. this.label3.Name = "label3";
  130. this.label3.Size = new System.Drawing.Size(48, 16);
  131. this.label3.TabIndex = 4;
  132. this.label3.Text = "气费:";
  133. // 
  134. // textBox3
  135. // 
  136. this.textBox3.Location = new System.Drawing.Point(24, 184);
  137. this.textBox3.Name = "textBox3";
  138. this.textBox3.Size = new System.Drawing.Size(144, 21);
  139. this.textBox3.TabIndex = 5;
  140. this.textBox3.Text = "";
  141. // 
  142. // label4
  143. // 
  144. this.label4.BackColor = System.Drawing.Color.Transparent;
  145. this.label4.Location = new System.Drawing.Point(24, 224);
  146. this.label4.Name = "label4";
  147. this.label4.Size = new System.Drawing.Size(56, 16);
  148. this.label4.TabIndex = 6;
  149. this.label4.Text = "其他费:";
  150. // 
  151. // textBox4
  152. // 
  153. this.textBox4.Location = new System.Drawing.Point(24, 248);
  154. this.textBox4.Name = "textBox4";
  155. this.textBox4.Size = new System.Drawing.Size(144, 21);
  156. this.textBox4.TabIndex = 7;
  157. this.textBox4.Text = "";
  158. this.textBox4.TextChanged += new System.EventHandler(this.textBox4_TextChanged);
  159. // 
  160. // label5
  161. // 
  162. this.label5.BackColor = System.Drawing.Color.Transparent;
  163. this.label5.Location = new System.Drawing.Point(24, 32);
  164. this.label5.Name = "label5";
  165. this.label5.Size = new System.Drawing.Size(56, 16);
  166. this.label5.TabIndex = 8;
  167. this.label5.Text = "门牌号:";
  168. // 
  169. // textBox5
  170. // 
  171. this.textBox5.Location = new System.Drawing.Point(24, 56);
  172. this.textBox5.Name = "textBox5";
  173. this.textBox5.Size = new System.Drawing.Size(144, 21);
  174. this.textBox5.TabIndex = 9;
  175. this.textBox5.Text = "";
  176. // 
  177. // label6
  178. // 
  179. this.label6.BackColor = System.Drawing.Color.Transparent;
  180. this.label6.Location = new System.Drawing.Point(224, 96);
  181. this.label6.Name = "label6";
  182. this.label6.Size = new System.Drawing.Size(48, 16);
  183. this.label6.TabIndex = 10;
  184. this.label6.Text = "电费:";
  185. // 
  186. // textBox6
  187. // 
  188. this.textBox6.Location = new System.Drawing.Point(224, 120);
  189. this.textBox6.Name = "textBox6";
  190. this.textBox6.Size = new System.Drawing.Size(144, 21);
  191. this.textBox6.TabIndex = 11;
  192. this.textBox6.Text = "";
  193. // 
  194. // label7
  195. // 
  196. this.label7.BackColor = System.Drawing.Color.Transparent;
  197. this.label7.Location = new System.Drawing.Point(224, 156);
  198. this.label7.Name = "label7";
  199. this.label7.Size = new System.Drawing.Size(56, 16);
  200. this.label7.TabIndex = 12;
  201. this.label7.Text = "物管费:";
  202. // 
  203. // textBox7
  204. // 
  205. this.textBox7.Location = new System.Drawing.Point(224, 184);
  206. this.textBox7.Name = "textBox7";
  207. this.textBox7.Size = new System.Drawing.Size(144, 21);
  208. this.textBox7.TabIndex = 13;
  209. this.textBox7.Text = "";
  210. // 
  211. // label8
  212. // 
  213. this.label8.BackColor = System.Drawing.Color.Transparent;
  214. this.label8.Location = new System.Drawing.Point(224, 224);
  215. this.label8.Name = "label8";
  216. this.label8.Size = new System.Drawing.Size(72, 16);
  217. this.label8.TabIndex = 14;
  218. this.label8.Text = "收费日期:";
  219. // 
  220. // button1
  221. // 
  222. this.button1.BackColor = System.Drawing.Color.Transparent;
  223. this.button1.Location = new System.Drawing.Point(40, 288);
  224. this.button1.Name = "button1";
  225. this.button1.Size = new System.Drawing.Size(64, 28);
  226. this.button1.TabIndex = 16;
  227. this.button1.Text = "添加";
  228. this.button1.Click += new System.EventHandler(this.button1_Click);
  229. // 
  230. // button2
  231. // 
  232. this.button2.BackColor = System.Drawing.Color.Transparent;
  233. this.button2.Location = new System.Drawing.Point(256, 288);
  234. this.button2.Name = "button2";
  235. this.button2.Size = new System.Drawing.Size(64, 28);
  236. this.button2.TabIndex = 17;
  237. this.button2.Text = "退  出";
  238. this.button2.Click += new System.EventHandler(this.button2_Click);
  239. // 
  240. // dateTimePicker1
  241. // 
  242. this.dateTimePicker1.Location = new System.Drawing.Point(224, 248);
  243. this.dateTimePicker1.Name = "dateTimePicker1";
  244. this.dateTimePicker1.Size = new System.Drawing.Size(152, 21);
  245. this.dateTimePicker1.TabIndex = 18;
  246. // 
  247. // button3
  248. // 
  249. this.button3.BackColor = System.Drawing.Color.Transparent;
  250. this.button3.Location = new System.Drawing.Point(152, 288);
  251. this.button3.Name = "button3";
  252. this.button3.Size = new System.Drawing.Size(64, 28);
  253. this.button3.TabIndex = 19;
  254. this.button3.Text = "修改";
  255. this.button3.Click += new System.EventHandler(this.button3_Click);
  256. // 
  257. // modisf
  258. // 
  259. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  260. this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
  261. this.ClientSize = new System.Drawing.Size(400, 336);
  262. this.Controls.Add(this.button3);
  263. this.Controls.Add(this.dateTimePicker1);
  264. this.Controls.Add(this.button2);
  265. this.Controls.Add(this.button1);
  266. this.Controls.Add(this.label8);
  267. this.Controls.Add(this.textBox7);
  268. this.Controls.Add(this.label7);
  269. this.Controls.Add(this.textBox6);
  270. this.Controls.Add(this.label6);
  271. this.Controls.Add(this.textBox5);
  272. this.Controls.Add(this.label5);
  273. this.Controls.Add(this.textBox4);
  274. this.Controls.Add(this.label4);
  275. this.Controls.Add(this.textBox3);
  276. this.Controls.Add(this.label3);
  277. this.Controls.Add(this.textBox2);
  278. this.Controls.Add(this.label2);
  279. this.Controls.Add(this.textBox1);
  280. this.Controls.Add(this.label1);
  281. this.Name = "modisf";
  282. this.Text = "添加、修改收费信息";
  283. this.Load += new System.EventHandler(this.modisf_Load);
  284. this.ResumeLayout(false);
  285. }
  286. #endregion
  287. private void button1_Click(object sender, System.EventArgs e)
  288. {
  289. //增加记录
  290. if(this.textBox2.Text.Length<1|this.textBox2.Text.Length<1|this.textBox3.Text.Length<1|this.textBox4.Text.Length<1|this.textBox5.Text.Length<1|this.textBox6.Text.Length<1|this.textBox3.Text.Length<1)
  291. {
  292. MessageBox.Show("客户所有信息必须填写!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
  293. return;
  294. }
  295. try
  296. {
  297. string connstr="Provider=Microsoft.jet.oledb.4.0;data source="+Application.StartupPath+"\xqwy.mdb";
  298. OleDbConnection conn=new OleDbConnection(connstr);
  299. conn.Open();
  300. string StrSQL="INSERT INTO sfb (Bh,Mph,Sf,Df,Qf,Wgf,Qtf)VALUES('"+this.textBox1.Text.Trim()+"','"+this.textBox5.Text.Trim()+"','"+this.textBox2.Text.Trim()+"','"+this.textBox6.Text.Trim()+"','"+this.textBox3.Text.Trim()+"','"+this.textBox7.Text.Trim()+"','"+this.textBox4.Text.Trim()+"')";
  301. OleDbCommand cmd=new OleDbCommand(StrSQL,conn);
  302. cmd.ExecuteNonQuery();
  303. MessageBox.Show("增加数据集记录操作成功!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
  304. }
  305. catch(Exception Err)
  306. {
  307. MessageBox.Show("增加数据集记录操作失败:"+Err.Message,"信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
  308. }
  309. }
  310. private void modisf_Load(object sender, System.EventArgs e)
  311. {
  312. }
  313. private void button3_Click(object sender, System.EventArgs e)
  314. {
  315. //修改记录
  316. try
  317. {
  318. OleDbConnection conn2=new OleDbConnection(@"provider=Microsoft.jet.oledb.4.0;data source="+Application.StartupPath+ "\xqwy.mdb");
  319. conn2.Open();
  320. string strsql="select * from sfb where Mph='"+this.textBox5.Text.Trim()+"' ";
  321. OleDbDataAdapter da=new OleDbDataAdapter(strsql,conn2);
  322. DataSet ds=new DataSet();
  323. da.Fill(ds);
  324. DataTable mytable=new DataTable();
  325. mytable=ds.Tables[0];
  326. DataRow row1;
  327. row1=mytable.Rows[0];
  328. row1[1]=this.textBox1.Text.Trim();
  329. row1[2]=this.textBox5.Text.Trim();
  330. row1[3]=this.textBox2.Text.Trim();
  331. row1[4]=this.textBox6.Text.Trim();
  332. row1[5]=this.textBox3.Text.Trim();
  333. row1[6]=this.textBox7.Text.Trim();
  334. row1[7]=this.textBox4.Text.Trim();
  335. //row1[7]=this.textBox8.Text.Trim();
  336. OleDbCommandBuilder cmdbld=new OleDbCommandBuilder(da);
  337. da.Update(mytable);
  338. MessageBox.Show("记录修改成功!");
  339. conn2.Close();
  340. }
  341. catch(Exception err)
  342. {
  343. MessageBox.Show(err.Message);
  344. }
  345. }
  346. private void button2_Click(object sender, System.EventArgs e)
  347. {
  348. Application.Exit();
  349. }
  350. private void textBox4_TextChanged(object sender, System.EventArgs e)
  351. {
  352. }
  353. }
  354. }