Example #1
0
        public string themXe(XeCo xe, NguoiGuiXe nguoi)
        {
            int hangXe = (int)xe.getTypeOfVehicle();

            for (int i = 0; i < sucChua; i++)
            {
                if (slotXe[hangXe, i] == 0)
                {
                    //Đánh dấu = 1 tại chỗ nào có xe
                    slotXe[hangXe, i] = 1;
                    //Tăng số lượng xe hiện đang gửi của hàng đó
                    slXe[hangXe]++;
                    //Gán thẻ xe đó cho người lái xe
                    nguoi.theXe = phatTheXe();
                    //Mã hóa vị trí đỗ xe thành mã xe
                    xe.maXe = (hangXe + "." + i).ToString();
                    //Thêm thông tin cho người và xe
                    ThongTinXeTrongBai TTXTB;
                    TTXTB.maXe     = xe.maXe;
                    TTXTB.anhNguoi = nguoi.anhNguoi();
                    TTXTB.anhXe    = xe.anhXe();
                    TTXTB.hang     = hangXe;
                    TTXTB.cot      = i;
                    TTXeTrongBai.Add(nguoi.theXe, TTXTB);
                    break;
                }
            }
            return($"Da them xe {xe.getTypeOfVehicle()} Ma the xe la: {nguoi.theXe}");
        }
Example #2
0
 public XeCo(XeCo xe)
 {
     this.maXe    = xe.maXe;
     this.hangXe  = xe.hangXe;
     this.ngayGio = xe.ngayGio;
     this.loaiXe  = xe.loaiXe;
 }
Example #3
0
 public int xuLyTheXe(XeCo xe, NguoiGuiXe nguoilayxe)
 {
     foreach (KeyValuePair <int, ThongTinXeTrongBai> TimKiem in this.TTXeTrongBai)
     {
         if (xe.maXe == TimKiem.Value.maXe && nguoilayxe.anhNguoi() == TimKiem.Value.anhNguoi && xe.anhXe() == TimKiem.Value.anhXe)
         {
             return(TimKiem.Key);
         }
     }
     return(-1);
 }
Example #4
0
        private bool thucHienXacNhan(int maTheXe, XeCo xe, NguoiGuiXe nguoilayxe)
        {
            string anhXeVao, anhNguoiVao, anhXeRa, anhNguoiRa;

            anhNguoiVao = this.TTXeTrongBai[maTheXe].anhNguoi;
            anhXeVao    = this.TTXeTrongBai[maTheXe].anhXe;
            anhXeRa     = xe.anhXe();
            anhNguoiRa  = nguoilayxe.anhNguoi();
            if (anhXeVao == anhXeRa && anhNguoiVao == anhNguoiRa)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #5
0
        public string xuLyLayXe(XeCo xe, NguoiGuiXe nguoilayxe, HinhThucThanhToan hinhThucThanhToan, int tienNguoiGuiXe, tinhTienGXe cachTinhTien)
        {
            int      maTheXe          = nguoilayxe.theXe;
            DateTime thoiGianXacNhan  = DateTime.Now;
            Scanner  loaiXe           = xe.getTypeOfVehicle();
            int      soTienCanPhaiTra = tinhTienGuiXe(cachTinhTien, tinhThoiGianGuiXe(xe.ngayGio, thoiGianXacNhan), loaiXe);

            if (maTheXe == -1)                          //Người lấy xe bị mất thẻ xe
            {
                soTienCanPhaiTra += 50000;
                maTheXe           = xuLyTheXe(xe, nguoilayxe);
            }
            if (TTXeTrongBai.ContainsKey(maTheXe) == true)
            {
                if (thucHienXacNhan(maTheXe, xe, nguoilayxe) == true)
                {
                    string anhNguoiVao = this.TTXeTrongBai[maTheXe].anhNguoi;
                    string anhXeVao    = this.TTXeTrongBai[maTheXe].anhXe;
                    //Loại bỏ các dữ liệu về xe trong cơ sở dữ liệu
                    xoaThongTinXe(maTheXe, (int)loaiXe);
                    //Lưu thông tin cơ bản của xe vào Dictionary để xử lý trường hợp mất xe
                    this.danhSachTTXeDaLay.Add(thongTinXe(maTheXe, xe.ngayGio, thoiGianXacNhan, anhXeVao, anhNguoiVao, xe.anhXe(), nguoilayxe.anhNguoi()));
                    //Lấy tiền gửi xe
                    if (tienNguoiGuiXe < soTienCanPhaiTra)
                    {
                        return($"{thanhToan(hinhThucThanhToan, tienNguoiGuiXe, soTienCanPhaiTra)}\nLay {xe.getTypeOfVehicle()} khong thanh cong\n");
                    }
                    return($"{thanhToan(hinhThucThanhToan, tienNguoiGuiXe, soTienCanPhaiTra)}\nDa lay {xe.getTypeOfVehicle()} thanh cong\n");
                }
                else
                {
                    return("Thong bao: Anh khong khop");
                }
            }
            else
            {
                return("The xe khong ton tai");
            }
        }