コード例 #1
0
ファイル: FrmSignUp.cs プロジェクト: ducdv98/ParkingManager
        private void btnRegister_Click(object sender, EventArgs e)
        {
            if (tbCustomerName.Text.Equals("") || tbTicketIdGen.Text.Equals("") || cbArea.SelectedIndex == -1 ||
                cbType.SelectedIndex == -1)
            {
                return;
            }
            if (cbType.SelectedIndex != 0 && tbLicensePlate.Text.Trim().Equals(""))
            {
                MessageBox.Show("Nhập biển kiểm soát!", "Thông báo", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                tbLicensePlate.Focus();
                return;
            }

            if (cbType.SelectedIndex == 0)
            {
                tbLicensePlate.Text = "";
            }

            DialogResult dialogResult = MessageBox.Show("Phí giữ xe là: " + _priceList[cbType.SelectedIndex].Price.ToString("###,###") + "đ, \nTiếp tục?", "Xác nhận", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                CustomerDto customer = new CustomerDto()
                {
                    AreaID       = cbArea.SelectedIndex + 1,
                    Block        = tbBlock.Text.Trim(),
                    LicensePlate = tbLicensePlate.Text.Trim(),
                    TicketID     = tbTicketIdGen.Text,
                    PhoneNumber  = tbPhoneNum.Text.Trim(),
                    IDCard       = tbIdCard.Text.Trim(),
                    Name         = tbCustomerName.Text,
                    VehicleType  = cbType.SelectedIndex + 1,
                    Fee          = _priceList[cbType.SelectedIndex]
                };

                if (parkingDao.SignUp(customer) == Constants.RESULT_OK)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Có lỗi xảy ra!", "Thông báo", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
            else if (dialogResult == DialogResult.No)
            {
                // do nothing
            }
        }