ZKView.cs
上传用户:chizxy
上传日期:2014-11-29
资源大小:407k
文件大小:11k
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- using System.Data.SqlClient;
- namespace MKIms3
- {
- /// <summary>
- /// ZKView 的摘要说明。
- /// </summary>
- public class ZKView : System.Windows.Forms.Form
- {
- private bool hide;
- private System.Windows.Forms.DataGrid dataGrid_kong;
- private System.Windows.Forms.DataGrid dataGrid_ceng;
- private System.Windows.Forms.GroupBox groupBox_query;
- private System.Windows.Forms.TextBox txt_k_id;
- private System.Windows.Forms.Label label_k_id;
- private System.Windows.Forms.Button btn_query;
- private System.Windows.Forms.Button btn_all;
- private System.Windows.Forms.Splitter splitter1;
- private System.Windows.Forms.ContextMenu contextMenu_tool;
- private System.Windows.Forms.MenuItem menuItem_show;
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.Container components = null;
- public ZKView()
- {
- //
- // Windows 窗体设计器支持所必需的
- //
- InitializeComponent();
- //
- // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
- //
- this.hide = false;
- }
- /// <summary>
- /// 清理所有正在使用的资源。
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if(components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ZKView));
- this.dataGrid_kong = new System.Windows.Forms.DataGrid();
- this.contextMenu_tool = new System.Windows.Forms.ContextMenu();
- this.menuItem_show = new System.Windows.Forms.MenuItem();
- this.dataGrid_ceng = new System.Windows.Forms.DataGrid();
- this.groupBox_query = new System.Windows.Forms.GroupBox();
- this.btn_all = new System.Windows.Forms.Button();
- this.btn_query = new System.Windows.Forms.Button();
- this.label_k_id = new System.Windows.Forms.Label();
- this.txt_k_id = new System.Windows.Forms.TextBox();
- this.splitter1 = new System.Windows.Forms.Splitter();
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid_kong)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid_ceng)).BeginInit();
- this.groupBox_query.SuspendLayout();
- this.SuspendLayout();
- //
- // dataGrid_kong
- //
- this.dataGrid_kong.AlternatingBackColor = System.Drawing.SystemColors.Info;
- this.dataGrid_kong.CaptionBackColor = System.Drawing.Color.DarkGray;
- this.dataGrid_kong.CaptionText = "·钻孔基本信息";
- this.dataGrid_kong.ContextMenu = this.contextMenu_tool;
- this.dataGrid_kong.DataMember = "";
- this.dataGrid_kong.Dock = System.Windows.Forms.DockStyle.Top;
- this.dataGrid_kong.HeaderForeColor = System.Drawing.SystemColors.ControlText;
- this.dataGrid_kong.Location = new System.Drawing.Point(0, 48);
- this.dataGrid_kong.Name = "dataGrid_kong";
- this.dataGrid_kong.ReadOnly = true;
- this.dataGrid_kong.Size = new System.Drawing.Size(738, 192);
- this.dataGrid_kong.TabIndex = 0;
- this.dataGrid_kong.CurrentCellChanged += new System.EventHandler(this.dataGrid_kong_CurrentCellChanged);
- //
- // contextMenu_tool
- //
- this.contextMenu_tool.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItem_show});
- //
- // menuItem_show
- //
- this.menuItem_show.Enabled = false;
- this.menuItem_show.Index = 0;
- this.menuItem_show.Text = "查看该钻孔详细信息";
- this.menuItem_show.Click += new System.EventHandler(this.menuItem_show_Click);
- //
- // dataGrid_ceng
- //
- this.dataGrid_ceng.AlternatingBackColor = System.Drawing.SystemColors.Info;
- this.dataGrid_ceng.CaptionBackColor = System.Drawing.Color.DarkGray;
- this.dataGrid_ceng.CaptionText = "·当前钻孔相关煤层信息";
- this.dataGrid_ceng.DataMember = "";
- this.dataGrid_ceng.Dock = System.Windows.Forms.DockStyle.Fill;
- this.dataGrid_ceng.HeaderForeColor = System.Drawing.SystemColors.ControlText;
- this.dataGrid_ceng.Location = new System.Drawing.Point(0, 240);
- this.dataGrid_ceng.Name = "dataGrid_ceng";
- this.dataGrid_ceng.ReadOnly = true;
- this.dataGrid_ceng.Size = new System.Drawing.Size(738, 175);
- this.dataGrid_ceng.TabIndex = 1;
- //
- // groupBox_query
- //
- this.groupBox_query.Controls.Add(this.btn_all);
- this.groupBox_query.Controls.Add(this.btn_query);
- this.groupBox_query.Controls.Add(this.label_k_id);
- this.groupBox_query.Controls.Add(this.txt_k_id);
- this.groupBox_query.Dock = System.Windows.Forms.DockStyle.Top;
- this.groupBox_query.Location = new System.Drawing.Point(0, 0);
- this.groupBox_query.Name = "groupBox_query";
- this.groupBox_query.Size = new System.Drawing.Size(738, 48);
- this.groupBox_query.TabIndex = 0;
- this.groupBox_query.TabStop = false;
- this.groupBox_query.Text = "钻孔查询操作区";
- //
- // btn_all
- //
- this.btn_all.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.btn_all.Location = new System.Drawing.Point(328, 15);
- this.btn_all.Name = "btn_all";
- this.btn_all.Size = new System.Drawing.Size(112, 24);
- this.btn_all.TabIndex = 3;
- this.btn_all.Text = "浏览所有钻孔数据";
- this.btn_all.Click += new System.EventHandler(this.btn_all_Click);
- //
- // btn_query
- //
- this.btn_query.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.btn_query.Location = new System.Drawing.Point(255, 15);
- this.btn_query.Name = "btn_query";
- this.btn_query.Size = new System.Drawing.Size(56, 24);
- this.btn_query.TabIndex = 2;
- this.btn_query.Text = "查询";
- this.btn_query.Click += new System.EventHandler(this.btn_query_Click);
- //
- // label_k_id
- //
- this.label_k_id.Location = new System.Drawing.Point(39, 21);
- this.label_k_id.Name = "label_k_id";
- this.label_k_id.Size = new System.Drawing.Size(104, 16);
- this.label_k_id.TabIndex = 1;
- this.label_k_id.Text = "请输入钻孔编号:";
- this.label_k_id.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // txt_k_id
- //
- this.txt_k_id.Location = new System.Drawing.Point(142, 17);
- this.txt_k_id.Name = "txt_k_id";
- this.txt_k_id.TabIndex = 0;
- this.txt_k_id.Text = "";
- //
- // splitter1
- //
- this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
- this.splitter1.Location = new System.Drawing.Point(0, 240);
- this.splitter1.Name = "splitter1";
- this.splitter1.Size = new System.Drawing.Size(738, 4);
- this.splitter1.TabIndex = 2;
- this.splitter1.TabStop = false;
- //
- // ZKView
- //
- this.AcceptButton = this.btn_query;
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.AutoScroll = true;
- this.ClientSize = new System.Drawing.Size(738, 415);
- this.Controls.Add(this.splitter1);
- this.Controls.Add(this.dataGrid_ceng);
- this.Controls.Add(this.dataGrid_kong);
- this.Controls.Add(this.groupBox_query);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
- this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.MaximizeBox = false;
- this.Name = "ZKView";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "钻孔数据浏览";
- this.Load += new System.EventHandler(this.ZKView_Load);
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid_kong)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid_ceng)).EndInit();
- this.groupBox_query.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- #endregion
- private void ZKView_Load(object sender, System.EventArgs e)
- {
- }
- private void btn_query_Click(object sender, System.EventArgs e)
- {
- this.dataGrid_ceng.SetDataBinding(null,null);
- string k_id = "%"+this.txt_k_id.Text.Trim().ToString()+"%";
- this.Cursor = Cursors.WaitCursor;
- query_kong(k_id);
- this.Cursor = Cursors.Default;
- }
- private void dataGrid_kong_CurrentCellChanged(object sender, System.EventArgs e)
- {
- this.Cursor = Cursors.WaitCursor;
- string k_id = dataGrid_kong[dataGrid_kong.CurrentCell.RowNumber,0].ToString();
- fill_lay(k_id);
- this.Cursor = Cursors.Default;
- }
- private void btn_all_Click(object sender, System.EventArgs e)
- {
- this.txt_k_id.Text="";
- this.dataGrid_ceng.SetDataBinding(null,null);
- this.Cursor = Cursors.WaitCursor;
- fill_kong();
- this.Cursor = Cursors.Default;
- }
- #region 钻孔查询,相关煤层信息的显示
- /// <summary>
- /// 显示所有钻孔的信息
- /// </summary>
- private void fill_kong()
- {
- DataBase myDB = new DataBase();
- DataSet kongSet = new DataSet();
- kongSet = myDB.RunProcedure("up_get_kong_Allinfo","all_kong");
- this.dataGrid_kong.SetDataBinding(kongSet,"all_kong");
- this.menuItem_show.Enabled = true;
- }
- private void menuItem_show_Click(object sender, System.EventArgs e)
- {
- string k_id = dataGrid_kong[dataGrid_kong.CurrentCell.RowNumber,0].ToString().Trim();
- if(k_id.Length==0)
- {
- MessageBox.Show("请先选中一行再查看详细信息","错误信息",MessageBoxButtons.OK,MessageBoxIcon.Warning);
- }
- else
- {
- this.Cursor = Cursors.WaitCursor;
- ZKShow myshow = new ZKShow(k_id);
- myshow.ShowDialog();
- this.Cursor = Cursors.Default;
- }
- }
- /// <summary>
- /// 显示相关钻孔的煤层信息
- /// </summary>
- /// <param name="k_id"></param>
- private void fill_lay(string k_id)
- {
- DataBase myDB = new DataBase();
- DataSet LayDataSet = new DataSet();
- SqlParameter[] myParamers={new SqlParameter("@k_id",SqlDbType.Char,10)} ;
- myParamers[0].Value = k_id;
- LayDataSet = myDB.RunProcedure("up_get_ceng_info",myParamers,"all_kong");
- this.dataGrid_ceng.SetDataBinding(LayDataSet,"all_kong");
- if(this.hide == false)
- {
- hideColumn();
- }
- this.hide = true;
- }
- /// <summary>
- /// 隐藏前两列
- /// </summary>
- private void hideColumn()
- {
- DataGridTableStyle ts = new DataGridTableStyle();
- ts.MappingName = dataGrid_ceng.DataMember;
- dataGrid_ceng.TableStyles.Add(ts);
- dataGrid_ceng.TableStyles[0].GridColumnStyles[0].Width = 0;
- dataGrid_ceng.TableStyles[0].GridColumnStyles[1].Width = 0;
- dataGrid_ceng.TableStyles[0].AlternatingBackColor = System.Drawing.SystemColors.Info;
- }
- private void query_kong(string k_id)
- {
- DataBase myDB = new DataBase();
- DataSet LayDataSet = new DataSet();
- SqlParameter[] myParamers={new SqlParameter("@k_id",SqlDbType.Char,10)} ;
- myParamers[0].Value = k_id;
- LayDataSet = myDB.RunProcedure("up_get_kong_info",myParamers,"kong");
- this.dataGrid_kong.SetDataBinding(LayDataSet,"kong");
- this.menuItem_show.Enabled = true;
- }
-
- #endregion
-
-
-
-
- }
- }