예제 #1
0
        private void ButtonBack_Click(object sender, RoutedEventArgs e)
        {
            var adminMain = new AdminMain();

            adminMain.Show();
            this.Close();
        }
예제 #2
0
        private void bunifuThinButton21_Click(object sender, EventArgs e)
        {
            MySqlConnection conn = new MySqlConnection(connstr);

            conn.Open();

            string       AdmLog_query = "Select count(*) from Login where User_Name = '" + UsertextBox.Text + "' and Pasword = '" + PasstextBox.Text + "' AND RoleID = 2 ";
            MySqlCommand cmd          = new MySqlCommand(AdmLog_query, conn);

            cmd.ExecuteReader();
            conn.Close();

            MySqlDataAdapter sda = new MySqlDataAdapter(cmd);
            DataTable        dt  = new DataTable();

            sda.Fill(dt);
            if (Convert.ToInt32(dt.Rows[0][0]) == 1)
            {
                MessageBox.Show("Vendosja e kredencialeve u krye me sukses!", "         ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                AdminMain m = new AdminMain();
                m.Show();
                this.Hide();
            }
            else
            {
                label1.Show();
            }
        }
예제 #3
0
        private void Login_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(connection);


            MD5 md5 = new MD5CryptoServiceProvider();

            md5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(password.Text.Trim()));
            byte[] result = md5.Hash;

            StringBuilder strBuilder = new StringBuilder();

            for (int i = 0; i < result.Length; i++)
            {
                strBuilder.Append(result[i].ToString("x2"));
            }

            SqlDataAdapter sda = new SqlDataAdapter("select count(*) from login where username ='******' and password='******'", conn);
            DataTable      dt  = new DataTable();

            sda.Fill(dt);


            SqlCommand oCmd = new SqlCommand("SELECT id from login where username ='******'", conn);

            conn.Open();
            using (SqlDataReader oReader = oCmd.ExecuteReader())
            {
                while (oReader.Read())
                {
                    LoginID = Convert.ToInt32(oReader["id"]);
                    // MessageBox.Show(matchingUsername);
                }

                conn.Close();
            }

            if (dt.Rows[0][0].ToString() == "1")
            {
                if (LoginID == 1 || LoginID == 2)
                {
                    this.Hide();
                    AdminMain admin = new AdminMain();
                    admin.Show();
                }

                else
                {
                    this.Hide();
                    Main user = new Main(LoginID);
                    user.Show();
                }
            }
            else
            {
                MessageBox.Show("Please enter the correct username and password", "alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void bunifuTileButton4_Click(object sender, EventArgs e)
        {
            AdminMain item = new AdminMain();

            panel2.Controls.Clear();
            //item.Top = 10;
            //item.Left = 10;
            panel2.Controls.Add(item);
        }
예제 #5
0
        private void login(object sender, EventArgs e)
        {
            if (Program.verifySGBDConnection())
            {
                String     Email    = LoginEmailBox.Text;
                String     Password = LoginPasswordBox.Text;
                SqlCommand cm       = new SqlCommand("Project.pd_Login");
                cm.CommandType = CommandType.StoredProcedure;
                cm.Parameters.Add(new SqlParameter("@Loginemail", SqlDbType.VarChar));
                cm.Parameters.Add(new SqlParameter("@password", SqlDbType.VarChar));
                cm.Parameters.Add(new SqlParameter("@response", SqlDbType.VarChar, 1));
                cm.Parameters["@LoginEmail"].Value   = Email;
                cm.Parameters["@password"].Value     = Password;
                cm.Parameters["@response"].Direction = ParameterDirection.Output;
                cm.Connection = Program.cn;
                cm.ExecuteNonQuery();

                if ("" + cm.Parameters["@response"].Value == "1")
                {
                    //check admin

                    SqlCommand comand = new SqlCommand("select Project.udf_isadmin ('" + Email + "')", Program.cn);
                    int        value  = (int)comand.ExecuteScalar();
                    Console.WriteLine(value);
                    if (value > 0)
                    {
                        Program.currentUser = value;
                        this.Hide();
                        AdminMain admin = new AdminMain();
                        admin.ShowDialog();
                        this.Close();
                    }
                    else
                    {
                        SqlCommand cmd    = new SqlCommand("select Project.udf_isclient ('" + Email + "')", Program.cn);
                        int        value2 = (int)cmd.ExecuteScalar();
                        Console.WriteLine(Email);
                        Console.WriteLine("Login:"******"current_user " + Program.currentUser);
                }
                else
                {
                    MessageBox.Show("Incorrent Login");
                }
                Program.cn.Close();
            }
        }
        public int SaveAdmin(AdminMain admin)
        {
            string query = "Insert Into Admin (Name,ContractNumber,AdminUserName,AdminPassword,Question,Answer) Values ('" + admin.AdminName + "','" + admin.AdminContract + "','" + admin.AdminUserName + "','" + admin.Password + "','" + admin.Question + "','" + admin.Answer + "')";

            Command = new SqlCommand(query, Connection);
            Connection.Open();
            int result = Command.ExecuteNonQuery();

            Connection.Close();
            return(result);
        }
예제 #7
0
        private void Login()
        {
            if (radioButtonVet.IsChecked == true)
            {
                // try to find the user
                var user = vet.GetByName(textBoxName.Text);
                if (user == null)
                {
                    MessageBox.Show("Wrooong!");
                    return;
                }

                if (!PasswordHelper.VerifyHashedPassword(user.PasswordHash, user.PasswordSalt, passwordBox.Password))
                {
                    MessageBox.Show("Wrooong!");
                    return;
                }

                Configuration.Save(new ConfigurationModel()
                {
                    IsAdmin  = false,
                    Name     = textBoxName.Text,
                    Password = passwordBox.Password
                });

                var vetMain = new VetMain(vet);
                vetMain.Show();
                this.Close();
            }
            else
            {
                if (textBoxName.Text == "admin" && passwordBox.Password == "123456")
                {
                    Configuration.Save(new ConfigurationModel()
                    {
                        IsAdmin  = true,
                        Name     = textBoxName.Text,
                        Password = passwordBox.Password
                    });

                    var adminMain = new AdminMain();
                    adminMain.Show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Wrooong!");
                }
            }
        }
예제 #8
0
        private void btLogin_Click(object sender, RoutedEventArgs e)
        {
            appviemodel.Pass = txtPassword.Password.ToString();
            if (!appviemodel.Validate())
            {
                MessageBox.Show("Invalid data! Repeat one more time!");
            }

            else
            {
                AdminMain adminMain = new AdminMain(appviemodel);
                adminMain.Show();
                Close();
            }
        }
예제 #9
0
        private void Hyni_button_Click(object sender, EventArgs e)
        {
            if (UsertextBox.Text == "admin01" && PasstextBox.Text == "1234")
            {
                MessageBox.Show("Vendosja e kredencialeve u krye me sukses!", "         ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                AdminMain am = new AdminMain();
                am.Show();
                this.Hide();
            }

            else
            {
                MessageBox.Show("Vendosni sakte kredencialet!", " Administratori nuk ekziston ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #10
0
        public ActionResult AdminMainPage(AdminMain inMain)
        {
            string result;

            if (ModelState.IsValid)
            {
                try
                {
                    result = main.InsertContactDetails(inMain);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(View());
        }
예제 #11
0
 private void AdminBtn_Click(object sender, RoutedEventArgs e)
 {
     AdminMain main = new AdminMain();
     main.Show();
 }