Example #1
0
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex < 0)
     {
         return;
     }
     if (dgv_grant_sa_localuser.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "ChangePassword")
     {
         frm_grant_changepassword changepassword = new frm_grant_changepassword(Account, Accountpassword);
         changepassword.ShowDialog();
     }
 }
Example #2
0
        private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            if (dgv_grant_sa_alluser.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "SendEmail")
            {
                frm_grant_changepassword changepassword = new frm_grant_changepassword(Account, Accountpassword);
                changepassword.ShowDialog();
            }

            if (dgv_grant_sa_alluser.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Delete")
            {
                DialogResult dr = MessageBox.Show("刪除帳號", "確定刪除嗎?", MessageBoxButtons.OKCancel);
                switch (dr)
                {
                case DialogResult.OK:
                    SqlConnection con = new SqlConnection(SqlLink.linkmethod());
                    SqlCommand    cmd = new SqlCommand(SqlDelete.AlluserDeletemethod(), con);
                    cmd.Parameters.AddWithValue("@username", dgv_grant_sa_alluser.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].Value);
                    con.Open();
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("刪除成功");
                    dgv_grant_sa_alluser.DataSource = null;

                    SqlConnection con1 = new SqlConnection(SqlLink.linkmethod());
                    SqlCommand    cmd1 = new SqlCommand(SqlSelect.GrantLoadAllusermethod(), con1);
                    con1.Open();
                    SqlDataAdapter adapt1 = new SqlDataAdapter(cmd1);
                    DataSet        ds1    = new DataSet();
                    adapt1.Fill(ds1);
                    con.Close();
                    dgv_grant_sa_alluser.DataSource = ds1.Tables[0];
                    break;

                case DialogResult.Cancel:
                    break;
                }
            }
        }
Example #3
0
 private void 修改密碼ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     grant.frm_grant_changepassword grant_Changepassword = new grant.frm_grant_changepassword(Account, Accountpassword);
     grant_Changepassword.MdiParent = this;
     grant_Changepassword.Show();
 }