Ejemplo n.º 1
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;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }