예제 #1
0
        public void EquipmentSelected_Click(object sender, ListViewCommandEventArgs e)
        {
            int equipmentID = int.Parse(e.CommandArgument.ToString());

            int employeeID = int.Parse(EmployeeID.Text);
            int customerID = int.Parse(CustomerID.Text);
            int rentalID   = int.Parse(RentalID.Text);

            if (employeeID == 0 || customerID == 0)
            {
                MessageUserControl.ShowInfo("No Customer Selected", "Please select a customer before adding equipment to be rented");
            }
            else
            {
                MessageUserControl.TryRun(() =>
                {
                    RentalController rentalcontroller = new RentalController();
                    if (rentalID == 0)
                    {
                        rentalID = rentalcontroller.Create_Rental(employeeID, customerID, int.Parse(RentalID.Text));
                    }
                    rentalcontroller.Create_RentalDetails(rentalID, equipmentID);
                    List <RentalEquipmentInfo> renting = rentalcontroller.List_RentingEquipment(int.Parse(RentalID.Text));

                    EquipmentBeingRentedListview.DataSource = renting;
                    EquipmentBeingRentedListview.DataBind();
                }, "Equipment Info Added", "Added Equipment to rental");

                RentalID.Text = rentalID.ToString();
            }
        }