Example #1
0
 public WorkerScreen(Models.Worker worker)
 {
     this.worker = worker;
     InitializeComponent();
     IsMdiContainer               = true;
     btn_logout.Enabled           = false;
     btn_login.Enabled            = false;
     cmb_myProjects.DataSource    = ProjectRequests.GetAllProjectsByWorker(worker.WorkerId);
     cmb_myProjects.DisplayMember = "ProjectName";
 }
        private void btn_enter_Click(object sender, EventArgs e)
        {
            LoginWorker loginWorker = new LoginWorker {
                WorkerName = txt_userName.Text, Password = LoginWorker.sha256_hash(txt_password.Text).ToUpper()
            };
            var validationContext = new ValidationContext(loginWorker, null, null);
            var results           = new List <ValidationResult>();

            Models.Worker worker = new Models.Worker();

            if (Validator.TryValidateObject(loginWorker, validationContext, results, true))
            {
                worker = Requests.WorkerRequests.LoginByPassword(loginWorker);
                if (worker != null)
                {
                    if (cb_rememberUser.Checked)
                    {
                        worker.WorkerComputer = Requests.WorkerRequests.GetIp();
                        if (!Requests.WorkerRequests.UpdateWorker(worker))
                        {
                            MessageBox.Show("this computer already registred to another worker");
                        }
                    }

                    switch (worker.statusObj.StatusName)
                    {
                    case "Manager":
                        Manager.ManagerMainScreen managerMainScreen = new Manager.ManagerMainScreen(worker);
                        managerMainScreen.Show();
                        Close();
                        break;

                    case "TeamHead":
                        TeamHeadScreen TeamHeadScreen = new TeamHeadScreen(worker);
                        TeamHeadScreen.Show();
                        Close();
                        break;

                    default:
                        WorkerScreen workerScreen = new WorkerScreen(worker);
                        workerScreen.Show();
                        Close();
                        break;
                    }
                }
            }
            else
            {
                MessageBox.Show(string.Join(",\n", results.Select(p => p.ErrorMessage)));
            }
        }
Example #3
0
        public Welcome()
        {
            IsMdiContainer = true;
            Models.Worker worker = Requests.WorkerRequests.LoginByComputerWorker();
            if (worker != null)
            {
                switch (worker.statusObj.StatusName)
                {
                case "Manager":
                    Manager.ManagerMainScreen managerMainScreen = new Manager.ManagerMainScreen(worker);

                    managerMainScreen.Show();
                    break;

                case "TeamHead":
                    TeamHeadScreen TeamHeadScreen = new TeamHeadScreen(worker);

                    TeamHeadScreen.Show();
                    break;

                default:
                    WorkerScreen workerScreen = new WorkerScreen(worker);

                    workerScreen.Show();
                    break;
                }
            }
            else
            {
                ManagementTaskLogin managementTaskLogin = new ManagementTaskLogin();
                managementTaskLogin.MdiParent = this;
                managementTaskLogin.Show();
            }


            InitializeComponent();
        }