Esempio n. 1
0
 void btnDongY_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
 {
     if (txtGio.Text != "" && txtPhut.Text != "" && cbbDsBanNang.EditValue.ToString() != "")
     {
         Int32     i_TG = Convert.ToInt16(txtGio.Text) * 60 + Convert.ToInt16(txtPhut.Text);
         string    s_ID = cbbDsBanNang.EditValue.ToString();
         DsBanNang dsBN = new DsBanNang();
         dsBN.UpdateTrangThai(conn, s_ID, TrangThai.TrangThaiBanNang.DangSuaChua);
         dsBN.UpdateThongTinKH(conn, s_ID, s_MaQL, (short)i_TG);
         DsKhachHang dsKH = new DsKhachHang();
         dsKH.UpdateTrangThai(conn, s_MaQL, TrangThai.TrangThaiKhachHang.DangSuaChua);
         if (i_TG > 0)
         {
             string s_ThoiGian = Convert.ToDecimal(txtGio.Text == "" ? "0" : txtGio.Text).ToString("00") + ":" + Convert.ToDecimal(txtPhut.Text == "" ? "0" : txtPhut.Text).ToString("00");
             string str        = "#LED," + s_ID + "," + TienIch.Access.convertToUnSign3(s_HoTen).ToUpper() + "," + s_BienSoXe + "," + s_ThoiGian + "*";
             byte[] data       = System.Text.Encoding.UTF8.GetBytes(str);
             TienIch.ComPort.serialPort_Send(data, 0, data.Length);
         }
         this.Close();
     }
     else
     {
         MessageBox.Show("Dữ liệu không hợp lệ");
     }
 }
        private void btnDongY_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            if (TT_trangthai == TrangThai.TrangThaiBanNang.ChoNhanXe)
            {
                string str  = "#LED," + this.s_IDBanNang.PadLeft(2, '0') + "," + TienIch.Access.convertToUnSign3(this.s_HoTen).ToUpper() + "," + this.s_BienSoXe + "," + "00:00" + "*";
                byte[] data = System.Text.Encoding.UTF8.GetBytes(str);
                TienIch.ComPort.serialPort_Send(data, 0, data.Length);
            }
            else if (TT_trangthai == TrangThai.TrangThaiBanNang.DangSuaChua)
            {
                Int32 iGio  = i_TGConLai_TinhTheoPhut / 60;
                Int32 iPhut = i_TGConLai_TinhTheoPhut % 60;

                string s_ThoiGian = iGio.ToString("00") + ":" + iPhut.ToString("00");

                string str  = "#LED," + this.s_IDBanNang.PadLeft(2, '0') + "," + TienIch.Access.convertToUnSign3(txtHoTen.Text).ToUpper() + "," + this.txtBienSoXe.Text.ToUpper() + "," + s_ThoiGian + "*";
                byte[] data = System.Text.Encoding.UTF8.GetBytes(str);
                TienIch.ComPort.serialPort_Send(data, 0, data.Length);
            }
            if (this.txtHoTen.Text != this.s_HoTen || this.txtBienSoXe.Text != this.s_BienSoXe)
            {
                DsKhachHang ds = new DsKhachHang();
                ds.UpdateThongTin(this.conn, this.s_MaKH, this.txtHoTen.Text, this.txtBienSoXe.Text);
            }
            this.Close();
        }
Esempio n. 3
0
 public frmNhanKhachVaoBanNang(SqlConnection _conn, string _maql, string s__SerialPort)
 {
     InitializeComponent();
     this.conn   = _conn;
     this.s_MaQL = _maql;
     if (conn.State == ConnectionState.Open)
     {
         try
         {
             DsBanNang ds = new DsBanNang();
             DataTable dt = ds.LoadDsTheoTrangThai(conn, TrangThai.TrangThaiBanNang.ChoNhanXe);
             cbbDsBanNang.Properties.DataSource = dt;
             DsKhachHang dsKH = new DsKhachHang();
             DataTable   dtKH = dsKH.LoadTheoMaQL(conn, s_MaQL);
             if (dtKH != null && dtKH.Rows.Count > 0)
             {
                 DataRow r = dtKH.Rows[0];
                 s_HoTen    = r["hoten"].ToString();
                 s_BienSoXe = r["biensoxe"].ToString();
             }
         }
         catch
         {
             MessageBox.Show("Xử lý lỗi !", "Lỗi");
         }
     }
     this.s_SerialPort = s__SerialPort;
 }
