private void button2_Click(object sender, EventArgs e) { string sql = "SELECT * FROM tbl_income JOIN tbl_emp ON tbl_income_emp_id=tbl_emp_id WHERE tbl_income_around_id IS NULL"; //MessageBox.Show(txtCpoint.SelectedItem.ToString()); if (codeEdit == "") { cpoint = (txtCpoint.SelectedItem as ComboboxItem).Value.ToString(); } MySqlDataReader rs = adminScript.Select_SQL(sql, adminScript.getConn(cpoint, groupBox1)); ListBoxEmp.Items.Clear(); int i = 0; while (rs.Read()) { ListBoxEmp.Items.Insert(i, new ComboboxItem("ถุงเงิน : " + rs.GetString("tbl_income_money_bag") + " ชื่อ-สกุล : " + rs.GetString("tbl_emp_name"), rs.GetString("tbl_income_id"))); i++; } rs.Close(); adminScript.CloseCon(); button1.Enabled = true; ListBoxEmp.Enabled = true; }
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(); } } } }