コード例 #1
0
        // Button 'Edit'
        private void buttonEditFolio_Click(object sender, EventArgs e)
        {
            if (dataGridViewFolio.SelectedRows.Count > 0 && dataGridViewFolio.CurrentRow != null)
            {
                // Set database record ID for reference
                int folioid = Convert.ToInt32(this.dataGridViewFolio.CurrentRow.Cells[0].Value);
                DBGetData.QueryID = folioid;
                Boolean duedate = false;

                MySqlDataReader getFolioDueStatus = DBGetData.GetFolioDueDate(folioid);
                if (getFolioDueStatus.Read())
                {
                    duedate = true;
                }
                getFolioDueStatus.Dispose();
                if (duedate)
                {
                    new StatusMessage("Folio has existing due date, cant make changes.");
                }
                else
                {
                    Form editForm = new EditFolio();
                    editForm.ShowDialog();
                }
            }
        }
コード例 #2
0
        private void buttonSetDuedate_Click(object sender, EventArgs e)
        {
            Boolean duedate         = false;
            Boolean roomreservation = false;
            Boolean hallreservation = false;

            if (dataGridViewFolio.SelectedRows.Count > 0 && dataGridViewFolio.CurrentRow != null)
            {
                int     folioid    = Convert.ToInt32(dataGridViewFolio.CurrentRow.Cells[0].Value);
                string  firstname  = Convert.ToString(dataGridViewFolio.CurrentRow.Cells[1].Value);
                string  lastname   = Convert.ToString(dataGridViewFolio.CurrentRow.Cells[2].Value);
                Decimal foliototal = Convert.ToDecimal(dataGridViewFolio.CurrentRow.Cells[3].Value);

                // Confirm setting due date
                DialogResult confirmDuedate = MessageBox.Show("Setting due date 21 days from today on folio that belongs to " + firstname + " " + lastname +
                                                              " with a total cost of kr " + foliototal +
                                                              "\nAre you sure you want to continue?", "Warning!", MessageBoxButtons.YesNo);

                if (confirmDuedate == DialogResult.Yes)
                {
                    // Checks -> Folio already has due date, Folio has room reservation active, Folio has hall reservation active
                    MySqlDataReader getFolioDueStatus = DBGetData.GetFolioDueDate(folioid);
                    if (getFolioDueStatus.Read())
                    {
                        duedate = true;
                    }
                    getFolioDueStatus.Dispose();
                    if (duedate)
                    {
                        new StatusMessage("Folio already has existing due date.");
                    }

                    if (DBGetData.GetFolioRoomreservation(folioid) > 0)
                    {
                        roomreservation = true;
                    }
                    if (roomreservation)
                    {
                        new StatusMessage("Folio owner has an active room reservation, cannot mark with due date until after checkout.");
                    }

                    if (DBGetData.GetFolioHallreservation(folioid) > 0)
                    {
                        hallreservation = true;
                    }
                    if (hallreservation)
                    {
                        new StatusMessage("Folio owner has an active hall reservation, cannot mark with due date until after checkout.");
                    }

                    if (!duedate && !roomreservation && !hallreservation)
                    {
                        // Save entry to database
                        DBSetData.FolioDueDate(folioid);
                        LoadDataFolio();
                        dataGridViewFolio.Refresh();
                        new StatusMessage("Folio marked with due date 21 days from today.");
                    }
                }
            }
        }