コード例 #1
0
        private void FormComputer_Load(object sender, EventArgs e)
        {
            if (id.HasValue)
            {
                try
                {
                    ChildViewModel view = logic.Read(new ChildBindingModel {
                        Id = id.Value
                    })?[0];

                    if (view != null)
                    {
                        textBoxFIO.Text = view.FIO;
                        textBoxAge.Text = view.Age.ToString();
                        childInterests  = view.ChildInterests;
                        LoadData();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                childInterests = new Dictionary <int, string>();
            }
        }
コード例 #2
0
        public FormGroupChild(ChildLogic childLogic)
        {
            this.childLogic = childLogic;
            InitializeComponent();
            var list = childLogic.Read(null);

            if (list != null)
            {
                comboBoxAddChild.DisplayMember = "FIO";
                comboBoxAddChild.ValueMember   = "Id";
                comboBoxAddChild.DataSource    = list;
                comboBoxAddChild.SelectedItem  = null;
            }
        }
コード例 #3
0
ファイル: FormChildren.cs プロジェクト: KDANext/Camp
 private void LoadData()
 {
     try
     {
         var list = logic.Read(null);
         if (list != null)
         {
             dataGridView.DataSource              = list;
             dataGridView.Columns[0].Visible      = false;
             dataGridView.Columns[1].Visible      = false;
             dataGridView.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
             dataGridView.Columns[4].Visible      = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #4
0
        private void FormGroup_Load(object sender, EventArgs e)
        {
            var counsellorsView = counsellorLogic.Read(null);

            comboBoxCounsellor.DisplayMember = "FIO";
            comboBoxCounsellor.ValueMember   = "Id";
            comboBoxCounsellor.DataSource    = counsellorsView;
            comboBoxCounsellor.SelectedItem  = null;
            if (id.HasValue)
            {
                try
                {
                    GroupViewModel view = logic.Read(new GroupBindingModel
                    {
                        Id = id.Value
                    })?[0];
                    if (view != null)
                    {
                        textBoxName.Text             = view.Name;
                        comboBoxProfile.SelectedItem = view.Profile;
                        if (view.CounsellorId.HasValue)
                        {
                            comboBoxCounsellor.SelectedItem = counsellorsView.First(x => x.Id == view.CounsellorId.Value);
                        }
                        groupChildren = childLogic.Read(new ChildBindingModel {
                            GroupId = id
                        }).ToDictionary(x => x.Id.Value, x => x.FIO);
                        LoadData();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
            else
            {
                groupChildren = new Dictionary <int, string>();
            }
        }