private void fiscalYearToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FiscalYear fiscalYear = new FiscalYear()
            {
                MdiParent = this
            };

            fiscalYear.Show();
        }
Example #2
0
        private void oKButton_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text == "")
            {
                MessageBox.Show("Please enter user name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUserName.Focus();
                return;
            }
            if (txtPassword.Text == "")
            {
                MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Focus();
                return;
            }
            try
            {
                string clearText      = txtPassword.Text.Trim();
                string password       = clearText;
                byte[] bytes          = Encoding.Unicode.GetBytes(password);
                byte[] inArray        = HashAlgorithm.Create("SHA1").ComputeHash(bytes);
                string readyPassword1 = Convert.ToBase64String(inArray);
                readyPassword = readyPassword1;


                con = new SqlConnection(cs.DBConn);
                con.Open();
                string qry = "SELECT Username,passwords FROM Registration WHERE Username = '******' AND passwords = '" + readyPassword + "'";
                cmd  = new SqlCommand(qry, con);
                rdr1 = cmd.ExecuteReader();
                if (rdr1.Read() == true)
                {
                    dbUserName = (rdr1.GetString(0));
                    dbPassword = (rdr1.GetString(1));


                    con = new SqlConnection(cs.DBConn);
                    con.Open();
                    string ct = "select usertype,UserId from Registration where Username='******' and Passwords='" + readyPassword + "'";
                    cmd            = new SqlCommand(ct);
                    cmd.Connection = con;
                    rdr            = cmd.ExecuteReader();
                    if (rdr.Read())
                    {
                        userType = (rdr.GetString(0));
                        uId      = (rdr.GetInt32(1));
                    }
                    if ((rdr != null))
                    {
                        rdr.Close();
                    }
                    if (dbUserName == txtUserName.Text)
                    {
                        if (dbPassword == readyPassword && userType.Trim() == "SuperAdmin")
                        {
                            this.Hide();
                            FiscalYear frm = new FiscalYear();
                            frm.Show();
                        }
                    }
                    if (dbUserName == txtUserName.Text)
                    {
                        if (dbPassword == readyPassword && userType.Trim() == "Admin")
                        {
                            this.Hide();
                            FiscalYear frm = new FiscalYear();
                            frm.Show();
                        }
                    }
                    if (dbUserName == txtUserName.Text)
                    {
                        if (dbPassword == readyPassword && userType.Trim() == "User")
                        {
                            this.Hide();
                            FiscalYear frm = new FiscalYear();
                            frm.Show();
                        }
                    }
                    if (dbUserName != txtUserName.Text)
                    {
                        MessageBox.Show("Please Type your User Name in Proper Case", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtUserName.Clear();
                        txtUserName.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("Login is Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtUserName.Clear();
                    txtPassword.Clear();
                    txtUserName.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }