コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: zinderud/SamArsiv
        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();
            }
        }
コード例 #2
0
        public AddEditDepartament(AddEditViewModel viewModel)
        {
            boxes = new List <TextBox> {
            };
            InitializeComponent();

            viewModel.CreateInterface(this);

            DataContext = viewModel;
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: dangost/PhoneBook
        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();
            }
        }