Esempio n. 4
0
        private void btnTra_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            DialogResult dialogResult = XtraMessageBox.Show("Bạn muốn xóa thông tin khách hàng khỏi danh sách ?", "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
                    {
                        string      s_MaQL = grvKhachHang.GetRowCellValue(grvKhachHang.FocusedRowHandle, "maql").ToString();
                        DsKhachHang ds     = new DsKhachHang();
                        ds.UpdateTrangThai(SqlConn, s_MaQL, TrangThai.TrangThaiKhachHang.KetThucSuaChua);
                    }
                    catch
                    {
                    }
                    finally
                    {
                        CapNhatDuLieuGridView();
                    }
                }
            }
            else if (dialogResult == DialogResult.No)
            {
            }
        }
Esempio n. 5
0
        private void btnTiepNhanKhach_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            frmTiepNhanKhach frm = new frmTiepNhanKhach(this.SqlConn, s_SerialPort);

            frm.ShowDialog();
            if (frm.s_HoTen != "" && frm.s_BienSoXe != "")
            {
                if (SqlConn == null || SqlConn.State != ConnectionState.Open)
                {
                    Database.Open(ref this.SqlConn);
                }
                if (SqlConn.State == ConnectionState.Open)
                {
                    try
                    {
                        DsKhachHang ds = new DsKhachHang();
                        ds.Insert(SqlConn, frm.s_HoTen, frm.s_BienSoXe, frm.s_GhiChu);
                    }
                    catch
                    {
                        MessageBox.Show("Xử lý lỗi !", "Lỗi");
                    }
                    finally
                    {
                        CapNhatDuLieuGridView();
                    }
                }
            }
        }
Esempio n. 6
0
        private void btnDongY_Click(object sender, EventArgs e)
        {
            string s_ID = s_IDBanNang;

            if (s_IDBanNang.Length < 2)
            {
                s_ID = "0" + s_IDBanNang;
            }
            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");
            Int32  d_ThoiGian = Convert.ToInt16(txtGio.Text == "" ? "0" : txtGio.Text) * 60 + Convert.ToInt16(txtPhut.Text == "" ? "0" : txtPhut.Text);

            if (d_ThoiGian > 0)
            {
                string str  = "#LED," + s_ID + "," + TienIch.Access.convertToUnSign3(s_Name).ToUpper() + "," + s_BienSoXe.ToUpper() + "," + s_ThoiGian + "*";
                byte[] data = System.Text.Encoding.UTF8.GetBytes(str);
                Console.WriteLine(str);
                TienIch.ComPort.serialPort_Send(data, 0, data.Length);
                if (conn != null && conn.State == ConnectionState.Open)
                {
                    DsKhachHang ds_KH  = new DsKhachHang();
                    string      s_MaKH = ds_KH.Insert_ReturnMaQL(conn, s_Name, s_BienSoXe, txtGhiChu.Text.ToString().Trim());
                    DsBanNang   ds_BN  = new DsBanNang();
                    ds_BN.UpdateTrangThai(conn, s_IDBanNang, TrangThai.TrangThaiBanNang.DangSuaChua);
                    ds_BN.UpdateThongTinKH(conn, s_IDBanNang, s_MaKH, Convert.ToInt16(d_ThoiGian));
                }
                this.Close();
            }
            else
            {
                MessageBox.Show("Thông tin không hợp lệ\rVui lòng kiểm tra lại!", "Cảnh báo");
            }
        }
