Пример #1
0
        public AdminForm()
        {
            InitializeComponent();

            btnEditUser.Enabled = false;

            db      = new TelephoneDirectoryDBContext();
            manager = new MainManager();

            if (db.Users.Count() == 0)
            {
                return;
            }

            manager.DataGridViewUserAdd(dataGridView1, db.Users);

            //int idUser = int.Parse(dataGridView1.CurrentRow.Cells["Id"].Value.ToString());
            int idUser = int.Parse(dataGridView1["Id", 0].Value.ToString());
            IEnumerable <MobilePhone> mobilePhone = db.MobilePhones.Where(m => m.UserId == idUser);

            manager.DataGridViewPhoneAdd(dataGridView2, mobilePhone);

            lblFIO.Text     = dataGridView1["FIO", 0].Value.ToString();
            lblFIOInfo.Text = dataGridView1["FIO", 0].Value.ToString();

            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            dataGridView2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        }
Пример #2
0
        public Form1()
        {
            InitializeComponent();

            manager = new MainManager();
            db      = new TelephoneDirectoryDBContext();

            if (db.Users.Count() == 0)
            {
                return;
            }

            manager.DataGridViewUserAdd(dataGridView1, db.Users);

            labFIO.Text = dataGridView1["FIO", 0].Value.ToString();

            int idUser = int.Parse(dataGridView1["Id", 0].Value.ToString());
            IEnumerable <MobilePhone> mobilePhone = db.MobilePhones.Where(m => m.UserId == idUser);

            manager.DataGridViewPhoneAdd(dataGridView2, mobilePhone);

            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            dataGridView2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        }