示例#1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || dateTimePicker1.Text == "" || comboBox1.Text == "" || comboBox2.Text == "" || comboBox3.Text == "")
            {
                MessageBox.Show("กรุณาป้อนข้อมูลให้ครบด้วยค่ะ", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                string sql = "SELECT * FROM claim WHERE  ID_CLAIM ='" + 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 claim WHERE  ID_CLAIM ='" + 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 claim(ID_CLAIM,CLAIM_DATE,STATUS,BILL_OF_LADING_ID_BILL,ORDERS_ID_ORDERS,EMPLOYEE_ID_EMPLOYEES,COMPANY_ID_COMPANY) VALUES ('" + textBox1.Text + "','" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "','" + label7.Text + "','" + comboBox2.Text + "','" + comboBox1.Text + "','" + label6.Text + "','" + comboBox3.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();
                    MessageBox.Show("เพิ่มการเคลมแล้ว");

                    detailclaim uy = new detailclaim(label6.Text);
                    uy.Show();
                }
            }
        }
示例#2
0
        private void button3_Click(object sender, EventArgs e)
        {
            detailclaim uy = new detailclaim(label6.Text);

            uy.Show();
        }