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

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