Exemplo n.º 1
0
 public void AddEmployeesToRestaurant(DataTable employeeData)
 {
     foreach (DataRow row in employeeData.Rows)
     {
         Server server = new Server(row["Name"].ToString());
         server.Cash      = (decimal)row["Cash"];
         server.Sales     = (decimal)row["Sales"];
         server.TipOut    = (decimal)row["BWTipout"];
         server.Shift     = row["Shift"].ToString().Trim();
         server.ShiftDate = DateTime.Parse(row["Date"].ToString()).Date;
         restaurant.AddEmployee(server);
     }
 }
Exemplo n.º 2
0
        public void fetchPerson()
        {
            Restaurant r = new Restaurant();
            Person     expectedPerson = r.AddEmployee("Jungeun", "Kim", "0412345678", "*****@*****.**");
            Person     FetchedPerson  = r.FetchPerson(expectedPerson.Id);

            Assert.AreEqual(expectedPerson, FetchedPerson);
        }
Exemplo n.º 3
0
        public void addEmployee()
        {
            string     expectedFirstName = "Jungeun";
            string     expectedLasttName = "Kim";
            string     expectedPhone     = "0412345678";
            string     expectedMail      = "*****@*****.**";
            Restaurant r = new Restaurant();
            Person     e = r.AddEmployee(expectedFirstName, expectedLasttName, expectedPhone, expectedMail);

            Assert.AreEqual(expectedFirstName, e.FirstName);
            Assert.AreEqual(expectedLasttName, e.LastName);
            Assert.AreEqual(expectedPhone, e.ContactNumber);
            Assert.AreEqual(expectedMail, e.Email);
        }
