コード例 #1
0
        private void btnBarB_Click(object sender, EventArgs e)
        {
            var dialog = MessageBox.Show("You will empty the checkout list \nAre you sure??", @"Warning!!!", MessageBoxButtons.YesNo);

            if (dialog == DialogResult.Yes)
            {
                var b = new Bartender(_plan);
                _plan.Controls.Remove(this);
                _plan.Controls.Add(b);
                ((Button)b.Controls["btnOrder"]).Text = @"Bar Order";
                ((Label)b.Controls["lbName"]).Text    = lbName.Text;
                ((Label)b.Controls["lbTitle"]).Text   = @"Bartender";
                ((Button)b.Controls["btnS"]).Text     = @"Bartender Schedule";
                ((Label)b.Controls["lbID"]).Text      = lbID.Text;
            }
        }
コード例 #2
0
        private void btnBack_Click(object sender, EventArgs e)
        {
            Chef      chef = new Chef(plan);
            Bartender bar  = new Bartender(plan);

            plan.Controls.Remove(this);
            if (lbS.Text == "Gift Cashier Schedule")
            {
                ((Button)bar.Controls["btnOrder"]).Text = "Gift Order";
                ((Button)bar.Controls["btnS"]).Text     = lbS.Text;
                ((Label)bar.Controls["lbTitle"]).Text   = "Gift Cashier";
                plan.Controls.Add(bar);
            }
            if (lbS.Text == "Bartender Schedule")
            {
                ((Button)bar.Controls["btnOrder"]).Text = "Bar Order";
                ((Button)bar.Controls["btnS"]).Text     = lbS.Text;
                ((Label)bar.Controls["lbTitle"]).Text   = "Bartender";
                plan.Controls.Add(bar);
            }
            if (lbS.Text == "Chef Schedule")
            {
                ((Button)chef.Controls["btnS"]).Text   = lbS.Text;
                ((Label)chef.Controls["lbTitle"]).Text = "Chef";
                plan.Controls.Add(chef);
            }
            if (lbS.Text == "Server Schedule")
            {
                ((Button)chef.Controls["btnS"]).Text   = lbS.Text;
                ((Label)chef.Controls["lbTitle"]).Text = "Server";
                plan.Controls.Add(chef);
            }
            if (lbS.Text == "Cleaner Schedule")
            {
                ((Button)chef.Controls["btnS"]).Text   = lbS.Text;
                ((Label)chef.Controls["lbTitle"]).Text = "Cleaner";
                plan.Controls.Add(chef);
            }
            ((Label)bar.Controls["lbName"]).Text  = lbName.Text;
            ((Label)chef.Controls["lbName"]).Text = lbName.Text;
            ((Label)bar.Controls["lbID"]).Text    = lbID.Text;
            ((Label)chef.Controls["lbID"]).Text   = lbID.Text;
        }
コード例 #3
0
        private void btnGSBack_Click(object sender, EventArgs e)
        {
            DialogResult dialog = MessageBox.Show("You will empty the checkout list \nAre you sure??", "Warning!!!", MessageBoxButtons.YesNo);

            if (dialog == DialogResult.Yes)
            {
                Bartender b = new Bartender(plan);
                plan.Controls.Remove(this);
                plan.Controls.Add(b);
                ((Button)b.Controls["btnOrder"]).Text = "Gift Order";
                ((Label)b.Controls["lbName"]).Text    = lbName.Text;
                ((Label)b.Controls["lbTitle"]).Text   = "Gift Cashier";
                ((Button)b.Controls["btnS"]).Text     = "Gift Cashier Schedule";
                ((Label)b.Controls["lbID"]).Text      = lbID.Text;
            }
            else
            {
                return;
            }
        }
