示例#1
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (btnAdd.Text == "Add")
            {

                objEmployee.FirstName = txtFname.Text;
                objEmployee.LastName = txtLname.Text;
                objEmployee.Email = txtEmail.Text;
                objEmployee.USER = new User();
                objEmployee.USER.Username = txtUsename.Text;
                objEmployee.USER.Password = txtPassword.Text;
                objEmployee.USER.Role = ddlrole.SelectedItem.Text;
                objEmployee.password = txtPassword.Text;
                objEmployee.Username = txtUsename.Text;
                objEmployee.status = ddlstatus.SelectedValue;
                objEmployee.title = txttitle.Text;
                objEmployee.department = ddlDepartment.Text;

                EmployeeServices addEmployee1 = new EmployeeServices();

                string returnstr = addEmployee1.addEmployee(objEmployee);

                if (returnstr == "Success")
                {
                    pnlmsg.Visible = true;
                    lblerror.Text = "";

                    pnltext.Visible = false;
                }
                else
                {
                    lblerror.Text = returnstr;
                    pnlmsg.Visible = false;

                    pnltext.Visible = true;
                }

            }
            else
            {

                empdao.UserIdEmp = intempid;
                objEmployee.EmployeeId = Convert.ToString(intempid);
                objEmployee.FirstName = txtFname.Text;
                objEmployee.LastName = txtLname.Text;
                objEmployee.Email = txtEmail.Text;
                objEmployee.USER = new User();
                objEmployee.USER.Username = txtUsename.Text;
                objEmployee.USER.Password = txtPassword.Text;
                objEmployee.USER.Role = ddlrole.SelectedValue;

                objEmployee.Username = txtUsename.Text;

                objEmployee.password = txtPassword.Text;
                objEmployee.status = ddlstatus.SelectedValue;
                objEmployee.role = ddlrole.Text;
                objEmployee.title = txttitle.Text;
                EmployeeServices addEmployee1 = new EmployeeServices();
                string returnstr = addEmployee1.updateEmployee(objEmployee);

                if (returnstr == "Success")
                {
                    pnlmsg.Visible = true;
                    lblerror.Text = "";

                    pnltext.Visible = false;
                }
                else
                {
                    lblerror.Text = returnstr;
                    pnlmsg.Visible = false;

                    pnltext.Visible = true;
                }

            }
        }
示例#2
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string userName = txtUsername.Text.Trim().ToUpper();
            string passWord = txtPassword.Text.Trim();
            UserServices userService = new UserServices();
            string returnString = userService.ValidateUser(userName, passWord);

            if (IdProConstants.SUCCESS.Equals(returnString))
            {
                User user = new User();
                user = userService.getUserbyUserName(userName);

                EmployeeServices employeeService = new EmployeeServices();

                Employee employee = new Employee();

                employee = employeeService.getEmployeeByUserName(userName);

                if (user == null || employee == null)
                {
                    returnString = IdProConstants.ADMIN;
                }
                //else if (UserStatusesConstants.INACTIVEEMPLOYEE.Equals(employee.getEmployeeStatus()))
                //{
                //    returnString = TransactionConfirmMessages.INACTIVEUSER;
                //}
                else
                {
                    string role = user.getRole().Trim();
                    Session["role"] = role;
                    Session["username"] = user.getUserName().Trim();

                    Session["name"] = employee.getFirstName();

                    FormsAuthenticationTicket tkt = default(FormsAuthenticationTicket);
                    string cookiestr = null;
                    System.Web.HttpCookie ck = default(System.Web.HttpCookie);

                    tkt = new FormsAuthenticationTicket(1, txtUsername.Text, DateTime.Now, DateTime.Now.AddMinutes(30), false, role);
                    cookiestr = FormsAuthentication.Encrypt(tkt);
                    ck = new System.Web.HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);

                    ck.Path = FormsAuthentication.FormsCookiePath;
                    Response.Cookies.Add(ck);

                    string strRedirect = null;
                    strRedirect = Request["ReturnURL"];
                    if (!string.IsNullOrEmpty(strRedirect) & strRedirect != "/")
                    {
                        Response.Redirect(strRedirect, true);
                    }
                    else
                    {
                        strRedirect = "ManageEmployee.aspx";
                        Response.Redirect(strRedirect, true);
                    }

                }
            }
            lblMsg.Text = returnString;
        }