隐藏标签页代码 [英] Code of hide tabpages

查看:76
本文介绍了隐藏标签页代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我有2种表单(登录表单,主表单).
登录表单通过数据库输入用户.换句话说,登录数据存储在数据库中.
某些选项卡页对某些用户不显示(按特权).
我已经使用过这种方法,但是它没有用.所以,如果您不介意,请告诉我我该怎么做.

Hello,
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).
i have already used this way but it was not useful.So please if you don''t mind could you tell me what I do.

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
        {
            this.Hide();
            Interfaces f = new Interfaces();
            f.Show();
        }
        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();
    }
}



感谢您的合作.



thank you for your cooperation

推荐答案

从哪里开始.我希望没有人为此代码付钱,因为它太可怕了.

this.mycmd =从用户名="的用户中选择用户名,密码"" +
Login_YourName_txt.文本+
"和密码=""+ login_pass_txt.文本+
";

这表明您对安全性一无所知,并且不应在安全的系统上工作.授予我访问您的登录页面的权限,我可能可以闯入,而且肯定可以擦除整个数据库.就像我说的那样,您实际上会是罪犯,而且要向任何人收取此代码的费用都是骗子,所以我认为这是一门课.向您的老师询问有关SQL注入攻击的信息.

SQL也是多余的.阅读选择计数语句.

另外,我建议您阅读有关专业开发人员如何设计其代码的信息,"n分层开发"是您应该在Google上找到的.

this.Hide();

是一个愚蠢的主意.让您的主表单显示一个登录表单.否则,如果您在应用程序中的任何位置查找它,则您的主要表单就是隐藏的登录表单.

我将删除标签页,而不是将其隐藏.你都尝试过.您希望找到什么其他解决方案?您可以一无所有,并根据需要添加它们,但这实际上是您唯一的选择.
Where to start. I hope no-one is paying for this code, because it is horrible.

this.mycmd = "select User_name , Password from Users where User_name=''" +
Login_YourName_txt.Text +
"'' and Password=''" + login_pass_txt.Text +
"''";

This show you have no idea about security and should NOT be working on a secure system. Give me access to your login page and I can probably break in and I can certainly erase your entire database. Like I said, you would be literally a criminal and a liar to be charging anyone for this code, so I assume this is a class. Ask your teacher about SQL Injection attacks.

The SQL is also redundant. Read up on select count statements.

Also I suggest reading up on how professional developers design their code, ''n tiered development'' is what you should google.

this.Hide();

is a dumb idea. Have your main form show a login form. Otherwise, your main form if you look it up anywhere in your app, is your hidden login form.

I would remove the tab page, not hide it. You''ve tried both. What other solution did you hope to find ? You could start with nothing and ADD them as needed, but those are really your only options.


您无法在tabcontrol中隐藏和显示选项卡.最好的办法是全部删除并添加所需的内容,或者不首先显示它们.
You cannot hide and show tabs in a tabcontrol. The best you can do is to remove them all and add the ones you need, or to not show some in the first place.


这篇关于隐藏标签页代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