示例#1
0
        private void ChargedForm_Load(object sender, EventArgs e)
        {
            string          sql    = "SELECT * FROM tbl_around ";
            ConnectDB       contxt = new ConnectDB();
            MySqlConnection conn   = new MySqlConnection();

            conn = new MySqlConnection(contxt.context());
            MySqlCommand cmd = new MySqlCommand(sql, conn);

            conn.Open();
            MySqlDataReader reader = cmd.ExecuteReader();

            cb_around.Text = "เลือก";
            while (reader.Read())
            {
                cb_around.Items.Add("ผลัด " + reader.GetString("tbl_around_id") + " (" + reader.GetString("tbl_around_time") + ")");
            }
            conn.Close();

            /*CultureInfo _cultureEnInfo = new CultureInfo("en-US");
             * DateTime dateEng = Convert.ToDateTime(DateTime.Now.ToString("dd/MM/yyyy"), _cultureEnInfo);
             *
             * dpk_date.Text = dateEng.ToString("dd/MM/yyyy", _cultureEnInfo);*/
            dpk_date.CustomFormat  = "dd-MM-yyyy";
            dpk_date1.CustomFormat = "dd-MM-yyyy";

            string          sql_check = "SELECT * FROM tbl_incom_other WHERE tbl_incom_other_list_incom_id = '4' AND tbl_incom_other_date_send = SUBSTR(DATE_FORMAT( NOW(), '%d-%m-%Y' ),1,10)";
            MySqlDataReader rs        = script.Select_SQL(sql_check);

            if (rs.Read())
            {
                rs.Close();
            }
            else
            {
                sql_check = "SELECT * FROM tbl_status_around WHERE tbl_status_around_close = '0' AND tbl_status_around_cpoint_id = '" + mainForm.cpoint_id + "'";
                rs        = script.Select_SQL(sql_check);
                if (rs.Read())
                {
                    //txt_straps.Text = script.GetStraps(rs.GetString("tbl_status_around_emp_open_id"));
                }
                else
                {
                    MessageBox.Show("รองผู้จัดการด่านยังไม่ได้ทำการเปิดกะ ยังไม่สามารถนำส่งเงินรายได้ ได้ในขณะนี้", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    this.Close();
                }
            }

            if (tabControl1.SelectedTab == tabPage1)
            {
                txt_t1_1.Text     = "ส่งเงินรายได้ขาดระบบ ตามบันทึกที่ ";
                lb_title.Text     = tabPage1.Text;
                lb_date.Text      = "";
                lb_line1.Text     = txt_t1_1.Text + txt_rs.Text;
                txt_t1_1.ReadOnly = true;
                //txt_note.Enabled = false;
            }
        }
示例#2
0
        private void next()
        {
            bool            chk_back_money = false;
            string          sql            = "SELECT * FROM tbl_income JOIN tbl_emp ON tbl_income_emp_id = tbl_emp_id WHERE tbl_emp_id = '" + textBox1.Text + "' AND tbl_income_status_backmaney = '0'";
            ConnectDB       contxt         = new ConnectDB();
            MySqlConnection conn           = new MySqlConnection();

            conn = new MySqlConnection(contxt.context());
            MySqlCommand cmd = new MySqlCommand(sql, conn);

            conn.Open();
            MySqlDataReader reader = cmd.ExecuteReader();

            try
            {
                if (reader.Read())
                {
                    BackMoneyForm backMoneyForm = new BackMoneyForm(mainForm, textBox1.Text);
                    this.Close();
                    backMoneyForm.ShowDialog();
                }
                else
                {
                    chk_back_money = true;
                }
                reader.Close();

                if (chk_back_money)
                {
                    sql    = "SELECT * FROM tbl_income JOIN tbl_emp ON tbl_income_emp_id = tbl_emp_id WHERE tbl_emp_id = '" + textBox1.Text + "' AND tbl_income_status_backmaney = '1' AND tbl_income_bank IS NULL";
                    cmd    = new MySqlCommand(sql, conn);
                    reader = cmd.ExecuteReader();
                    if (reader.Read())
                    {
                        //MessageBox.Show("คืนเงินแล้ว");
                        SendMoneyForm sendMoneyForm = new SendMoneyForm(mainForm, textBox1.Text);
                        sendMoneyForm.ShowDialog();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("ไม่พบข้อมูล หรืออาจจะนำส่งรายได้ไปแล้ว", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        textBox1.Clear();
                        textBox1.Focus();
                    }
                }
            }
            catch
            {
                //MessageBox.Show(e.ToString());
            }
            conn.Close();
        }
示例#3
0
        private void txt_job_SelectedIndexChanged(object sender, EventArgs e)
        {
            //MessageBox.Show((txt_job.SelectedItem as ComboboxItem).Value.ToString());
            ClearData();
            data = cb_emp_name.SelectedItem.ToString().Split(':');
            string          sql    = "SELECT * FROM tbl_income JOIN tbl_status_around ON tbl_income_around_id = tbl_status_around_id WHERE (tbl_income_user <> '0' OR tbl_income_fine <> '0') AND tbl_income_emp_id = '" + data[0].Trim() + "' AND tbl_status_around_aid = '" + cb_around.Text + "' AND tbl_income_job = '" + txt_job.Text + "' AND tbl_status_around_date = '" + date_value.Text + "'";
            ConnectDB       contxt = new ConnectDB();
            MySqlConnection conn   = new MySqlConnection();

            conn = new MySqlConnection(contxt.context());
            MySqlCommand cmd = new MySqlCommand(sql, conn);

            conn.Open();
            MySqlDataReader reader = cmd.ExecuteReader();

            try
            {
                if (reader.Read())
                {
                    if (!reader.IsDBNull(10))//10 = tbl_income_user
                    {
                        user = reader.GetString("tbl_income_user");
                    }
                    else
                    {
                        user = "******";
                    }
                    if (!reader.IsDBNull(11))// 11 = tbl_income_fine
                    {
                        fine = reader.GetString("tbl_income_fine");
                    }
                    else
                    {
                        fine = "0";
                    }

                    rdo_user.Enabled = Int32.Parse(user) > 0 ? true : false;
                    rdo_fine.Enabled = Int32.Parse(fine) > 0 ? true : false;

                    lb_user.Text    = "( มีเงินในระบบ : " + user + " บาท )";
                    lb_fine.Text    = "( มีเงินในระบบ : " + fine + " บาท )";
                    lb_user.Visible = true;
                    lb_fine.Visible = true;
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.ToString());
            }
            conn.Close();
        }
示例#4
0
        private void GetEmp()
        {
            ClearData();
            if (cb_around.Text != "เลือก")
            {
                cb_emp_name.Items.Clear();
                string date_select = date_value.Text;
                string sql         = "SELECT * FROM tbl_income JOIN tbl_emp ON tbl_income_emp_id = tbl_emp_id JOIN tbl_status_around ON tbl_income_around_id = tbl_status_around_id WHERE (tbl_income_user <> '0' OR tbl_income_fine <> '0') AND tbl_status_around_date = '" + date_select + "' AND tbl_status_around_aid = '" + cb_around.Text + "' AND tbl_status_around_cpoint_id = '" + mainForm.cpoint_id + "'";
                //MessageBox.Show(sql);
                ConnectDB       contxt = new ConnectDB();
                MySqlConnection conn   = new MySqlConnection();
                conn = new MySqlConnection(contxt.context());
                MySqlCommand cmd = new MySqlCommand(sql, conn);
                conn.Open();
                MySqlDataReader reader = cmd.ExecuteReader();
                try
                {
                    //cb_emp_name.SelectedIndex = 0;
                    int i = 0;
                    while (reader.Read())
                    {
                        if (!reader.IsDBNull(0))
                        {
                            if (i == 0)
                            {
                                cb_emp_name.Text = "เลือกพนักงานที่ทำรายการ";
                                //txt_job.Text = "เลือกงาน";
                            }

                            cb_emp_name.Items.Add(reader.GetString("tbl_emp_id") + " : " + reader.GetString("tbl_emp_name"));
                            //txt_job.Items.Add(reader.GetString("tbl_income_job"));
                            cb_emp_name.Enabled = true;
                            //txt_job.Enabled = true;
                        }
                        i++;
                    }
                    if (i == 0)
                    {
                        cb_emp_name.Items.Clear();
                        cb_emp_name.Enabled = false;
                    }

                    reader.Close();
                }
                catch
                {
                }
                conn.Close();
            }
        }
示例#5
0
        private void next()
        {
            if (txt_emp_id.Text != "")
            {
                string emp_id = null;
                string sql    = "SELECT * FROM tbl_emp WHERE tbl_emp_id = '" + txt_emp_id.Text + "' AND (tbl_emp_group_id=3 OR tbl_emp_group_id=7 OR tbl_emp_group_id=4 OR tbl_emp_group_id=10 OR tbl_emp_group_id=11 OR tbl_emp_group_id > 10)";

                ConnectDB       contxt = new ConnectDB();
                MySqlConnection conn   = new MySqlConnection();
                conn = new MySqlConnection(contxt.context());
                MySqlCommand cmd = new MySqlCommand(sql, conn);
                //MessageBox.Show(sql);
                conn.Open();
                MySqlDataReader reader = cmd.ExecuteReader();
                try
                {
                    if (reader.Read())
                    {
                        if (!reader.IsDBNull(0))
                        {
                            emp_id = reader.GetString("tbl_emp_id");
                            AroundOpenForm form = new AroundOpenForm(emp_id, mainForm, cpoint_id);
                            form.ShowDialog();
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("ไม่พบรหัส : " + txt_emp_id.Text + "  ในระบบ หรือรหัสนี้ไม่มีสิทธ์เปิดกะ", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        txt_emp_id.Clear();
                        txt_emp_id.Focus();
                    }
                    reader.Close();
                }
                catch
                {
                    //MessageBox.Show(e.ToString());
                }
                conn.Close();
            }
            else
            {
                MessageBox.Show("กรุณาใส่รหัสูผ้เปิดผลัด", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
示例#6
0
        public AroundOpenForm(string emp, Form callingForm, string cpoint)
        {
            maniForm = callingForm as MenuForm;
            InitializeComponent();
            cpoint_id = cpoint;
            emp_id    = emp;
            ConnectDB       contxt = new ConnectDB();
            MySqlConnection conn   = new MySqlConnection();

            conn = new MySqlConnection(contxt.context());
            string sql = "SELECT * FROM tbl_emp e JOIN tbl_emp_group g ON e.tbl_emp_group_id = g.tbl_emp_group_id WHERE tbl_emp_id = '" + emp_id + "'";

            MySqlCommand cmd = new MySqlCommand(sql, conn);

            //MessageBox.Show(sql);
            conn.Open();
            MySqlDataReader reader = cmd.ExecuteReader();

            try
            {
                if (reader.Read())
                {
                    if (!reader.IsDBNull(0))
                    {
                        txt_emp_name.Text      = reader.GetString("tbl_emp_name");
                        txt_emp_name.BackColor = DefaultBackColor;
                        txt_emp_name.ForeColor = Color.Blue;
                        lb_group.Text          = reader.GetString("tbl_emp_group_name");
                        lb_group.BackColor     = DefaultBackColor;
                        lb_group.ForeColor     = Color.Blue;
                    }
                }
                reader.Close();
            }
            catch
            {
            }
            conn.Close();

            //txt_emp.Text = data[0]+" "+data[1]+" "+data[2]+" "+data[3];
        }
示例#7
0
        private void next()
        {
            //MessageBox.Show("คืนเงิน");
            if (txt_fine.Text == "")
            {
                txt_fine.Text = "0.00";
            }

            if (double.Parse(txt_fine.Text) % 140 != 0)
            {
                MessageBox.Show("จำนวนเงินค่าปรับบัตรไม่ถูกต้อง", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txt_fine.Clear();
                txt_fine.Focus();
            }
            else
            {
                if (MessageBox.Show("คืนเงินยืม\r\n" + txt_emp_id.Text + " " + txt_emp_name.Text + "\r\n- จำนวน " + txt_money.Text + " บาท \r\n- เงินผู้ใช้ทางไม่รับเงินทอน " + txt_chang.Text + " บาท \r\n- ค่าปรับบัตรหาย " + txt_fine.Text + " บาท \r\n----------------------\r\nยืนยัน ใช่ หรือ ไม่", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    ConnectDB       contxt = new ConnectDB();
                    MySqlConnection conn   = new MySqlConnection();
                    conn = new MySqlConnection(contxt.context());
                    conn.Open();
                    MySqlCommand comm = conn.CreateCommand();
                    try
                    {
                        comm.CommandText = "UPDATE tbl_income SET tbl_income_user = '******' ,tbl_income_fine = '" + double.Parse(txt_fine.Text) + "' ,tbl_income_status_backmaney = '1' WHERE tbl_income_emp_id = '" + txt_emp_id.Text + "' AND tbl_income_status_backmaney = '0' AND tbl_income_money_bag = '" + txt_bag.Text + "'";
                        comm.ExecuteNonQuery();
                        conn.Close();
                        MessageBox.Show("บันทึกข้อมูลเรียบร้อยแล้ว", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        mainForm.Enabled = true;
                        this.Close();
                    }
                    catch
                    {
                        //
                    }
                }
            }
        }
示例#8
0
        private void txt_emp_id_KeyUp(object sender, KeyEventArgs e)
        {
            string          sql    = "SELECT * FROM tbl_emp WHERE tbl_emp_id = '" + txt_emp_id.Text + "'";
            ConnectDB       contxt = new ConnectDB();
            MySqlConnection conn   = new MySqlConnection();

            conn = new MySqlConnection(contxt.context());
            MySqlCommand cmd = new MySqlCommand(sql, conn);

            conn.Open();
            MySqlDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                txt_emp_name.Text = reader.GetString("tbl_emp_name");
                lb_line3.Text     = "เรียกเก็บจาก " + txt_emp_name.Text;
            }
            else
            {
                txt_emp_name.Text = "ไม่พบข้อมูล";
                //lb_line3.Text = "" + txt_note.Text;
            }
        }
示例#9
0
        private void BackMoneyForm_Load(object sender, EventArgs e)
        {
            if (mainForm.line9 == "9")
            {
                label10.Visible  = false;
                txt_fine.Visible = false;
                label9.Visible   = false;
            }

            string          sql    = "SELECT * FROM tbl_income JOIN tbl_emp ON tbl_income_emp_id = tbl_emp_id WHERE tbl_emp_id = '" + emp_id + "' AND tbl_income_status_backmaney = '0'";
            ConnectDB       contxt = new ConnectDB();
            MySqlConnection conn   = new MySqlConnection();

            conn = new MySqlConnection(contxt.context());
            MySqlCommand cmd = new MySqlCommand(sql, conn);

            conn.Open();
            MySqlDataReader reader = cmd.ExecuteReader();

            try
            {
                if (reader.Read())
                {
                    txt_emp_id.Text   = emp_id;
                    txt_emp_name.Text = reader.GetString("tbl_emp_name");
                    txt_bag.Text      = reader.GetString("tbl_income_money_bag");
                    txt_money.Text    = String.Format("{0:N2}", double.Parse(reader.GetString("tbl_income_money")));
                    button2.Enabled   = true;
                }
                reader.Close();
            }
            catch
            {
                //MessageBox.Show(e.ToString());
            }
        }
示例#10
0
        public void MenuForm_Load(object sender, EventArgs e)
        {
            label2.Text  = "ฝ่ายบริหารการจัดเก็บเงินค่าธรรมเนียม กองทางหลวงพิเศษระหว่างเมือง\r\n";
            label2.Text += "Application : " + Application.ProductName;
            label2.Text += "\r\nVersion : " + Application.ProductVersion;
            script.Set_Max_Connection();
            FileInfo DirInfo = new FileInfo(script.file_conf);

            if (!DirInfo.Exists)
            {
                MessageBox.Show("ไม่พบการเชื่อมต่อฐานข้อมูล กรุณา 'ตั้งค่า' ", "ผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //server=localhost;database=testDB;uid=root;pwd=abc123;
                //this.Close();
                btn_around.Enabled  = false;
                btn_bag.Enabled     = false;
                btn_send.Enabled    = false;
                btn_edit.Enabled    = false;
                button1.Enabled     = false;
                btn_refund.Enabled  = false;
                btn_memo.Enabled    = false;
                btn_report.Enabled  = false;
                btn_setting.Enabled = true;
                button2.Enabled     = false;
                button3.Enabled     = false;
            }
            else
            {
                try
                {
                    /*FileInfo DirInfo1 = new FileInfo(script.file_around);
                     * if (!DirInfo1.Exists)
                     * {
                     *  btn_around.Image = Properties.Resources.success;
                     *  btn_around.Text = "เปิดกะ";
                     *  aroundStatus = true;
                     * }
                     * else
                     * {
                     *  btn_around.Image = Properties.Resources.error;
                     *  btn_around.Text = "ปิดกะ";
                     *  aroundStatus = false;
                     * }*/

                    FileInfo DirInfo2    = new FileInfo(script.file_cpoint);
                    FileInfo DirInfo3    = new FileInfo(script.file_Straps);
                    bool     cpoint_file = false;
                    if (DirInfo2.Exists && DirInfo3.Exists)
                    {
                        cpoint_file = true;
                        string[]        cpoint = File.ReadAllText(@script.file_cpoint).Split('|');
                        string          sql    = "SELECT * FROM tbl_cpoint WHERE tbl_cpoint_id =  '" + cpoint[0] + "'";
                        ConnectDB       contxt = new ConnectDB();
                        MySqlConnection conn   = new MySqlConnection();
                        conn = new MySqlConnection(contxt.context());
                        MySqlCommand cmd = new MySqlCommand(sql, conn);
                        //conn.Close();
                        conn.Open();
                        MySqlDataReader reader = cmd.ExecuteReader();
                        try
                        {
                            if (reader.Read())
                            {
                                if (!reader.IsDBNull(0))
                                {
                                    line9                  = File.ReadAllText(script.file_cpoint).Split('|')[3];
                                    lb_cpoint.Text         = cpoint[0] + "  ด่าน" + reader.GetString("tbl_cpoint_name") + " " + (line9 != "9" ? cpoint[1] : "") + "   ";
                                    cpoint_id              = cpoint[0];
                                    sub_cpoint             = cpoint[1];
                                    lb_time.ForeColor      = ColorTranslator.FromHtml(reader.GetString("tbl_cpoint_color"));
                                    groupBox1.ForeColor    = ColorTranslator.FromHtml(reader.GetString("tbl_cpoint_color"));
                                    lb_cpoint.ForeColor    = ColorTranslator.FromHtml(reader.GetString("tbl_cpoint_color"));
                                    group_around.ForeColor = ColorTranslator.FromHtml(reader.GetString("tbl_cpoint_color"));
                                    lb_emp_name.ForeColor  = ColorTranslator.FromHtml(reader.GetString("tbl_cpoint_color"));
                                    label_date.ForeColor   = ColorTranslator.FromHtml(reader.GetString("tbl_cpoint_color"));
                                    lb_group.ForeColor     = ColorTranslator.FromHtml(reader.GetString("tbl_cpoint_color"));
                                }
                            }
                            else
                            {
                                lb_cpoint.Text     = "ไม่พบข้อมูลด่าน";
                                btn_around.Enabled = false;
                            }
                            reader.Close();
                        }
                        catch
                        {
                        }
                        conn.Close();
                    }
                    else
                    {
                        btn_around.Enabled  = false;
                        btn_bag.Enabled     = false;
                        btn_send.Enabled    = false;
                        btn_edit.Enabled    = false;
                        btn_report.Enabled  = false;
                        btn_refund.Enabled  = false;
                        btn_memo.Enabled    = false;
                        button1.Enabled     = false;
                        button2.Enabled     = false;
                        button3.Enabled     = false;
                        btn_setting.Enabled = false;
                    }

                    if (cpoint_file)
                    {
                        if (File.ReadAllText(@script.file_cpoint).Split('|')[2] != "1")
                        {
                            /*if (aroundStatus)
                             * {
                             *  btn_bag.Enabled = false;
                             *  btn_send.Enabled = false;
                             *  btn_edit.Enabled = false;
                             *  button1.Enabled = false;
                             *  group_around.Visible = false;
                             *  button2.Enabled = false;
                             *  button3.Enabled = false;
                             *  btn_report.Enabled = false;
                             * }
                             * else
                             * {*/

                            Script script = new Script();
                            try
                            {
                                string[] around = File.ReadAllText(script.file_around).Split('|');
                                around_num = around[1];
                                //string emp_control = script.Select_SQL();
                                emp_control_id = around[0];
                            }
                            catch { }
                            //around_num = around[1];
                            string          sql    = "SELECT * FROM tbl_status_around JOIN tbl_emp e ON tbl_status_around_emp_open_id = tbl_emp_id JOIN tbl_emp_group g ON e.tbl_emp_group_id = g.tbl_emp_group_id WHERE tbl_status_around_close = '0' AND tbl_status_around_cpoint_id = '" + cpoint_id + "' AND tbl_status_around_cpoint_sub_id = '" + sub_cpoint + "'";
                            ConnectDB       contxt = new ConnectDB();
                            MySqlConnection conn   = new MySqlConnection();
                            conn = new MySqlConnection(contxt.context());
                            MySqlCommand cmd = new MySqlCommand(sql, conn);
                            conn.Open();
                            MySqlDataReader reader = cmd.ExecuteReader();
                            try
                            {
                                if (reader.Read())
                                {
                                    if (!reader.IsDBNull(0))
                                    {
                                        label_date.Text  = script.GetMontThai(script.DateTimeParse(reader.GetString("tbl_status_around_date")));
                                        lb_emp_name.Text = reader.GetString("tbl_emp_name");
                                        label_date.Text += "  " + script.GetAroundName(reader.GetString("tbl_status_around_aid"));
                                        lb_group.Text    = reader.GetString("tbl_emp_group_name");
                                        around           = int.Parse(reader.GetString("tbl_status_around_aid"));

                                        //string[] aid = File.ReadAllText(@"around.txt").Split('|');
                                        string sql_check_straps = "SELECT * FROM `tbl_income` JOIN `tbl_status_around` ON `tbl_income_around_id` = `tbl_status_around_id` JOIN `tbl_emp` ON `tbl_emp_id` = `tbl_income_emp_id` WHERE tbl_status_around_close = '0' AND tbl_status_around_cpoint_id = '" + cpoint_id + "' AND tbl_status_around_cpoint_sub_id = '" + sub_cpoint + "'";
                                        cmd = new MySqlCommand(sql_check_straps, conn);
                                        reader.Close();
                                        reader = cmd.ExecuteReader();

                                        if (reader.Read())
                                        {
                                            btn_send.Enabled = true;
                                            sql_check_straps = "SELECT * FROM `tbl_income` JOIN `tbl_status_around` ON `tbl_income_around_id` = `tbl_status_around_id` JOIN `tbl_emp` ON `tbl_emp_id` = `tbl_income_emp_id` WHERE tbl_status_around_close = '0' AND tbl_status_around_cpoint_id = '" + cpoint_id + "' AND tbl_status_around_cpoint_sub_id = '" + sub_cpoint + "' AND tbl_income_bank IS NOT NULL AND tbl_income_status_backmaney ='1' ORDER BY tbl_income_id DESC ";
                                            reader.Close();
                                            reader = script.Select_SQL(sql_check_straps);
                                            if (reader.Read())
                                            {
                                                button2.Enabled  = true;
                                                btn_edit.Enabled = true;
                                            }
                                            else
                                            {
                                                button2.Enabled  = false;
                                                btn_edit.Enabled = false;
                                            }
                                        }
                                        else
                                        {
                                            button2.Enabled  = false;
                                            btn_send.Enabled = false;
                                            btn_edit.Enabled = false;
                                        }
                                        conn.Close();
                                        group_around.Visible = true;
                                        btn_around.Image     = Resources.error;
                                        btn_around.Text      = "ปิดกะ";
                                        aroundStatus         = false;

                                        if (around == 2)
                                        {
                                            button1.Enabled = true;
                                        }
                                        else
                                        {
                                            button1.Enabled = false;
                                        }
                                    }
                                }
                                else
                                {
                                    //lb_cpoint.Text = "ไม่พบข้อมูลด่าน";
                                    group_around.Visible = false;
                                    btn_around.Image     = Resources.success;
                                    btn_around.Text      = "เปิดกะ";
                                    aroundStatus         = true;

                                    btn_around.Enabled  = true;
                                    btn_bag.Enabled     = false;
                                    btn_send.Enabled    = false;
                                    btn_edit.Enabled    = false;
                                    btn_report.Enabled  = false;
                                    btn_refund.Enabled  = false;
                                    btn_memo.Enabled    = false;
                                    button1.Enabled     = false;
                                    button2.Enabled     = false;
                                    button3.Enabled     = false;
                                    btn_setting.Enabled = false;
                                }
                            }
                            catch
                            {
                            }
                            conn.Close();
                            // }
                            //button1.Enabled = false;
                        }
                        else
                        {
                            btn_around.Enabled  = false;
                            btn_bag.Enabled     = false;
                            btn_send.Enabled    = false;
                            btn_edit.Enabled    = false;
                            btn_report.Enabled  = true;
                            btn_refund.Enabled  = false;
                            btn_memo.Enabled    = false;
                            button1.Enabled     = true;
                            button2.Enabled     = false;
                            button3.Enabled     = false;
                            btn_setting.Enabled = false;
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("มีปัญหาการเชื่อมต่อฐานข้อมูล กรุุณาปิด/เปิดโปรแกรมใหม่ " + e.ToString(), "ผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //MessageBox.Show("Error:" + err.ToString(), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.Close();
                }
            }
        }
示例#11
0
        private void InsertAround()
        {
            if (script.AddCheckStraps(txt_straps_start.Text))
            {
                ConnectDB       contxt = new ConnectDB();
                MySqlConnection conn   = new MySqlConnection();
                conn = new MySqlConnection(contxt.context());
                int aid = 0;

                if (rb_2.Checked)
                {
                    //MessageBox.Show("2");
                    aid = 2;
                }
                if (rb_3.Checked)
                {
                    //MessageBox.Show("3");
                    aid = 3;
                }
                if (rb_1.Checked)
                {
                    //MessageBox.Show("1");
                    aid = 1;
                }
                conn.Open();
                DateTime     date_send = new Script().GetDateAround();
                MySqlCommand comm      = conn.CreateCommand();
                comm.CommandText = "INSERT INTO tbl_status_around (tbl_status_around_aid,tbl_status_around_emp_open_id,tbl_status_around_close,tbl_status_around_date,tbl_status_around_cpoint_id,tbl_status_around_cpoint_sub_id) VALUES(@aid, @emp_id,'0',@date,@cpoint,@subcpoint)";
                comm.Parameters.Add("@aid", aid);
                comm.Parameters.Add("@emp_id", emp_id);
                comm.Parameters.Add("@date", date_send.ToString("dd-MM-yyyy"));
                comm.Parameters.Add("@cpoint", cpoint_id);
                comm.Parameters.Add("@subcpoint", maniForm.sub_cpoint);
                comm.ExecuteNonQuery();
                conn.Close();

                StreamWriter file = new StreamWriter(script.file_around);
                file.WriteLine(emp_id + "|" + aid + "|" + date_send.ToString("dd-MM-yyyy") + "|" + txt_straps_start.Text + "|");
                file.Close();

                FileInfo DirInfo2 = new FileInfo(filename);
                if (DirInfo2.Exists)
                {
                    string[]        data1            = File.ReadAllText(new Script().file_around).Split('|');
                    Script          script           = new Script();
                    string          status_around_id = "";
                    MySqlDataReader rs = script.Select_SQL("SELECT * FROM tbl_status_around WHERE `tbl_status_around_aid`='" + data1[1] + "' AND `tbl_status_around_emp_open_id`='" + data1[0] + "' AND `tbl_status_around_close` = '0'");
                    if (rs.Read())
                    {
                        status_around_id = rs.GetString("tbl_status_around_id");
                        string[] data = File.ReadAllLines(filename);
                        foreach (string line in data)
                        {
                            string[] line_data = line.Split('|');
                            script.InsertUpdae_SQL("UPDATE tbl_income SET tbl_income_around_id = '" + status_around_id + "' WHERE tbl_income_emp_id='" + line_data[0] + "' AND tbl_income_around_id IS NULL AND tbl_income_money_bag = '" + line_data[1] + "'");
                        }
                        File.Delete(filename);
                    }
                    rs.Close();
                    script.conn.Close();
                }

                //maniForm.Refresh();
                Application.Restart();
            }
        }
示例#12
0
        private void next()
        {
            ConnectDB       contxt = new ConnectDB();
            MySqlConnection conn   = new MySqlConnection();

            conn = new MySqlConnection(contxt.context());
            MySqlCommand comm  = conn.CreateCommand();
            bool         check = false;

            string sql_check_emp = "SELECT tbl_emp_id FROM tbl_emp WHERE tbl_emp_id = '" + txt_emp_id.Text + "' AND (tbl_emp_group_id=3 OR tbl_emp_group_id=7 OR tbl_emp_group_id=4 OR tbl_emp_group_id=10 OR tbl_emp_group_id=11 OR tbl_emp_group_id > 10)";

            comm = new MySqlCommand(sql_check_emp, conn);
            conn.Open();
            MySqlDataReader reader = comm.ExecuteReader();

            if (reader.Read())
            {
                check = true;
            }
            else
            {
                MessageBox.Show("รหัสไม่ถูกต้อง หรือไม่มีสิทธิ์ทำรายการ", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            conn.Close();

            if (check)
            {
                string sql_insert = "INSERT INTO tbl_refun (tbl_refun_job,tbl_refun_transaction,tbl_refun_amount,tbl_refun_emp,tbl_refun_note,tbl_refun_date) VALUES ('" + (refunForm.txt_job.SelectedItem as ComboboxItem).Value.ToString() + "','" + (refunForm.rdo_fine.Checked ? "ค่าปรับบัตรหาย" : "เงินทอน") + "','" + (refunForm.rdo_fine.Checked ? refunForm.txt_fine.Text : refunForm.txt_user.Text) + "','" + txt_emp_id.Text + "','" + refunForm.txt_note.Text + "',NOW())";
                conn.Open();
                comm.CommandText = sql_insert;
                if (comm.ExecuteNonQuery() > 0)
                {
                    check = true;
                }
                else
                {
                    check = false;
                }
                conn.Close();
                if (check)
                {
                    if (refunForm.rdo_fine.Checked == true)
                    {
                        if (refunForm.txt_fine.Text != "")
                        {
                            if (Int32.Parse(refunForm.txt_fine.Text) <= Int32.Parse(refunForm.fine))
                            {
                                conn.Open();
                                string sql = "UPDATE tbl_income SET tbl_income_fine = '" + (Int32.Parse(refunForm.fine) - Int32.Parse(refunForm.txt_fine.Text)) + "' WHERE tbl_income_id = '" + (refunForm.txt_job.SelectedItem as ComboboxItem).Value.ToString() + "'";
                                comm.CommandText = sql;
                                comm.ExecuteNonQuery();
                                MessageBox.Show("บันทึกข้อมูลเรียบร้อย", "ผลลัพธ์", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                conn.Close();
                                mainForm.Enabled = true;
                                refunForm.Close();
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show("ยอดเงินที่คืนผู้ใช้ทางมากกว่าเงินในระบบ " + (Int32.Parse(refunForm.txt_fine.Text) - Int32.Parse(refunForm.fine)) + " บาท", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                    }

                    if (refunForm.rdo_user.Checked == true)
                    {
                        if (refunForm.txt_user.Text != "")
                        {
                            if (Int32.Parse(refunForm.txt_user.Text) <= Int32.Parse(refunForm.user))
                            {
                                conn.Open();
                                string sql = "UPDATE tbl_income SET tbl_income_user = '******' WHERE tbl_income_id = '" + (refunForm.txt_job.SelectedItem as ComboboxItem).Value.ToString() + "'";
                                comm.CommandText = sql;
                                comm.ExecuteNonQuery();
                                MessageBox.Show("บันทึกข้อมูลเรียบร้อย", "ผลลัพธ์", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                conn.Close();
                                refunForm.Close();
                                mainForm.Enabled = true;
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show("ยอดเงินที่คืนผู้ใช้ทางมากกว่าเงินในระบบ " + (Int32.Parse(refunForm.txt_user.Text) - Int32.Parse(refunForm.user)) + " บาท", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                    }
                }
            }
        }