示例#1
0
        /// <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>
        /// Handle click event station detail but
        /// </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;
            Station station = viewStationController.ViewStationDetail((int)but.Tag);

            this.Hide();
            stationDetailForm.FillStationDetail(station);
            stationDetailForm.Show(this, this);
        }