Exemplo n.º 1
0
        private void listBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            string selIterm = (string)listBox.SelectedItem;

            for (int i = 0; i < max; i++)
            {
                if (salesman[i] != null)
                {
                    if (selIterm == salesman[i].getFname() + " " + salesman[i].getLname())
                    {
                        Saleman edit = null;
                        if (edit == null)
                        {
                            edit = new Saleman(salesman[i].getFname(), salesman[i].getLname(), salesman[i].getStNum(), salesman[i].getStreet(), salesman[i].getSurb(), salesman[i].getCode(), salesman[i].getState(), salesman[i].getPhone(), salesman[i].getMail(), salesman[i].getSales());
                            edit.editSalesman("Edit Salesman");
                            edit.disableStateInput();
                            if (edit.ShowDialog() == DialogResult.OK)
                            {
                                salesman[i].setSalesman(edit.getFname(), edit.getLname(), edit.getStNum(), edit.getStreet(), edit.getSurb(), edit.getCode(), edit.getState(), edit.getPhone(), edit.getMail(), edit.getSales());
                                tsLabel.Text = "Team Total Sales $" + calTeamSales().ToString();
                            }
                        }
                    }
                }
            }
        }
        private void edit_Click(object sender, EventArgs e)
        {
            Object name;

            while (checkedListBox.CheckedItems.Count > 0)
            {
                name = checkedListBox.CheckedItems[0];
                char[]   sep   = new char[] { ' ' };         // separator character
                string[] parts = name.ToString().Split(sep); // remove spaces

                for (int i = 0; i < total; i++)
                {
                    if (salesmen[i] != null)
                    {
                        if (salesmen[i].getFname().Equals(parts[0]) && salesmen[i].getLname().Equals(parts[1]))
                        {
                            Saleman edit = null;
                            if (edit == null)
                            {
                                edit = new Saleman(salesmen[i].getFname(), salesmen[i].getLname(), salesmen[i].getStNum(), salesmen[i].getStreet(), salesmen[i].getSurb(), salesmen[i].getCode(), salesmen[i].getState(), salesmen[i].getPhone(), salesmen[i].getMail(), salesmen[i].getSales());
                                edit.editSalesman("Edit Salesman");
                                if (edit.ShowDialog() == DialogResult.OK)
                                {
                                    salesmen[i].setSalesman(edit.getFname(), edit.getLname(), edit.getStNum(), edit.getStreet(), edit.getSurb(), edit.getCode(), edit.getState(), edit.getPhone(), edit.getMail(), edit.getSales());
                                }
                            }
                        }
                    }
                }
                checkedListBox.Items.Remove(name);
            }
            ListSalesman_Click(new Object(), EventArgs.Empty);
        }
Exemplo n.º 3
0
        private void addSalesman_Click(object sender, EventArgs e)
        {
            Saleman newSaleman = new Saleman();

            newSaleman.setArea(location);
            newSaleman.disableStateInput();
            newSaleman.editSalesman("Add Salesman");
            if (newSaleman.ShowDialog() == DialogResult.OK)
            {
                if (newSaleman.getFname().Length != 0 && newSaleman.getLname().Length != 0)
                {
                    salesman[itr] = new Saleman(newSaleman.getFname(), newSaleman.getLname(), newSaleman.getStNum(), newSaleman.getStreet(), newSaleman.getSurb(), newSaleman.getCode(), newSaleman.getState(), newSaleman.getPhone(), newSaleman.getMail(), newSaleman.getSales());
                    itr++;
                    tsLabel.Text = "Team Total Sales $" + calTeamSales().ToString();
                }
            }
        }
Exemplo n.º 4
0
        // deletes selected sales man
        private void delete_Click(object sender, EventArgs e)
        {
            string [] selected = new string[1000];
            string [] names    = getNames();
            Selection delet    = new Selection("Select Salesman to Delete", names);

            if (delet.ShowDialog() == DialogResult.OK)
            {
                selected = delet.getSelected();
                for (int i = 0; i <= count; i++)
                {
                    if (salesman[i] != null)
                    {
                        string SName = salesman[i].getFname() + " " + salesman[i].getLname();
                        for (int x = 0; x < selected.Length; x++)
                        {
                            if (selected[x] != null)
                            {
                                if (SName.Equals(selected[x]))
                                {
                                    Saleman del = null;
                                    if (del == null)
                                    {
                                        del = new Saleman(salesman[i].getFname(), salesman[i].getLname(), salesman[i].getStNum(), salesman[i].getStreet(), salesman[i].getSurb(), salesman[i].getCode(), salesman[i].getState(), salesman[i].getPhone(), salesman[i].getMail(), salesman[i].getSales());
                                        del.editSalesman(true);
                                        if (del.ShowDialog() == DialogResult.OK)
                                        {
                                            if (del.Deleted())
                                            {
                                                if (count > -1)
                                                {
                                                    salesman[i] = null;
                                                    count--;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }