Ejemplo n.º 1
0
        private void usersTable_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 3) //edit
            {
                new AddEditUser((User)usersTable.CurrentRow.Tag).ShowDialog();
                LoadData();
            }
            if (e.ColumnIndex == 4) //delete
            {
                User user = (User)usersTable.CurrentRow.Tag;
                if (MessageBox.Show("Уволить " + user.FullName + "?", "CONFIRM", MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
                {
                    var compille = new MySqlCompiler();

                    var query = new Query("fires").AsInsert(new
                    {
                        user_id    = user.id,
                        status     = 0,
                        updated_at = DateTime.Now
                    });

                    micron.Exec(compille.Compile(query).ToString());
                    LoadData();
                }
            }

            if (e.ColumnIndex == 5) //retraining
            {
                User user = (User)usersTable.CurrentRow.Tag;
                if (MessageBox.Show("Отправить на переквалификацию " + user.FullName + "?", "CONFIRM", MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
                {
                    var compille = new MySqlCompiler();

                    var query = new Query("fires").AsInsert(new
                    {
                        user_id    = user.id,
                        status     = 1,
                        updated_at = DateTime.Now
                    });

                    micron.Exec(compille.Compile(query).ToString());
                    LoadData();
                }
            }
        }
Ejemplo n.º 2
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            if (validateInput())
            {
                var compiller = new MySqlCompiler();


                var query = new Query("users");

                if (_User == null)
                {
                    query = query.AsInsert(new
                    {
                        patronymic      = userPatronymic.Text,
                        secondname      = userSecondname.Text,
                        firstname       = userFirstname.Text,
                        birthday        = userBirthday.Value,
                        role_id         = (userRole.SelectedItem as ComboboxItem).Value.ToString(),
                        placeliving     = userPlaceliving.Text,
                        passport_series = userPassportSeries.Text,
                        passport_number = userPassportNumber.Text,
                        passport_place  = userPassportPlace.Text,
                        email           = userEmail.Text,
                    });
                }
                else
                {
                    query = query.Where("id", _User.id).AsUpdate(new
                    {
                        patronymic      = userPatronymic.Text,
                        secondname      = userSecondname.Text,
                        firstname       = userFirstname.Text,
                        birthday        = userBirthday.Value,
                        role_id         = (userRole.SelectedItem as ComboboxItem).Value.ToString(),
                        placeliving     = userPlaceliving.Text,
                        passport_series = userPassportSeries.Text,
                        passport_number = userPassportNumber.Text,
                        passport_place  = userPassportPlace.Text,
                        email           = userEmail.Text,
                    });
                }

                micron.Exec(compiller.Compile(query).ToString());
            }
        }