ZKView.cs
上传用户:chizxy
上传日期:2014-11-29
资源大小:407k
文件大小:11k
源码类别:

其他行业

开发平台:

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.SqlClient;
  8. namespace MKIms3
  9. {
  10. /// <summary>
  11. /// ZKView 的摘要说明。
  12. /// </summary>
  13. public class ZKView : System.Windows.Forms.Form
  14. {
  15.         private bool hide;
  16. private System.Windows.Forms.DataGrid dataGrid_kong;
  17. private System.Windows.Forms.DataGrid dataGrid_ceng;
  18. private System.Windows.Forms.GroupBox groupBox_query;
  19. private System.Windows.Forms.TextBox txt_k_id;
  20. private System.Windows.Forms.Label label_k_id;
  21. private System.Windows.Forms.Button btn_query;
  22. private System.Windows.Forms.Button btn_all;
  23. private System.Windows.Forms.Splitter splitter1;
  24. private System.Windows.Forms.ContextMenu contextMenu_tool;
  25. private System.Windows.Forms.MenuItem menuItem_show;
  26. /// <summary>
  27. /// 必需的设计器变量。
  28. /// </summary>
  29. private System.ComponentModel.Container components = null;
  30. public ZKView()
  31. {
  32. //
  33. // Windows 窗体设计器支持所必需的
  34. //
  35. InitializeComponent();
  36. //
  37. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  38. //
  39. this.hide = false;
  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(ZKView));
  63. this.dataGrid_kong = new System.Windows.Forms.DataGrid();
  64. this.contextMenu_tool = new System.Windows.Forms.ContextMenu();
  65. this.menuItem_show = new System.Windows.Forms.MenuItem();
  66. this.dataGrid_ceng = new System.Windows.Forms.DataGrid();
  67. this.groupBox_query = new System.Windows.Forms.GroupBox();
  68. this.btn_all = new System.Windows.Forms.Button();
  69. this.btn_query = new System.Windows.Forms.Button();
  70. this.label_k_id = new System.Windows.Forms.Label();
  71. this.txt_k_id = new System.Windows.Forms.TextBox();
  72. this.splitter1 = new System.Windows.Forms.Splitter();
  73. ((System.ComponentModel.ISupportInitialize)(this.dataGrid_kong)).BeginInit();
  74. ((System.ComponentModel.ISupportInitialize)(this.dataGrid_ceng)).BeginInit();
  75. this.groupBox_query.SuspendLayout();
  76. this.SuspendLayout();
  77. // 
  78. // dataGrid_kong
  79. // 
  80. this.dataGrid_kong.AlternatingBackColor = System.Drawing.SystemColors.Info;
  81. this.dataGrid_kong.CaptionBackColor = System.Drawing.Color.DarkGray;
  82. this.dataGrid_kong.CaptionText = "·钻孔基本信息";
  83. this.dataGrid_kong.ContextMenu = this.contextMenu_tool;
  84. this.dataGrid_kong.DataMember = "";
  85. this.dataGrid_kong.Dock = System.Windows.Forms.DockStyle.Top;
  86. this.dataGrid_kong.HeaderForeColor = System.Drawing.SystemColors.ControlText;
  87. this.dataGrid_kong.Location = new System.Drawing.Point(0, 48);
  88. this.dataGrid_kong.Name = "dataGrid_kong";
  89. this.dataGrid_kong.ReadOnly = true;
  90. this.dataGrid_kong.Size = new System.Drawing.Size(738, 192);
  91. this.dataGrid_kong.TabIndex = 0;
  92. this.dataGrid_kong.CurrentCellChanged += new System.EventHandler(this.dataGrid_kong_CurrentCellChanged);
  93. // 
  94. // contextMenu_tool
  95. // 
  96. this.contextMenu_tool.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  97.  this.menuItem_show});
  98. // 
  99. // menuItem_show
  100. // 
  101. this.menuItem_show.Enabled = false;
  102. this.menuItem_show.Index = 0;
  103. this.menuItem_show.Text = "查看该钻孔详细信息";
  104. this.menuItem_show.Click += new System.EventHandler(this.menuItem_show_Click);
  105. // 
  106. // dataGrid_ceng
  107. // 
  108. this.dataGrid_ceng.AlternatingBackColor = System.Drawing.SystemColors.Info;
  109. this.dataGrid_ceng.CaptionBackColor = System.Drawing.Color.DarkGray;
  110. this.dataGrid_ceng.CaptionText = "·当前钻孔相关煤层信息";
  111. this.dataGrid_ceng.DataMember = "";
  112. this.dataGrid_ceng.Dock = System.Windows.Forms.DockStyle.Fill;
  113. this.dataGrid_ceng.HeaderForeColor = System.Drawing.SystemColors.ControlText;
  114. this.dataGrid_ceng.Location = new System.Drawing.Point(0, 240);
  115. this.dataGrid_ceng.Name = "dataGrid_ceng";
  116. this.dataGrid_ceng.ReadOnly = true;
  117. this.dataGrid_ceng.Size = new System.Drawing.Size(738, 175);
  118. this.dataGrid_ceng.TabIndex = 1;
  119. // 
  120. // groupBox_query
  121. // 
  122. this.groupBox_query.Controls.Add(this.btn_all);
  123. this.groupBox_query.Controls.Add(this.btn_query);
  124. this.groupBox_query.Controls.Add(this.label_k_id);
  125. this.groupBox_query.Controls.Add(this.txt_k_id);
  126. this.groupBox_query.Dock = System.Windows.Forms.DockStyle.Top;
  127. this.groupBox_query.Location = new System.Drawing.Point(0, 0);
  128. this.groupBox_query.Name = "groupBox_query";
  129. this.groupBox_query.Size = new System.Drawing.Size(738, 48);
  130. this.groupBox_query.TabIndex = 0;
  131. this.groupBox_query.TabStop = false;
  132. this.groupBox_query.Text = "钻孔查询操作区";
  133. // 
  134. // btn_all
  135. // 
  136. this.btn_all.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
  137. this.btn_all.Location = new System.Drawing.Point(328, 15);
  138. this.btn_all.Name = "btn_all";
  139. this.btn_all.Size = new System.Drawing.Size(112, 24);
  140. this.btn_all.TabIndex = 3;
  141. this.btn_all.Text = "浏览所有钻孔数据";
  142. this.btn_all.Click += new System.EventHandler(this.btn_all_Click);
  143. // 
  144. // btn_query
  145. // 
  146. this.btn_query.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
  147. this.btn_query.Location = new System.Drawing.Point(255, 15);
  148. this.btn_query.Name = "btn_query";
  149. this.btn_query.Size = new System.Drawing.Size(56, 24);
  150. this.btn_query.TabIndex = 2;
  151. this.btn_query.Text = "查询";
  152. this.btn_query.Click += new System.EventHandler(this.btn_query_Click);
  153. // 
  154. // label_k_id
  155. // 
  156. this.label_k_id.Location = new System.Drawing.Point(39, 21);
  157. this.label_k_id.Name = "label_k_id";
  158. this.label_k_id.Size = new System.Drawing.Size(104, 16);
  159. this.label_k_id.TabIndex = 1;
  160. this.label_k_id.Text = "请输入钻孔编号:";
  161. this.label_k_id.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  162. // 
  163. // txt_k_id
  164. // 
  165. this.txt_k_id.Location = new System.Drawing.Point(142, 17);
  166. this.txt_k_id.Name = "txt_k_id";
  167. this.txt_k_id.TabIndex = 0;
  168. this.txt_k_id.Text = "";
  169. // 
  170. // splitter1
  171. // 
  172. this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
  173. this.splitter1.Location = new System.Drawing.Point(0, 240);
  174. this.splitter1.Name = "splitter1";
  175. this.splitter1.Size = new System.Drawing.Size(738, 4);
  176. this.splitter1.TabIndex = 2;
  177. this.splitter1.TabStop = false;
  178. // 
  179. // ZKView
  180. // 
  181. this.AcceptButton = this.btn_query;
  182. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  183. this.AutoScroll = true;
  184. this.ClientSize = new System.Drawing.Size(738, 415);
  185. this.Controls.Add(this.splitter1);
  186. this.Controls.Add(this.dataGrid_ceng);
  187. this.Controls.Add(this.dataGrid_kong);
  188. this.Controls.Add(this.groupBox_query);
  189. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
  190. this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
  191. this.MaximizeBox = false;
  192. this.Name = "ZKView";
  193. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  194. this.Text = "钻孔数据浏览";
  195. this.Load += new System.EventHandler(this.ZKView_Load);
  196. ((System.ComponentModel.ISupportInitialize)(this.dataGrid_kong)).EndInit();
  197. ((System.ComponentModel.ISupportInitialize)(this.dataGrid_ceng)).EndInit();
  198. this.groupBox_query.ResumeLayout(false);
  199. this.ResumeLayout(false);
  200. }
  201. #endregion
  202. private void ZKView_Load(object sender, System.EventArgs e)
  203. {
  204. }
  205. private void btn_query_Click(object sender, System.EventArgs e)
  206. {
  207. this.dataGrid_ceng.SetDataBinding(null,null);
  208. string k_id = "%"+this.txt_k_id.Text.Trim().ToString()+"%";
  209.             this.Cursor = Cursors.WaitCursor;
  210. query_kong(k_id);
  211. this.Cursor = Cursors.Default;
  212. }
  213. private void dataGrid_kong_CurrentCellChanged(object sender, System.EventArgs e)
  214. {
  215. this.Cursor = Cursors.WaitCursor;
  216. string k_id = dataGrid_kong[dataGrid_kong.CurrentCell.RowNumber,0].ToString();
  217. fill_lay(k_id);
  218. this.Cursor = Cursors.Default;
  219. }
  220. private void btn_all_Click(object sender, System.EventArgs e)
  221. {
  222. this.txt_k_id.Text="";
  223. this.dataGrid_ceng.SetDataBinding(null,null);
  224. this.Cursor = Cursors.WaitCursor;
  225.     fill_kong();
  226. this.Cursor = Cursors.Default;
  227. }
  228. #region 钻孔查询,相关煤层信息的显示
  229. /// <summary>
  230. /// 显示所有钻孔的信息
  231. /// </summary>
  232. private void fill_kong()
  233. {
  234. DataBase myDB = new DataBase();
  235. DataSet kongSet = new DataSet();
  236. kongSet = myDB.RunProcedure("up_get_kong_Allinfo","all_kong");
  237. this.dataGrid_kong.SetDataBinding(kongSet,"all_kong");
  238. this.menuItem_show.Enabled = true;
  239. }
  240. private void menuItem_show_Click(object sender, System.EventArgs e)
  241. {
  242. string k_id = dataGrid_kong[dataGrid_kong.CurrentCell.RowNumber,0].ToString().Trim();
  243. if(k_id.Length==0)
  244. {
  245. MessageBox.Show("请先选中一行再查看详细信息","错误信息",MessageBoxButtons.OK,MessageBoxIcon.Warning);
  246. }
  247. else
  248. {
  249. this.Cursor = Cursors.WaitCursor;
  250. ZKShow myshow = new ZKShow(k_id);
  251. myshow.ShowDialog();
  252. this.Cursor = Cursors.Default;
  253. }
  254. }
  255. /// <summary>
  256. /// 显示相关钻孔的煤层信息
  257. /// </summary>
  258. /// <param name="k_id"></param>
  259. private void fill_lay(string k_id)
  260. {
  261. DataBase myDB = new DataBase();
  262. DataSet LayDataSet = new DataSet();
  263. SqlParameter[] myParamers={new SqlParameter("@k_id",SqlDbType.Char,10)} ;
  264. myParamers[0].Value = k_id;
  265. LayDataSet = myDB.RunProcedure("up_get_ceng_info",myParamers,"all_kong");
  266. this.dataGrid_ceng.SetDataBinding(LayDataSet,"all_kong");
  267. if(this.hide == false)
  268. {
  269. hideColumn();
  270. }
  271. this.hide = true;
  272. }
  273. /// <summary>
  274. /// 隐藏前两列
  275. /// </summary>
  276. private void hideColumn()
  277. {
  278. DataGridTableStyle ts = new DataGridTableStyle();
  279. ts.MappingName = dataGrid_ceng.DataMember;
  280. dataGrid_ceng.TableStyles.Add(ts);
  281. dataGrid_ceng.TableStyles[0].GridColumnStyles[0].Width = 0;
  282. dataGrid_ceng.TableStyles[0].GridColumnStyles[1].Width = 0;
  283. dataGrid_ceng.TableStyles[0].AlternatingBackColor = System.Drawing.SystemColors.Info;
  284. }
  285. private void query_kong(string k_id)
  286. {
  287. DataBase myDB = new DataBase();
  288. DataSet LayDataSet = new DataSet();
  289. SqlParameter[] myParamers={new SqlParameter("@k_id",SqlDbType.Char,10)} ;
  290. myParamers[0].Value = k_id;
  291. LayDataSet = myDB.RunProcedure("up_get_kong_info",myParamers,"kong");
  292. this.dataGrid_kong.SetDataBinding(LayDataSet,"kong");
  293. this.menuItem_show.Enabled = true;
  294. }
  295. #endregion
  296. }
  297. }