private void dataGridView1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.P && e.Modifiers == Keys.Control) { MessageBox.Show(EncodeString.Decrypt(dataGridView1.SelectedRows[0].Cells[3].Value.ToString())); } }
private void cmd_login_Click(object sender, EventArgs e) { try { DataClasses2DataContext db = new DataClasses2DataContext(Properties.Settings.Default.MyConString); string pwd = EncodeString.Encrypt(txt_password.Text); var list = db.sp_login(txt_username.Text, pwd).ToList(); if (list.Count() >= 1) { foreach (var i in list) { fmain.UserLevel = Convert.ToInt32(i.UserLevel); fmain.UserCn = i.cn; } txt_username.Clear(); txt_password.Clear(); this.Close(); } else { MessageBox.Show("User does not exist", "Access Denied", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } catch { new frm_server().ShowDialog(); } }
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { txt_name.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); txt_username.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString(); txt_password.Text = EncodeString.Decrypt(dataGridView1.SelectedRows[0].Cells[3].Value.ToString()); cbo_level.Text = dataGridView1.SelectedRows[0].Cells[4].Value.ToString(); cmd_save.Enabled = false; cmd_edit.Enabled = true; cmd_edit.Enabled = true; txt_name.Enabled = false; txt_username.Enabled = false; txt_password.Enabled = false; txt_confirmPassword.Enabled = false; cbo_level.Enabled = false; }
private void cmd_save_Click(object sender, EventArgs e) { string Levelcn = ((this.cbo_level.SelectedItem as ComboBoxItem).Value.ToString()); if (txt_name.Text == "" || txt_username.Text == "" || txt_password.Text == "" || txt_password.Text != txt_confirmPassword.Text || cbo_level.Text == "") { MessageBox.Show("Please check/Verify required informaion", "Action Denied", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { if (cmd_save.Text == "Save") { db.ExecuteCommand("INSERT INTO [Centerport_Medical].[dbo].[tbl_user] ([Fullname], [Username], [Password], [UserLevel], [Remark]) VALUES ({0},{1}, {2}, {3}, {4})", txt_name.Text, txt_username.Text, EncodeString.Encrypt(txt_password.Text), Levelcn, "1"); Availability(false, "Save"); cmd_edit.Enabled = false; cmd_new.Enabled = true; cmd_save.Enabled = false; txt_name.Clear(); txt_username.Clear(); txt_password.Clear(); txt_confirmPassword.Clear(); cbo_level.SelectedIndex = -1; cmd_new.Text = "New"; } else { db.ExecuteCommand("UPDATE [Centerport_Medical].[dbo].[tbl_user] SET [Fullname]={0}, [Username]={1}, [Password]={2}, [UserLevel]={3} WHERE ([cn]={4})", txt_name.Text, txt_username.Text, EncodeString.Encrypt(txt_password.Text), Levelcn, dataGridView1.SelectedRows[0].Cells[0].Value.ToString()); Availability(false, "Modify"); cmd_edit.Enabled = false; cmd_new.Enabled = true; cmd_save.Enabled = false; txt_confirmPassword.Clear(); cmd_new.Text = "New"; } } loaduser(); }