Exemplo n.º 1
0
        void IMainView.ShowAddEditDialog(ViewModel viewModel, AddEditViewModel addEditView)
        {
            selectedContact = addEditView.selectedContact;

            selectedContactModel = addEditView.selectedContactModel;

            if (viewModel.Form == "add")
            {
                AddEditDialog addDialog = new AddEditDialog(addEditView);
                addDialog.Title          = "Create";
                addDialog.button.Content = "Create";


                addDialog.ShowDialog();
            }



            else if (viewModel.Form == "edit")
            {
                AddEditDialog editDialog = new AddEditDialog(addEditView);
                editDialog.Title          = "Edit";
                editDialog.button.Content = "Save";

                editDialog.textBoxName.Text    = selectedContactModel.D_no;
                editDialog.textBoxSurname.Text = selectedContactModel.S_no;
                editDialog.textBoxNumber.Text  = selectedContactModel.Ad_soyad;
                editDialog.textBoxEmail.Text   = selectedContactModel.Tc;
                editDialog.button.IsEnabled    = false;



                editDialog.ShowDialog();
            }
        }
Exemplo n.º 2
0
        void IMainView.ShowAddEditDialog(ViewModel viewModel, AddEditViewModel addEditView)
        {
            selectedContact      = addEditView.selectedContact;
            selectedDepartment   = addEditView.selectedDepartment;
            selectedContactModel = addEditView.selectedContactModel;

            if (viewModel.Form == "add")
            {
                AddEditDialog addDialog = new AddEditDialog(addEditView);
                addDialog.Title          = "Create";
                addDialog.button.Content = "Create";

                List <string> depsNames = new List <string> {
                };

                foreach (var d in viewModel.PhoneBook.GetAllDepartments())
                {
                    depsNames.Add(d.Department);
                }
                addDialog.comboBoxDepartment.ItemsSource = depsNames;
                addDialog.ShowDialog();
            }

            else if (viewModel.Form == "addDep")
            {
                AddEditDepartament addDepDialog = new AddEditDepartament(addEditView);
                addDepDialog.Title          = "Create";
                addDepDialog.button.Content = "Create";


                addDepDialog.ShowDialog();
            }

            else if (viewModel.Form == "edit")
            {
                AddEditDialog editDialog = new AddEditDialog(addEditView);
                editDialog.Title          = "Edit";
                editDialog.button.Content = "Save";

                editDialog.textBoxName.Text    = selectedContactModel.Name;
                editDialog.textBoxSurname.Text = selectedContactModel.Surname;
                editDialog.textBoxNumber.Text  = selectedContactModel.Number;
                editDialog.textBoxEmail.Text   = selectedContactModel.Email;
                editDialog.button.IsEnabled    = false;

                List <string> depsNames = new List <string> {
                };

                foreach (var d in viewModel.PhoneBook.GetAllDepartments())
                {
                    depsNames.Add(d.Department);
                }
                editDialog.comboBoxDepartment.ItemsSource = depsNames;

                editDialog.comboBoxDepartment.Text = selectedContactModel.Department;

                /*
                 * foreach (var d in viewModel.PhoneBook.GetAllDepartments())
                 * {
                 *  if(selectedContact.DepId == d.Id)
                 *  {
                 *      editDialog.comboBoxDepartment.Text = d.Name;
                 *      break;
                 *  }
                 * }*/

                editDialog.ShowDialog();
            }

            else if (viewModel.Form == "editDep")
            {
                AddEditDepartament editDepDialog = new AddEditDepartament(addEditView);
                editDepDialog.Title          = "Edit";
                editDepDialog.button.Content = "Save";

                editDepDialog.textBoxName.Text = selectedDepartment.Department;

                editDepDialog.ShowDialog();
            }
        }