Пример #1
0
        //Add button
        private async void toolStripButton1_Click(object sender, EventArgs e)
        {
            ApplicationViewModel applicationViewModel = new ApplicationViewModel();
            await applicationViewModel.GetUsers(loginStart, passwordStart);

            var         user     = applicationViewModel.Users.Where(u => u.login == loginStart).FirstOrDefault();
            AddUserForm userForm = new AddUserForm(user, applicationViewModel.Users, this);

            userForm.Show();
        }
Пример #2
0
        //private async void btnAdd_Click(object sender, EventArgs e)
        //{
        //    User user=new User();
        //    if(txtId.Text !="")
        //    {
        //        user.id = Int32.Parse(txtId.Text);
        //    }
        //    user.login = txtLogin.Text;
        //    user.fullName = txtFullName.Text;
        //    user.roles = Int32.Parse(txtRoles.Text);
        //    user.password = txtPassword.Text;


        //    ApplicationViewModel applicationViewModel = new ApplicationViewModel();
        //    await applicationViewModel.AddUser(loginStart, passwordStart, user);

        //    await applicationViewModel.GetUsers(loginStart, passwordStart);

        //    dataGridView.Rows.Clear();
        //    foreach (var users in applicationViewModel.Users)
        //    {

        //        var rowNumber = dataGridView.Rows.Add();
        //        dataGridView.Rows[rowNumber].Cells["Id"].Value = users.id;
        //        dataGridView.Rows[rowNumber].Cells["login"].Value = users.login;
        //        dataGridView.Rows[rowNumber].Cells["fullName"].Value = users.fullName;
        //        dataGridView.Rows[rowNumber].Cells["roles"].Value = users.roles;
        //        dataGridView.Rows[rowNumber].Cells["password"].Value = users.password;
        //    }

        //}

        private async void dataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            User userForCorrect = new User();

            userForCorrect.id       = Int32.Parse(dataGridView.Rows[e.RowIndex].Cells["Id"].FormattedValue.ToString());
            userForCorrect.login    = dataGridView.Rows[e.RowIndex].Cells["login"].FormattedValue.ToString();
            userForCorrect.password = dataGridView.Rows[e.RowIndex].Cells["fullName"].FormattedValue.ToString();
            userForCorrect.roles    = Int32.Parse(dataGridView.Rows[e.RowIndex].Cells["roles"].FormattedValue.ToString());
            userForCorrect.password = dataGridView.Rows[e.RowIndex].Cells["password"].FormattedValue.ToString();


            ApplicationViewModel applicationViewModel = new ApplicationViewModel();
            await applicationViewModel.GetUsers(loginStart, passwordStart);

            var         user     = applicationViewModel.Users.Where(u => u.login == loginStart).FirstOrDefault();
            AddUserForm userForm = new AddUserForm(user, applicationViewModel.Users, this, userForCorrect);

            userForm.Show();
        }