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;
        }
Ejemplo n.º 2
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");
            }
        }