Example #1
0
        private void btnUpdate_record_Click(object sender, EventArgs e)
        {
            try
            {
                con = new SqlConnection(cs.DBcon);
                con.Open();

                string cb = "update user_registration set UserID=@d1 , password=@d2,contact_no=@d3,email=@d4,name=@d5,usertype=@d7 where userid=@d8";

                cmd = new SqlCommand(cb);

                cmd.Connection = con;
                cmd.Parameters.AddWithValue("@d1", UserID.Text);
                cmd.Parameters.AddWithValue("@d7", cmbUsertype.Text);
                cmd.Parameters.AddWithValue("@d2", txtPassword.Text);
                cmd.Parameters.AddWithValue("@d5", txtName.Text);
                cmd.Parameters.AddWithValue("@d3", txtContact_no.Text);
                cmd.Parameters.AddWithValue("@d4", txtEmail_Address.Text);
                cmd.Parameters.AddWithValue("@d8", TextBox1.Text);
                cmd.ExecuteReader();
                con.Close();
                frmRegisteredUsersDetails frm = new frmRegisteredUsersDetails();
                frm.GetData();
                MessageBox.Show("Successfully updated", "User Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                st1 = lblUser.Text;
                st2 = " Registered User is Updated in User Registration";
                cf.LogFunc(st1, System.DateTime.Now, st2);
                Autocomplete();
                btnRegister.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void btnGetDetails_Click(object sender, EventArgs e)
        {
            this.Hide();
            frmRegisteredUsersDetails frm = new  frmRegisteredUsersDetails();

            frm.lblUser.Text     = lblUser.Text;
            frm.lblUserType.Text = lblUserType.Text;

            frm.Show();
        }
Example #3
0
        private void delete_records()
        {
            try
            {
                if (UserID.Text == "admin")
                {
                    MessageBox.Show("Admin Account can not be deleted", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                int RowsAffected = 0;
                con = new SqlConnection(cs.DBcon);
                con.Open();
                string cq = "delete from User_Registration where UserID='" + UserID.Text + "'";
                cmd            = new SqlCommand(cq);
                cmd.Connection = con;
                RowsAffected   = cmd.ExecuteNonQuery();


                if (RowsAffected > 0)
                {
                    MessageBox.Show("Successfully deleted", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    st1 = lblUser.Text;
                    st2 = " Registered User is Deleted in User Registration";
                    cf.LogFunc(st1, System.DateTime.Now, st2);
                    Autocomplete();
                    Reset();
                }
                else
                {
                    MessageBox.Show("No Record found", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Reset();
                    Autocomplete();
                }
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
                frmRegisteredUsersDetails frm1 = new frmRegisteredUsersDetails();
                frm1.GetData();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }