Esempio n. 1
0
        private void returnReturnButton_Click(object sender, EventArgs e)
        {
            int employeeID = loginInformation.getEmployeeID();
            int rentalID   = Convert.ToInt32(this.returnRentalIDComboBox.SelectedItem);

            DataTable data = new DataTable();

            data.Columns.Add("rentalItemID", typeof(int));
            data.Columns.Add("quantityReturned", typeof(int));

            foreach (DataRow row in this.returnInfoTable.Rows)
            {
                int rentalItemID = Convert.ToInt32(row[2]);
                Debug.WriteLine("rentalItemId: " + rentalItemID);

                int quantity = Convert.ToInt32(row[8]);
                Debug.WriteLine("quantity: " + quantity);

                if (quantity > 0)
                {
                    DataRow newRow = data.NewRow();
                    newRow["rentalItemID"] = rentalItemID;
                    Debug.WriteLine("newRow rentalItemId: " + newRow["rentalItemID"]);
                    newRow["quantityReturned"] = quantity;
                    Debug.WriteLine("newRow quantityReturned: " + newRow["quantityReturned"]);

                    data.Rows.Add(newRow);
                }
            }

            DatabaseAccessController dba = new DatabaseAccessController();
            bool   isReturnSuccessful    = dba.InsertReturns(data, employeeID);
            string successReturn         = "Your items were returned.";

            if (!isReturnSuccessful)
            {
                successReturn = "Your return was not successful. Contact Administrator.";
            }

            MessageBox.Show(successReturn, "Return", MessageBoxButtons.OK, MessageBoxIcon.None);
            this.returnInfoTable.Rows.Clear();
            dba.GetRentalInfo(rentalID, returnInfoTable);
        }