Пример #1
0
        private void btnTatThongBao_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            DialogResult dialogResult = XtraMessageBox.Show("Bạn muốn tắt thông báo ?", "Cảnh báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.Yes)
            {
                if (SqlConn == null || SqlConn.State != ConnectionState.Open)
                {
                    Database.Open(ref this.SqlConn);
                }
                if (SqlConn.State == ConnectionState.Open)
                {
                    try
                    {
                        DsThongBao ds = new DsThongBao();
                        ds.UpdateTrangThai(SqlConn);
                    }
                    catch
                    {
                    }
                    finally
                    {
                        CapNhatDuLieuGridView();
                    }
                }
            }
        }
Пример #2
0
        private void tmrHeaderEffect_Tick(object sender, EventArgs e)
        {
            tmrHeaderEffect_Counter++;
            if (tmrHeaderEffect_Counter > 10)
            {
                DsThongBao ds_Thongbao = new DsThongBao();
                dt_ThongBao = ds_Thongbao.LoadDsHienThiThongBao(SqlConn);

                tmrHeaderEffect_Counter = 0;
            }
            this.Invoke((MethodInvoker) delegate
            {
                if (dt_ThongBao != null && dt_ThongBao.Rows.Count > 0)
                {
                    if (dt_ThongBao != null && dt_ThongBao.Rows.Count > 0 && Database.SoLanHienThiThongBaoTraXe > 0)
                    {
                        i_IndexThongBao = 0;

                        DataRow r         = dt_ThongBao.Rows[i_IndexThongBao];
                        string s_ThongBao = r["noidung"].ToString();
                        lblTenCty.Text    = s_ThongBao.ToUpper(); //Hiển thị thông báo
                        if (lblTenCty.Left < (0 - lblTenCty.Width))
                        {
                            lblTenCty.Left = this.Width - grpDateTime.Width;
                        }
                        else
                        {
                            lblTenCty.Left -= iTocDoHieuUngThongBaoTraXe;
                        }
                    }
                    else
                    {
                        i_IndexThongBao = 0;
                        lblTenCty.Text  = s_Header;
                        lblTenCty.Left  = 0;
                    }
                }
                else
                {
                    i_IndexThongBao = 0;
                    lblTenCty.Text  = s_Header;
                    lblTenCty.Left  = 0;
                }
            });
        }
Пример #3
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (this.SqlConn == null || this.SqlConn.State != ConnectionState.Open)
            {
                Database.Open(ref this.SqlConn);
            }
            if (this.bDuocPhepGoi)
            {
                try
                {
                    if (this.SqlConn != null && this.SqlConn.State == ConnectionState.Open)
                    {
                        DsTraXe ds_TraXe = new DsTraXe();
                        DataTable dtDSGoi = ds_TraXe.LoadDsGoiLayXe(SqlConn);
                        if (dtDSGoi != null && dtDSGoi.Rows.Count > 0)
                        {
                            tmrThongBao.Stop();                            
                            foreach (DataRow r in dtDSGoi.Select("", ""))
                            {
                                string s_BienSoXe = r["biensoxe"].ToString();
                                string s_TenKH = r["hoten"].ToString();
                                string s_MaQL = r["maql"].ToString();
                                if (chkGoiTenKH.Checked == false)
                                {
                                    TienIch.Media.GoiKhachHangNhanXe(s_BienSoXe.Replace("-", "").Trim());
                                }
                                else
                                {
                                    string text = "Mời khách hàng " + s_TenKH + " biển số xe " + s_BienSoXe + " đến nhận xe";
                                    PlayMp3FromUrl("nhanxe.mp3", text, Voice.hatieumai);
                                }
                                ds_TraXe.UpdateTrangThaiGoiLayXe(this.SqlConn, s_MaQL, TrangThai.TraiThaiGoiLayXe.DaGoi);
                                //Thread.Sleep(THOIGIANNGHI);
                            }
                            tmrThongBao.Start();
                        }
                    }
                }
                catch { }
            }
            if (this.bDuocPhepThongBao)
            {
                this.bDuocPhepThongBao = false;

                tmrThongBao.Stop();
                try
                {
                    if (this.SqlConn != null && this.SqlConn.State == ConnectionState.Open)
                    {
                        DsThongBao ds_Thongbao = new DsThongBao();
                        DataTable dt_ThongBao = ds_Thongbao.LoadDsHienThiThongBao(SqlConn);
                        if (dt_ThongBao != null && dt_ThongBao.Rows.Count > 0)
                        {
                            DataRow r = dt_ThongBao.Rows[0];
                            string s_ThongBao = r["noidung"].ToString();
                            if (chkGoiTenKH.Checked == true)
                            {
                                PlayMp3FromUrl("thongbao.mp3", s_ThongBao, Voice.hatieumai);
                            }
                        }
                    }
                }
                catch { }
                finally
                {
                    tmrThongBao.Stop();
                    tmrThongBao.Start();
                }
            }
        }