コード例 #1
0
        private void retrieveButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (VehUtil.isEmpty(txtCustomerID.Text))
                {
                    MessageBox.Show(VehMessage.EmptyCustomerID);
                    return;
                }


                if (!VehUtil.isCustomerID(txtCustomerID.Text))
                {
                    MessageBox.Show(VehMessage.InvalidCustomerID);
                    return;
                }

                RentVehicleControl c        = new RentVehicleControl();
                Customer           customer = c.RetrieveCustomerDetails(Int32.Parse(txtCustomerID.Text));
                txtName.Text      = customer.CustomerName;
                txtTelephone.Text = customer.Telephone.ToString();
                txtEmail.Text     = customer.EmailAddress;
            }
            catch (Exception)
            {
                MessageBox.Show(VehMessage.GeneralErrorMsg);
            }
        }
コード例 #2
0
        private void rentButton_Click(object sender, EventArgs e)
        {
            //if (VehUtil.isEmpty(txtCustomerID.Text))
            //{
            //    MessageBox.Show(VehMessage.CreateCustomer);

            //}

            try
            {
                if (VehUtil.isEmpty(txtCustomerID.Text))
                {
                    MessageBox.Show(VehMessage.EmptyCustomerID);
                    return;
                }
                if (!VehUtil.isCustomerID(txtCustomerID.Text))
                {
                    MessageBox.Show(VehMessage.InvalidCustomerID);
                    return;
                }
                if (!VehUtil.isEmailValid(txtEmail.Text))
                {
                    MessageBox.Show(VehMessage.InvalidEmaildAddress);
                    return;
                }
                if (!VehUtil.isTelephone(txtTelephone.Text))
                {
                    MessageBox.Show(VehMessage.InvalidTelephone);
                    return;
                }
                if (!VehUtil.isRentalDayValid(txtRentalDays.Text))
                {
                    MessageBox.Show(VehMessage.InvalidDays);
                    return;
                }


                RentVehicleControl c = new RentVehicleControl();
                string             carPlateNumber = vehicleDetails.Cells[6].Value.ToString();
                int customerID = Int32.Parse(txtCustomerID.Text);
                int days       = Int32.Parse(txtRentalDays.Text);
                c.CreateTransaction(carPlateNumber, customerID, days);
                MessageBox.Show("Rent Success!");
            }
            catch (Exception)
            {
                MessageBox.Show(VehMessage.GeneralErrorMsg);
            }
        }