Ejemplo n.º 1
0
        private void AddCustomerButton_Click(object sender, EventArgs e)
        {
            try
            {
                // If any of the fields is empty
                if (main.isEmpty(CustomerIDBox.Text) || main.isEmpty(DriversLicenseBox.Text) || main.isEmpty(NameBox.Text) ||
                    main.isEmpty(PhoneNumberBox.Text) || main.isEmpty(AddressBox.Text) || main.isEmpty(CityBox.Text) ||
                    main.isEmpty(ProvinceBox.Text) || main.isEmpty(PostalCodeBox.Text))
                {
                    MessageBox.Show("Please fill in all fields");
                    return;
                }

                string command = "INSERT INTO Customer VALUES('" + CustomerIDBox.Text + "','" + DriversLicenseBox.Text.ToUpper() + "','" + text.ToTitleCase(NameBox.Text) + "','" +
                                 PhoneNumberBox.Text + "','" + text.ToTitleCase(AddressBox.Text) + "','" + text.ToTitleCase(CityBox.Text) + "','" +
                                 text.ToTitleCase(ProvinceBox.Text) + "','" + PostalCodeBox.Text.ToUpper() + "')";

                datab.insert(command);

                main.CustomersDGV_LoadAll(datab);
                this.Close();
            }
            catch (Exception e2)
            {
                //  MessageBox.Show("VIN already exists in the system", "VIN Error");
                MessageBox.Show(e2.ToString(), "Error");
            }
        }
Ejemplo n.º 2
0
        private void SubmitChangesButton_Click(object sender, EventArgs e)
        {
            if (!main.isMakeValid(MakeBox.Text) && MakeBox.Text != "")
            {
                MessageBox.Show(MakeBox.Text + " is not a valid make", "Car Make Error");
                return;
            }

            /* Compare the corresponding input text to the value of the cell selected. If they are different update. If not, dont do anything*/
            try
            {
                // converts the string into something "System.Globalization" can manipulate?
                TextInfo text = CultureInfo.CurrentCulture.TextInfo;

                // Ensure the input text is not empty and different from the original value
                if (VINBox.Text != this.getVINValue() && !main.isEmpty(VINBox.Text))
                {
                    string updateVIN = "UPDATE Car SET VIN = '" + VINBox.Text.ToUpper() + "' WHERE VIN = '" + this.getVINValue() + "'";
                    datab.insert(updateVIN);
                }


                if (MakeBox.Text != this.getMakeValue() && !main.isEmpty(MakeBox.Text))
                {
                    string updateMake = "UPDATE Car SET make = '" + main.ProperMakeFormat(MakeBox) + "' WHERE make = '" + this.getMakeValue() + "' AND VIN ='" + VINBox.Text + "'";
                    datab.insert(updateMake);
                }


                if (ModelBox.Text != this.getModelValue() && !main.isEmpty(ModelBox.Text))
                {
                    string updateModel = "UPDATE Car SET model = '" + text.ToTitleCase(ModelBox.Text) + "' WHERE model = '" + this.getModelValue() + "' AND VIN ='" + VINBox.Text + "'";
                    datab.insert(updateModel);
                }

                if (ColorBox.Text != this.getColorValue() && !main.isEmpty(ColorBox.Text))
                {
                    string updateColor = "UPDATE Car SET color = '" + text.ToTitleCase(ColorBox.Text) + "' WHERE color = '" + this.getColorValue() + "' AND VIN ='" + VINBox.Text + "'";
                    datab.insert(updateColor);
                }

                if (CarTypeDropBox.Text != this.getcTypeValue() && !main.isEmpty(CarTypeDropBox.Text))
                {
                    string updatecType = "UPDATE Car SET cType = '" + main.ProperCarTypeFormat(CarTypeDropBox) + "' WHERE cType = '" + this.getcTypeValue() + "' AND VIN ='" + VINBox.Text + "'";
                    datab.insert(updatecType);
                }
                if (BranchIDDropBox.Text != this.getbIDValue() && !main.isEmpty(BranchIDDropBox.Text))
                {
                    string updatebID = "UPDATE Car SET branchID = '" + BranchIDDropBox.Text + "' WHERE branchID = '" + this.getbIDValue() + "' AND VIN ='" + VINBox.Text + "'";
                    datab.insert(updatebID);
                }

                main.CarsDGV_LoadAll(datab);
                this.Close();
            }
            catch (Exception e2)
            {
                MessageBox.Show(e2.ToString(), "Error");
            }
        }
