private void button1_Click(object sender, EventArgs e) { if (MessageBox.Show("ยืนยัน", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { string code = adminScript.RandomString(6); int i = 0; while (i < 10) { string sql = "SELECT tbl_code_name FROM tbl_code_edit WHERE tbl_code_name='" + code + "'"; MySqlDataReader rs = adminScript.GetCodeEdit(sql); if (!rs.Read()) { adminScript.InsertUpdaeCodeEdit("Insert into tbl_code_edit (tbl_code_name) Values ('" + code + "')"); i++; } else { code = adminScript.RandomString(6); } } if (i == 10) { MessageBox.Show("เรียบร้อย"); this.Close(); } } }
private void EditJobForm_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.F1 && e.Modifiers == Keys.Shift) { string getCode_sql = "SELECT * FROM tbl_code_exigent WHERE status=1"; MySqlDataReader rs = adminScript.GetCodeEdit(getCode_sql); if (rs.Read()) { rs.Close(); if (MessageBox.Show("ยืนยัน ขอรหัสแก้ไขฉุกเฉิน!!!", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { string code = adminScript.RandomString(6); int i = 0; while (i < 1) { string sql = "SELECT tbl_code_name FROM tbl_code_edit WHERE tbl_code_name='" + code + "'"; rs = adminScript.GetCodeEdit(sql); if (!rs.Read()) { adminScript.InsertUpdaeCodeEdit("Insert into tbl_code_edit (tbl_code_name) Values ('" + code + "')"); i++; } else { code = adminScript.RandomString(6); } } if (i == 1) { textBox1.Text = code; //this.Close(); } } } else { MessageBox.Show("ไม่ได้รับอนุญาติจาก Admin!!!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }