Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a windows forms. 5 form first registration form, second login form ,third home form etc.... suppose In registration form  if user register  username operator&  password operator, checkbox 1(form1), checkbox2 (form2)  checked checkbox1(form1), not click form2  then save record.
& login(uername: admin , pass admin)
then  home screen was open in home screen button1(form1),button2(form2)  if i click button1(form1) then open form 1 , and button2(form2 ) not open button on click. admin user not permission access form2. & same as a different  user username: admin, pass: adminlogin then click both button access open form1, form2 on button click ?


This is windows application. Actually. Checkbox checked save record in mysql db. In db if checkbox checked save value yes. If yes in db then login user then home screen was open. In home screen button there if on button click then form open. If checked save value in db and if not permission unchecked save value ( no) then not open form


What I have tried:

//first button in home screen
private void btnManual_Click(object sender, EventArgs e)
        {
           try
            {
               string ChechBoxName = "CH1";
                CheckBox chkManual = new CheckBox();
                chkManual.Name = ChechBoxName;
                chkManual.Checked = true;
                if (chkManual.Checked)
                {
                 frmManual manual = new frmManual();
                 manual.Show();
                }
              }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "btnManual_Click,frmHome", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
}


second button in home screen

private void btnAuto_Click(object sender, EventArgs e)
       {
           try
           {
               frmAuto auto = new frmAuto(); // source screen
           //    // frmAuto Auto = new frmAuto();   // Destination screen
           //    dal.change_screen2(auto);
           //}
           //catch (Exception ex)
           {
              MessageBox.Show(ex.Message, "btnAuto_Click, frmHome", MessageBoxButtons.OK, MessageBoxIcon.Error);
          }



      }
Posted
Updated 2-Apr-21 18:11pm
v3

That code ... um ... it shows little comprehension of what is actually going on.
Look at it:
chkManual.Checked = true;
if (chkManual.Checked)
{
Under what circumstances can that check ever fail?
You set a property to a value in one line, and check it in the second: it will be the same as you just set it every single time.

And this:
C#
CheckBox chkManual = new CheckBox();
chkManual.Name = ChechBoxName;
chkManual.Checked = true;
if (chkManual.Checked)
Does not check user input at all: it creates a new Checkbox, sets some properties, and never, ever, shows it to the user.
To get user input, you need to access controls that he can see, and has had time to change as necessary.

And your second chunk of code won't even compile, much less run!

You need to go back to your book or course notes and read again what you need to do - because right at the moment you don't understand the basics of what you are trying to do and until you do there is no point at all in your continuing with this project!
 
Share this answer
 
Using session to allow access on any page at application.
 
Share this answer
 
Comments
Dave Kreskowiak 2-Apr-21 15:44pm    
There's no such thing as a session in a Windows Forms app.
Member 11893460 2-Apr-21 23:50pm    
This is windows application. Actually. Checkbox checked save record in mysql db. In db if checkbox checked save yes. If yes in db then login user then home screen was open. In home screen button there if button click then form open. If checked save value in db then open form and if not permission unchecked save value ( no) then not open form

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900