Ejemplo n.º 3
0
        private void AddCarButton_Click(object sender, EventArgs e)
        {
            // Error message if inputted text is not found in the ModelsList array
            if (!main.isMakeValid(MakeBox.Text) && MakeBox.Text != "")
            {
                MessageBox.Show(text.ToTitleCase(MakeBox.Text) + " is not a valid make", "Car Make Error");
                return;
            }

            try
            {
                // If any of the fields is empty
                if (main.isEmpty(VINBox.Text) || main.isEmpty(MakeBox.Text) || main.isEmpty(ModelBox.Text) ||
                    main.isEmpty(ColorBox.Text) || main.isEmpty(CarTypeDropBox.Text) || main.isEmpty(BranchIDDropBox.Text))
                {
                    MessageBox.Show("Please fill in all fields");
                    return;
                }

                // Proper make format variable
                string Make;

                // if 'bmw', 'gmc', or 'srt' is entered, make them all upper case
                if (MakeBox.Text.ToLower() == "bmw" || MakeBox.Text.ToLower() == "gmc" || MakeBox.Text.ToLower() == "srt")
                {
                    Make = MakeBox.Text.ToUpper();
                }

                else
                {
                    Make = text.ToTitleCase(MakeBox.Text);
                }



                string command = "INSERT INTO Car VALUES('" + VINBox.Text.ToUpper() + "','" + main.ProperMakeFormat(MakeBox) + "','" + text.ToTitleCase(ModelBox.Text) + "','" +
                                 text.ToTitleCase(ColorBox.Text) + "','" + main.ProperCarTypeFormat(CarTypeDropBox) + "'," + BranchIDDropBox.Text + ")";

                datab.insert(command);

                main.CarsDGV_LoadAll(datab);
                this.Close();
            }
            catch (Exception e2)
            {
                //  MessageBox.Show("VIN already exists in the system", "VIN Error");
                MessageBox.Show(e2.ToString(), "Error");
            }
        }
Ejemplo n.º 4
0
        private void AddTransactionButton_Click(object sender, EventArgs e)
        //20190610TAG
        //TODO need to be able to add transaction and still have branchIn and employeeIn boxes empty
        {
            if (TransactionIDBox.Text == "" || main.isEmpty(TransactionIDBox.Text) ||
                CustomerIDDropBox.Text == "" || main.isEmpty(CustomerIDDropBox.Text) ||
                VINDropBox.Text == "" || main.isEmpty(VINDropBox.Text) ||
                OutBranchIDDropBox.Text == "" || main.isEmpty(OutBranchIDDropBox.Text) ||
                //InBranchIDDropBox.Text == ""    || main.isEmpty(InBranchIDDropBox.Text) ||
                OutEmployeeIDDropBox.Text == "" || main.isEmpty(OutEmployeeIDDropBox.Text) ||
                //InEmployeeIDDropBox.Text == ""  || main.isEmpty(InEmployeeIDDropBox.Text) ||
                PaymentInformationBox.Text == "" || main.isEmpty(PaymentInformationBox.Text)) //||
            //TotalBalanceBox.Text == ""      || main.isEmpty(TotalBalanceBox.Text))
            {
                MessageBox.Show("Please ensure all fields are filled", "Empty Field!");
                return;
            }

            if (VINDropBox.Text == "No cars available - try different dates")
            {
                MessageBox.Show("Please change date range to select an available car", "Message");
                return;
            }

            try
            {
                string command = "INSERT INTO RentalTransaction VALUES('" + TransactionIDBox.Text + "', (SELECT cID FROM Customer WHERE name = '" + CustomerIDDropBox.Text + "'),'" + VINDropBox.Text + "','" +
                                 DateOutPicker.Value.ToString("yyyy-MM-dd") + "'," + "NULL" + ",'" + DateExpectedInPicker.Value.ToString("yyyy-MM-dd") +
                                 "', (SELECT branchID FROM Branch WHERE branchName = '" + OutBranchIDDropBox.Text + "'), (SELECT branchID FROM Branch WHERE branchName = '" + InBranchIDDropBox.Text + "')," +
                                 "(SELECT eID FROM Employee WHERE name = '" + OutEmployeeIDDropBox.Text + "'), (SELECT eID FROM Employee WHERE name = '" + InEmployeeIDDropBox.Text + "'),'" +
                                 PaymentInformationBox.Text + "','" + TotalBalanceBox.Text + "')";

                datab.insert(command);

                main.TransactionDGV_LoadAll(datab);
                this.Close();
            }
            catch (Exception e2)
            {
                MessageBox.Show(e2.ToString(), "Error");
            }
        }
Ejemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Check
            if (Check_Input() == 0)
            {
                return;
            }

            string Customer_ID = Convert.ToString(Get_NewCID(localDB));

            //Commit new customer
            string Customer_Name    = (TextFirstName.Text + TextLastName.Text);
            string Customer_License = TextLicenseNum.Text;

            string Customer_address    = TextAddress1.Text;
            string Customer_city       = TextCity.Text;
            string Customer_Province   = ComboProvince.Text;
            string Customer_PostalCode = TextPostalCode.Text;
            string Customer_PhoneNum   = TextPhoneNum.Text;

            string Insert_String = @"insert into Customer values " + "('" + Customer_ID + "','" +
                                   Customer_License + "','" + Customer_Name + "','" + Customer_PhoneNum + "','" +
                                   Customer_address + "','" + Customer_city + "','" + Customer_Province + "','" + Customer_PostalCode + "')";

            localDB.insert(Insert_String);


            //string test = "SELECT cID FROM Customer WHERE cID = " + Customer_ID;

            //localDB.query(test);
            //int custID = localDB.myReader.Read().

            //string MemberStatus_Update = @"INSERT INTO MemberStatus(cID, sinceDate) VALUES
            //                         ((SELECT cID FROM Customer WHERE cID = " + Customer_ID + "), " + DateTime.Now.ToString("yyyy-MM-dd") + ")";

            //localDB.insert(MemberStatus_Update);
            this.Close();
        }
Ejemplo n.º 6
0
        private void EditTransactionButton_Click(object sender, EventArgs e)
        //20190610TAG
        //20190611TAG
        {
            try
            {
                string command = "UPDATE RentalTransaction " +
                                 "SET rID = " + TransactionIDBox.Text + ", " +
                                 "customerID = (SELECT cID FROM Customer WHERE name = '" + CustomerIDDropBox.Text + "'), " +
                                 "carID = '" + VINDropBox.Text + "', " +
                                 "dateOut = '" + DateOutPicker.Value.ToString("yyyy-MM-dd") + "', " +
                                 "dateIn = '" + DateInPicker.Value.ToString("yyyy-MM-dd") + "', " +
                                 "dateExpectedIn = '" + DateExpectedInPicker.Value.ToString("yyyy-MM-dd") + "', " +
                                 "branchOutID = (SELECT branchID FROM Branch WHERE branchName = '" + OutBranchIDDropBox.Text + "'), " +
                                 "branchInID = (SELECT branchID FROM Branch WHERE branchName = '" + InBranchIDDropBox.Text + "'), " +
                                 "employeeOutID = (SELECT eID FROM Employee WHERE name = '" + OutEmployeeIDDropBox.Text + "'), " +
                                 "employeeInID = (SELECT eID FROM Employee WHERE name = '" + InEmployeeIDDropBox.Text + "'), " +
                                 "paymentInformation = '" + PaymentInformationBox.Text + "' " +
                                 //"totalBalance = " + TotalBalanceBox.Text +
                                 "WHERE rID = '" + TransactionIDBox.Text + "';";

                //calculate the regular daily rate
                command = command + "UPDATE RentalTransaction " +
                          "SET totalBalance = (SELECT DATEDIFF(day, dateOut, dateIn)) *dailyRate " +
                          "FROM RentalTransaction " +
                          "JOIN Car ON RentalTransaction.carID = Car.VIN " +
                          "JOIN CarType ON Car.cType = CarType.cType " +
                          "JOIN Customer ON RentalTransaction.customerID = Customer.cID " +
                          "LEFT JOIN MemberStatus on Customer.cID = MemberStatus.cID " +
                          "WHERE rID = '" + TransactionIDBox.Text + "';";
                //
                //calculate the late fee if returned after expected date
                command = command + "UPDATE RentalTransaction " +
                          "SET totalBalance = totalBalance + ((SELECT DATEDIFF(day, dateExpectedIn, dateIn)) *lateDailyRate) " +
                          "FROM RentalTransaction " +
                          "JOIN Car ON RentalTransaction.carID = Car.VIN " +
                          "JOIN CarType ON Car.cType = CarType.cType " +
                          "JOIN Customer ON RentalTransaction.customerID = Customer.cID " +
                          "LEFT JOIN MemberStatus on Customer.cID = MemberStatus.cID " +
                          "WHERE dateIn > dateExpectedIn " +
                          "and rID = '" + TransactionIDBox.Text + "';";
                //
                //apply location penalty if returned at different location and not gold member
                command = command + "UPDATE RentalTransaction " +
                          "SET totalBalance = totalBalance + penaltyRate " +
                          "FROM RentalTransaction " +
                          "JOIN Car ON RentalTransaction.carID = Car.VIN " +
                          "JOIN CarType ON Car.cType = CarType.cType " +
                          "JOIN Customer ON RentalTransaction.customerID = Customer.cID " +
                          "WHERE NOT EXISTS(SELECT * FROM MemberStatus WHERE MemberStatus.cID = Customer.cID) and " +
                          "RentalTransaction.branchInID != RentalTransaction.branchOutID " +
                          "and rID = '" + TransactionIDBox.Text + "';";


                datab.insert(command);

                main.TransactionDGV_LoadAll(datab);
                this.Close();
            }
            catch (Exception e2)
            {
                MessageBox.Show(e2.ToString(), "Error");
            }
        }
