示例#1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string id      = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
            string command = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();

            if (command.ToLower() == "delete")
            {
                try
                {
                    if (MessageBox.Show("Are you sure to Delete", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        string       deletequery = "delete from [tblUser] where user_id=" + id;
                        DBConnection db          = new DBConnection();
                        db.executyQuery(deletequery);
                        MessageBox.Show("successfully Deleted");
                        LoadDisplayUser();
                    }
                    else
                    {
                        LoadDisplayUser();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else if (command.ToLower() == "edit")
            {
                string       query = "select * from [tblUser] where user_id=" + id;;
                DBConnection db    = new DBConnection();
                DataTable    dt    = db.GetData(query);
                if (dt.Rows.Count > 0)
                {
                    User user = new User();
                    user.user_id  = (int)dt.Rows[0]["user_id"];
                    user.username = (string)dt.Rows[0]["username"];
                    user.password = (string)dt.Rows[0]["password"];
                    user.email    = (string)dt.Rows[0]["email"];
                    user.mobile   = (string)dt.Rows[0]["mobile"];
                    user.address  = (string)dt.Rows[0]["address"];
                    RegisterUserForm frmregister = new RegisterUserForm(user);
                    frmregister.Show();
                }
            }
        }
示例#2
0
        private void addToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            RegisterUserForm register = new RegisterUserForm(null);

            register.Show();
        }
示例#3
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            RegisterUserForm frmRegister = new RegisterUserForm(null);

            frmRegister.Show();
        }