Ejemplo n.º 1
0
        private void ReportsUI_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.Hide();
            frmMainUI frm = new frmMainUI();

            frm.Show();
        }
Ejemplo n.º 2
0
        private void CloseButton_Click(object sender, EventArgs e)
        {
            this.Hide();
            frmMainUI frm = new frmMainUI();

            frm.Show();
        }
Ejemplo n.º 3
0
        private void btnSignIn_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,Password FROM Registration WHERE UserName = '******' AND Password = '******'";
                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 Password='******'";
                    cmd            = new SqlCommand(ct);
                    cmd.Connection = con;
                    rdr            = cmd.ExecuteReader();
                    if (rdr.Read())
                    {
                        userType = (rdr.GetString(0));
                        uId2     = (rdr.GetInt32(1));
                    }
                    if ((rdr != null))
                    {
                        rdr.Close();
                    }
                    //if (dbUserName == txtUserName.Text && dbPassword == readyPassword && userType.Trim() == "SuperAdmin")
                    //{


                    //}
                    if (dbUserName == txtUserName.Text && dbPassword == readyPassword && userType.Trim() == "Admin")
                    {
                        this.Hide();
                        frmMainUI frm = new frmMainUI();
                        frm.Show();
                        frm.lblUser.Text = txtUserName.Text;
                        txtPassword.Clear();
                        txtUserName.Clear();
                    }
                    //if (dbUserName == txtUserName.Text && dbPassword == readyPassword && userType.Trim() == "User")
                    //{
                    //    this.Hide();
                    //    FiscalYear frm = new FiscalYear();
                    //    frm.Show();

                    //}
                }
                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);
            }
            //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
            //{
            //    SqlConnection myConnection = default(SqlConnection);
            //    myConnection = new SqlConnection(cs.DBConn);

            //    SqlCommand myCommand = default(SqlCommand);

            //    myCommand = new SqlCommand("SELECT Username,password FROM Registration WHERE Username = @username AND Password = @UserPassword", myConnection);
            //    SqlParameter uName = new SqlParameter("@username", SqlDbType.VarChar);
            //    SqlParameter uPassword = new SqlParameter("@UserPassword", SqlDbType.VarChar);
            //    uName.Value = txtUserName.Text;
            //    uPassword.Value = txtPassword.Text;
            //    myCommand.Parameters.Add(uName);
            //    myCommand.Parameters.Add(uPassword);

            //    myCommand.Connection.Open();

            //    SqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

            //    if (myReader.Read() == true)
            //    {
            //        int i;
            //        ProgressBar1.Visible = true;
            //        ProgressBar1.Maximum = 5000;
            //        ProgressBar1.Minimum = 0;
            //        ProgressBar1.Value = 4;
            //        ProgressBar1.Step = 1;

            //        for (i = 0; i <= 5000; i++)
            //        {
            //            ProgressBar1.PerformStep();
            //        }
            //        con = new SqlConnection(cs.DBConn);
            //        con.Open();
            //        string ct = "select usertype,UserId from Registration where Username='******'and Password='******'";
            //        cmd = new SqlCommand(ct);
            //        cmd.Connection = con;
            //        rdr = cmd.ExecuteReader();
            //        if (rdr.Read())
            //        {
            //            txtUserType.Text = (rdr.GetString(0));
            //            uId2 = (rdr.GetInt32(1));

            //        }
            //        if ((rdr != null))
            //        {
            //            rdr.Close();
            //        }

            //        if (txtUserType.Text.Trim() == "Admin")
            //        {
            //            this.Hide();
            //            frmMainUI frm = new frmMainUI();
            //            frm.Show();
            //            //this.Visible = false;
            //            //frm.ShowDialog();
            //            frm.lblUser.Text = txtUserName.Text;
            //            //this.Visible = true;
            //            txtPassword.Clear();
            //            txtUserName.Clear();
            //        }
            //        //if (txtUserType.Text.Trim() == "User")
            //        //{

            //        //    MasterPagesForUser frm = new MasterPagesForUser();
            //        //    this.Visible = false;
            //        //    frm.ShowDialog();
            //        //    this.Visible = true;

            //        //}

            //    }


            //    else
            //    {
            //        MessageBox.Show("Login is Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);

            //        txtUserName.Clear();
            //        txtPassword.Clear();
            //        txtUserName.Focus();

            //    }
            //    if (myConnection.State == ConnectionState.Open)
            //    {
            //        myConnection.Dispose();
            //    }



            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}
        }