コード例 #4
0
        private void btnGSCheck_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtRoom.Text) || cbShip.SelectedItem == null || cbCruise.SelectedItem == null || listViewCheck.Items.Count == 0)
            {
                if (String.Compare(txtRoom.Text.TrimStart(), "630") > 0 || String.Compare(txtRoom.Text.TrimStart(), "101") < 0)
                {
                    lbWarning.Text = "Please choose a valid room!!";
                }
                else
                {
                    lbWarning.Text = "Ship_id, Cuise_id, Room and Order cannot be empty!!";
                }
            }

            else
            {
                lbWarning.Text = "";
                DialogResult dialog = MessageBox.Show("Checkout \nDo you want to continue??", "Message", MessageBoxButtons.YesNo);
                if (dialog == DialogResult.Yes)
                {
                    string query = "SELECT max(Purchase_Number) as number FROM Purchases";

                    if (connection != null)
                    {
                        connection.Open();
                        setupSqlCommand(query);
                        MySqlDataReader dataReader = cmd.ExecuteReader();
                        double          PN         = 0;
                        while (dataReader.Read())
                        {
                            PN = Double.Parse(dataReader["number"].ToString()) + 1;
                        }
                        dataReader.Close();
                        string shipid      = cbShip.Text;
                        string cruiseid    = cbCruise.Text;
                        string roomnum     = txtRoom.Text.TrimStart();
                        string facility    = "1";
                        string purchaseNum = PN.ToString();

                        query = "INSERT INTO `Purchases`(`Room_Num`, `Purchase_Date`, `Purchase_Time`, `Facility_ID`, `Purchase_Number`, `TotalCost`, `Ship_ID`,`Cruise_ID`)"
                                + " VALUES ('" + roomnum + "','" + DateTime.Now.ToString("yyyy-MM-dd")
                                + "','" + DateTime.Now.ToString("HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo) + "','"
                                + facility + "','"
                                + purchaseNum + "','"
                                + result.Text.Substring(result.Text.LastIndexOf("$") + 1) + "','"
                                + shipid + "','"
                                + cruiseid + "')";
                        int v = 0;
                        setupSqlCommand(query);
                        v = cmd.ExecuteNonQuery();
                        connection.Close();
                        Bartender b = new Bartender(plan);
                        plan.Controls.Remove(this);
                        plan.Controls.Add(b);
                        ((Button)b.Controls["btnOrder"]).Text = "Gift Order";
                        ((Label)b.Controls["lbName"]).Text    = lbName.Text;
                        ((Label)b.Controls["lbTitle"]).Text   = "Giftshop Cashier";
                        ((Button)b.Controls["btnS"]).Text     = "Gift Cashier Schedule";
                        ((Label)b.Controls["lbID"]).Text      = lbID.Text;
                    }
                    else
                    {
                        connection.Close(); MessageBox.Show("Try to reconnect database server");
                    }
                }
                else
                {
                    return;
                }
            }
        }
コード例 #5
0
        private void btnGSCheck_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtRoom.Text) || cbShip.SelectedItem == null || cbCruise.SelectedItem == null || listView1.Items.Count == 0)
            {
                if (string.CompareOrdinal(txtRoom.Text.TrimStart(), "630") > 0 || string.CompareOrdinal(txtRoom.Text.TrimStart(), "101") < 0)
                {
                    lbWarning.Text = @"Please choose a valid room!!";
                }
                else
                {
                    lbWarning.Text = @"Ship_id, Cuise_id, Room and Order cannot be empty!!";
                }
            }

            else
            {
                lbWarning.Text = "";
                var dialog = MessageBox.Show(@"Checkout" + Environment.NewLine + @"Do you want to continue??", @"CheckOut", MessageBoxButtons.YesNo);
                if (dialog == DialogResult.Yes)
                {
                    var query = "SELECT max(Purchase_Number) as number FROM Purchases";

                    if (_connection != null)
                    {
                        _connection.Open();
                        SetupSqlCommand(query);
                        var    dataReader = _cmd.ExecuteReader();
                        double pn         = 0;
                        while (dataReader.Read())
                        {
                            pn = double.Parse(dataReader["number"].ToString()) + 1;
                        }
                        dataReader.Close();
                        var          shipid      = cbShip.Text;
                        var          cruiseid    = cbCruise.Text;
                        var          roomnum     = txtRoom.Text.TrimStart();
                        const string facility    = "2";
                        var          purchaseNum = pn.ToString(CultureInfo.CurrentCulture);

                        query = "INSERT INTO `Purchases`(`Room_Num`, `Purchase_Date`, `Purchase_Time`, `Facility_ID`, `Purchase_Number`, `TotalCost`, `Ship_ID`,`Cruise_ID`)"
                                + " VALUES ('" + roomnum + "','" + DateTime.Now.ToString("yyyy-MM-dd")
                                + "','" + DateTime.Now.ToString("HH:mm:ss", DateTimeFormatInfo.InvariantInfo) + "','"
                                + facility + "','"
                                + purchaseNum + "','"
                                + result.Text.Substring(result.Text.LastIndexOf("$", StringComparison.Ordinal) + 1) + "','"
                                + shipid + "','"
                                + cruiseid + "')";
                        SetupSqlCommand(query);
                        _cmd.ExecuteNonQuery();
                        _connection.Close();
                        var b = new Bartender(_plan);
                        _plan.Controls.Remove(this);
                        _plan.Controls.Add(b);
                        ((Button)b.Controls["btnOrder"]).Text = @"Bar Order";
                        ((Label)b.Controls["lbName"]).Text    = lbName.Text;
                        ((Label)b.Controls["lbTitle"]).Text   = @"Bartender";
                        ((Button)b.Controls["btnS"]).Text     = @"Bartender Schedule";
                        ((Label)b.Controls["lbID"]).Text      = lbID.Text;
                    }
                    else
                    {
                        _connection?.Close();
                        MessageBox.Show(@"Try to reconnect database server");
                    }
                }
            }
        }
