Ejemplo n.º 1
0
 private void frmTraXe_Load(object sender, EventArgs e)
 {
     btnDongY.LinkClicked += btnDongY_LinkClicked;
     if (s_SerialPort != "")
     {
         TienIch.ComPort.serialPort_Open(s_SerialPort, false);
     }
     if (conn == null || conn.State != ConnectionState.Open)
     {
         Database.Open(ref this.conn);
     }
     if (conn.State == ConnectionState.Open)
     {
         TienIch.DsBanNang ds = new TienIch.DsBanNang();
         DataTable         dt = ds.LoadDsTheoID(conn, this.s_MaBN);
         if (dt != null && dt.Rows.Count > 0)
         {
             r_BN = dt.Rows[0];
             TrangThai.TrangThaiBanNang TT_trangthai = (TrangThai.TrangThaiBanNang)Convert.ToInt16(r_BN["trangthai"].ToString());
             if (TT_trangthai == TrangThai.TrangThaiBanNang.DangSuaChua)
             {
                 i_TongTG = Convert.ToInt32(r_BN["tongthoigian"].ToString());
                 DateTime TGCapNhat = r_BN["thoigianbd"] == DBNull.Value ? DateTime.Now : Convert.ToDateTime(r_BN["thoigianbd"]);
                 TimeSpan diff      = DateTime.Now.Subtract(TGCapNhat);
                 double   minutes   = diff.TotalMinutes;
                 i_TGConLai  = Convert.ToInt32(minutes) >= Convert.ToInt32(r_BN["tongthoigian"]) ? 0 : Convert.ToInt32(r_BN["tongthoigian"]) - Convert.ToInt32(minutes);
                 i_TGConLai += 1;
             }
         }
     }
 }
 private void frmTaoBanNang_Load(object sender, EventArgs e)
 {
     btnDongY.LinkClicked += btnDongY_LinkClicked;
     if (b_Sua == true)
     {
         txtID.Enabled = false;
         txtID.Text    = s_NewID;
         //
         TienIch.DsBanNang ds = new TienIch.DsBanNang();
         DataTable         dt = ds.LoadDsTheoID(conn, s_NewID);
         if (dt != null && dt.Rows.Count > 0)
         {
             DataRow r = dt.Rows[0];
             s_KyThuatVien    = r["kythuatvien"].ToString();
             s_NoiDungHienThi = r["ndhienthi"].ToString();
         }
         //
         txtKyThuatVien.Text = s_KyThuatVien;
         txtNoiDungHT.Text   = s_NoiDungHienThi;
         this.Text           = "Sửa bàn nâng";
     }
     if (s_SerialPort != "")
     {
         TienIch.ComPort.serialPort_Open(s_SerialPort, false);
     }
 }
Ejemplo n.º 3
0
        private void btnDongY_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            string s_MaKH = "";
            int    i_TG   = 0;
            string s_ID   = this.s_MaBN;

            if (this.s_MaBN.Length < 2)
            {
                s_ID = "0" + this.s_MaBN;
            }
            string s_NDLayXe = txtThongBao.Text;
            string str       = "#CTR," + s_ID + "," + TienIch.Access.convertToUnSign3(s_NDLayXe).ToUpper() + ",*";

            if (s_NDLayXe != "")
            {
                byte[] data = System.Text.Encoding.UTF8.GetBytes(str);
                if (s_SerialPort != "")
                {
                    TienIch.ComPort.serialPort_Send(data, 0, data.Length);
                }
            }
            else
            {
                GiamThoiGian();
            }
            TienIch.DsBanNang ds = new TienIch.DsBanNang();
            ds.UpdateTrangThai(conn, s_MaBN, TienIch.TrangThai.TrangThaiBanNang.ChoNhanXe);
            DataTable dt_BN = ds.LoadDsTheoID(conn, s_MaBN);

            if (dt_BN != null && dt_BN.Rows.Count > 0)
            {
                DataRow r = dt_BN.Rows[0];
                s_MaKH = r["makhachhang"].ToString();
                i_TG   = Convert.ToInt32(r["tongthoigian"].ToString());
            }

            TienIch.QLBanNang qlBN = new TienIch.QLBanNang();
            qlBN.Insert(conn, s_MaBN, s_MaKH, i_TG);
            TienIch.DsTraXe dsTraXe = new TienIch.DsTraXe();
            dsTraXe.Insert(conn, s_MaKH);
            this.Close();
        }
 private void frmSuaThongTinKH_Load(object sender, EventArgs e)
 {
     btnDongY.LinkClicked += btnDongY_LinkClicked;
     if (conn == null || conn.State != ConnectionState.Open)
     {
         Database.Open(ref this.conn);
     }
     if (s_SerialPort != "")
     {
         TienIch.ComPort.serialPort_Open(s_SerialPort, false);
     }
     if (conn.State == ConnectionState.Open)
     {
         TienIch.DsBanNang ds = new TienIch.DsBanNang();
         DataTable         dt = ds.LoadDsTheoID(conn, s_IDBanNang);
         if (dt != null && dt.Rows.Count > 0)
         {
             DataRow r_BN = dt.Rows[0];
             this.s_MaKH     = r_BN["makhachhang"].ToString();
             this.s_HoTen    = r_BN["hoten"].ToString();
             this.s_BienSoXe = r_BN["biensoxe"].ToString();
             TT_trangthai    = (TrangThai.TrangThaiBanNang)Convert.ToInt16(r_BN["trangthai"].ToString());
             i_TongTG        = Convert.ToInt32(r_BN["tongthoigian"].ToString());
             DateTime TGCapNhat = r_BN["thoigianbd"] == DBNull.Value ? DateTime.Now : Convert.ToDateTime(r_BN["thoigianbd"]);
             TimeSpan diff      = DateTime.Now.Subtract(TGCapNhat);
             double   minutes   = diff.TotalMinutes;
             double   seconds   = diff.TotalSeconds;
             //Int32 minutes = Convert.ToInt32(Math.Ceiling(diff.TotalMinutes)); //Làm tròn lên để hiển thị khớp với bảng LED
             i_TGConLai_TinhTheoGiay = Convert.ToInt32(seconds) >= (Convert.ToInt32(r_BN["tongthoigian"]) * 60) ? 0 : ((Convert.ToInt32(r_BN["tongthoigian"]) * 60) - Convert.ToInt32(seconds));
             i_TGConLai_TinhTheoPhut = Convert.ToInt32(minutes) >= Convert.ToInt32(r_BN["tongthoigian"]) ? 0 : Convert.ToInt32(r_BN["tongthoigian"]) - Convert.ToInt32(minutes);
         }
     }
     if (TT_trangthai == TrangThai.TrangThaiBanNang.ChoNhanXe)
     {
         txtHoTen.Enabled    = false;;
         txtBienSoXe.Enabled = false;
     }
     txtBanNang.Text  = s_IDBanNang;
     txtHoTen.Text    = s_HoTen;
     txtBienSoXe.Text = s_BienSoXe;
     txtThoiGian.Text = i_TGConLai_TinhTheoPhut.ToString() + " Phút";
 }