/// <summary> /// Fill bike information in rent bike form when rent bike status is RENTING_BIKE /// </summary> /// <param name="bike">the rental bike information</param> public void FillRentingBikeForm(BaseBike bike) { this.bike = bike; this.StartTimer(); rentingBikePnl.Visible = true; DateTime begin = rentBikeController.GetBeginDate(this.bike.BikeId); rentingTimedRentValueLbl.Text = Utilities.SubtractDate(DateTime.Now, begin); rentingQrCodeTxt.Text = bike.QRCode; rentingAvatarPb.Image = Image.FromFile(bike.Images); if (bike is Bike) { rentingCategoryTxt.Text = "Xe đạp thường"; rentingRemainPowerValueLbl.Text = "Không có thông tin"; rentingLicenseTxt.Text = "Không có thông tin"; } else if (bike is ElectricBike) { ElectricBike electricBike = bike as ElectricBike; rentingCategoryTxt.Text = "Xe đạp điện"; rentingRemainPowerValueLbl.Text = $"{electricBike.Powers}%"; rentingLicenseTxt.Text = electricBike.LicensePlate; } else { rentingCategoryTxt.Text = "Xe đạp đôi"; rentingRemainPowerValueLbl.Text = "Không có thông tin"; rentingLicenseTxt.Text = "Không có thông tin"; } rentingManufactureTxt.Text = bike.Manufacturer; }
/// <summary> /// Get bike by qrcode and save name and address of station contain this bike /// </summary> /// <param name="qrCode">The qr code to get bike</param> /// <param name="stationName">The string save name of station</param> /// <param name="stationAddress">The string save address of station</param> /// <returns>The BaseBike representing the bike has qr code</returns> public BaseBike SubmitQrCode(string qrCode, ref string stationName, ref string stationAddress) { BaseBike bike = null; if (qrCode[0] == '0') { bike = bikeService.GetBikeByQRCode(qrCode); } else if (qrCode[0] == '1') { bike = tandemService.GetBikeByQRCode(qrCode); } else if (qrCode[0] == '2') { bike = electricBikeService.GetBikeByQRCode(qrCode); } if (bike == null) { return(null); } Station station = stationService.GetStationById(bike.StationId); stationName = station.NameStation; stationAddress = station.AddressStation; return(bike); }
/// <summary> /// Get bike information /// </summary> /// <param name="bikeId">The bike id you want to get information</param> /// <param name="category">The bike type</param> /// <param name="stationName">Representing station name contain the bike</param> /// <param name="stationAddress">Repensting station address contain the bike</param> /// <returns>The BaseBike representing the bike you want to get</returns> public BaseBike ViewBikeDetail(int bikeId, BikeCategory category, ref string stationName, ref string stationAddress) { BaseBike bike = null; if (category == BikeCategory.BIKE) { bike = bikeService.GetBikeById(bikeId); } else if (category == BikeCategory.ELECTRIC) { bike = electricBikeService.GetBikeById(bikeId); } else if (category == BikeCategory.TANDEM) { bike = tandemService.GetBikeById(bikeId); } if (bike == null) { return(null); } Station station = stationService.GetStationById(bike.StationId); stationName = station.NameStation; stationAddress = station.AddressStation; return(bike); }
/// <summary> /// Handle click event SearchBut, display information of bike if finded /// </summary> /// <param name="sender">The object send event</param> /// <param name="e">An EventArgs</param> private void SearchBut_Click(object sender, EventArgs e) { string qrCode = searchTxt.Text; if (qrCode == "") { MessageBox.Show("Nhập mã xe bạn muốn tìm kiếm", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!Utilities.InvlidString(Config.QRValid, qrCode)) { MessageBox.Show($"QRCode không hợp lệ\nQRCode là dãy số có chín chữ số", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string stationName = "", stationAddress = ""; BaseBike bike = bikeStationController.ViewBikeDetail(qrCode, ref stationName, ref stationAddress); if (bike == null) { MessageBox.Show($"Không tìm được xe có qrcode: {qrCode}", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } bikeDetailForm.FillBikeInformation(bike, stationName, stationAddress); bikeDetailForm.Show(this); this.Hide(); }
/// <summary> /// Insert new transaction when user deposit money to rent the bike /// </summary> /// <param name="userId">the Id of user who want to rent the bike</param> /// <param name="bikeId">the id of rental bike</param> /// <param name="deposit">the desposit money to rent the bike</param> /// <returns>Return the new transaction or null if get error</returns> public Transaction InsertNewTransaction(int userId, int bikeId, int deposit) { User checkUser = connecter.SqlData.Users.Find(userId); if (checkUser == null) { return(null); } BaseBike checkBike = connecter.SqlData.BaseBikes.Find(bikeId); if (checkBike == null) { return(null); } Transaction transaction = new Transaction(userId, bikeId, deposit); connecter.SqlData.Transactions.Add(transaction); int check = connecter.SqlData.SaveChanges(); if (check > 0) { return(transaction); } else { return(null); } }
/// <summary> /// Handle click event RentBikeRentBut, if user enter correct or code, display detail information of bike have this qr code /// </summary> /// <param name="sender">The object send event</param> /// <param name="e">An EventArgs</param> private void RentBikeRentBut_Click(object sender, EventArgs e) { string qrCode = rentBikeQrCodeTxt.Text; if (qrCode == "") { MessageBox.Show("Nhập mã xe bạn muốn tìm kiếm", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!Utilities.InvlidString(Constant.QRValid, qrCode)) { MessageBox.Show($"QRCode không hợp lệ\nQRCode là dãy số có chín chữ số", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error); rentBikeQrCodeTxt.Text = ""; return; } string stationName = "", stationAddress = ""; BaseBike bike = rentBikeController.SubmitQrCode(qrCode, ref stationName, ref stationAddress); if (bike == null) { MessageBox.Show($"Không tìm thấy xe có mã qr code {qrCode}", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); rentBikeQrCodeTxt.Text = ""; return; } if (bike.BikeStatus) { MessageBox.Show($"Xe đang được thuê, vui lòng chọn xe khác", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); rentBikeQrCodeTxt.Text = ""; return; } bikeDetailForm.FillBikeInformation(bike, stationName, stationAddress); bikeDetailForm.Show(this); this.Hide(); }
/// <summary> /// Handle click event SearchBut, display information of bike if finded /// </summary> /// <param name="sender">The object send event</param> /// <param name="e">An EventArgs</param> private void SearchBut_Click(object sender, EventArgs e) { string qrCode = searchTxt.Text; searchTxt.Text = ""; if (qrCode == "") { MessageBox.Show("Nhập mã xe bạn muốn tìm kiếm", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!Utilities.InvlidString(Constant.QRValid, qrCode)) { MessageBox.Show($"QRCode không hợp lệ\nQRCode là dãy số có chín chữ số", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } BaseBike bike = bikes.SingleOrDefault(x => x.QRCode == qrCode); if (bike == null) { MessageBox.Show($"Không tìm được xe có qrcode: {qrCode}", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Station station = viewStationController.ViewStationDetail(bike.StationId); bikeDetailForm.FillBikeInformation(bike, station.NameStation, station.AddressStation); bikeDetailForm.Show(this, this); this.Hide(); }
/// <summary> /// Fill bike information in rent bike form when rent bike status is RENTING_BIKE /// </summary> /// <param name="bikeId">The bike id of specified bike</param> public void FillRentingBikeForm() { BaseBike bike = Config.RENTAL_BIKE; rentingQrCodeTxt.Text = bike.QRCode; if (bike is Bike) { rentingCategoryTxt.Text = "Xe đạp thường"; rentingRemainPowerValueLbl.Text = "Không có thông tin"; rentingLicenseTxt.Text = "Không có thông tin"; } else if (bike is ElectricBike) { ElectricBike electricBike = bike as ElectricBike; rentingCategoryTxt.Text = "Xe đạp điện"; rentingRemainPowerValueLbl.Text = $"${electricBike.Powers}%"; rentingLicenseTxt.Text = electricBike.LicensePlate; } else { rentingCategoryTxt.Text = "Xe đạp đôi"; rentingRemainPowerValueLbl.Text = "Không có thông tin"; rentingLicenseTxt.Text = "Không có thông tin"; } rentingManufactureTxt.Text = bike.Manufacturer; }
/// <summary> /// Fill bike information in rent bike /// </summary> /// <param name="bike">The bike id of specified bike</param> public void FillRentElectricInfoForm(BaseBike bike) { FillInfo(bike); ElectricBike electricBike = bike as ElectricBike; rentBikeInfoCategoryTxt.Text = "Xe đạp điện"; rentBikeInfoLicenseTxt.Text = electricBike.LicensePlate; }
private void FillInfo(BaseBike bike) { rentBikeInfoPnl.Visible = true; this.bike = bike; rentBikeInfoQrCodeTxt.Text = bike.QRCode; int deposit = bike.CalculateDeposit(); rentBikeInfoDepositTxt.Text = String.Format("{0:n0}", deposit); }
/// <summary> /// Update bike information /// </summary> /// <param name="bikeId">The bike id</param> /// <param name="update">The update information</param> /// <returns>The bike information after updated</returns> public BaseBike UpdateBike(int bikeId, UpdateBikeInfo update) { BaseBike bike = connecter.SqlData.BaseBikes.Find(bikeId); bike.UpdateBike(update); int check = connecter.SqlData.SaveChanges(); bike = connecter.SqlData.BaseBikes.Find(bikeId); if (check > 0) { return(bike); } return(null); }
/// <summary> /// Get bike by qrcode and save name and address of station contain this bike /// </summary> /// <param name="qrCode">The qr code to get bike</param> /// <param name="stationName">The string save name of station</param> /// <param name="stationAddress">The string save address of station</param> /// <returns>The BaseBike representing the bike has qr code</returns> public BaseBike SubmitQrCode(string qrCode, ref string stationName, ref string stationAddress) { BaseBike bike = bikeService.GetBikeByQRCode(qrCode); if (bike == null) { return(null); } Station station = stationService.GetStationById(bike.StationId); stationName = station.NameStation; stationAddress = station.AddressStation; return(bike); }
/// <summary>Insert new transaction when user deposit money to rent the bike</summary> /// <param name="userId">the Id of user who want to rent the bike</param> /// <param name="bikeId">the Id of rental bike</param> /// <param name="deposit">the desposit money to rent the bike</param> /// <returns>Return the new transaction or null if get error</returns> public Transaction InsertNewTransaction(int userId, string qrcode, int deposit) { User checkUser = connecter.SqlData.Users.Find(userId); if (checkUser == null) { return(null); } BaseBike checkBike = null; if (qrcode[0] == '0') { checkBike = connecter.SqlData.Bikes.SingleOrDefault(x => x.QRCode == qrcode); } else if (qrcode[0] == '1') { checkBike = connecter.SqlData.Tandems.SingleOrDefault(x => x.QRCode == qrcode); } else if (qrcode[0] == '2') { checkBike = connecter.SqlData.ElectricBikes.SingleOrDefault(x => x.QRCode == qrcode); } if (checkBike == null) { return(null); } Transaction transaction = new Transaction() { UserId = userId, BikeQrCode = qrcode, Deposit = deposit, RentalMoney = 0, TotalTimeRent = 0, DateTransaction = DateTime.Now }; connecter.SqlData.Transactions.Add(transaction); int check = connecter.SqlData.SaveChanges(); if (check > 0) { return(transaction); } else { return(null); } }
/// <summary> /// Handle click event bike detail button, display the information of specified bike /// </summary> /// <param name="sender">The object send event</param> /// <param name="e">An EventArgs</param> private void But_Click(object sender, EventArgs e) { Button but = sender as Button; int bikeId = (int)but.Tag; BaseBike bike = viewBikeController.ViewBikeDetail(bikeId); if (bike == null) { MessageBox.Show($"Không tìm được xe có id: {bikeId}", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } bikeDetailForm.FillBikeInformation(bike, this.stationName, this.stationAddress); bikeDetailForm.Show(this); bikeDetailForm.Show(this, this); this.Hide(); }
/// <summary> /// Get bike information /// </summary> /// <param name="bikeId">The bike id you want to get information</param> /// <param name="category">The bike type</param> /// <returns>The BaseBike representing the bike you want to get</returns> public BaseBike ViewBikeDetail(int bikeId, BikeCategory category) { BaseBike bike = null; if (category == BikeCategory.BIKE) { bike = bikeService.GetBikeById(bikeId); } else if (category == BikeCategory.ELECTRIC) { bike = electricBikeService.GetBikeById(bikeId); } else if (category == BikeCategory.TANDEM) { bike = tandemService.GetBikeById(bikeId); } return(bike); }
/// <summary> /// Handle click event bike detail button, display the information of specified bike /// </summary> /// <param name="sender">The object send event</param> /// <param name="e">An EventArgs</param> private void But_Click(object sender, EventArgs e) { Button but = sender as Button; (int, Config.SQL.BikeCategory)bikeInfo = ((int, Config.SQL.BikeCategory))but.Tag; string stationName = "", stationAddress = ""; BaseBike bike = bikeStationController.ViewBikeDetail(bikeInfo.Item1, bikeInfo.Item2, ref stationName, ref stationAddress); if (bike == null) { MessageBox.Show($"Không tìm được xe có id: {bikeInfo.Item1}", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } bikeDetailForm.FillBikeInformation(bike, stationName, stationAddress); bikeDetailForm.Show(this); this.Hide(); bikeDetailForm.Show(this, this); }
/// <summary> /// Display bike information /// </summary> /// <param name="bike">The bike information</param> /// <param name="stationName">The station name contain this bike</param> /// <param name="stationAddress">The station address contain this bike</param> public void FillBikeInformation(BaseBike bike, string stationName, string stationAddress) { stationRtb.Text = $"{stationName}\n{stationAddress}"; qrCodeTxt.Text = bike.QRCode; manufactureTxt.Text = bike.Manufacturer; avatarPb.Image = Image.FromFile(bike.Images); if (bike.BikeStatus) { statusBikeLbl.Text = "Renting"; statusBikeLbl.BackColor = Color.Red; viewRentingBut.Visible = true; rentThisBikeBut.Visible = false; } else { statusBikeLbl.Text = "Available"; statusBikeLbl.BackColor = Color.Green; viewRentingBut.Visible = false; rentThisBikeBut.Visible = true; } if (bike.Category == "bike") { categoryBikeTxt.Text = "Xe đạp thường"; powerTxt.Text = "Không có thông tin"; licenceTxt.Text = "Không có thông tin"; this.category = BikeCategory.BIKE; } else if (bike.Category == "tandem") { categoryBikeTxt.Text = "Xe đạp đôi"; powerTxt.Text = "Không có thông tin"; licenceTxt.Text = "Không có thông tin"; this.category = BikeCategory.TANDEM; } else { ElectricBike electric = bike as ElectricBike; categoryBikeTxt.Text = "Xe đạp điện"; powerTxt.Text = $"{electric.Powers}%"; licenceTxt.Text = electric.LicensePlate; this.category = BikeCategory.ELECTRIC; } this.bike = bike; }
/// <summary> /// Get bike by bike's id /// </summary> /// <param name="id">the bike's id you want to find</param> /// <returns>Return the bike with specified ID or null if not found</returns> public BaseBike GetBikeById(int id) { BaseBike baseBike = connecter.SqlData.BaseBikes.Find(id); BaseBike result = null; if (baseBike.Category == "bike") { result = new Bike(baseBike); } else if (baseBike.Category == "tandem") { result = new Tandem(baseBike); } else if (baseBike.Category == "electric") { ElectricBikeTable electricBike = connecter.SqlData.ElectricBikes.Find(baseBike.BikeId); result = new ElectricBike(baseBike, electricBike); } return(result); }
/// <summary>Get bike by QR code</summary> /// <param name="QRCode">QR Code you want to find</param> /// <returns>Return the bike with specified QR Code or null if not found</returns> public BaseBike GetBikeByQRCode(string QRCode) { BaseBike baseBike = connecter.SqlData.BaseBikes.SingleOrDefault(x => x.QRCode == QRCode); BaseBike result = null; if (baseBike.Category == "bike") { result = new Bike(baseBike); } else if (baseBike.Category == "tandem") { result = new Tandem(baseBike); } else if (baseBike.Category == "electric") { ElectricBikeTable electricBike = connecter.SqlData.ElectricBikes.Find(baseBike.BikeId); result = new ElectricBike(baseBike, electricBike); } return(result); }
/// <summary> /// Display bike information /// </summary> /// <param name="bike">The bike information</param> /// <param name="stationName">The station name contain this bike</param> /// <param name="stationAddress">The station address contain this bike</param> public void FillBikeInformation(BaseBike bike, string stationName, string stationAddress) { stationRtb.Text = string.Format("{0}\n{1}", stationName, stationAddress); qrCodeTxt.Text = bike.QRCode; manufactureTxt.Text = bike.Manufacturer; if (bike.BikeStatus) { statusBikeLbl.Text = "Renting"; statusBikeLbl.BackColor = Color.Red; } else { statusBikeLbl.Text = "Availiable"; statusBikeLbl.BackColor = Color.Green; } if (bike is Bike) { categoryBikeTxt.Text = "Xe đạp thường"; powerTxt.Text = "Không có thông tin"; licenceTxt.Text = "Không có thông tin"; rentThisBikeBut.Tag = (bike.BikeId, Config.SQL.BikeCategory.BIKE); } else if (bike is Tandem) { categoryBikeTxt.Text = "Xe đạp đôi"; powerTxt.Text = "Không có thông tin"; licenceTxt.Text = "Không có thông tin"; rentThisBikeBut.Tag = (bike.BikeId, Config.SQL.BikeCategory.TANDEM); } else { ElectricBike electric = bike as ElectricBike; categoryBikeTxt.Text = "Xe đạp điện"; powerTxt.Text = $"{electric.Powers}%"; licenceTxt.Text = electric.LicensePlate; rentThisBikeBut.Tag = (bike.BikeId, Config.SQL.BikeCategory.ELECTRIC); } }
/// <summary> /// Fill transaction form with transaction's information when user process transaction for pay deposit money /// </summary> /// <param name="bike">the rental bike</param> /// <param name="card">The card</param> public void FillTransactionInformationWhenRentBike(BaseBike bike, Card card) { this.bike = bike; this.card = card; this.isPay = false; if (bike is Bike) { category = BikeCategory.BIKE; } else if (bike is ElectricBike) { category = BikeCategory.ELECTRIC; } else if (bike is Tandem) { category = BikeCategory.TANDEM; } this.deposit = 40 * bike.Value / 100; depositTxt.Text = String.Format("{0:n0}", this.deposit); rentalMoneyTxt.Text = "Không có dữ liệu"; transactionDateTxt.Text = "Không có dữ liệu"; cancelBut.Visible = true; }
/// <summary> /// Fill transaction form with transaction's information when user process transaction for pay rental money /// </summary> /// <param name="stationId">The return station id</param> /// <param name="bike">The rental need to return</param> public void FillTransactionInformationWhenPay(int stationId, BaseBike bike) { this.bike = bike; this.stationId = stationId; remainMoneyTxt.Text = "1000000"; transactionDateTxt.Text = DateTime.Now.ToString("f"); cancelBut.Visible = false; this.isPay = true; if (bike is Bike) { category = BikeCategory.BIKE; } else if (bike is ElectricBike) { category = BikeCategory.ELECTRIC; } else if (bike is Tandem) { category = BikeCategory.TANDEM; } rentalMoney = rentBikeController.CalculateFee(rentingBikeForm.GetTotalTimeRent(), category); rentalMoneyTxt.Text = (rentalMoney == 0) ? "Miễn phí" : rentalMoney.ToString(); }
public void Setup(IBike ibike, IBeamAppCore backend) { bb = ibike as BaseBike; appCore = backend; SetupImpl(); }
/// <summary> /// Read rental bike need to return /// </summary> /// <param name="bike">The rental bike need to return</param> public void ReadRentalBike(BaseBike bike) { this.rentalBike = bike; }
/// <summary> /// Fill card information /// </summary> public void FillCardInformation(BaseBike bike) { this.bike = bike; }
/// <summary> /// Get bike information /// </summary> /// <param name="bikeId">The bike id you want to get information</param> /// <returns>The BaseBike representing the bike you want to get</returns> public BaseBike ViewBikeDetail(int bikeId) { BaseBike bike = bikeService.GetBikeById(bikeId); return(bike); }
/// <summary> /// Fill bike information in rent bike /// </summary> /// <param name="bike">The bike id of specified bike</param> public void FillRentTandemInfoForm(BaseBike bike) { FillInfo(bike); rentBikeInfoCategoryTxt.Text = "Xe đạp đôi"; rentBikeInfoLicenseTxt.Text = "Không có thông tin"; }
/// <summary>Showing some type of equipments</summary> private void ShowEquipmentByType(int eq) { if (eq < 0 || eq > 2) { return; } Console.Clear(); if (eqCollection.Length == 0) { Console.WriteLine("The shop is empty!"); return; } Console.WriteLine("The list of the concrete type of the equipment:"); int countItemsConcreteType = 0; StringBuilder sb = new StringBuilder(); for (int i = 0; i < eqCollection.Length; i++) { switch (eq) { case 0: { BaseBall beq = eqCollection.GetEquipmentByIndex(i) as BaseBall; if (beq != null) { SetEquipmentInfoForType(ref sb, ref countItemsConcreteType, beq.GetInfo()); } break; } case 1: { BaseBike beq = eqCollection.GetEquipmentByIndex(i) as BaseBike; if (beq != null) { SetEquipmentInfoForType(ref sb, ref countItemsConcreteType, beq.GetInfo()); } break; } case 2: { BaseBoat beq = eqCollection.GetEquipmentByIndex(i) as BaseBoat; if (beq != null) { SetEquipmentInfoForType(ref sb, ref countItemsConcreteType, beq.GetInfo()); } break; } } } if (countItemsConcreteType == 0) { Console.WriteLine("The equipments of the concrete type were not found!"); } else { Console.WriteLine(sb); } }