Example #1
0
        private void btnLogin_Paint(object sender, PaintEventArgs e)
        {
            string role = roleManager.GetEmployeeRole(this.employee.EmployeeId);
            this.Hide();
            if (role == Roles.SalesMan)
            {
                if (dashboard == null)
                {
                    dashboard = new DashboardForSalesMan();
                }
                dashboard.employee = employee;
                dashboard.dashboardEntryForSales = this;
                dashboard.SetUserInfor(_userName);
                dashboard.Show();
                dashboard.LoadDashboardForSalesMan();
            }
            if (role == Roles.Designer)
            {
                if (designerDashboard == null)
                    designerDashboard = new DashboardForDesigner();
                designerDashboard.employee = employee;
                designerDashboard.dashboardEntryForSales = this;
                designerDashboard.SetUserInfor(_userName);
                designerDashboard.Show();
                designerDashboard.LoadDashboardForDesigner();
            }
            if (role == Roles.SalesManManager)
            {
                if (managerDashboard == null)
                {
                    managerDashboard = new DashboardForSalesManager();
                }
                managerDashboard.employee = employee;
                managerDashboard.dashboardEntryForSales = this;
                managerDashboard.SetUserInfor(employee.Name);
                managerDashboard.Show();
                managerDashboard.LoadDashboardForSalesManager();

            }
            if (role == Roles.DesignerManager)
            {
                if (designerManagerDashboard == null)
                {
                    designerManagerDashboard = new DashboardForDesignerManager();
                }
                designerManagerDashboard.employee = employee;
                designerManagerDashboard.dashboardEntryForSales = this;
                designerManagerDashboard.SetUserInfor(employee.Name);
                designerManagerDashboard.Show();
            }
            if (role == Roles.DesignerLeader)
            {
                if (designerLeaderDashboard == null)
                {
                    designerLeaderDashboard = new DashboardForDesignerLeader();
                }
                designerLeaderDashboard.employee = employee;
                designerLeaderDashboard.dashboardEntryForSales = this;
                designerLeaderDashboard.SetUserInfor(employee.Name);
                designerLeaderDashboard.Show();
            }
            if (role == Roles.GeneralManager)
            {
                //TODO
                MessageBox.Show("GeneralManager's Dashboard");
            }
        }
        private void picHome_Click(object sender, EventArgs e)
        {
            employee = empManager.GetEmployeeById(txtUserName.Text);
            if (!empManager.ValidateEmployee(txtUserName.Text, txtPassword.Text) ||
                txtPassword.Text == "" || txtUserName.Text == "")
            {
                lblMsg.Visible = true;
                return;
            }
            else
            {
                //this.SetUserInfor(employee.Name);
                //userInfo.SetForeColor();
                this.employee = employee;
                //picHome.Enabled = true;
                //picEditPwd.Enabled = true;
                //MainContent.Visible = false;
            }

            string role = roleManager.GetEmployeeRole(this.employee.EmployeeId);
            this.Hide();
            if (role == Roles.SalesMan)
            {
                if (dashboard == null)
                {
                    dashboard = new DashboardForSalesMan();
                }
                dashboard.employee = employee;
                dashboard.dashboardEntryForDesigner = this;
                dashboard.SetUserInfor(employee.Name);
                dashboard.Show();
                dashboard.LoadDashboardForSalesMan();
            }
            if (role == Roles.Designer)
            {
                if (designerDashboard == null)
                    designerDashboard = new DashboardForDesigner();
                designerDashboard.employee = employee;
                designerDashboard.dashboardEntryForDesigner = this;
                designerDashboard.SetUserInfor(employee.Name);
                designerDashboard.Show();
                designerDashboard.LoadDashboardForDesigner();
            }
            if (role == Roles.SalesManManager)
            {
                if (managerDashboard == null)
                {
                    managerDashboard = new DashboardForSalesManager();
                }
                managerDashboard.employee = employee;
                managerDashboard.dashboardEntryForDesigner = this;
                managerDashboard.SetUserInfor(employee.Name);
                managerDashboard.Show();
                managerDashboard.LoadDashboardForSalesManager();

            }
            if (role == Roles.DesignerManager)
            {
                if (designerManagerDashboard == null)
                {
                    designerManagerDashboard = new DashboardForDesignerManager();
                }
                designerManagerDashboard.employee = employee;
                designerManagerDashboard.dashboardEntryForDesigner = this;
                designerManagerDashboard.SetUserInfor(employee.Name);
                designerManagerDashboard.Show();
            }
            if (role == Roles.DesignerLeader)
            {
                if (designerLeaderDashboard == null)
                {
                    designerLeaderDashboard = new DashboardForDesignerLeader();
                }
                designerLeaderDashboard.employee = employee;
                designerLeaderDashboard.dashboardEntryForDesigner = this;
                designerLeaderDashboard.SetUserInfor(employee.Name);
                designerLeaderDashboard.Show();
            }
            if (role == Roles.GeneralManager)
            {
                //TODO
                MessageBox.Show("GeneralManager's Dashboard");
            }
        }