Exemplo n.º 1
0
        //Button click navigates user to previous window.
        private void Btn_Cancel(object sender, RoutedEventArgs e)
        {
            ManagerWindow window = new ManagerWindow();

            window.Show();
            this.Close();
        }
Exemplo n.º 2
0
 //Button click executes AddProduct method.
 private void Btn_Confirm(object sender, RoutedEventArgs e)
 {
     //Validation for Product properties.
     if (ValidateProduct.Validate(apvm.Product))
     {
         apvm.AddProduct();
         ManagerWindow window = new ManagerWindow();
         window.Show();
         this.Close();
     }
 }
 //Button click executes EditProduct method.
 private void Btn_Confirm(object sender, RoutedEventArgs e)
 {
     //Validation for Product properties.
     if (ValidateProduct.Validate(epvm.Product))
     {
         if (IsStored.IsChecked == false)
         {
             Checked = false;
         }
         epvm.EditProduct();
         ManagerWindow window = new ManagerWindow();
         window.Show();
         this.Close();
     }
 }
Exemplo n.º 4
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            for (int i = 0; i < mvm.Employes.Count(); i++)
            {
                mvm.GeneralSalary(sender, e, mvm.Employes[i].Id);
                (sender as BackgroundWorker).ReportProgress((i + 1) * (100 / mvm.Employes.Count()));
                Thread.Sleep(250);
            }
            MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("All salaries successfully updated.", "Notification");

            App.Current.Dispatcher.Invoke((Action) delegate
            {
                ManagerWindow window = new ManagerWindow();
                window.Show();
                Close();
            });
        }
Exemplo n.º 5
0
 private void btnSubmit_Click(object sender, RoutedEventArgs e)
 {
     //If username is as value below, Manager window is engaged.
     if (txtUsername.Text == "Man2019" && txtPassword.Password == "Man2019")
     {
         ManagerWindow window = new ManagerWindow();
         window.Show();
         this.Close();
     }
     //If username is as value below, Shopkeeper window is engaged.
     else if (txtUsername.Text == "Mag2019" && txtPassword.Password == "Mag2019")
     {
         ShopkeeperWindow window = new ShopkeeperWindow();
         window.Show();
         this.Close();
     }
     else
     {
         MessageBox.Show("Username or password is incorrect.");
     }
 }
Exemplo n.º 6
0
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            List <string> text  = new List <string>();
            Owner         owner = new Owner();

            StreamReader sr = new StreamReader(@"..\\..\Files\OwnerAccess.txt");
            string       line;

            while ((line = sr.ReadLine()) != null)
            {
                text.Add(line);
            }
            sr.Close();

            if (text.Any())
            {
                foreach (string t in text)
                {
                    string[] temp = t.Split(' ');
                    owner.Username = temp[1];
                    owner.Password = temp[3];
                }
            }

            if (txtUsername.Text == owner.Username && txtPassword.Password == owner.Password)
            {
                OwnerWindow window = new OwnerWindow();
                window.Show();
                Close();
                return;
            }

            CurrentManager = null;

            //Inserted value in password field is being converted into enrypted verson for latter matching with database version.
            byte[] data = System.Text.Encoding.ASCII.GetBytes(txtPassword.Password);
            data = new System.Security.Cryptography.SHA256Managed().ComputeHash(data);
            String hash = System.Text.Encoding.ASCII.GetString(data);

            SqlConnection sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());
            //User is extracted from the database matching inserted paramaters Username and Password.
            SqlCommand query = new SqlCommand("SELECT * FROM tblManger WHERE Username=@Username AND Password=@Password", sqlCon);

            query.CommandType = CommandType.Text;
            query.Parameters.AddWithValue("@Username", txtUsername.Text);
            query.Parameters.AddWithValue("@Password", hash);
            sqlCon.Open();
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(query);
            DataTable      dataTable      = new DataTable();

            sqlDataAdapter.Fill(dataTable);

            foreach (DataRow row in dataTable.Rows)
            {
                CurrentManager = new Manager
                {
                    Id             = int.Parse(row[0].ToString()),
                    FirstName      = row[1].ToString(),
                    LastName       = row[2].ToString(),
                    DateOfBirth    = DateTime.Parse(row[3].ToString()),
                    Mail           = row[4].ToString(),
                    Username       = row[5].ToString(),
                    Password       = row[6].ToString(),
                    Floor          = int.Parse(row[7].ToString()),
                    Experience     = int.Parse(row[8].ToString()),
                    EducationLevel = row[9].ToString()
                };
            }
            sqlCon.Close();

            if (CurrentManager != null)
            {
                ManagerWindow window = new ManagerWindow();
                window.Show();
                Close();
                return;
            }

            MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Incorrect login credentials, please try again.", "Notification");
        }