ZKAdd.cs
上传用户:chizxy
上传日期:2014-11-29
资源大小:407k
文件大小:31k
- 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>
- /// ZKAdd 的摘要说明。
- /// </summary>
- public class ZKAdd : System.Windows.Forms.Form
- {
- public delegate void SendMess ( double x,double y ,double z ,string k_id) ;
- //定义委托类型
- public event SendMess Send ;
-
- private string k_no;
- private double k_x;
- private double k_y;
- private double k_z;
- private double k_h;
- private string k_com;
- private DateTime k_date;
- private string k_other;
- private int k_id;
- private string k_lay;
- private bool bk_no;
- private bool bk_x;
- private bool bk_y;
- private bool bk_z;
- private bool bk_h;
- private bool bk_com;
- private bool bk_lay;
- private DataSet null_Set;
- private DataGridTableStyle GridTableStyle;
- private bool point; //用来标示是直接输入还是图上添加,图上为true
- #region 系统自己生成的字段
- private System.Windows.Forms.GroupBox groupBox4;
- private System.Windows.Forms.Button button_add_ceng;
- private System.Windows.Forms.TextBox textBox2;
- private System.Windows.Forms.Button button_add_kong;
- private System.Windows.Forms.GroupBox groupBox3;
- private System.Windows.Forms.DateTimePicker dateTimePicker_data;
- private System.Windows.Forms.TextBox txt_other;
- private System.Windows.Forms.Label label10;
- private System.Windows.Forms.Label label11;
- private System.Windows.Forms.Label label12;
- private System.Windows.Forms.Label label13;
- private System.Windows.Forms.Label label14;
- private System.Windows.Forms.Label label15;
- private System.Windows.Forms.Label label16;
- private System.Windows.Forms.TextBox txt_no;
- private System.Windows.Forms.TextBox txt_lay;
- private System.Windows.Forms.Label label17;
- private System.Windows.Forms.Label label18;
- private System.Windows.Forms.GroupBox groupBox2;
- private System.Windows.Forms.DataGrid dataGrid_lay;
-
- private System.Windows.Forms.NumericUpDown numericUpDown_x;
- private System.Windows.Forms.NumericUpDown numericUpDown_y;
- private System.Windows.Forms.NumericUpDown numericUpDown_z;
- private System.Windows.Forms.NumericUpDown numericUpDown_h;
- private System.Windows.Forms.TextBox txt_com;
- private System.Windows.Forms.ErrorProvider erp;
- #endregion
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.Container components = null;
- public ZKAdd(double x,double y,bool point)
- {
- //
- // Windows 窗体设计器支持所必需的
- //
- InitializeComponent();
- //
- // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
- //
- bk_no = false;
- bk_x= false;
- bk_y= false;
- bk_z= false;
- bk_h= false;
- bk_com= false;
- bk_lay= false;
- this.numericUpDown_x.Value = Convert.ToDecimal(x);
- this.numericUpDown_y.Value = Convert.ToDecimal(y);
- this.point = point;
- }
- /// <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(ZKAdd));
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.button_add_ceng = new System.Windows.Forms.Button();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.button_add_kong = new System.Windows.Forms.Button();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.numericUpDown_h = new System.Windows.Forms.NumericUpDown();
- this.numericUpDown_z = new System.Windows.Forms.NumericUpDown();
- this.numericUpDown_y = new System.Windows.Forms.NumericUpDown();
- this.numericUpDown_x = new System.Windows.Forms.NumericUpDown();
- this.dateTimePicker_data = new System.Windows.Forms.DateTimePicker();
- this.txt_other = new System.Windows.Forms.TextBox();
- this.txt_com = new System.Windows.Forms.TextBox();
- this.label10 = new System.Windows.Forms.Label();
- this.label11 = new System.Windows.Forms.Label();
- this.label12 = new System.Windows.Forms.Label();
- this.label13 = new System.Windows.Forms.Label();
- this.label14 = new System.Windows.Forms.Label();
- this.label15 = new System.Windows.Forms.Label();
- this.label16 = new System.Windows.Forms.Label();
- this.txt_no = new System.Windows.Forms.TextBox();
- this.txt_lay = new System.Windows.Forms.TextBox();
- this.label17 = new System.Windows.Forms.Label();
- this.label18 = new System.Windows.Forms.Label();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.dataGrid_lay = new System.Windows.Forms.DataGrid();
- this.erp = new System.Windows.Forms.ErrorProvider();
- this.groupBox4.SuspendLayout();
- this.groupBox3.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_h)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_z)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_y)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_x)).BeginInit();
- this.groupBox2.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid_lay)).BeginInit();
- this.SuspendLayout();
- //
- // groupBox4
- //
- this.groupBox4.Controls.Add(this.button_add_ceng);
- this.groupBox4.Controls.Add(this.textBox2);
- this.groupBox4.Controls.Add(this.button_add_kong);
- this.groupBox4.Location = new System.Drawing.Point(424, 8);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(272, 184);
- this.groupBox4.TabIndex = 10;
- this.groupBox4.TabStop = false;
- this.groupBox4.Text = "操作说明";
- //
- // button_add_ceng
- //
- this.button_add_ceng.Enabled = false;
- this.button_add_ceng.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.button_add_ceng.Location = new System.Drawing.Point(139, 144);
- this.button_add_ceng.Name = "button_add_ceng";
- this.button_add_ceng.Size = new System.Drawing.Size(119, 24);
- this.button_add_ceng.TabIndex = 1;
- this.button_add_ceng.Text = "提交钻孔煤层信息";
- this.button_add_ceng.Click += new System.EventHandler(this.button_add_ceng_Click);
- //
- // textBox2
- //
- this.textBox2.AcceptsReturn = true;
- this.textBox2.BackColor = System.Drawing.SystemColors.Info;
- this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.textBox2.Cursor = System.Windows.Forms.Cursors.No;
- this.textBox2.Enabled = false;
- this.textBox2.ForeColor = System.Drawing.Color.DarkRed;
- this.textBox2.Location = new System.Drawing.Point(8, 16);
- this.textBox2.Multiline = true;
- this.textBox2.Name = "textBox2";
- this.textBox2.Size = new System.Drawing.Size(256, 120);
- this.textBox2.TabIndex = 2;
- this.textBox2.Text = " 1.带(*)的项为必填项 。 2.首先填写钻孔" +
- "基本信息,确认无误后提交。 3.依次填写钻孔煤层信息,确认无误后提交。 4.您添加的钻孔只能在系统默认地图上显示。 5.岩性说明:您可以从下拉列表框中选择" +
- ",如果所需岩性不存在,请先在岩性管理操作中添加。6.层位说明:例如 P2(2-1)中前一个2为下标“2-1”为上标,其他依此类推。 ";
- //
- // button_add_kong
- //
- this.button_add_kong.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.button_add_kong.Location = new System.Drawing.Point(11, 144);
- this.button_add_kong.Name = "button_add_kong";
- this.button_add_kong.Size = new System.Drawing.Size(120, 24);
- this.button_add_kong.TabIndex = 0;
- this.button_add_kong.Text = "提交钻孔基本信息";
- this.button_add_kong.Click += new System.EventHandler(this.button_add_kong_Click);
- //
- // groupBox3
- //
- this.groupBox3.Controls.Add(this.numericUpDown_h);
- this.groupBox3.Controls.Add(this.numericUpDown_z);
- this.groupBox3.Controls.Add(this.numericUpDown_y);
- this.groupBox3.Controls.Add(this.numericUpDown_x);
- this.groupBox3.Controls.Add(this.dateTimePicker_data);
- this.groupBox3.Controls.Add(this.txt_other);
- this.groupBox3.Controls.Add(this.txt_com);
- this.groupBox3.Controls.Add(this.label10);
- this.groupBox3.Controls.Add(this.label11);
- this.groupBox3.Controls.Add(this.label12);
- this.groupBox3.Controls.Add(this.label13);
- this.groupBox3.Controls.Add(this.label14);
- this.groupBox3.Controls.Add(this.label15);
- this.groupBox3.Controls.Add(this.label16);
- this.groupBox3.Controls.Add(this.txt_no);
- this.groupBox3.Controls.Add(this.txt_lay);
- this.groupBox3.Controls.Add(this.label17);
- this.groupBox3.Controls.Add(this.label18);
- this.groupBox3.Location = new System.Drawing.Point(8, 8);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(408, 184);
- this.groupBox3.TabIndex = 8;
- this.groupBox3.TabStop = false;
- this.groupBox3.Text = "钻孔基本信息";
- //
- // numericUpDown_h
- //
- this.numericUpDown_h.DecimalPlaces = 2;
- this.numericUpDown_h.Location = new System.Drawing.Point(286, 24);
- this.numericUpDown_h.Maximum = new System.Decimal(new int[] {
- 999999999,
- 0,
- 0,
- 0});
- this.numericUpDown_h.Name = "numericUpDown_h";
- this.numericUpDown_h.Size = new System.Drawing.Size(98, 21);
- this.numericUpDown_h.TabIndex = 4;
- this.numericUpDown_h.ThousandsSeparator = true;
- this.numericUpDown_h.Validated += new System.EventHandler(this.numericUpDown_h_Validated);
- //
- // numericUpDown_z
- //
- this.numericUpDown_z.DecimalPlaces = 2;
- this.numericUpDown_z.Location = new System.Drawing.Point(88, 97);
- this.numericUpDown_z.Maximum = new System.Decimal(new int[] {
- 999999999,
- 0,
- 0,
- 0});
- this.numericUpDown_z.Name = "numericUpDown_z";
- this.numericUpDown_z.Size = new System.Drawing.Size(96, 21);
- this.numericUpDown_z.TabIndex = 3;
- this.numericUpDown_z.ThousandsSeparator = true;
- this.numericUpDown_z.Validated += new System.EventHandler(this.numericUpDown_z_Validated);
- //
- // numericUpDown_y
- //
- this.numericUpDown_y.DecimalPlaces = 2;
- this.numericUpDown_y.Location = new System.Drawing.Point(88, 73);
- this.numericUpDown_y.Maximum = new System.Decimal(new int[] {
- 999999999,
- 0,
- 0,
- 0});
- this.numericUpDown_y.Name = "numericUpDown_y";
- this.numericUpDown_y.Size = new System.Drawing.Size(96, 21);
- this.numericUpDown_y.TabIndex = 2;
- this.numericUpDown_y.ThousandsSeparator = true;
- this.numericUpDown_y.Validated += new System.EventHandler(this.numericUpDown_y_Validated);
- //
- // numericUpDown_x
- //
- this.numericUpDown_x.DecimalPlaces = 2;
- this.numericUpDown_x.Location = new System.Drawing.Point(88, 49);
- this.numericUpDown_x.Maximum = new System.Decimal(new int[] {
- 999999999,
- 0,
- 0,
- 0});
- this.numericUpDown_x.Name = "numericUpDown_x";
- this.numericUpDown_x.Size = new System.Drawing.Size(96, 21);
- this.numericUpDown_x.TabIndex = 1;
- this.numericUpDown_x.ThousandsSeparator = true;
- this.numericUpDown_x.Validated += new System.EventHandler(this.numericUpDown_x_Validated);
- //
- // dateTimePicker_data
- //
- this.dateTimePicker_data.Location = new System.Drawing.Point(286, 99);
- this.dateTimePicker_data.Name = "dateTimePicker_data";
- this.dateTimePicker_data.Size = new System.Drawing.Size(98, 21);
- this.dateTimePicker_data.TabIndex = 7;
- //
- // txt_other
- //
- this.txt_other.Location = new System.Drawing.Point(86, 128);
- this.txt_other.Multiline = true;
- this.txt_other.Name = "txt_other";
- this.txt_other.Size = new System.Drawing.Size(298, 48);
- this.txt_other.TabIndex = 8;
- this.txt_other.Text = "";
- //
- // txt_com
- //
- this.txt_com.Location = new System.Drawing.Point(286, 73);
- this.txt_com.Name = "txt_com";
- this.txt_com.Size = new System.Drawing.Size(98, 21);
- this.txt_com.TabIndex = 6;
- this.txt_com.Text = "";
- this.txt_com.Validated += new System.EventHandler(this.txt_com_Validated);
- //
- // label10
- //
- this.label10.Location = new System.Drawing.Point(38, 144);
- this.label10.Name = "label10";
- this.label10.Size = new System.Drawing.Size(32, 16);
- this.label10.TabIndex = 23;
- this.label10.Text = "备注";
- //
- // label11
- //
- this.label11.Location = new System.Drawing.Point(206, 81);
- this.label11.Name = "label11";
- this.label11.Size = new System.Drawing.Size(76, 16);
- this.label11.TabIndex = 20;
- this.label11.Text = "施工单位(*)";
- //
- // label12
- //
- this.label12.Location = new System.Drawing.Point(206, 104);
- this.label12.Name = "label12";
- this.label12.Size = new System.Drawing.Size(76, 16);
- this.label12.TabIndex = 19;
- this.label12.Text = "施工时间(*)";
- //
- // label13
- //
- this.label13.Location = new System.Drawing.Point(6, 77);
- this.label13.Name = "label13";
- this.label13.Size = new System.Drawing.Size(80, 16);
- this.label13.TabIndex = 2;
- this.label13.Text = "孔口坐标Y(*)";
- //
- // label14
- //
- this.label14.Location = new System.Drawing.Point(6, 102);
- this.label14.Name = "label14";
- this.label14.Size = new System.Drawing.Size(80, 16);
- this.label14.TabIndex = 3;
- this.label14.Text = "孔口坐标Z(*)";
- //
- // label15
- //
- this.label15.Location = new System.Drawing.Point(206, 30);
- this.label15.Name = "label15";
- this.label15.Size = new System.Drawing.Size(76, 16);
- this.label15.TabIndex = 21;
- this.label15.Text = "终孔深度(*)";
- //
- // label16
- //
- this.label16.Location = new System.Drawing.Point(14, 28);
- this.label16.Name = "label16";
- this.label16.Size = new System.Drawing.Size(72, 17);
- this.label16.TabIndex = 0;
- this.label16.Text = "钻孔编号(*)";
- //
- // txt_no
- //
- this.txt_no.Location = new System.Drawing.Point(88, 23);
- this.txt_no.Name = "txt_no";
- this.txt_no.Size = new System.Drawing.Size(96, 21);
- this.txt_no.TabIndex = 0;
- this.txt_no.Text = "";
- this.txt_no.Validated += new System.EventHandler(this.txt_no_Validated);
- //
- // txt_lay
- //
- this.txt_lay.Location = new System.Drawing.Point(286, 48);
- this.txt_lay.Name = "txt_lay";
- this.txt_lay.Size = new System.Drawing.Size(98, 21);
- this.txt_lay.TabIndex = 5;
- this.txt_lay.Text = "";
- this.txt_lay.Validated += new System.EventHandler(this.txt_lay_Validated);
- //
- // label17
- //
- this.label17.Location = new System.Drawing.Point(206, 54);
- this.label17.Name = "label17";
- this.label17.Size = new System.Drawing.Size(76, 16);
- this.label17.TabIndex = 22;
- this.label17.Text = "终孔层位(*)";
- //
- // label18
- //
- this.label18.Location = new System.Drawing.Point(6, 53);
- this.label18.Name = "label18";
- this.label18.Size = new System.Drawing.Size(80, 17);
- this.label18.TabIndex = 1;
- this.label18.Text = "孔口坐标X(*)";
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.dataGrid_lay);
- this.groupBox2.Location = new System.Drawing.Point(8, 192);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(688, 186);
- this.groupBox2.TabIndex = 9;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "钻孔煤层信息";
- //
- // dataGrid_lay
- //
- this.dataGrid_lay.CaptionVisible = false;
- this.dataGrid_lay.DataMember = "";
- this.dataGrid_lay.Dock = System.Windows.Forms.DockStyle.Fill;
- this.dataGrid_lay.HeaderForeColor = System.Drawing.SystemColors.ControlText;
- this.dataGrid_lay.Location = new System.Drawing.Point(3, 17);
- this.dataGrid_lay.Name = "dataGrid_lay";
- this.dataGrid_lay.Size = new System.Drawing.Size(682, 166);
- this.dataGrid_lay.TabIndex = 0;
- //
- // erp
- //
- this.erp.ContainerControl = this;
- //
- // ZKAdd
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(704, 389);
- this.Controls.Add(this.groupBox4);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox2);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
- this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.Name = "ZKAdd";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "钻孔数据添加";
- this.groupBox4.ResumeLayout(false);
- this.groupBox3.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_h)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_z)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_y)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_x)).EndInit();
- this.groupBox2.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid_lay)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion
- #region 得到输入的数据、验证数据
- private void get_value()
- {
- this.k_no = this.txt_no.Text.Trim();
- this.k_x = Convert.ToDouble(this.numericUpDown_x.Value);
- this.k_y = Convert.ToDouble(this.numericUpDown_y.Value);
- this.k_z = Convert.ToDouble(this.numericUpDown_z.Value);
- this.k_h = Convert.ToDouble(this.numericUpDown_h.Value);
- this.k_other = this.txt_other.Text.Trim();
- this.k_com = this.txt_com.Text.Trim();
- this.k_date = (DateTime)this.dateTimePicker_data.Value;
- this.k_lay = this.txt_lay.Text.Trim();
- }
- /// <summary>
- /// 设置错误信息和去掉错误信息
- /// </summary>
- /// <param name="no">是否错误</param>
- /// <param name="control">错误的对象</param>
- /// <param name="errstring">错误的信息</param>
- private void setErr(bool no,System.Windows.Forms.Control control,string errstring,ref bool b_ok)
- {
- if(no)
- {
- this.erp.SetError(control,errstring);
- b_ok = false;
- }
- else
- {
- this.erp.SetError(control,"");
- b_ok = true;
- }
- }
-
- #endregion
- #region 添加钻孔的基本信息 、添加相关煤层信息
- /// <summary>
- /// 判断钻孔是否存在
- /// </summary>
- /// <param name="k_no">钻孔的编号</param>
- /// <returns>true or false 不存在返回true</returns>
- private bool kong_isin(string k_no)
- {
- DataBase myDB = new DataBase();
- SqlParameter[] myParamers={
- new SqlParameter("@k_id",SqlDbType.Char,10),
- new SqlParameter("@count",SqlDbType.Int)
- };
- myParamers[0].Value = k_no;
- myParamers[1].Direction = ParameterDirection.Output;
- if(myDB.RunProcedure_Nr("up_find_kong",myParamers))
- {
- int m = Convert.ToInt32(myParamers[1].Value);
- if(m==0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
-
- }
- /// <summary>
- /// 开始添加钻孔的基本信息,并且得到该条纪录的id号
- /// </summary>
- /// <returns>添加是否成功</returns>
- private bool add_kong_ok()
- {
- DataBase myDB = new DataBase();
- SqlParameter[] myParamers={
- new SqlParameter("@k_bianhao",SqlDbType.Char,10),
- new SqlParameter("@x",SqlDbType.Float),
- new SqlParameter("@y",SqlDbType.Float),
- new SqlParameter("@z",SqlDbType.Float),
- new SqlParameter("@shigong_time",SqlDbType.DateTime),
- new SqlParameter("@shigong_danwei",SqlDbType.Char,30),
- new SqlParameter("@beizhu",SqlDbType.VarChar,500),
- new SqlParameter("@kong_shendu",SqlDbType.Float),
- new SqlParameter("@kong_cengwei",SqlDbType.Char,5),
- new SqlParameter("@k_id",SqlDbType.Int,4)
- } ;
- myParamers[0].Value = this.k_no;
- myParamers[1].Value = this.k_x;
- myParamers[2].Value = this.k_y;
- myParamers[3].Value = this.k_z;
- myParamers[4].Value = this.k_date;
- myParamers[5].Value = this.k_com;
- myParamers[6].Value = this.k_other;
- myParamers[7].Value = this.k_h;
- myParamers[8].Value = this.k_lay;
- myParamers[9].Direction = ParameterDirection.Output;
- if(myDB.RunProcedure_Nr("up_add_kong",myParamers))
- {
- this.k_id = Convert.ToInt32(myParamers[9].Value);
- return true;
- }
- else
- {
- MessageBox.Show("添加钻孔信息错误!","错误信息",MessageBoxButtons.OK,MessageBoxIcon.Error);
- return false;
- }
- }
- /// <summary>
- /// 得到所有的填充选项
- /// </summary>
- /// <returns>DataSet 包含填充信息</returns>
- private DataSet get_fill()
- {
- DataSet yanset = new DataSet();
- DataBase myDB = new DataBase();
- yanset = myDB.RunProcedure("get_yanxin","yan");
- return yanset;
- }
-
- /// <summary>
- /// 得到一个空的dataset以接受煤层信息的输入
- /// </summary>
- /// <returns>DataSet 空的 包含煤层信息字段</returns>
- private DataSet get_null_lay()
- {
- DataSet myset = new DataSet();
- DataBase myDB = new DataBase();
- SqlParameter[] myParamers={new SqlParameter("@k_id",SqlDbType.Char,10)} ;
- myParamers[0].Value = 0; //显示一个空的
- myset = myDB.RunProcedure("up_get_ceng_info",myParamers,"null_lay");
- return myset;
- }
-
- /// <summary>
- /// 添加datagrid的列标题
- /// </summary>
- /// <param name="myset">空的层位dataset</param>
- /// <param name="yanset">下拉框的填充</param>
- /// <param name="k_id">所添加的钻孔的id号</param>
- private void Addstyle(DataSet myset,DataSet yanset,int k_id)
- {
-
- CurrencyManager objcengCM;
- GridTableStyle = new DataGridTableStyle();
- GridTableStyle.MappingName = "null_lay";
- objcengCM = (System.Windows.Forms.CurrencyManager)this.BindingContext[myset.Tables[0]];
- GridTableStyle.GridColumnStyles.Add(new DataGridTextBoxColumn(objcengCM .GetItemProperties()["煤层名称"]));
- GridTableStyle.GridColumnStyles[0].MappingName = "煤层名称";
- GridTableStyle.GridColumnStyles[0].HeaderText = "煤层名称";
- GridTableStyle.GridColumnStyles[0].Alignment = HorizontalAlignment.Left;
- GridTableStyle.GridColumnStyles[0].NullText = string.Empty;
- GridTableStyle.GridColumnStyles.Add(new DataGridTextBoxColumn(objcengCM .GetItemProperties()["止煤深度"]));
- GridTableStyle.GridColumnStyles[1].MappingName = "止煤深度";
- GridTableStyle.GridColumnStyles[1].HeaderText = "止煤深度";
- GridTableStyle.GridColumnStyles[1].Alignment = HorizontalAlignment.Left;
- GridTableStyle.GridColumnStyles[1].NullText = string.Empty;
- GridTableStyle.GridColumnStyles.Add(new DataGridTextBoxColumn(objcengCM .GetItemProperties()["底板坐标x"]));
- GridTableStyle.GridColumnStyles[2].MappingName = "底板坐标x";
- GridTableStyle.GridColumnStyles[2].HeaderText = "底板坐标x";
- GridTableStyle.GridColumnStyles[2].Alignment = HorizontalAlignment.Left;
- GridTableStyle.GridColumnStyles[2].NullText = string.Empty;
- GridTableStyle.GridColumnStyles.Add(new DataGridTextBoxColumn(objcengCM .GetItemProperties()["底板坐标y"]));
- GridTableStyle.GridColumnStyles[3].MappingName = "底板坐标y";
- GridTableStyle.GridColumnStyles[3].HeaderText = "底板坐标y";
- GridTableStyle.GridColumnStyles[3].Alignment = HorizontalAlignment.Left;
- GridTableStyle.GridColumnStyles[3].NullText = string.Empty;
-
- GridTableStyle.GridColumnStyles.Add(new DataGridTextBoxColumn(objcengCM .GetItemProperties()["底板坐标z"]));
- GridTableStyle.GridColumnStyles[4].MappingName = "底板坐标z";
- GridTableStyle.GridColumnStyles[4].HeaderText = "底板坐标z";
- GridTableStyle.GridColumnStyles[4].Alignment = HorizontalAlignment.Left;
- GridTableStyle.GridColumnStyles[4].NullText = string.Empty;
- GridTableStyle.GridColumnStyles.Add(new DataGridTextBoxColumn(objcengCM .GetItemProperties()["煤层伪厚"]));
- GridTableStyle.GridColumnStyles[5].MappingName = "煤层伪厚";
- GridTableStyle.GridColumnStyles[5].HeaderText = "煤层伪厚";
- GridTableStyle.GridColumnStyles[5].Alignment = HorizontalAlignment.Left;
- GridTableStyle.GridColumnStyles[5].NullText = string.Empty;
- GridTableStyle.GridColumnStyles.Add(new DataGridTextBoxColumn(objcengCM .GetItemProperties()["利用厚度"]));
- GridTableStyle.GridColumnStyles[6].MappingName = "利用厚度";
- GridTableStyle.GridColumnStyles[6].HeaderText = "利用厚度";
- GridTableStyle.GridColumnStyles[6].Alignment = HorizontalAlignment.Left;
- GridTableStyle.GridColumnStyles[6].NullText = string.Empty;
- GridTableStyle.GridColumnStyles.Add(new DataGridTextBoxColumn(objcengCM .GetItemProperties()["煤层倾角"]));
- GridTableStyle.GridColumnStyles[7].MappingName = "煤层倾角";
- GridTableStyle.GridColumnStyles[7].HeaderText = "煤层倾角";
- GridTableStyle.GridColumnStyles[7].Alignment = HorizontalAlignment.Left;
- GridTableStyle.GridColumnStyles[7].NullText = string.Empty;
- GridTableStyle.GridColumnStyles.Add(new DataGridComboBoxColumn(yanset.Tables["yan"],0,0));
- GridTableStyle.GridColumnStyles[8].MappingName = "顶板岩性";
- GridTableStyle.GridColumnStyles[8].HeaderText = "顶板岩性";
- GridTableStyle.GridColumnStyles[8].Alignment = HorizontalAlignment.Left;
- GridTableStyle.GridColumnStyles[8].NullText = string.Empty;
- GridTableStyle.GridColumnStyles.Add(new DataGridComboBoxColumn(yanset.Tables["yan"],0,0));
- GridTableStyle.GridColumnStyles[9].MappingName = "底板岩性";
- GridTableStyle.GridColumnStyles[9].HeaderText = "底板岩性";
- GridTableStyle.GridColumnStyles[9].Alignment = HorizontalAlignment.Left;
- GridTableStyle.GridColumnStyles[9].NullText = string.Empty;
- GridTableStyle.GridColumnStyles.Add(new DataGridTextBoxColumn(objcengCM .GetItemProperties()["等级"]));
- GridTableStyle.GridColumnStyles[10].MappingName = "等级";
- GridTableStyle.GridColumnStyles[10].HeaderText = "等级";
- GridTableStyle.GridColumnStyles[10].Alignment = HorizontalAlignment.Left;
- GridTableStyle.GridColumnStyles[10].NullText = string.Empty;
-
- GridTableStyle.GridColumnStyles.Add(new DataGridTextBoxColumn(objcengCM .GetItemProperties()["钻孔序号"]));
- GridTableStyle.GridColumnStyles[11].MappingName = "钻孔序号";
- GridTableStyle.GridColumnStyles[11].HeaderText = "钻孔序号";
- GridTableStyle.GridColumnStyles[11].Alignment = HorizontalAlignment.Left;
- GridTableStyle.GridColumnStyles[11].Width =0; //隐藏起来不让用户输入
- GridTableStyle.GridColumnStyles[11].NullText = k_id.ToString();
- GridTableStyle.GridColumnStyles[11].ReadOnly = true;
- }
- private void show_add_lay()
- {
- this.null_Set = get_null_lay();
- null_Set.Tables[0].Columns["钻孔序号"].DefaultValue = this.k_id;
- DataSet yanset = new DataSet();
- yanset = get_fill();
- Addstyle(this.null_Set,yanset,this.k_id);
- this.dataGrid_lay.DataSource = this.null_Set;
- this.dataGrid_lay.DataMember="null_lay";
- this.dataGrid_lay.TableStyles.Add(this.GridTableStyle);
- }
-
- #endregion
- #region 添加钻孔有关的煤层信息 ,在地图关联钻孔中添加相应的纪录
- /// <summary>
- /// 将与null_set关联的datagrid里面的数据更新回数据库
- /// </summary>
- /// <returns></returns>
- private bool add_lay()
- {
- DataBase myDB = new DataBase();
- string selectaa = " select ceng.煤层名称, ceng.止煤深度, ceng.底板坐标x, ceng.底板坐标y, ceng.底板坐标z, ceng.煤层伪厚, ceng.煤层倾角, ceng.利用厚度, ceng.顶板岩性, ceng.底板岩性, ceng.钻孔序号, ceng.等级 from 煤层关联钻孔 as ceng where 1>2";
- if(myDB.Run_change(selectaa,this.null_Set,"null_lay"))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 添加钻孔关联地图的纪录
- /// </summary>
- /// <param name="kong_id">钻孔的id</param>
- /// <param name="map_id">地图的id</param>
- /// <returns></returns>
- private bool add_map_kong(int kong_id,int map_id)
- {
- DataBase myDB = new DataBase();
- SqlParameter[] myParamers={
- new SqlParameter("@k_id",SqlDbType.Int),
- new SqlParameter("@map_id",SqlDbType.Int)
- };
- myParamers[0].Value = kong_id;
- myParamers[1].Value = map_id;
- if(myDB.RunProcedure_Nr("up_add_map_kong",myParamers))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- #endregion
- private void txt_no_Validated(object sender, System.EventArgs e)
- {
- bool no = (this.txt_no.Text.Length == 0);
- setErr(no,this.txt_no,"钻孔编号不能为空",ref this.bk_no);
- }
- private void txt_lay_Validated(object sender, System.EventArgs e)
- {
- bool no = (this.txt_lay.Text.Length == 0);
- setErr(no,this.txt_lay,"终孔层位不能为空",ref this.bk_lay);
- }
- private void txt_com_Validated(object sender, System.EventArgs e)
- {
- bool no = (this.txt_com.Text.Length == 0);
- setErr(no,this.txt_com,"施工单位不能为空",ref this.bk_com);
-
- }
- private void numericUpDown_x_Validated(object sender, System.EventArgs e)
- {
- bool no = (Convert.ToDouble(this.numericUpDown_x.Value) == 0);
- setErr(no,this.numericUpDown_x,"孔口坐标X不能为“0”",ref this.bk_x);
- }
- private void numericUpDown_y_Validated(object sender, System.EventArgs e)
- {
- bool no = (Convert.ToDouble(this.numericUpDown_y.Value) == 0);
- setErr(no,this.numericUpDown_y,"孔口坐标Y不能为“0”",ref this.bk_y);
- }
- private void numericUpDown_z_Validated(object sender, System.EventArgs e)
- {
-
- bool no = (Convert.ToDouble(this.numericUpDown_z.Value) == 0);
- setErr(no,this.numericUpDown_z,"孔口坐标Z不能为“0”",ref this.bk_z);
- }
- private void numericUpDown_h_Validated(object sender, System.EventArgs e)
- {
- bool no = (Convert.ToDouble(this.numericUpDown_h.Value) == 0);
- setErr(no,this.numericUpDown_h,"终孔深度不能为“0”",ref this.bk_h);
- }
- private void button_add_kong_Click(object sender, System.EventArgs e)
- {
- bool submit_ok = false;
- if(this.point ==false)
- {
- submit_ok = bk_no & bk_x & bk_y & bk_z & bk_h & bk_com & bk_lay;
- }
- else
- {
- submit_ok = bk_no & bk_z & bk_h & bk_com & bk_lay; //图上添加的,x,y不需要验证。
- }
- if(submit_ok)
- {
- get_value(); //得到数据。准备往数据库里面添加
- if(kong_isin(this.k_no))
- {
- if(add_kong_ok())
- {
- if(add_map_kong(this.k_id,1))
- {
- this.Cursor = Cursors.WaitCursor;
- this.button_add_kong.Enabled = false;
- this.button_add_ceng.Enabled = true;
- double xx = Convert.ToDouble(this.numericUpDown_x.Value);
- double yy = Convert.ToDouble(this.numericUpDown_y.Value);
- double zz = Convert.ToDouble(this.numericUpDown_z.Value);
- string idd = this.txt_no.Text.Trim();
- //发送在图上加点的事件
- this.Send(xx,yy,zz,idd);
- show_add_lay();
- this.Cursor = Cursors.Default;
- }
- else
- {
- MessageBox.Show("钻孔相关地图记录添加错误","错误提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
- }
- }
- }
- else
- {
- MessageBox.Show("该钻孔信息已经存在","错误提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
- }
-
- }
- else
- {
- MessageBox.Show("请将必需的数据填充完毕后再提交","错误提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
- }
- }
- private void button_add_ceng_Click(object sender, System.EventArgs e)
- {
- if(add_lay())
- {
- MessageBox.Show("相关煤层信息添加成功!","系统信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
- }
- else
- {
- MessageBox.Show("相关煤层信息添加失败!","错误信息",MessageBoxButtons.OK,MessageBoxIcon.Error);
- }
- }
-
- }
- }