コード例 #1
0
ファイル: PL_GUI.xaml.cs プロジェクト: tomerkeizler/E-Mart
        private void CallAdd(object sender, RoutedEventArgs e)
        {
            int    catToAdd = int.Parse(((Button)sender).Uid);
            Window addForm  = null;

            switch (catToAdd)
            {
            case 1:
                addForm = new AddEditClubMember(this, true, null);
                break;

            case 2:
                addForm = new AddEditCustomer(null, this, false, true, null);
                break;

            case 3:
                addForm = new AddEditDepartment(this, true, null);
                break;

            case 4:
                if (AreThereDepartments())
                {
                    addForm = new AddEditEmployee(this, cats[3], cats[4], true, null);
                }
                else
                {
                    MessageBox.Show("You cannot add an employee since there are no departments");
                }
                break;

            case 5:
                if (AreThereDepartments())
                {
                    addForm = new AddEditProduct(this, cats[3], true, null);
                }
                else
                {
                    MessageBox.Show("You cannot add a product since there are no departments");
                }
                break;
            }
            if (addForm != null)
            {
                addForm.ShowDialog();
            }
        }
コード例 #2
0
ファイル: PL_GUI.xaml.cs プロジェクト: tomerkeizler/E-Mart
        //////////////////
        // Edit methods //
        //////////////////

        private void CallEdit(object sender, RoutedEventArgs e)
        {
            Object selectedRow = grids[currentCategory].SelectedItem;

            if (selectedRow != null)
            {
                Type   type     = selectedRow.GetType();
                Window editForm = null;
                if (type.Equals(typeof(ClubMember)))
                {
                    editForm = new AddEditClubMember(this, false, selectedRow);
                }
                else if (type.Equals(typeof(Customer)))
                {
                    editForm = new AddEditCustomer(null, this, false, false, selectedRow);
                }
                else if (type.Equals(typeof(Department)))
                {
                    editForm = new AddEditDepartment(this, false, selectedRow);
                }
                else if (type.Equals(typeof(Employee)))
                {
                    editForm = new AddEditEmployee(this, cats[3], cats[4], false, selectedRow);
                }
                else if (type.Equals(typeof(Product)))
                {
                    editForm = new AddEditProduct(this, cats[3], false, selectedRow);
                }
                else if (type.Equals(typeof(Transaction)))
                {
                    editForm = new AddEditTransaction(this, selectedRow);
                }
                else
                {
                    editForm = new AddEditUser(this, selectedRow);
                }
                editForm.ShowDialog();
            }
            else
            {
                MessageBox.Show("You must choose a " + cats[currentCategory].GetEntityName() + " first");
            }
        }
コード例 #3
0
ファイル: View.xaml.cs プロジェクト: tomerkeizler/E-Mart
        private void CallEdit(object sender, RoutedEventArgs e)
        {
            Window editForm = null;

            switch (currentCategory)
            {
            case 1:
                editForm = new AddEditClubMember(parentWindow, false, oldObj);
                break;

            case 2:
                editForm = new AddEditCustomer(null, parentWindow, false, false, oldObj);
                break;

            case 3:
                editForm = new AddEditDepartment(parentWindow, false, oldObj);
                break;

            case 4:
                editForm = new AddEditEmployee(parentWindow, parentWindow.cats[3], parentWindow.cats[4], false, oldObj);
                break;

            case 5:
                editForm = new AddEditProduct(parentWindow, parentWindow.cats[3], false, oldObj);
                break;

            case 6:
                editForm = new AddEditTransaction(parentWindow, oldObj);
                break;

            case 7:
                editForm = new AddEditUser(parentWindow, oldObj);
                break;
            }
            this.Close();
            editForm.ShowDialog();
        }