Ejemplo n.º 1
0
        private void dsensor_Load(object sender, EventArgs e)
        {
            skinLabel4.Text   = "";
            skinTextBox4.Text = "";
            skinTextBox5.Text = "";
            skinTextBox6.Text = "";
            skinTextBox7.Text = "";
            skinTextBox8.Text = "";
            skinTextBox9.Text = "";

            Thread fac_thread = new Thread(getFactory);

            fac_thread.Start();
            try
            {
                string sql = "select dsensor.workid,workname,Ename,Eid,Sid,Sname,Smax,Smin,dsensor.caiji,dsensor.shangchuan from work,dsensor where `work`.workid = dsensor.workid ORDER BY workid asc";



                MySqlConnection  conn = msc.GetConn();
                MySqlDataAdapter sda  = new MySqlDataAdapter(sql, conn); //获取数据表
                                                                         //DataTable table = new DataTable();
                DataSet ds = new DataSet();
                sda.Fill(ds, "ds");                                      //填充数据库
                this.dataGridView1.DataSource = ds.Tables[0];
            }
            catch (Exception ee)
            {
                MessageBox.Show("查询数据库错误:" + ee.ToString());
            }
        }
Ejemplo n.º 2
0
        private void equipment_Load(object sender, EventArgs e)
        {
            Thread fac_thread = new Thread(getFactory);

            fac_thread.Start();
            try
            {
                string sql = "select equipment.workid,workname,equipment.Eid,equiptype.Ename,equipment.caiji,equipment.shangchuan from work,equipment,equiptype where `work`.workid = equipment.workid and equipment.Etype = equiptype.Etype ORDER BY workid asc";



                MySqlConnection  conn = msc.GetConn();
                MySqlDataAdapter sda  = new MySqlDataAdapter(sql, conn); //获取数据表
                                                                         //DataTable table = new DataTable();
                DataSet ds = new DataSet();
                sda.Fill(ds, "ds");                                      //填充数据库
                this.dataGridView1.DataSource = ds.Tables[0];
                msc.Close();
            }
            catch (Exception ee)
            {
                MessageBox.Show("查询数据库错误:" + ee.ToString());
            }
        }
Ejemplo n.º 3
0
        private void skinButton1_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text.Equals(""))
            {
                MessageBox.Show("请输入工作面的名称", "提示");
            }
            else if (TextBox2.Text.Equals(""))
            {
                MessageBox.Show("请输入支架型式", "提示");
            }
            else if (extBox3.Text.Equals(""))
            {
                MessageBox.Show("请输入缸径", "提示");
            }
            else if (extBox4.Text.Equals(""))
            {
                MessageBox.Show("请输入压力上限", "提示");
            }
            else if (extBox5.Text.Equals(""))
            {
                MessageBox.Show("请输入压力下限", "提示");
            }
            else if (TextBox6.Text.Equals(""))
            {
                MessageBox.Show("请输入工作面编号", "提示");
            }
            else
            {
                string          sql11 = "SELECT max(workid) from work";
                MySqlConn       ms    = new MySqlConn();
                MySqlDataReader rd    = ms.getDataFromTable(sql11);
                while (rd.Read())
                {
                    t1 = rd["max(workid)"].ToString();
                }
                rd.Close();
                ms.Close();
                //int A = int.Parse(skinTextBox6.Text);
                //int B = int.Parse(t1);
                int p1 = 1;
                //int A= int.Parse(skinTextBox1.Text);
                //MessageBox.Show(""+skinTextBox1.Text, "提示");
                string          sql12 = "SELECT workid FROM work";
                MySqlConn       ms1   = new MySqlConn();
                MySqlDataReader rd1   = ms1.getDataFromTable(sql12);
                while (rd1.Read())
                {
                    t1 = rd1["workid"].ToString();
                    //MessageBox.Show("t1是" +t1, "提示");
                    if (TextBox6.Text.Equals(t1))
                    {
                        p1 = 0;
                        break;
                    }
                }
                rd1.Close();
                ms1.Close();

                if (p1 == 1)
                {
                    if (skinTextBox4.Text == "")
                    {
                        skinTextBox4.Text = "0";
                    }
                    if (skinTextBox5.Text == "")
                    {
                        skinTextBox5.Text = "0";
                    }
                    if (skinTextBox6.Text == "")
                    {
                        skinTextBox6.Text = "0";
                    }
                    if (skinTextBox7.Text == "")
                    {
                        skinTextBox7.Text = "0";
                    }
                    if (skinTextBox8.Text == "")
                    {
                        skinTextBox8.Text = "0";
                    }
                    if (skinTextBox9.Text == "")
                    {
                        skinTextBox9.Text = "0";
                    }

                    string    ss  = skinTextBox4.Text + "分" + skinTextBox5.Text + "秒" + skinTextBox6.Text + "毫秒";
                    string    sss = skinTextBox7.Text + "分" + skinTextBox8.Text + "秒" + skinTextBox9.Text + "毫秒";
                    string    sql = "insert into work  values(" + TextBox6.Text + ", '" + TextBox1.Text + "',' " + TextBox2.Text + "', " + extBox3.Text + ", " + extBox4.Text + ", " + extBox5.Text + ", '" + ss + "', '" + sss + "')";
                    MySqlConn ms2 = new MySqlConn();
                    int       n   = ms2.nonSelect(sql);
                    ms2.Close();
                    MessageBox.Show("添加工作面成功", "提示");
                    TextBox1.Text = "";
                    TextBox2.Text = "";
                    extBox3.Text  = "";
                    extBox4.Text  = "";
                    extBox5.Text  = "";
                    TextBox6.Text = "";
                    //if (dataGridView1.DataSource != null)
                    //{

                    //    DataTable dt = (DataTable)dataGridView1.DataSource;

                    //    dt.Rows.Clear();

                    //    dataGridView1.DataSource = dt;

                    //}
                    //else

                    //{

                    //    dataGridView1.Rows.Clear();

                    //}
                    try
                    {
                        string sql1 = "select * from work order by workid asc";



                        MySqlConnection  conn = msc.GetConn();
                        MySqlDataAdapter sda  = new MySqlDataAdapter(sql1, conn); //获取数据表
                                                                                  //DataTable table = new DataTable();
                        DataSet ds = new DataSet();
                        sda.Fill(ds, "ds");                                       //填充数据库
                        this.dataGridView1.DataSource = ds.Tables[0];
                        msc.Close();
                    }
                    catch (Exception ee)
                    {
                    }
                }
                else
                {
                    MessageBox.Show("请输入正确工作面编号", "提示");
                }
            }
        }