Exemplo n.º 4
0
    protected void btnSend_Click(object sender, EventArgs e)
    {
        lblCash.Text = "";
        decimal dblSales;
        decimal dblResult;
        decimal dblOwed;
        decimal dblBackwait;
        decimal dblTips;
        decimal dblBartips;
        string  firstName;

        firstName  = txtName.Text;
        restaurant = (Restaurant)Session["Restaurant"];
        var regex     = new Regex(@"^[0-9]*(?:\.[0-9]*)?$");
        var cashregex = new Regex(@"^[-+]?[0-9]*(?:\.[0-9]*)?$");

        if (!CheckDate(txtDatePicker.Text))
        {
            return;
        }

        if (regex.IsMatch(txtTips.Text.Replace("$", string.Empty).Replace(",", string.Empty)) == false)
        {
            if (regex.IsMatch(txtTips.Text.Replace("$", string.Empty).Replace(",", string.Empty)) == false)
            {
                lblTipsEdit.Text      = "*Invalid entry.";
                lblTipsEdit.ForeColor = System.Drawing.Color.Red;
            }
        }
        else
        {
            if (txtName.Text == "" || txtSales.Text == "" || txtOwed.Text == "" || txtCharge.Text == "" || txtTips.Text == "" ||
                (txtBarTips.Text == "" && serverSections.Contains(cboOptions.Text)) || (serverSections.Contains(cboOptions.Text) && decimal.Parse(txtTips.Text.Replace("$", string.Empty).Replace(",", string.Empty))
                                                                                        < (decimal.Parse(txtSales.Text.Replace("$", string.Empty).Replace(",", string.Empty)) * (decimal).15)))
            {
                if (txtName.Text == "")
                {
                    lblNameEdit.Text      = "*Required";
                    lblNameEdit.ForeColor = System.Drawing.Color.Red;
                    txtName.BorderStyle   = BorderStyle.Dotted;
                    txtName.BorderColor   = System.Drawing.Color.Red;
                }

                if (txtSales.Text == "")
                {
                    lblSalesEdit.Text      = "*Required.";
                    lblSalesEdit.ForeColor = System.Drawing.Color.Red;
                    txtSales.BorderStyle   = BorderStyle.Dotted;
                    txtSales.BorderColor   = System.Drawing.Color.Red;
                }

                if (txtOwed.Text == "")
                {
                    lblCashEdit.Text      = "*Required.";
                    lblCashEdit.ForeColor = System.Drawing.Color.Red;
                    txtOwed.BorderStyle   = BorderStyle.Dotted;
                    txtOwed.BorderColor   = System.Drawing.Color.Red;
                }

                if (txtCharge.Text == "")
                {
                    lblChargeEdit.Text      = "*Required.";
                    lblChargeEdit.ForeColor = System.Drawing.Color.Red;
                    txtCharge.BorderStyle   = BorderStyle.Dotted;
                    txtCharge.BorderColor   = System.Drawing.Color.Red;
                }

                if (txtTips.Text == "")
                {
                    lblTipsEdit.Text      = "*Required.";
                    lblTipsEdit.ForeColor = System.Drawing.Color.Red;
                    txtTips.BorderStyle   = BorderStyle.Dotted;
                    txtTips.BorderColor   = System.Drawing.Color.Red;
                }

                else if (serverSections.Contains(cboOptions.Text) && decimal.Parse(txtTips.Text.Replace("$", string.Empty).Replace(",", string.Empty)) < (decimal.Parse(txtSales.Text.Replace("$", string.Empty).Replace(",", string.Empty)) * (decimal).15))
                {
                    lblTipsEdit.Text      = "*Must claim a minimum of " + String.Format("{0:C}", decimal.Parse(txtSales.Text) * (decimal).15) + " or 15% of sales.";
                    lblTipsEdit.ForeColor = System.Drawing.Color.Red;
                    txtTips.BorderStyle   = BorderStyle.Dotted;
                    txtTips.BorderColor   = System.Drawing.Color.Red;
                }

                if (txtBarTips.Text == "" && serverSections.Contains(cboOptions.Text))
                {
                    lblBarEdit.Text        = "*Required.";
                    lblBarEdit.ForeColor   = System.Drawing.Color.Red;
                    txtBarTips.BorderStyle = BorderStyle.Dotted;
                    txtBarTips.BorderColor = System.Drawing.Color.Red;
                }
            }
            else
            {
                //verify cash values
                if (checkCashValues())
                {
                    dblTips  = decimal.Parse(txtTips.Text.Replace("$", string.Empty).Replace(",", string.Empty));
                    dblSales = decimal.Parse(txtSales.Text.Replace("$", string.Empty).Replace(",", string.Empty));
                    dblOwed  = decimal.Parse(txtOwed.Text.Replace("$", string.Empty).Replace(",", string.Empty));
                    decimal dblCharge;
                    dblCharge = decimal.Parse(txtCharge.Text.Replace("$", string.Empty).Replace(",", string.Empty));

                    if (!serverSections.Contains(cboShiftOptions.Text) && txtBarTips.Text == "")
                    {
                        dblBartips = 0;
                    }
                    else
                    {
                        dblBartips = decimal.Parse(txtBarTips.Text.Replace("$", string.Empty).Replace(",", string.Empty));
                    }

                    if (!serverSections.Contains(cboOptions.Text))
                    {
                        dblBackwait = 0;
                        dblResult   = dblOwed;
                    }
                    else
                    {
                        dblBackwait = dblSales * (decimal).025;
                        dblResult   = dblSales * (decimal).025 + dblOwed;
                    }

                    Server server = new Server(txtName.Text);
                    server.Section     = cboOptions.Text;
                    server.Sales       = dblSales;
                    server.CashToHouse = dblResult;
                    server.Cash        = dblOwed;
                    server.ChargeTips  = dblCharge;
                    server.BarTipOut   = dblBartips;
                    server.TipOut      = dblBackwait;
                    server.Shift       = cboShiftOptions.Text.Trim();
                    server.Tips        = dblTips;
                    server.ShiftDate   = GetDate();
                    restaurant.AddEmployee(server);
                    insertServerData(server);
                    decimal dinner_result = 0;

                    if (restaurant.LunchBackWaitHours > 0)
                    {
                        decimal result = restaurant.LunchBackWaitHours;
                        updateBackWaitTips(Shift.Lunch.ToString(), result);
                    }

                    if (restaurant.DinnerBackWaitHours > 0)
                    {
                        dinner_result = restaurant.DinnerBackWaitHours;
                        updateBackWaitTips(Shift.Dinner.ToString(), dinner_result);
                    }

                    ServerFormReset();
                    //mpeTipsInput.Hide();
                    ScriptManager.RegisterStartupScript(this, GetType(), "Close", "$('#serverClose').click();", true);
                    this.Page_Load(null, null);
                }
            }
        }
    }