public void InsertRentRecord(RentRecords r)
        {
            SqlParameter RecordsID =
                new SqlParameter("@RecordsID", SqlDbType.NVarChar, 10);
            SqlParameter StaffID =
                new SqlParameter("@StaffID", SqlDbType.NVarChar, 10);
            SqlParameter CustomerID =
                new SqlParameter("@CustomerID", SqlDbType.NVarChar, 10);
            SqlParameter RentalStartDate =
                new SqlParameter("@RentalStartDate", SqlDbType.Date);
            SqlParameter RentalEndDate =
                new SqlParameter("@RentalEndDate", SqlDbType.Date);
            SqlParameter ActualReturnDate =
                new SqlParameter("@ActualReturnDate", SqlDbType.Date);
            SqlParameter BookingDate =
                new SqlParameter("@BookingDate", SqlDbType.Date);
            SqlParameter VehiclePlateNumber =
                new SqlParameter("@VehiclePlateNumber", SqlDbType.NVarChar, 10);

            // clear any previous parameters set before adding new parameters
            cmInsert.Parameters.Clear();
            cmInsert.Parameters.AddRange(new SqlParameter[]
                                         { RecordsID, StaffID, CustomerID, RentalStartDate, RentalEndDate, ActualReturnDate, BookingDate, VehiclePlateNumber });

            RecordsID.Value          = r.RecordsID;
            StaffID.Value            = r.StaffID;
            CustomerID.Value         = r.CustomerID;
            RentalStartDate.Value    = r.RentalStartDate;
            RentalEndDate.Value      = r.RentalEndDate;
            ActualReturnDate.Value   = r.ActualReturnDate;
            BookingDate.Value        = r.BookingDate;
            VehiclePlateNumber.Value = r.VehiclePlateNumber;

            cmInsert.ExecuteNonQuery();
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (RVMUtil.isEmpty(CustomerIDtextBox.Text))
                {
                    MessageBox.Show(RVMMessage.EmptyCustomerID);
                    return;
                }

                if (RVMUtil.isEmpty(OrderIDtextBox.Text))
                {
                    MessageBox.Show(RVMMessage.EmptyOrderID);
                    return;
                }
                VehicleRentalControl mcControl = new VehicleRentalControl();
                RentRecords          r         = new RentRecords();
                r.RecordsID          = OrderIDtextBox.Text;
                r.StaffID            = "S112233D";
                r.CustomerID         = CustomerIDtextBox.Text;
                r.RentalStartDate    = StartDate.Value;
                r.RentalEndDate      = EndDate.Value;
                r.ActualReturnDate   = StartDate.Value;
                r.BookingDate        = StartDate.Value;
                r.VehiclePlateNumber = dataGridView1.CurrentRow.Cells[0].Value.ToString();

                mcControl.CreateRentRecords(r);
                MessageBox.Show(RVMMessage.VehicleRecordSuccessful);
            }
            catch (RVMException dftExcep)
            {
                Console.WriteLine("Exception !!!");
                Console.WriteLine(dftExcep.Message);
                Console.WriteLine(dftExcep.StackTrace);
                MessageBox.Show(dftExcep.Message);
            }
            catch (Exception excep)
            {
                Console.WriteLine("Exception !!!");
                Console.WriteLine(excep.Message);
                Console.WriteLine(excep.StackTrace);
                MessageBox.Show(RVMMessage.GeneralErrorMsg);
            }
        }
Example #3
0
        public void CreateRentRecords(RentRecords r)
        {
            RentRecordsDAO rentRecordsDAO = RentRecordsDAO.getInstance();
            VehicleDAO     vehicleDAO     = VehicleDAO.getInstance();

            try
            {
                rentRecordsDAO.openConnection();
                rentRecordsDAO.InsertRentRecord(r);
                //vehicleDAO.RentOut(r.VehiclePlateNumber);
                return;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                throw;
            }
            finally
            {
                rentRecordsDAO.CloseConnection();
            }
        }