Ejemplo n.º 7
0
        private void SubmitChangesButton_Click(object sender, EventArgs e)
        {
            /* Compare the corresponding input text to the value of the cell selected. If they are different update. If not, dont do anything*/
            try
            {
                // converts the string into something "System.Globalization" can manipulate?
                TextInfo text = CultureInfo.CurrentCulture.TextInfo;

                // Ensure the input text is not empty and different from the original value
                if (CustomerIDBox.Text != this.getCustomerIDValue() && !main.isEmpty(CustomerIDBox.Text))
                {
                    string updatecID = "UPDATE Customer SET cID = '" + CustomerIDBox.Text + "' WHERE cID = '" + this.getCustomerIDValue() + "'";
                    datab.insert(updatecID);
                }


                if (DriversLicenseBox.Text != this.getDriverLicenseValue() && !main.isEmpty(DriversLicenseBox.Text))
                {
                    string updateDriversLicense = "UPDATE Customer SET driverLicense = '" + DriversLicenseBox.Text + "' WHERE driverLicense = '" + this.getDriverLicenseValue() + "' AND cID ='" + getCustomerIDValue() + "'";
                    datab.insert(updateDriversLicense);
                }


                if (NameBox.Text != this.getNameValue() && !main.isEmpty(NameBox.Text))
                {
                    string updateName = "UPDATE Customer SET name = '" + NameBox.Text + "' WHERE name = '" + this.getNameValue() + "' AND cID ='" + getCustomerIDValue() + "'";
                    datab.insert(updateName);
                }

                if (PhoneNumberBox.Text != this.getPhoneNumberValue() && !main.isEmpty(PhoneNumberBox.Text))
                {
                    string updatePhoneNumber = "UPDATE Customer SET phoneNumber = '" + PhoneNumberBox.Text + "' WHERE phoneNumber = '" + this.getPhoneNumberValue() + "' AND cID ='" + getCustomerIDValue() + "'";
                    datab.insert(updatePhoneNumber);
                }

                if (AddressBox.Text != this.getAddressValue() && !main.isEmpty(AddressBox.Text))
                {
                    string updateAddress = "UPDATE Customer SET address1 = '" + AddressBox.Text + "' WHERE address1 = '" + this.getAddressValue() + "' AND cID ='" + getCustomerIDValue() + "'";
                    datab.insert(updateAddress);
                }
                if (CityBox.Text != this.getCityValue() && !main.isEmpty(CityBox.Text))
                {
                    string updateCity = "UPDATE Customer SET city = '" + CityBox.Text + "' WHERE city = '" + this.getCityValue() + "' AND cID ='" + getCustomerIDValue() + "'";
                    datab.insert(updateCity);
                }

                if (ProvinceBox.Text != this.getProvinceValue() && !main.isEmpty(ProvinceBox.Text))
                {
                    string updateProvince = "UPDATE Customer SET province = '" + ProvinceBox.Text + "' WHERE province = '" + this.getProvinceValue() + "' AND cID ='" + getCustomerIDValue() + "'";
                    datab.insert(updateProvince);
                }
                if (PostalCodeBox.Text != this.getPostalCodeValue() && !main.isEmpty(PostalCodeBox.Text))
                {
                    string updatePostalCode = "UPDATE Customer SET postCode = '" + PostalCodeBox.Text + "' WHERE postCode = '" + this.getPostalCodeValue() + "' AND cID ='" + getCustomerIDValue() + "'";
                    datab.insert(updatePostalCode);
                }

                main.CustomersDGV_LoadAll(datab);
                this.Close();
            }
            catch (Exception e2)
            {
                MessageBox.Show(e2.ToString(), "Error");
            }
        }