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