Esempio n. 7
0
        void CapNhatDuLieuGridView()
        {
            int i_TGConLai = 0;

            if (SqlConn == null || SqlConn.State != ConnectionState.Open)
            {
                Database.Open(ref this.SqlConn);
            }
            if (SqlConn.State == ConnectionState.Open)
            {
                try
                {
                    //Cập nhật thông số
                    TienIch.tshienthi ts = new tshienthi();
                    ts.LoadAll(SqlConn);
                    s_Header               = ts.Header;
                    s_Footer               = ts.Footer;
                    i_SoDongHienThi        = ts.SoDongHienThi;
                    iThoiGianHienThiDuLieu = ts.TGHienThi;
                    //
                    TienIch.DsKhachHang dskhachhang = new DsKhachHang();
                    dt_KhachHang = dskhachhang.LoadDSKHChoSuaChua(SqlConn);
                    if (bHienThiDuLieuMoi) //định kỳ 5s hiển thị dữ liệu
                    {
                        if (dt_KhachHang != null && dt_KhachHang.Rows.Count > 0)
                        {
                            DataTable dt_dsKH = new DataTable();
                            if (dt_KhachHang.Rows.Count < i_SoDongHienThi)
                            {
                                dt_dsKH           = dt_KhachHang.Copy();
                                iDsKhachHangIndex = 0;
                            }
                            else
                            {
                                dt_dsKH = dt_KhachHang.Clone();
                                if (iDsKhachHangIndex >= dt_KhachHang.Rows.Count)
                                {
                                    iDsKhachHangIndex = 0;
                                }
                                for (int i = 0; i < i_SoDongHienThi; i++)
                                {
                                    if ((iDsKhachHangIndex + i) < dt_KhachHang.Rows.Count)
                                    {
                                        dt_dsKH.ImportRow(dt_KhachHang.Rows[iDsKhachHangIndex + i]);
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                iDsKhachHangIndex += i_SoDongHienThi;
                                if (iDsKhachHangIndex >= dt_KhachHang.Rows.Count)
                                {
                                    iDsKhachHangIndex = 0;
                                }
                            }
                            grdKhachHang.DataSource = dt_dsKH;
                        }
                        else
                        {
                            grdKhachHang.DataSource = dt_KhachHang;
                            iDsKhachHangIndex       = 0;
                        }
                    }
                    ///////////////////////////////////////////////
                    TienIch.DsBanNang dsbannang = new DsBanNang();
                    dt_BanNang = dsbannang.LoadAll(SqlConn);
                    try
                    {
                        if (dt_BanNang != null && dt_BanNang.Rows.Count > 0)
                        {
                            dt_BanNang.Columns.Add("thoigianconlai", typeof(decimal)).DefaultValue = 0;
                            dt_BanNang.Columns.Add("trangthaibn", typeof(string)).DefaultValue     = "";
                            foreach (DataRow r in dt_BanNang.Rows)
                            {
                                TrangThai.TrangThaiBanNang TT_TrangThai = (TrangThai.TrangThaiBanNang)Convert.ToInt16(r["trangthai"].ToString());
                                r["trangthaibn"] = TienIch.TrangThai.TrangThaiBanNang2String((TrangThai.TrangThaiBanNang)Convert.ToInt16(r["trangthai"].ToString()));
                                DateTime TGCapNhat = r["thoigianbd"] == DBNull.Value ? DateTime.Now : Convert.ToDateTime(r["thoigianbd"]);
                                TimeSpan diff      = DateTime.Now.Subtract(TGCapNhat);
                                Int32    minutes   = Convert.ToInt32(Math.Ceiling(diff.TotalMinutes)); //Làm tròn lên để hiển thị khớp với bảng LED
                                if (r["tongthoigian"] == DBNull.Value)
                                {
                                    r["tongthoigian"] = 0;
                                }
                                i_TGConLai          = Convert.ToInt32(minutes) >= Convert.ToInt32(r["tongthoigian"]) ? 0 : Convert.ToInt32(r["tongthoigian"]) - Convert.ToInt32(minutes);
                                r["thoigianconlai"] = i_TGConLai;
                                if (TT_TrangThai != TrangThai.TrangThaiBanNang.DangSuaChua)
                                {
                                    r["hoten"]          = "";
                                    r["thoigianbd"]     = DateTime.MinValue;
                                    r["biensoxe"]       = "";
                                    r["thoigianconlai"] = -1;
                                    r["tongthoigian"]   = -1;
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                    if (bHienThiDuLieuMoi) //định kỳ 5s hiển thị dữ liệu
                    {
                        if (dt_BanNang != null && dt_BanNang.Rows.Count > 0)
                        {
                            DataTable dt_HienThi = new DataTable();
                            if (dt_BanNang.Rows.Count < i_SoDongHienThi)
                            {
                                dt_HienThi      = dt_BanNang.Copy();
                                iDsBanNangIndex = 0;
                            }
                            else
                            {
                                dt_HienThi = dt_BanNang.Clone();
                                if (iDsBanNangIndex >= dt_BanNang.Rows.Count)
                                {
                                    iDsBanNangIndex = 0;
                                }
                                for (int i = 0; i < i_SoDongHienThi; i++)
                                {
                                    if ((iDsBanNangIndex + i) < dt_BanNang.Rows.Count)
                                    {
                                        dt_HienThi.ImportRow(dt_BanNang.Rows[iDsBanNangIndex + i]);
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                iDsBanNangIndex += i_SoDongHienThi;
                                if (iDsBanNangIndex >= dt_BanNang.Rows.Count)
                                {
                                    iDsBanNangIndex = 0;
                                }
                            }
                            grdBanNang.DataSource = dt_HienThi;
                        }
                        else
                        {
                            grdBanNang.DataSource = dt_BanNang;
                            iDsBanNangIndex       = 0;
                        }
                    }
                    //////////////////////////////////////////////////////////////////////////////////////
                    DsTraXe ds_TraXe = new DsTraXe();
                    // Hiển thị lên grid
                    dt_TraXe = ds_TraXe.LoadDsChuaLayXe(SqlConn);
                    if (bHienThiDuLieuMoi) //định kỳ 5s hiển thị dữ liệu
                    {
                        if (dt_TraXe != null && dt_TraXe.Rows.Count > 0)
                        {
                            DataTable dt_HienThi = new DataTable();
                            if (dt_TraXe.Rows.Count < i_SoDongHienThi)
                            {
                                dt_HienThi    = dt_TraXe.Copy();
                                iDsTraXeIndex = 0;
                            }
                            else
                            {
                                dt_HienThi = dt_TraXe.Clone();
                                if (iDsTraXeIndex >= dt_TraXe.Rows.Count)
                                {
                                    iDsTraXeIndex = 0;
                                }
                                for (int i = 0; i < i_SoDongHienThi; i++)
                                {
                                    if ((iDsTraXeIndex + i) < dt_TraXe.Rows.Count)
                                    {
                                        dt_HienThi.ImportRow(dt_TraXe.Rows[iDsTraXeIndex + i]);
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                iDsTraXeIndex += i_SoDongHienThi;
                                if (iDsTraXeIndex >= dt_TraXe.Rows.Count)
                                {
                                    iDsTraXeIndex = 0;
                                }
                            }
                            grdTraXe.DataSource = dt_HienThi;
                        }
                        else
                        {
                            grdTraXe.DataSource = dt_TraXe;
                            iDsTraXeIndex       = 0;
                        }
                    }
                    // Chạy chữ footer
                    DataTable dt_KQTraXe = ds_TraXe.LoadDsHienThiThongBao(SqlConn);

                    if (dt_KQTraXe != null && dt_KQTraXe.Rows.Count > 0)
                    {
                        if (dt_ThongBaoLayXe == null)
                        {
                            dt_ThongBaoLayXe = dt_KQTraXe.Clone();// Clone() only clones the table structure. It does not also clone the data.
                        }
                        for (int i = 0; i < dt_KQTraXe.Rows.Count; i++)
                        {
                            bool isDupe = false;
                            for (int j = 0; j < dt_ThongBaoLayXe.Rows.Count; j++)
                            {
                                if (dt_KQTraXe.Rows[i][0].ToString() == dt_ThongBaoLayXe.Rows[j][0].ToString())
                                {
                                    isDupe = true;
                                    break;
                                }
                            }

                            if (!isDupe)
                            {
                                dt_ThongBaoLayXe.ImportRow(dt_KQTraXe.Rows[i]);
                            }
                        }
                    }
                }
                catch
                {
                }
            }
        }
Esempio n. 8
0
        void CapNhatDuLieuGridView()
        {
            int    i_TongBanNang           = 0;
            int    i_BanNangBan            = 0;
            int    i_TGConLai              = 0;
            int    i_BanNang_SelectIndex   = 0;
            int    i_KhachHang_SelectIndex = 0;
            int    i_TraXe_SelectIndex     = 0;
            string s_BanNangSuaChuaXong    = "";

            if (SqlConn == null || SqlConn.State != ConnectionState.Open)
            {
                Database.Open(ref this.SqlConn);
            }
            if (SqlConn.State == ConnectionState.Open)
            {
                try
                {
                    i_BanNang_SelectIndex   = grvBanNang.FocusedRowHandle;
                    i_KhachHang_SelectIndex = grvKhachHang.FocusedRowHandle;
                    i_TraXe_SelectIndex     = grvTraXe.FocusedRowHandle;

                    TienIch.DsKhachHang dskhachhang = new DsKhachHang();
                    DataTable           dt_DsKH     = dskhachhang.LoadDSKHChoSuaChua(SqlConn);
                    grdKhachHang.DataSource = dt_DsKH;

                    TienIch.DsBanNang dsbannang = new DsBanNang();
                    DataTable         dt_DsBN   = dsbannang.LoadTheoTrangThaiKichHoat(SqlConn, TrangThai.TrangThaiKichHoatBanNang.HoatDong);

                    TienIch.DsTraXe ds_TraXe = new DsTraXe();
                    DataTable       dt_TraXe = ds_TraXe.LoadDsChuaLayXe(SqlConn);
                    grdTraXe.DataSource = dt_TraXe;

                    try
                    {
                        if (dt_DsBN != null && dt_DsBN.Rows.Count > 0)
                        {
                            dt_DsBN.Columns.Add("thoigianconlai", typeof(decimal)).DefaultValue = 0;
                            dt_DsBN.Columns.Add("trangthaibn", typeof(string)).DefaultValue     = "";
                            i_TongBanNang = dt_DsBN.Rows.Count;
                            foreach (DataRow r in dt_DsBN.Rows)
                            {
                                TrangThai.TrangThaiBanNang TT_TrangThai = (TrangThai.TrangThaiBanNang)Convert.ToInt16(r["trangthai"].ToString());
                                r["trangthaibn"] = TienIch.TrangThai.TrangThaiBanNang2String((TrangThai.TrangThaiBanNang)Convert.ToInt16(r["trangthai"].ToString()));
                                DateTime TGCapNhat = r["thoigianbd"] == DBNull.Value ? DateTime.Now : Convert.ToDateTime(r["thoigianbd"]);
                                TimeSpan diff      = DateTime.Now.Subtract(TGCapNhat);
                                //double minutes = diff.TotalMinutes;
                                Int32 minutes = Convert.ToInt32(Math.Ceiling(diff.TotalMinutes)); //Làm tròn lên để hiển thị khớp với bảng LED
                                if (r["tongthoigian"] == DBNull.Value)
                                {
                                    r["tongthoigian"] = 0;
                                }
                                i_TGConLai          = Convert.ToInt32(minutes) >= Convert.ToInt32(r["tongthoigian"]) ? 0 : Convert.ToInt32(r["tongthoigian"]) - Convert.ToInt32(minutes);
                                r["thoigianconlai"] = i_TGConLai;
                                if (TT_TrangThai != TrangThai.TrangThaiBanNang.DangSuaChua)
                                {
                                    r["hoten"]          = "";
                                    r["thoigianbd"]     = DateTime.MinValue;
                                    r["biensoxe"]       = "";
                                    r["thoigianconlai"] = -1;
                                    r["tongthoigian"]   = -1;
                                }
                                if (i_TGConLai <= 0 && TT_TrangThai == TrangThai.TrangThaiBanNang.DangSuaChua)
                                {
                                    s_BanNangSuaChuaXong += String.Format("[{0}]", r["maql"].ToString());
                                }
                            }
                        }
                        lblSLBanNang.Caption  = String.Format("Hoạt động: {0}/{1}", i_BanNangBan, i_TongBanNang);
                        grdBanNang.DataSource = dt_DsBN;

                        grvBanNang.FocusedRowHandle   = i_BanNang_SelectIndex;
                        grvKhachHang.FocusedRowHandle = i_KhachHang_SelectIndex;
                        grvTraXe.FocusedRowHandle     = i_TraXe_SelectIndex;
                    }
                    catch
                    {
                    }
                }
                catch
                {
                }
                finally
                {
                    if (s_BanNangSuaChuaXong != s_NhacNhoTraXe)
                    {
                        s_NhacNhoTraXe = s_BanNangSuaChuaXong;
                        if (s_NhacNhoTraXe != "")
                        {
                            ntfNhacNho.Visible         = true;
                            ntfNhacNho.Icon            = SystemIcons.Exclamation;
                            ntfNhacNho.BalloonTipTitle = "IKY-LED";
                            ntfNhacNho.BalloonTipText  = "Bàn nâng " + s_NhacNhoTraXe + " đã sửa chữa xong";
                            ntfNhacNho.BalloonTipIcon  = ToolTipIcon.Warning;
                            ntfNhacNho.ShowBalloonTip(10000);
                        }
                    }
                }
            }
        }