コード例 #6
0
        private void btnEmLog_Click(object sender, EventArgs e)
        {
            var uid      = txtEmId.Text;
            var password = txtEmPW.Text;
            var query    = "SELECT Staff_ID,Password,Position_Name,First_Name,Last_Name FROM Staff,Positions WHERE Staff_ID = '" + uid
                           + "' AND Password = '******' AND Positions.Position_ID = Staff.Position_ID";

            var chef = new Chef(_plan);
            var bar  = new Bartender(_plan);

            if (_connection != null)
            {
                _connection.Open();
                SetupSqlCommand(query);
                var dataReader = _cmd.ExecuteReader();
                if (dataReader.HasRows)
                {
                    var em = new Employee();
                    while (dataReader.Read())
                    {
                        em.EmID         = dataReader["Staff_ID"].ToString();
                        em.Password     = dataReader["Password"].ToString();
                        em.PositionName = dataReader["Position_Name"].ToString();
                        em.FName        = dataReader["First_Name"].ToString();
                        em.LName        = dataReader["Last_Name"].ToString();
                        //     employees.Add(em);
                    }

                    //   Chef chef = new Chef(plan);
                    if ((em.PositionName == "Server") || (em.PositionName == "Chef") || (em.PositionName == "Cleaner"))
                    {
                        if (em.PositionName == "Cleaner")
                        {
                            ((Button)chef.Controls["btnS"]).Text = @"Cleaner Schedule";
                        }
                        if (em.PositionName == "Server")
                        {
                            ((Button)chef.Controls["btnS"]).Text = @"Server Schedule";
                        }
                        if (em.PositionName == "Chef")
                        {
                            ((Button)chef.Controls["btnS"]).Text = @"Chef Schedule";
                        }
                        ((Label)chef.Controls["lbTitle"]).Text = em.PositionName;
                        ((Label)chef.Controls["lbName"]).Text  = em.FName + @" " + em.LName;
                        ((Label)chef.Controls["lbID"]).Text    = em.EmID;
                        _plan.Controls.Add(chef);
                        _plan.Controls.Remove(this);
                    }
                    else
                    {
                        if (em.PositionName == "Cashier")
                        {
                            ((Button)bar.Controls["btnOrder"]).Text = @"Gift Order";
                            ((Button)bar.Controls["btnS"]).Text     = @"Gift Cashier Schedule";
                            ((Label)bar.Controls["lbTitle"]).Text   = @"Gift " + em.PositionName;
                        }
                        if (em.PositionName == "Bartender")
                        {
                            ((Button)bar.Controls["btnOrder"]).Text = @"Bar Order";
                            ((Button)bar.Controls["btnS"]).Text     = @"Bartender Schedule";
                            ((Label)bar.Controls["lbTitle"]).Text   = em.PositionName;
                        }
                        ((Label)bar.Controls["lbName"]).Text = em.FName + @" " + em.LName;
                        ((Label)bar.Controls["lbID"]).Text   = em.EmID;
                        _plan.Controls.Add(bar);
                        _plan.Controls.Remove(this);
                    }

                    dataReader.Close();
                }

                else
                {
                    MessageBox.Show(@"Invalid username/password, please try again");
                }

                _connection.Close();
            }

            else
            {
                _connection?.Close();
                MessageBox.Show(@"Try to reconnect database server");
            }
        }