private void dataGrid_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) { if (dataGrid.CurrentCell.Value.ToString().Length > 0) { selected_id = long.Parse(dataGrid.CurrentCell.Value.ToString()); btnEdit.Visible = true; btnDelete.Visible = true; btnAddDeposit.Visible = true; } else { selected_id = -1; operationMode = DataOperationMode.none; btnEdit.Visible = false; btnDelete.Visible = false; btnAddDeposit.Visible = false; } } else { selected_id = -1; operationMode = DataOperationMode.none; btnEdit.Visible = false; btnDelete.Visible = false; btnAddDeposit.Visible = false; } }
private void dataGrid_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) { if (dataGrid.CurrentCell.Value.ToString().Length > 0) { selected_id = long.Parse(dataGrid.CurrentCell.Value.ToString()); btnEdit.Visible = true; btnDelete.Visible = true; } else { selected_id = -1; operationMode = DataOperationMode.none; btnDelete.Visible = false; btnEdit.Visible = false; } } else { selected_id = -1; operationMode = DataOperationMode.none; btnDelete.Visible = false; btnEdit.Visible = false; } }
private void btnAdd_Click(object sender, EventArgs e) { clear_data_detail(); dataOperationMode = DataOperationMode.add; groupBoxEdit.Enabled = true; groupBoxEdit.Text = "Manage Tarif [Add]"; btnSave.Enabled = true; }
private void btnEdit_Click(object sender, EventArgs e) { dataOperationMode = DataOperationMode.edit; btnSave.Enabled = true; groupBoxEdit.Enabled = true; groupBoxEdit.Text = "Manage Tarif [Edit]"; show_data_detail(); }
private void btnAdd_Click(object sender, EventArgs e) { clear_field_data(); selected_id = -1; groupBox1.Enabled = true; groupBox1.Text = "Manage User [Add]"; operationMode = DataOperationMode.add; txtUsername.Enabled = true; }
private void btnEdit_Click(object sender, EventArgs e) { operationMode = DataOperationMode.edit; groupManage.Enabled = true; groupManage.Text = "Manage Member [Edit]"; label10.Visible = true; txtLastDeposit.Visible = true; FillDataDetail(selected_id); }
private void btnAdd_Click(object sender, EventArgs e) { operationMode = DataOperationMode.add; groupManage.Enabled = true; groupManage.Text = "Manage Member [Add]"; label10.Visible = false; txtLastDeposit.Visible = false; ClearDataDetail(); txtRFID.Focus(); }
private void clear_data_detail() { txtName.Clear(); txtInitialPrice.Clear(); txtExtendedPrice.Clear(); cbPriceGroups.SelectedItem = null; selected_id = -1; selected_group_id = -1; selected_group_name = ""; dataOperationMode = DataOperationMode.none; }
private void btnDelete_Click(object sender, EventArgs e) { groupManage.Text = "Manage Member [Delete]"; if (MessageBox.Show(this, "Yakin untuk menghapus data member ini ?", "Konfirmasi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { operationMode = DataOperationMode.delete; MySqlConnection conn = new MySqlConnection( AppConfig.Instance.ConnectionString); MySqlCommand cmd = new MySqlCommand( "delete from members where id = " + selected_id, conn); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); RefreshGrid(); } }
private void UserData(DataOperationMode mode) { if (mode == DataOperationMode.INSERT) { user.Password = txtPassword.Text; } if (mode == DataOperationMode.UPDATE || mode == DataOperationMode.DELETE) { // User Id only in case of update and we get it from selected row/cell in datagridview user.UserId = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString()); } if (mode == DataOperationMode.INSERT || mode == DataOperationMode.UPDATE) { user.UserName = txtUserName.Text; user.Role = txtRole.Text; user.RoleDescription = txtRoleDescription.Text; } }
private void btnDelete_Click(object sender, EventArgs e) { string sql = ""; MySqlConnection conn; MySqlCommand cmn; show_data_detail(); groupBoxEdit.Enabled = true; groupBoxEdit.Text = "Manage Tarif [Hapus]"; dataOperationMode = DataOperationMode.delete; //TODO add confirm dialog if (MessageBox.Show(this, "Yakin untuk menghapus data ini ?", "Konfirmasi", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { sql = "delete from tarifs where id = " + selected_id; conn = new MySqlConnection(AppConfig.Instance.ConnectionString); cmn = new MySqlCommand(sql, conn); conn.Open(); cmn.ExecuteNonQuery(); conn.Close(); RefreshGridData(); } }
private void btnEdit_Click(object sender, EventArgs e) { groupBox1.Enabled = true; groupBox1.Text = "Manage User [Edit]"; string sql = "select u.id as id, u.username as name, u.password as password " + ", r.role_name as role_name from users u, roles r where u.id = " + selected_id + " and u.role_id = r.id"; MySqlConnection conn = new MySqlConnection(AppConfig.Instance.ConnectionString); MySqlCommand cmd = new MySqlCommand(sql, conn); conn.Open(); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { txtUsername.Text = reader.GetString("name"); txtPassword.Text = reader.GetString("password"); cmbRole.SelectedItem = reader.GetString("role_name"); } reader.Close(); conn.Close(); operationMode = DataOperationMode.edit; txtUsername.Enabled = false; }
private bool AreRegisterControlsValid(DataOperationMode mode) { Dictionary <Control, TextBoxEntryCheck> ControlsList = new Dictionary <Control, TextBoxEntryCheck>(); ControlsList.Add(txtUserName, TextBoxEntryCheck.CHECK_IF_ANY_TEXT_ENTERED); // Check if username is not null or empty if (cvf.IsFormControlNullOrEmptyValidation(ControlsList) == false) { ControlsList.Remove(txtUserName); return(false); } if (mode == DataOperationMode.INSERT) { ControlsList.Add(txtPassword, TextBoxEntryCheck.CHECK_IF_ANY_TEXT_ENTERED); ControlsList.Add(txtConfirmPassword, TextBoxEntryCheck.CHECK_IF_ANY_TEXT_ENTERED); // Check if password is not null or empty if (cvf.IsFormControlNullOrEmptyValidation(ControlsList) == false) { ControlsList.Remove(txtPassword); ControlsList.Remove(txtConfirmPassword); return(false); } // If password is not null or empty then check and compare password and confirm password field else { #region Password pattern requirement // The password must be a minimum of 8 characters long // The password must contain atleast 1 uppercase letter // The password must be a minimum of 1 lowercase letter // The password must contain atleast 1 numeric #endregion if (txtPassword.Text.Length < Constants.USER_PASSWORD_MIN_CHARACTERS_CONSTRAINT || CheckUpperCase(txtPassword.Text) < Constants.USER_PASSWORD_MIN_UPPERCASE_CHARACTERS_CONSTRAINT || CheckLowerCase(txtPassword.Text) < Constants.USER_PASSWORD_MIN_LOWERCASE_CHARACTERS_CONSTRAINT || CheckNumeric(txtPassword.Text) < Constants.USER_PASSWORD_MIN_DIGIT_CHARACTERS_CONSTRAINT ) { MessageBox.Show(Constants.MSG_PLEASE_ENTER_VALID_PASSWORD + "\n\n HINT: \n\t" + constants.USER_PASSWORD_MIN_CHARACTERS_MSG + "\n\t" + constants.USER_PASSWORD_MIN_UPPERCASE_CHARACTERS_MSG + "\n\t" + constants.USER_PASSWORD_MIN_LOWERCASE_CHARACTERS_MSG + "\n\t" + constants.USER_PASSWORD_MIN_DIGIT_CHARACTERS_MSG , Constants.MSG_DATA_ENTRY_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); txtConfirmPassword.Focus(); return(false); } // Password and Confirm password are not empty, then compare them if (txtPassword.Text != txtConfirmPassword.Text) { MessageBox.Show(Constants.MSG_PASSWORD_MATCH_ERROR, Constants.MSG_DATA_ENTRY_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); txtConfirmPassword.Focus(); return(false); } } } ControlsList.Add(txtRole, TextBoxEntryCheck.CHECK_IF_ANY_TEXT_ENTERED); if (cvf.IsFormControlNullOrEmptyValidation(ControlsList) == false) { ControlsList.Remove(txtRole); return(false); } ControlsList.Clear(); return(true); }