コード例 #1
0
        private void mnuUnregisterRestaurant_Click(object sender, EventArgs e)
        {
            DialogResult button =
                MessageBox.Show(
                    "Are you sure you want to delete the entire restaurant layout?",
                    "Confirm Layout Delete",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question,
                    MessageBoxDefaultButton.Button2);

            if (button == DialogResult.Yes)
            {
                ReservationDA.DeleteAllReservations();
                TableDA.DeleteAllTables();
                BarSeatDA.DeleteAllBarSeats();
                BarTableDA.DeleteBarTable();
                ServerDA.DeleteAllServers();
                RestaurantDA.DeleteRestaurant();

                NoCurrentRestaurant();

                if (mnuRegisterRestaurant.Enabled == false)
                {
                    mnuRegisterRestaurant.Enabled = true;
                }

                MessageBox.Show("Restaurant has been unregistered!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #2
0
        private void ViewCompanyInfo()
        {
            Restaurant oRestaurant = RestaurantDA.GetRestaurantInfo();

            lblCompanyName.Text = oRestaurant.RestaurantName;
            lblAddress.Text     = oRestaurant.Address;
            lblCity.Text        = oRestaurant.City;
            lblState.Text       = oRestaurant.State;
            lblZip.Text         = oRestaurant.Zip;
        }
コード例 #3
0
        public frmMain()
        {
            InitializeComponent();
            //SectionDA.AddStaticSections();
            //RestaurantDA.DeleteRestaurant();
            //SectionDA.DeleteSectionAssignments();
            //DeleteSectionAssignments();
            Restaurant oRestaurant = RestaurantDA.GetRestaurantInfo();

            if (oRestaurant.RestaurantID != 0)
            {
                //restaurant has been set
                CurrentRestaurant();
                mnuAbout.Text = "About " + oRestaurant.RestaurantName;
            }
            else
            {
                //if you want to force a delete of restraunt call RestaurantDA.DeleteRestaurant();
                //restaurant hasnt been set
                NoCurrentRestaurant();
            }
        }
コード例 #4
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            string     sRestaurantName = txtRName.Text.Trim();
            string     sAddress        = txtAddress.Text.Trim();
            string     sCity           = txtCity.Text.Trim();
            string     sState          = txtState.Text.Trim();
            string     sZip            = txtZip.Text.Trim();
            string     sErrorMess      = "";
            Restaurant oRestaurant     = new Restaurant();
            bool       bIsValid        = true;


            if (String.IsNullOrEmpty(sRestaurantName))
            {
                bIsValid    = false;
                sErrorMess += "Please enter a Restaurant Name";
            }
            if (String.IsNullOrEmpty(sAddress))
            {
                bIsValid    = false;
                sErrorMess += "\nPlease enter an address";
            }
            if (String.IsNullOrEmpty(sCity))
            {
                bIsValid    = false;
                sErrorMess += "\nPlease enter a city";
            }
            if (String.IsNullOrEmpty(sState))
            {
                bIsValid    = false;
                sErrorMess += "\nPlease enter a state";
            }
            if (String.IsNullOrEmpty(sZip))
            {
                bIsValid    = false;
                sErrorMess += "\nPlease enter a zip code";
            }

            //valid input
            if (bIsValid)
            {
                //add Restaurant to database
                oRestaurant.RestaurantName = sRestaurantName;
                oRestaurant.Address        = sAddress;
                oRestaurant.City           = sCity;
                oRestaurant.State          = sState;
                oRestaurant.Zip            = sZip;

                //db logic here to insert into database
                RestaurantDA.AddRestaurant(oRestaurant);
                //Success
                MessageBox.Show(oRestaurant.RestaurantName + " Has been Added!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);

                //Deletes Table Layout because new restaurant
                //TableDA.DeleteAllTables();
                //Possibly try to find another way to refresh the main form to re run the code to check if restraunt is initialized
                Application.Restart();
            }
            else
            {
                MessageBox.Show(sErrorMess, "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }