protected void Page_Load(object sender, EventArgs e)
        {
            bool isTempHead = false;
            RegistrationService rser = new RegistrationService();
            string userId = HttpContext.Current.User.Identity.Name;
            isTempHead = rser.IsTempDepHead(userId);

            if ((HttpContext.Current.User.IsInRole("Department Head")!= true) && (isTempHead!=true))
            {
                Response.Redirect("/Presentation/Login.aspx");

            }

            _RequisitionService = new RequisitionService();
            _EmployeeService = new EmployeeService();

            if (!IsPostBack)
            {
                int LoginId = Convert.ToInt32(Session["userid"].ToString());
                currentEmp = new employee();
                currentEmp = _EmployeeService.GetEmployeeDetailsByEmpID(LoginId);
                if (currentEmp!=null)
                {
                    int curdeptID = currentEmp.EmployeeDepId ?? default(int);
                    LoadAllGridView(curdeptID);
                }
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bool isTempHead = false;
            RegistrationService rser = new RegistrationService();
            string userId = HttpContext.Current.User.Identity.Name;
            isTempHead = rser.IsTempDepHead(userId);

            if (isTempHead == true)
            {
                link_Delg.Visible = false;
            }

            HttpCookie user = new HttpCookie("usercookie");
            user = Request.Cookies["usercookie"];
            if (user != null)
            {
                lbl_username.InnerText = user.Value;
            }
        }
Beispiel #3
0
        protected void CreateUser_Click(object sender, EventArgs e)
        {
            RegistrationService re = new RegistrationService();

            ////Creating the user in our database
            string username = txt_Username.Text;
            string contact = txt_ContactNumber.Text;
            string email = txt_UserEmailID.Text; ; //Userid shall be email to make it truly unique
            string password = txt_Password.Text;
            int roleid = ddl_Role.SelectedIndex + 1;
            string rolename = ddl_Role.SelectedValue;
            int depid = Convert.ToInt32(ddl_Department.SelectedValue);

            if ((roleid == 4) || (roleid == 5))
            {
                //employee emp = new employee();
                //emp.EmpIsDepRep = false;
                //emp.EmployeeContact = Convert.ToInt32(contact);
                //emp.EmployeeName = username;
                //emp.EmployeeDepId = Convert.ToInt32(depid);
                //emp.EmployeeEmail = email;
                //emp.EmployeeRoleID = roleid;
                //se.employees.Add(emp);
                //se.SaveChanges();
                re.registeremployee(username, email, depid, roleid, contact);

            }
            else
            {
                //    //storeemp semp = new storeemp();
                //    //semp.StoreEmpEmail = email;
                //    //semp.StoreEmpName = username;
                //    //semp.StoreEmpContact = Convert.ToInt32(contact);
                //    //semp.StoreEmpRoleID = roleid;
                //    //se.storeemps.Add(semp);
                //    //se.SaveChanges();
                re.registerStoreemployee(username, email, roleid, contact);
            }

            try
            {
                MembershipCreateStatus status;

                MembershipUser newuser = Membership.CreateUser(txt_UserEmailID.Text, txt_Password.Text, email, null, null, true, out status);
                if (newuser != null)
                {
                    //Roles.CreateRole(rolename);
                    Roles.AddUserToRole(txt_UserEmailID.Text, rolename);
                    StatusMessage.Text = "Successfull";
                }
                else
                {
                    StatusMessage.Text = "Try Again";

                }

            }
            catch (Exception ex)
            {

            }

            //// Default UserStore constructor uses the default connection string named: DefaultConnection
            //var userStore = new UserStore<IdentityUser>();
            //var manager = new UserManager<IdentityUser>(userStore);
            //var user = new IdentityUser(email);

            ////role managers
            ////var rolestore = new RoleStore<IdentityRole>();
            ////var rolemanager = new RoleManager<IdentityRole>(rolestore);
            ////var role = new IdentityRole(rolename);
            ////rolemanager.Create(role);

            //IdentityResult result = manager.Create(user, Password.Text);

            //if (result.Succeeded)
            //{
            //    var cuuser=manager.FindByName(email);
            //    manager.AddToRole(cuuser.Id, rolename);

            //    var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
            //    var userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);
            //    authenticationManager.SignIn(new AuthenticationProperties() { }, userIdentity);
            //    Response.Redirect("~/Login.aspx");
            //}
            //else
            //{
            //    StatusMessage.Text = result.Errors.FirstOrDefault();
            //}
        }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RegistrationService re = new RegistrationService();
            List<object> roles = new  List<object>();
            List<object> departments = new List<object>();
            if (!IsPostBack)
            {
                roles = re.getallroles();
                departments = re.getalldep();
                ddl_Role.DataTextField = "RoleName";
                ddl_Role.DataValueField = "RoleName";
                ddl_Role.DataSource = roles;
                ddl_Role.DataBind();

                ddl_Department.DataTextField = "DepName";
                ddl_Department.DataValueField = "DepID";
                ddl_Department.DataSource = departments;
                ddl_Department.DataBind();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            bool isTempHead = false;
            RegistrationService rser = new RegistrationService();
            string userId = HttpContext.Current.User.Identity.Name;
            isTempHead = rser.IsTempDepHead(userId);

            if ((HttpContext.Current.User.IsInRole("Department Head") != true) && (isTempHead != true))
            {
                Response.Redirect("/Presentation/Login.aspx");

            }

            _RequisitionService = new RequisitionService();
            _EmployeeService = new EmployeeService();
            _DepartmentService = new DepartmentService();
            _ItemService = new ItemService();

            if (!IsPostBack)
            {
                int QueryStringReqID = Int32.Parse(Request.QueryString["ID"]);

                var Req_Emp_DeptDetails = _RequisitionService.GetReq_Emp_DeptDetailsListByReqId(QueryStringReqID);

                Type t = Req_Emp_DeptDetails.GetType();

                PropertyInfo EmployeeName = t.GetProperty("EmployeeName");
                lblEmployeeName.Text = Convert.ToString(EmployeeName.GetValue(Req_Emp_DeptDetails,null));
                PropertyInfo EmpNo = t.GetProperty("EmployeeID");
                lblEmpNo.Text = Convert.ToString(EmpNo.GetValue(Req_Emp_DeptDetails, null));
                PropertyInfo EmpEmail = t.GetProperty("EmployeeEmail");
                lblEmpEmail.Text = Convert.ToString(EmpEmail.GetValue(Req_Emp_DeptDetails, null));

                PropertyInfo DeptName = t.GetProperty("DepName");
                lblDeptName.Text = Convert.ToString(DeptName.GetValue(Req_Emp_DeptDetails, null));
                PropertyInfo DeptCode = t.GetProperty("DepID");
                lblDeptCode.Text = Convert.ToString(DeptCode.GetValue(Req_Emp_DeptDetails, null));
                PropertyInfo reason=t.GetProperty("ReqReason");
                txtReason.Text = Convert.ToString(reason.GetValue(Req_Emp_DeptDetails, null));

                PropertyInfo status= t.GetProperty("ReqStatus");
                string searchStatus = Convert.ToString(status.GetValue(Req_Emp_DeptDetails, null));
                if (searchStatus == "approved")
                {
                    btnConfirmRequisition.Enabled = false;
                    btnRejectRequisition.Enabled = false;
                    txtReason.Enabled = false;
                    PanelApprove.Visible = true;
                }

                loadItemGridViewData(QueryStringReqID);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            bool isTempHead = false;
            RegistrationService rser = new RegistrationService();
            string userId = HttpContext.Current.User.Identity.Name;
            isTempHead = rser.IsTempDepHead(userId);

            if ((HttpContext.Current.User.IsInRole("Department Head") != true) && (isTempHead != true))
            {
                Response.Redirect("/Presentation/Login.aspx");

            }

            _EmployeeService = new EmployeeService();
            _DepartmentService = new DepartmentService();

            if (!IsPostBack)
            {
                int i = Convert.ToInt32(Session["userid"].ToString());
                currentEmployee = new employee();
                currentEmployee = _EmployeeService.GetEmployeeDetailsByEmpID(i);

                if (currentEmployee!=null)
                {
                    int DepID = currentEmployee.EmployeeDepId ?? default(int);
                    currentDepartment = new department();
                    currentDepartment = _DepartmentService.GetdepartmentDetailsByDeptID(DepID);

                    lblDeptName.Text = currentDepartment.DepName;
                    txtDeptContactName.Text = currentDepartment.DepContactName;
                    txtDeptContactNum.Text = currentDepartment.DepContactNumber.ToString();
                    lblCurrentDeptRep.Text = currentDepartment.DepRepName;

                }
                else
                {
                    PanelError.Visible = true;
                }

                int curdeptID = currentEmployee.EmployeeDepId ?? default(int);
                employeeList = new List<employee>();
                employeeList = _EmployeeService.GetEmployeeDetailsByDeptID(curdeptID, i);

                if (employeeList!=null)
                {
                    ddlDeptRep.DataSource = employeeList;
                    ddlDeptRep.DataTextField = "EmployeeName";
                    ddlDeptRep.DataValueField = "EmployeeID";
                    ddlDeptRep.DataBind();
                }
                else
                {
                    PanelError.Visible = true;
                }
                ddlCollectionID.SelectedValue = currentDepartment.DepCollectionPointID.ToString();
            }
        }
Beispiel #7
0
        protected void btn_Login_Click(object sender, EventArgs e)
        {
            RegistrationService rservice = new RegistrationService();
            string username = txt_Username.Text;
            string password = txt_Password.Text;
            string storeclerk = "Store Clerk";
            string storemanager = "Store Manager";
            string storesupervisor = "Store Supervisor";
            string dephead = "Department Head";
            string depemployee = "Department Employee";
            string[] roles;
            HttpCookie usercookie = new HttpCookie("usercookie");
            if (Membership.ValidateUser(username, password))
            {

                FormsAuthentication.SetAuthCookie(txt_Username.Text, false);
                bool ans;

                //ans=User.IsInRole(storeclerk);

                ans = Roles.IsUserInRole(storeclerk);

                roles = Roles.GetRolesForUser(txt_Username.Text);
                string role = roles[0];

                if (role == dephead)
                {
                    usercookie.Value = rservice.getusernameofemp(username);
                    Response.Cookies.Add(usercookie);
                    Session["userid"] = rservice.getUserIDofemp(username);
                    Response.Redirect("/Presentation/Department/RequisitionList_haead.aspx");

                }
                else if (role == depemployee)
                {
                    bool ans1 = false;
                    bool ans2 = false;
                    usercookie.Value = rservice.getusernameofemp(username);
                    Response.Cookies.Add(usercookie);
                    Session["userid"] = rservice.getUserIDofemp(username);
                    ans1 = rservice.IsDepRep(username);
                    ans2 = rservice.IsTempDepHead(username);
                    if ((ans1 == false) && (ans2 == false))
                    {
                        Response.Redirect("/Presentation/Department/RequestStationery_Emp.aspx");
                    }
                    else if (ans2 == true)
                    {
                        Response.Redirect("/Presentation/Department/RequisitionList_haead.aspx");

                    }
                    else
                    {
                        Response.Redirect("/Presentation/Department/RequestStationery_DepRep.aspx");

                    }

                }

                else if (role == storeclerk)
                {
                    usercookie.Value = rservice.getusernameofStoreEmp(username);
                    Response.Cookies.Add(usercookie);
                    Session["userid"] = rservice.getUserIDofStoreEmp(username);
                    Response.Redirect("/Presentation/Store/StationeryRetrieveal_Emp.aspx");

                }
                else if (role == storesupervisor)
                {
                    usercookie.Value = rservice.getusernameofStoreEmp(username);
                    Response.Cookies.Add(usercookie);
                    Session["userid"] = rservice.getUserIDofStoreEmp(username);
                    Response.Redirect("/Presentation/Store/ViewAdjustmentVoucherListBySupervisor.aspx");

                }
                else if (role == storemanager)
                {
                    usercookie.Value = rservice.getusernameofStoreEmp(username);
                    Response.Cookies.Add(usercookie);
                    Session["userid"] = rservice.getUserIDofStoreEmp(username);
                    Response.Redirect("/Presentation/Store/ViewAdjustmentVoucherListBySupervisor.aspx");

                }
            }
            else
            {
                statusdiv.Visible = true;
                lbl_status.InnerText = "Username or Password is incorrect, please try again";

            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            bool isTempHead = false;
            RegistrationService rser = new RegistrationService();
            string userId = HttpContext.Current.User.Identity.Name;
            isTempHead=rser.IsTempDepHead(userId);

            if ((HttpContext.Current.User.IsInRole("Department Head") != true) && (isTempHead != true))
            {
                Response.Redirect("/Presentation/Login.aspx");

            }

            _EmployeeService = new EmployeeService();
            _DepartmentService = new DepartmentService();
            _DelegationService = new DelegationService();

            if (!IsPostBack)
            {
                #region ** ClearAll
                ClearNewAllData();
                BtnEnable(false);
                #endregion

                #region ** DataBind for ddl with DeptID
                int LoginId = Convert.ToInt32(Session["userid"].ToString());

                currentEmp = new employee();
                currentEmp = _EmployeeService.GetEmployeeDetailsByEmpID(LoginId);

                int curdeptID = currentEmp.EmployeeDepId ?? default(int);
                employeeList = new List<employee>();
                employeeList = _EmployeeService.GetEmployeeDetailsByDeptID(curdeptID, LoginId);
                ddlEmpName.DataSource = employeeList;
                ddlEmpName.DataBind();
                #endregion

                searchDelegation();
            }
        }