Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            MD5    md5Hash = MD5.Create();
            string hash    = GetMd5Hash(md5Hash, textBox2.Text);

            hash = GetMd5Hash(md5Hash, hash);
            ///MessageBox.Show(hash);

            dataGridView1.DataSource = db.Get_DataTable("SELECT * from Users WHERE Name='" + textBox1.Text + "' ", "idpoints");
            string hashdb     = dataGridView1.Rows[0].Cells["Pass"].Value.ToString();
            string uid        = dataGridView1.Rows[0].Cells["id"].Value.ToString();
            string UserTypeId = dataGridView1.Rows[0].Cells["UserTypeId"].Value.ToString();

            //MessageBox.Show(hashdb);

            if (hash == hashdb)
            {
                MessageBox.Show("Залогинились");

                if (UserTypeId == "1")
                {
                    AdminForm f = new AdminForm();
                    //f.textBox_uid.Text = uid;
                    f.Show();
                    Hide();
                }

                if (UserTypeId == "2")
                {
                    OperForm f = new OperForm();
                    f.textBox_uid.Text = uid;
                    f.Show();
                    Hide();
                }

                if (UserTypeId == "3")
                {
                    MessageBox.Show("RKS");
                    RksForm f = new RksForm();
                    f.Show();
                    Hide();
                }
            }
            else
            {
                MessageBox.Show("Неверный логин пароль");
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string hash = db_idp.GetMD5ofMD5(textBox2.Text);
            string q    = @"SELECT `Users`.`id`, `Users`.`Pass`, `Users`.`Name`, `Users`.`UserTypeId` FROM `Users`
                        WHERE `Users`.`Name` = '" + textBox1.Text + "'";

            dataGridView1.DataSource = db_idp.Get_DataTable(q);
            string hashdb     = dataGridView1.Rows[0].Cells["Pass"].Value.ToString();
            string uid        = dataGridView1.Rows[0].Cells["id"].Value.ToString();
            string UserTypeId = dataGridView1.Rows[0].Cells["UserTypeId"].Value.ToString();
            string RegionId   = "";

            if (hash == hashdb)
            {
                if (textBox1.Text == "Denis" || textBox1.Text == "UlyaAdmin")
                {
                    timer1.Enabled = true;
                }

                string ip = checkIp();

                string ret = db_idp.SqlQueryWithResult("SELECT * from ip_permitted WHERE ip='" + ip + "'");

                if (ret != "0")
                {
                    db_idp.SqlQuery("INSERT into visitors (id, ip, login, version, machine) VALUES (NULL,'" + ip + "','" + textBox1.Text + "', '" + db_idp.version + "', '" + Environment.MachineName + "'); ", "");
                }
                else
                {
                    db_idp.SqlQuery("INSERT into visitors (id, ip, login, version, machine) VALUES (NULL,'" + ip + "','" + textBox1.Text + "', '" + db_idp.version + "', '" + Environment.MachineName + "');", "");
                }

                if (checkBox1.Checked)
                {
                    if (textBox1.Text.IndexOf("RKS") < 0 && textBox1.Text != "Denis")
                    {
                        string s = textBox1.Text + ":" + textBox2.Text;
                        File.WriteAllText(PwdFile, s, Encoding.Default);
                    }
                    else
                    {
                        string s = textBox1.Text + ":";
                        File.WriteAllText(PwdFile, s, Encoding.Default);
                    }
                }

                if (UserTypeId == "1")
                {
                    AdminForm f = new AdminForm();
                    f.username = textBox1.Text;
                    f.Show();
                    Hide();
                }

                if (UserTypeId == "2")
                {
                    ShowOperForm(uid);
                    Hide();
                }

                if (UserTypeId == "3")
                {
                    /*string qq = @"SELECT `Users`.`id`, `Users`.`Pass`, `Users`.`Name`, `Users`.`UserTypeId`,`Limits`.`RksId`, `Limits`.`RegionId`
                     *  FROM `Users`
                     *  INNER JOIN `Limits` ON `Limits`.`UserId`=`Users`.`id`
                     *  WHERE `Users`.`Name` = '" + textBox1.Text + "'";
                     *
                     * RegionId = dataGridView1.Rows[0].Cells["RegionId"].Value.ToString();*/

                    //MessageBox.Show(RegionId)

                    RksForm f = new RksForm();
                    f.rksname = textBox1.Text;
                    f.Show();
                    Hide();
                }
                if (UserTypeId == "4")
                {
                    FormAudit f = new FormAudit();
                    f.Show();
                    Hide();
                }
                if (UserTypeId == "5")
                {
                    FormDostavka f = new FormDostavka();
                    f.textBox_uname.Text = textBox1.Text;
                    f.Show();
                    Hide();
                }
            }
            else
            {
                MessageBox.Show("Неверный логин пароль");

                if (Environment.MachineName == db_idp.mycomp && UserTypeId != "5")
                {
                    ShowOperForm(uid);
                }
            }
        }