please Sir, if you don't mind could you explain to me what you mean because I didn't understand what you wrote
this is the code that i did.
private void Login_Enter_but_Click(object sender, EventArgs e)
{
this.m.connect.Open();
this.mycmd = "select User_name , Password from Users where User_name='" + Login_YourName_txt.Text + "' and Password='" + login_pass_txt.Text + "'";
this.command= new SqlCommand(this.mycmd,this.m.connect);
if (this.command.ExecuteScalar() != null)
{
this.mycmd = "select U_State from Users where User_name='" + Login_YourName_txt.Text + "' and Password='" + login_pass_txt.Text + "'";
this.command = new SqlCommand(this.mycmd, this.m.connect);
string num = this.command.ExecuteScalar().ToString();
if (num == "1")
{
this.Hide();
Interfaces f = new Interfaces();
f.Show();
//f.tabControl1.TabPages.Remove(tabPage1);
f.tabControl1.TabPages[0].Hide();
}
else
{
MessageBox.Show("You aren't actived","NotActive",MessageBoxButtons.OK,MessageBoxIcon.Stop);
}
}
else
{
MessageBox.Show("Sorry,your name or passwrod are wrong try agian", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Warning);
/* count++;
if (count >= 4)
{
this.Close();
count++;
}*/
}
m.connect.Close();
}
when you user make login you might use like:
Form1 f1 = new Form1();
now when you create instance of Form1() , overload constructor of form1(bool flag) now in login form: Form1 f1 = new Form1(true);
pass true if it is admin , false for employee.
and in form1_load event check the value is true or false, and hide/show tabpage.
i have already used this way but it was not useful .so i used the code I sent to u.
i will explain what i want to do ?
i have 2 forms (login form,main form)
the login form enters the user by the database. In other words, the data of log in is stored in database.
a certain tabpage does not appear to a certain user (by privileges).
thank you for your cooperation
I know that way but i would like to know how to hide Tabpages in certain form by another form
this is the code of hide tabpages
//this button in form1
private void button1_Click(object sender, EventArgs e)
{
Form2.tabControl1.TabPages[0].Hide();
}
but it doesn't do anything so what can i do?
thank you for your cooperation
Muhammad ElBarawiPosted Oct 17, 2015, 5:28 PM
MeshaPosted Jul 3, 2010, 9:53 AM
please Sir, if you don't mind could you explain to me what you mean because I didn't understand what you wrote
this is the code that i did.
private void Login_Enter_but_Click(object sender, EventArgs e)
{
this.m.connect.Open();
this.mycmd = "select User_name , Password from Users where User_name='" + Login_YourName_txt.Text + "' and Password='" + login_pass_txt.Text + "'";
this.command= new SqlCommand(this.mycmd,this.m.connect);
if (this.command.ExecuteScalar() != null)
{
this.mycmd = "select U_State from Users where User_name='" + Login_YourName_txt.Text + "' and Password='" + login_pass_txt.Text + "'";
this.command = new SqlCommand(this.mycmd, this.m.connect);
string num = this.command.ExecuteScalar().ToString();
if (num == "1")
{
this.Hide();
Interfaces f = new Interfaces();
f.Show();
//f.tabControl1.TabPages.Remove(tabPage1);
f.tabControl1.TabPages[0].Hide();
}
else
{
MessageBox.Show("You aren't actived","NotActive",MessageBoxButtons.OK,MessageBoxIcon.Stop);
}
}
else
{
MessageBox.Show("Sorry,your name or passwrod are wrong try agian", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Warning);
/* count++;
if (count >= 4)
{
this.Close();
count++;
}*/
}
m.connect.Close();
}
Hiren SoniPosted Jul 3, 2010, 8:26 AM
when you user make login you might use like:
Form1 f1 = new Form1();
now when you create instance of Form1() , overload constructor of form1(bool flag)
now in login form: Form1 f1 = new Form1(true);
pass true if it is admin , false for employee.
and in form1_load event check the value is true or false, and hide/show tabpage.
if you like it, dont 4get to accept answer
MeshaPosted Jul 3, 2010, 5:47 AM
i have already used this way but it was not useful .so i used the code I sent to u.
i will explain what i want to do ?
i have 2 forms (login form,main form)
the login form enters the user by the database. In other words, the data of log in is stored in database.
a certain tabpage does not appear to a certain user (by privileges).
thank you for your cooperation
vishal jadavPosted Jul 3, 2010, 3:57 AM
MeshaPosted Jul 3, 2010, 3:32 AM
I know that way but i would like to know how to hide Tabpages in certain form by another form
this is the code of hide tabpages
//this button in form1
private void button1_Click(object sender, EventArgs e)
{
Form2.tabControl1.TabPages[0].Hide();
}
but it doesn't do anything so what can i do?
thank you for your cooperation
Sam HobbsPosted Jul 2, 2010, 9:48 PM