示例#1
0
        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);
                }
            }
        }
示例#2
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("ยืนยันที่จะแก้ไขข้อมูล?", "ยืนยัน?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         if (textBox2.Text != "" && comboBox1.Text != "")
         {
             string sql = "UPDATE tbl_emp SET tbl_emp_name = '" + textBox2.Text.Trim() + "',tbl_emp_group_id='" + (comboBox1.SelectedItem as ComboboxItem).Value.ToString() + "' WHERE tbl_emp_id = '" + label3.Text.Trim() + "'";
             if (script.InsertUpdae_SQL(sql))
             {
                 MessageBox.Show("แก้ไขข้อมูลสำเร็จ");
                 button3.Enabled = true;
             }
             else
             {
                 MessageBox.Show("!!!Error : แก้ไขข้อมูล ล้มเหลว ลองใหม่อีกครั้ง", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             MessageBox.Show("ใส่ข้อมูลให้ถูกต้อง", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
 }
示例#3
0
        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();
                    }
                }
            }
        }
示例#4
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("ยืนยันที่จะบันทึกข้อมูล?", "ยืนยัน?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {
                    delimiter = Convert.ToChar(",");
                }
                catch (Exception exceptionObject)
                {
                    MessageBox.Show(exceptionObject.ToString());
                    this.Close();
                }

                try
                {
                    string columnHeaderText = "";

                    //Writing DataGridView Header in File
                    int countColumn = dataGridView1.ColumnCount - 1;

                    if (countColumn >= 0)
                    {
                        columnHeaderText = dataGridView1.Columns[0].HeaderText;
                    }

                    for (int i = 1; i <= countColumn; i++)
                    {
                        columnHeaderText = columnHeaderText + delimiter + dataGridView1.Columns[i].HeaderText;
                    }

                    //fileWriter.WriteLine(columnHeaderText);

                    //Writing Data in File
                    string dataFromGrid = "";

                    int count = 1;
                    foreach (DataGridViewRow dataRowObject in dataGridView1.Rows)
                    {
                        if (!dataRowObject.IsNewRow)
                        {
                            dataFromGrid = dataRowObject.Cells[0].Value.ToString();

                            for (int i = 1; i <= countColumn; i++)
                            {
                                dataFromGrid = dataFromGrid + delimiter + "'" + dataRowObject.Cells[i].Value.ToString() + "'";
                            }

                            if (count == 1)
                            {
                                sql += "(" + dataFromGrid + ")";
                            }
                            else
                            {
                                sql += ",(" + dataFromGrid + ")";
                            }
                            count++;
                            //fileWriter.WriteLine(dataFromGrid);
                        }
                    }

                    if (script.InsertUpdae_SQL(sql))
                    {
                        MessageBox.Show("บันทึกข้อมูลสำเร็จ", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        button5.Enabled = true;
                    }
                    else
                    {
                        MessageBox.Show("!!!Error : บันทึกข้อมูล ล้มเหลว ลองใหม่อีกครั้ง", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception exceptionObject)
                {
                    MessageBox.Show(exceptionObject.ToString());
                }
            }
        }