Пример #1
0
        private void changePasswordToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PassChangeFrm frm = new PassChangeFrm();

            frm.MdiParent = this;
            frm.Show();
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (checkBox1.Checked)
                {
                    Properties.Settings.Default.username = textBox1.Text.Trim().ToString();
                    Properties.Settings.Default.password = textBox2.Text.Trim().ToString();
                    Properties.Settings.Default.Save();
                }
                if (checkBox1.Checked == false)
                {
                    Properties.Settings.Default.username = "";
                    Properties.Settings.Default.password = "";
                    Properties.Settings.Default.Save();
                    checkBox1.Checked = false;
                }


                obj.connection_Opener();
                _txtName = textBox1.Text.Trim().ToString();
                val1     = textBox1.Text.Trim() + textBox2.Text.Trim() + "abdullah";
                val2     = cls.MD5Encrypt(val1);
                obj.data_fetchCmd("select * from users where IsStatus='A' And Users_name='" + textBox1.Text.Trim() + "'");
                if (pg.dr.Read())
                {
                    val3 = pg.dr["Field2"].ToString();
                }

                if (val2 == val3)
                {
                    messageBoxSu MxgSuccess = new messageBoxSu();
                    MxgSuccess.ShowDialog();
                    //MessageBox.Show("Login Successful", "Login Panel", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    Program.gh = pg.dr["Users_id"].ToString();
                    qrylg      = "insert into login_Time values('" + textBox1.Text + "',Getdate(),null)";
                    obj.simInsert(qrylg);
                    if (pg.dr["FirstLogin"].ToString() == "True")
                    {
                        PassChangeFrm pfrm = new PassChangeFrm();
                        pfrm.ShowDialog();
                    }
                    this.Close();
                    Thread thr = new Thread(new ThreadStart(app));
                    thr.SetApartmentState(ApartmentState.STA);
                    thr.Start();
                }
                else
                {
                    StrQuery = "update users set IvalidCount = IvalidCount+1 where IsStatus ='A' And Users_name='" + textBox1.Text.Trim() + "'";
                    obj.simInsert(StrQuery);

                    obj.data_fetchCmd("Select InvalidAttamp, IvalidCount, IsStatus From users Where IsStatus = 'A' And Users_name='" + textBox1.Text.Trim() + "'");

                    if (pg.dr.Read())
                    {
                        val4 = pg.dr["IvalidCount"].ToString();
                        val5 = pg.dr["InvalidAttamp"].ToString();
                    }
                    if (val4 == val5)
                    {
                        StrQuery = " Update users set IsStatus = 'X' Where IsStatus = 'A' And Users_name='" + textBox1.Text.Trim() + "'";
                        obj.simInsert(StrQuery);
                        //MessageBox.Show("User ID Has Been Blocked!" + Environment.NewLine + "Please Contact Admin!", "Error", MessageBoxButtons.OK);
                        MessageBoxConfrm mxgCon = new MessageBoxConfrm();
                        mxgCon.ShowDialog();
                        this.Close();
                    }
                    else
                    {
                        // MessageBox.Show("Wrong ID or Password", "Login Panel", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MessageBoxWarning mxgWarning = new MessageBoxWarning();
                        mxgWarning.ShowDialog();
                    }


                    clr();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }