private void button1_Click(object sender, EventArgs e) { if (MessageBox.Show("ยืนยันลบข้อมูลการเบิกถุงเงิน", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { for (int i = 0; i < ListBoxEmp.CheckedItems.Count; i++) { //MessageBox.Show((ListBoxEmp.CheckedItems[i] as ComboboxItem).Value.ToString()); string sql = "DELETE FROM tbl_income WHERE tbl_income_id = '" + (ListBoxEmp.CheckedItems[i] as ComboboxItem).Value.ToString() + "'"; adminScript.InsertUpdae_SQL(sql, adminScript.getConn(cpoint, groupBox1)); } if (codeEdit != "") { adminScript.InsertUpdaeCodeEdit("UPDATE tbl_code_edit SET tbl_code_status='1',tbl_code_date= NOW() where tbl_code_name = '" + codeEdit + "'"); } MessageBox.Show("ลบข้อมูลการเบิกถุงเงินเรียบร้อยแล้ว", "", MessageBoxButtons.OK, MessageBoxIcon.Information); button2_Click(null, null); } catch { MessageBox.Show("ลบข้อมูลการเบิกถุงเงิน ล้มเหลว!!!!!!!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
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 button1_Click(object sender, EventArgs e) { if (textBox3.Text != "") { if (script.GetEmpName(textBox2.Text.Trim()) != "ไม่พบข้อมูลพนักงาน") { string sql = "select * from tbl_code_edit where tbl_code_name = '" + textBox1.Text + "' and tbl_code_status is Null"; if (textBox1.Text != "" && textBox2.Text != "") { MySqlDataReader rs = adminScript.GetCodeEdit(sql); if (rs.Read()) { adminScript.InsertUpdaeCodeEdit("UPDATE tbl_code_edit SET tbl_code_user_emp='" + textBox2.Text + "',tbl_code_date= NOW(),tbl_code_cpoint='" + mainForm.cpoint_id + "',tbl_code_note='" + textBox3.Text + "' where tbl_code_name = '" + textBox1.Text + "'"); sql = "SELECT COUNT(*) AS num FROM tbl_code_edit WHERE tbl_code_user_emp = '" + textBox2.Text + "' AND MONTH(tbl_code_date) = MONTH(CURDATE()) AND YEAR(tbl_code_date) = YEAR(CURDATE())"; rs = adminScript.GetCodeEdit(sql); if (rs.Read()) { MessageBox.Show(script.GetEmpName(textBox2.Text) + " มีประวัติของแก้ไขงานใน " + script.GetMontThai(DateTime.Now.Date).Split(' ')[1] + " ทั้งหมด " + rs.GetString("num") + " ครั้ง\r\n !!ต้องมีความรอบครอบมากขึ้นกว่านี้^^", "", MessageBoxButtons.OK, MessageBoxIcon.Information); AdminMenuForm adminEdit = new AdminMenuForm(textBox1.Text.Trim()); this.Hide(); adminEdit.ShowDialog(); this.Close(); } // } else { MessageBox.Show("รหัสแก้ไขงานไม่ถูกต้อง", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } else { MessageBox.Show("รหัสรองฯ ไม่ถูกต้อง", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("กรุณาใส่เหตุที่ต้องแก้ไข", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void btn_confirm_Click(object sender, EventArgs e) { if (MessageBox.Show("ยืนยันบันทึกข้อมูลใช้หรือไม่", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string insert_sql = "UPDATE tbl_income SET tbl_income_money_bag ='" + txt_bag.Text + "'"; if (txt_straps.Text != "") { insert_sql += ",tbl_income_straps ='" + txt_straps.Text + "'"; } if (txt_emp_id.Text != "") { insert_sql += ",tbl_income_emp_id ='" + txt_emp_id.Text + "'"; } if (txt_cb.Text != "") { insert_sql += ",tbl_income_cabinet ='" + txt_cb.Text + "'"; } if (txt_job.Text != "") { insert_sql += ",tbl_income_job ='" + txt_job.Text + "'"; } if (txt_start.Text != " :") { insert_sql += ",tbl_income_in_time ='" + txt_start.Text + "'"; } if (txt_end.Text != " :") { insert_sql += ",tbl_income_out_time ='" + txt_end.Text + "'"; } if (txt_total.Text != "") { insert_sql += ",tbl_income_total ='" + double.Parse(txt_total.Text) + "'"; } if (txt_bank.Text != "") { insert_sql += ",tbl_income_bank ='" + double.Parse(txt_bank.Text) + "'"; } if (txt_user.Text != "") { insert_sql += ",tbl_income_user ='******',tbl_income_user_tmp ='" + double.Parse(txt_user.Text) + "'"; } if (txt_fine.Text != "") { insert_sql += ",tbl_income_fine ='" + double.Parse(txt_fine.Text) + "',tbl_income_fine_tmp ='" + double.Parse(txt_fine.Text) + "'"; } if (txt_over_ts2.Text != "") { insert_sql += ",tbl_income_over ='" + double.Parse(txt_over_ts2.Text) + "'"; } if (txt_over_sys.Text != "") { insert_sql += ",tbl_income_over_sys ='" + double.Parse(txt_over_sys.Text) + "'"; } if (txt_other_ts2.Text != "") { insert_sql += ",tbl_income_other_ts2 ='" + double.Parse(txt_other_ts2.Text) + "'"; } if (txt_other_sys.Text != "") { insert_sql += ",tbl_income_other ='" + double.Parse(txt_other_sys.Text) + "' "; } insert_sql += " WHERE tbl_income_id = '" + lb_income_id.Text + "'"; if (codeEdit != "") { script.InsertUpdaeCodeEdit("UPDATE tbl_code_edit SET tbl_code_status='1',tbl_code_date= NOW() where tbl_code_name = '" + codeEdit + "'"); } if (script.InsertUpdae_SQL(insert_sql, script.getConn(cpoint, groupbox1))) { MySqlDataReader rs = GetScript.Select_SQL("SELECT * FROM tbl_income WHERE tbl_income_around_id = '" + income_around_id.Text.Trim() + "' AND tbl_income_emp_id IS NULL"); if (!rs.Read()) { rs.Close(); script.CloseCon(); if (txt_other_ts2.Text != "" && txt_other_sys.Text != "" && txt_other_ts2.Text != "0" && txt_other_sys.Text != "0") { AddBagForm addBag = new AddBagForm(income_around_id.Text); addBag.ShowDialog(); } } rs.Close(); script.CloseCon(); rs = script.Select_SQL("SELECT SUM(tbl_income_other_ts2) + SUM(tbl_income_other) AS sum FROM tbl_income WHERE tbl_income_around_id = '" + income_around_id.Text.Trim() + "'", script.getConn(cpoint, groupbox1)); if (rs.Read() && !rs.IsDBNull(0)) { string update_income_edit = "UPDATE tbl_income SET tbl_income_bank='" + rs.GetString("sum") + "' ,tbl_income_total = '" + rs.GetString("sum") + "' WHERE tbl_income_around_id = '" + income_around_id.Text.Trim() + "' AND tbl_income_emp_id IS NULL"; if (script.InsertUpdae_SQL(update_income_edit, script.getConn(cpoint, groupbox1))) { MessageBox.Show("บันทึกข้อมูล สำเร็จ!!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); rs.Close(); script.CloseCon(); this.Close(); } else { MessageBox.Show("บันทึกข้อมูลสำเร็จ", "", MessageBoxButtons.OK, MessageBoxIcon.Information); rs.Close(); script.CloseCon(); this.Close(); } } else { MessageBox.Show("บันทึกข้อมูลสำเร็จ", "", MessageBoxButtons.OK, MessageBoxIcon.Information); rs.Close(); script.CloseCon(); this.Close(); } } } }