Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            _2 m = new _2(textBox2.Text);

            m.Show();
            Visible = false;
        }
Example #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || dateTimePicker1.Text == "" || label7.Text == "" || comboBox3.Text == "")
            {
                MessageBox.Show("กรุณาป้อนข้อมูลให้ครบด้วยค่ะ", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                string sql = "SELECT * FROM orders WHERE  ID_ORDERS ='" + textBox1.Text + "'";

                string          ConnectStrin = "datasource = localhost; username= root;" + "password=; database = database;CharSet=UTF8";
                MySqlConnection coq          = new MySqlConnection(ConnectStrin);
                MySqlCommand    cmdz         = new MySqlCommand(sql, coq);


                coq.Open();
                MySqlDataReader  reader        = cmdz.ExecuteReader();
                DataSet          s             = new DataSet();
                string           ConnectStrinz = "datasource = localhost; username= root;" + "password=; database = database;CharSet=UTF8";
                string           sqlq          = "SELECT * FROM orders WHERE  ID_ORDERS ='" + textBox1.Text + "'";
                MySqlConnection  coqq          = new MySqlConnection(ConnectStrinz);
                MySqlCommand     cm            = new MySqlCommand(sqlq, coqq);
                MySqlDataAdapter da            = new MySqlDataAdapter(cm);

                da.Fill(s);
                int i = s.Tables[0].Rows.Count;
                if (i > 0)
                {
                    MessageBox.Show("มีรหัสสั่งซื้อ " + textBox1.Text + " แล้วกรุณาเปลี่ยน");
                    s.Clear();
                }
                else
                {
                    string sqlT = "INSERT INTO orders(ID_ORDERS,ORDER_DATE,STATUS,COMPANY_ID_COMPANY,EMPLOYEE_ID_EMPLOYEES) VALUES ('" + textBox1.Text + "','" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "','" + label7.Text + "','" + comboBox3.Text + "','" + textBox2.Text + "')";

                    string ConnectStringT = "datasource = localhost; username= root;" + "password=; database = database;CharSet=UTF8;Convert Zero Datetime=True";

                    MySqlConnection conT = new MySqlConnection(ConnectStringT);
                    MySqlCommand    cmdT = new MySqlCommand(sqlT, conT);
                    conT.Open();
                    MySqlDataReader readerT = cmdT.ExecuteReader();



                    _2 m = new _2(textBox2.Text);
                    m.Show();
                    Visible = false;
                }
            }
        }