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