private void btnDongY_Click(object sender, EventArgs e)
        {
            string s_ID = s_BanNang;

            if (s_BanNang.Length < 2)
            {
                s_ID = "0" + s_BanNang;
            }
            string s_NDLayXe = txtNoiDung.Text;
            string str       = "#CTR," + s_ID + "," + s_NDLayXe + ",*";

            if (s_NDLayXe != "")
            {
                byte[] data = System.Text.Encoding.UTF8.GetBytes(str);
                if (s_SerialPort != "")
                {
                    ThuVienSerialPort.serialPort_Send(data, 0, data.Length);
                }
            }
            if (SQLiteCon.State == ConnectionState.Open && b_TaoMoi == false)
            {
                try
                {
                    string        sql     = "UPDATE bannang SET maql = '0',counter = 0 WHERE ID = " + s_BanNang;
                    SQLiteCommand command = new SQLiteCommand(sql, SQLiteCon);
                    command.ExecuteNonQuery();

                    sql     = "insert into  baocao (maql,id,khachhang,biensoxe,thoigian,ktv) values ('" + s_MaQL + "','" + s_BanNang + "','" + s_TTKhachHang + "','" + s_BienSoXe + "'," + d_ThoiGian.ToString() + ",'" + s_KyThuatVien + "')";
                    command = new SQLiteCommand(sql, SQLiteCon);
                    command.ExecuteNonQuery();
                }
                catch { }
            }
            this.Close();
        }
        private void btnDongY_Click(object sender, EventArgs e)
        {
            string s_ID = s_BanNang;

            if (s_BanNang.Length < 2)
            {
                s_ID = "0" + s_BanNang;
            }
            string s_CauChao = txtCauChao.Text == "" ? " " : txtCauChao.Text;
            string str       = "#CFG," + s_ID + "," + s_CauChao + ",*";

            byte[] data = System.Text.Encoding.UTF8.GetBytes(str);
            ThuVienSerialPort.serialPort_Send(data, 0, data.Length);
            if (SQLiteCon.State == ConnectionState.Open)
            {
                try
                {
                    string        sql     = "UPDATE bannang SET greetings = '" + txtCauChao.Text + "', ktv = '" + txtKTV.Text + "' WHERE ID = " + s_BanNang + " ";
                    SQLiteCommand command = new SQLiteCommand(sql, SQLiteCon);
                    command.ExecuteNonQuery();
                }
                catch
                {
                    MessageBox.Show("Xử lý lỗi\rVui lòng kiểm tra lại!", "Cảnh báo");
                }
            }
            this.Close();
        }
Esempio n. 3
0
        private void btnDongY_Click(object sender, EventArgs e)
        {
            string sql  = "";
            string s_ID = s_BanNang;

            if (s_BanNang.Length < 2)
            {
                s_ID = "0" + s_BanNang;
            }
            string s_Name     = txtKhachHang.Text == "" ? " " : txtKhachHang.Text;
            string s_BienSoXe = txtBienSoXe.Text == "" ? " " : txtBienSoXe.Text;
            string s_ThoiGian = Convert.ToDecimal(txtGio.Text == "" ? "0" : txtGio.Text).ToString("00") + ":" + Convert.ToDecimal(txtPhut.Text == "" ? "0" : txtPhut.Text).ToString("00");

            d_ThoiGian = Convert.ToDecimal(txtGio.Text == "" ? "0" : txtGio.Text) * 60 + Convert.ToDecimal(txtPhut.Text == "" ? "0" : txtPhut.Text);
            if (d_ThoiGian > 0)
            {
                string str  = "#LED," + s_ID + "," + s_Name + "," + s_BienSoXe + "," + s_ThoiGian + "*";
                byte[] data = System.Text.Encoding.UTF8.GetBytes(str);
                ThuVienSerialPort.serialPort_Send(data, 0, data.Length);
                if (SQLiteCon.State == ConnectionState.Open && b_TaoMoi == true && d_ThoiGian > 0)
                {
                    sql = "UPDATE bannang SET maql = '" + s_Maql + "' WHERE id = " + s_BanNang;
                    try
                    {
                        SQLiteCommand command = new SQLiteCommand(sql, SQLiteCon);
                        command.ExecuteNonQuery();
                    }
                    catch { }
                }
                if (SQLiteCon.State == ConnectionState.Open)
                {
                    try
                    {
                        sql = "UPDATE bannang SET counter = '" + d_ThoiGian.ToString() + "',khachhang = '" + txtKhachHang.Text + "',biensoxe='" + txtBienSoXe.Text + "',ktv='" + txtKTV.Text + "',time = (datetime('now','localtime')) WHERE id = " + s_BanNang;
                        SQLiteCommand command = new SQLiteCommand(sql, SQLiteCon);
                        command.ExecuteNonQuery();
                    }
                    catch { }
                }
            }
            else
            {
                MessageBox.Show("Thông tin không hợp lệ\rVui lòng kiểm tra lại!", "Cảnh báo");
            }
            this.Close();
        }
Esempio n. 4
0
        private void DKTGPhatSinh(string s_Mode)
        {
            string s_ID = s_BanNang;

            if (s_BanNang.Length < 2)
            {
                s_ID = "0" + s_BanNang;
            }
            string s_TGPhatSinh = numPhut.Value.ToString();
            string str          = "#TIME," + s_ID + "," + s_Mode + "," + s_TGPhatSinh + ",*";

            if (numPhut.Value != 0)
            {
                byte[] data = System.Text.Encoding.UTF8.GetBytes(str);
                ThuVienSerialPort.serialPort_Send(data, 0, data.Length);
                if (s_Mode == "1")
                {
                    d_ThoiGian += numPhut.Value;
                }
                else
                {
                    d_ThoiGian -= numPhut.Value;
                    if (d_ThoiGian < 0)
                    {
                        d_ThoiGian = 0;
                    }
                }
                if (SQLiteCon.State == ConnectionState.Open)
                {
                    try
                    {
                        string        sql     = "UPDATE bannang SET counter = '" + d_ThoiGian.ToString() + "' WHERE id = " + s_ID + " ";
                        SQLiteCommand command = new SQLiteCommand(sql, SQLiteCon);
                        command.ExecuteNonQuery();
                    }
                    catch { }
                }
            }
            else
            {
                MessageBox.Show("Thông tin không hợp lệ!", "Cảnh báo");
            }
        }