Ejemplo n.º 1
0
        private void MaintainMainBomForm_Load(object sender, EventArgs e)
        {
            try
            {
                this.Save_Btn.Click    += new System.EventHandler(this.Save);
                this.Copy_Btn.Click    += new System.EventHandler(this.Copy);
                this.Pasete_Btn.Click  += new System.EventHandler(this.Paste);
                this.Replace_Btn.Click += new System.EventHandler(this.Replace);
                this.Format_Btn.Click  += new System.EventHandler(this.Format);
                this.Cancel_Btn.Click  += new System.EventHandler(this.Cancel);
                this.AddLine_Btn.Click += new System.EventHandler(this.AddLine);

                InitialCombox();

                tabControl1.SelectedTabIndex  = 0;//默认初始打开的都是正式维护界面
                this.Formal_tabitem.TextColor = Color.LightGray;
                this.test_tabitem.TextColor   = Color.LightGray;

                Title_label.Text = string.Format("{0}-传感器物料号维护模块:{1}", Assembly_str, LCBOM_str);
                DataTable Sql_dt = sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("select lcbominfo,lcbominfo_test from {0} where lcbom_meaid='{1}'", Constant.MainBom_sqlname, UniqueID), null);

                if (Sql_dt.Rows.Count == 1)
                {
                    dataGridViewX1.DataSource = DgdDealHelper.InitiaDgd(Sql_dt, 0).Copy();
                    dataGridViewX2.DataSource = DgdDealHelper.InitiaDgd(Sql_dt, 1).Copy();
                }
                else if (Sql_dt.Rows.Count <= 0)// load and insert sql
                {
                    MessageBox.Show("未找到该物料号的数据,请重新创建该产品:" + UniqueID);
                    return;
                }

                NotModify_dt1 = ((DataTable)dataGridViewX1.DataSource).Copy();
                NotModify_dt2 = ((DataTable)dataGridViewX2.DataSource).Copy();
                UserRightHelper.Table_UserRight(this.Text, dataGridViewX1, dataGridViewX2, contextMenuStrip1);
                this.dataGridViewX1.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(DefineDTlineNO.datagridviewLineNO);
                this.dataGridViewX2.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(DefineDTlineNO.datagridviewLineNO);

                this.dataGridViewX1.EditingControlShowing += new System.Windows.Forms.DataGridViewEditingControlShowingEventHandler(this.Dgd_EditingControlShowing);
                this.dataGridViewX2.EditingControlShowing += new System.Windows.Forms.DataGridViewEditingControlShowingEventHandler(this.Dgd_EditingControlShowing);
                this.dataGridViewX1.CellErrorTextNeeded   += new System.Windows.Forms.DataGridViewCellErrorTextNeededEventHandler(this.Dgd_CellErrorTextNeeded);
                this.dataGridViewX2.CellErrorTextNeeded   += new System.Windows.Forms.DataGridViewCellErrorTextNeededEventHandler(this.Dgd_CellErrorTextNeeded);
                this.dataGridViewX1.CellValueChanged      += new System.Windows.Forms.DataGridViewCellEventHandler(this.Dgd_CellValueChanged);
                this.dataGridViewX2.CellValueChanged      += new System.Windows.Forms.DataGridViewCellEventHandler(this.Dgd_CellValueChanged);
                this.dataGridViewX1.CellBeginEdit         += new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.Dgd_CellBeginEdit);
                this.dataGridViewX2.CellBeginEdit         += new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.Dgd_CellBeginEdit);
                this.dataGridViewX1.CellClick             += new System.Windows.Forms.DataGridViewCellEventHandler(this.Dgd_CellClick);
                this.dataGridViewX2.CellClick             += new System.Windows.Forms.DataGridViewCellEventHandler(this.Dgd_CellClick);
                this.dataGridViewX1.CellValidating        += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.Dgd_CellValidating);
                this.dataGridViewX2.CellValidating        += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.Dgd_CellValidating);

                //载入图片信息
                Gage_pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
                if (File.Exists("MAINBOM.jpg"))
                {
                    Gage_pictureBox.Load("MAINBOM.jpg");
                }
                else
                {
                    Gage_pictureBox.Image = Properties.Resources.MT;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("界面载入时发生异常:" + ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void MaintainSgglueForm_Load(object sender, EventArgs e)
        {
            try
            {
                this.dataGridViewX1.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(DefineDTlineNO.datagridviewLineNO);
                this.dataGridViewX2.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(DefineDTlineNO.datagridviewLineNO);
                this.Save_Btn.Click    += new System.EventHandler(this.Save);
                this.Copy_Btn.Click    += new System.EventHandler(this.Copy);
                this.Pasete_Btn.Click  += new System.EventHandler(this.Paste);
                this.Replace_Btn.Click += new System.EventHandler(this.Replace);
                this.Format_Btn.Click  += new System.EventHandler(this.Format);
                this.Cancel_Btn.Click  += new System.EventHandler(this.Cancel);
                this.AddLine_Btn.Click += new System.EventHandler(this.AddLine);

                Title_label.Text              = string.Format("应变胶BOM:{0}------应变胶信息数据维护", SGglue_Bom);
                tabControl1.SelectedTabIndex  = 0;//默认初始打开的都是正式维护界面
                this.Formal_tabitem.TextColor = Color.LightGray;
                this.test_tabitem.TextColor   = Color.LightGray;

                DataTable Sql_dt = sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("select sgglueinfo,sgglueinfo_test from {0} where sggluebom='{1}'", Constant.Sgglue_sqlname, SGglue_Bom), null);
                if (Sql_dt.Rows.Count == 1)
                {
                    dataGridViewX1.DataSource = DgdDealHelper.InitiaDgd(Sql_dt, 0).Copy();
                    dataGridViewX2.DataSource = DgdDealHelper.InitiaDgd(Sql_dt, 1).Copy();
                }
                else if (Sql_dt.Rows.Count <= 0)// load and insert sql
                {
                    MessageBox.Show("当前数据信息第一次创建,请维护!");
                    dataGridViewX1.DataSource = Constant.Sgglue_dt.Copy();
                    dataGridViewX2.DataSource = Constant.Sgglue_dt.Copy();
                    StringBuilder Strconn = DgdDealHelper.GetCombineInfo(Constant.Sgglue_dt);
                    //insert
                    sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("insert into {0} (sggluebom,sgglueinfo,sgglueinfo_test) values ('{1}','{2}','{3}')", Constant.Sgglue_sqlname, SGglue_Bom, Strconn, Strconn), null);
                }
                NotModify_dt1 = ((DataTable)dataGridViewX1.DataSource).Copy();
                NotModify_dt2 = ((DataTable)dataGridViewX2.DataSource).Copy();
                UserRightHelper.Table_UserRight(this.Text, dataGridViewX1, dataGridViewX2, contextMenuStrip1);

                this.dataGridViewX1.EditingControlShowing += new System.Windows.Forms.DataGridViewEditingControlShowingEventHandler(this.Dgd_EditingControlShowing);
                this.dataGridViewX2.EditingControlShowing += new System.Windows.Forms.DataGridViewEditingControlShowingEventHandler(this.Dgd_EditingControlShowing);
                this.dataGridViewX1.CellErrorTextNeeded   += new System.Windows.Forms.DataGridViewCellErrorTextNeededEventHandler(this.Dgd_CellErrorTextNeeded);
                this.dataGridViewX2.CellErrorTextNeeded   += new System.Windows.Forms.DataGridViewCellErrorTextNeededEventHandler(this.Dgd_CellErrorTextNeeded);
                this.dataGridViewX1.CellValueChanged      += new System.Windows.Forms.DataGridViewCellEventHandler(this.Dgd_CellValueChanged);
                this.dataGridViewX2.CellValueChanged      += new System.Windows.Forms.DataGridViewCellEventHandler(this.Dgd_CellValueChanged);
                this.dataGridViewX1.CellBeginEdit         += new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.Dgd_CellBeginEdit);
                this.dataGridViewX2.CellBeginEdit         += new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.Dgd_CellBeginEdit);
                this.dataGridViewX1.CellClick             += new System.Windows.Forms.DataGridViewCellEventHandler(this.Dgd_CellClick);
                this.dataGridViewX1.CellValidating        += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.Dgd_CellValidating);
                this.dataGridViewX2.CellValidating        += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.Dgd_CellValidating);

                //载入图片信息
                Gage_pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
                if (File.Exists("SGGLUE.jpg"))
                {
                    Gage_pictureBox.Load("SGGLUE.jpg");
                }
                else
                {
                    Gage_pictureBox.Image = Properties.Resources.MT;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("界面载入时发生异常:" + ex.Message);
            }
        }