Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["LoginName"] = "ADMINISTRATOR";
            bool boolDecodeError = false;

            try
            {
                if (Session["LoginName"] == null || Session["LoginName"].ToString() == string.Empty)
                {
                    Session["SessionExpire"] = true;
                    //Response.Redirect("~/Mainpage.aspx", false);
                    //return;
                }

                if (!Page.IsPostBack)
                {
                    string strRecentPage = (lblHead.Text.Trim() + "-" + DateTime.Now.ToString("dd/MMM/yyyy hh:mm:ss tt")).ToString();
                    oUserBLL.InsertUserActivityDetails(strRecentPage, Session["LoginName"].ToString());

                    #region Permission Control added by Renu 11/06/2019
                    int pageID = 16;
                    int rights = oCommonDAL.GetPermissions(pageID, Convert.ToInt32(Session["UserRecNo"]));
                    if (rights >= 0)
                    {
                        vsIntRights = rights;
                        if (vsIntRights == 0)
                        {
                            btnSave.Visible   = false;
                            btnUpdate.Visible = false;
                        }
                        else
                        {
                            btnSave.Visible   = true;
                            btnUpdate.Visible = false;
                        }
                    }
                    else
                    {
                        //Access denied
                        Response.Redirect("~/AccessDenied.aspx", false);
                    }
                    #endregion
                    //oUserBLL.GetSIDCODistrict(ddlDistrict);

                    oUserBLL.BindRole(ddlRole);
                    oUserBLL.BindDivision(ddlDivision);
                    if (Request.QueryString["md"] != null && Request.QueryString["md"].ToString() != string.Empty)
                    {
                        string mode = oCommonDAL.DecodeString(Request.QueryString["md"].ToString());
                        boolDecodeError = false;

                        if (mode == "VIEW")
                        {
                            boolDecodeError = true;
                            vsIntUserRecNo  = Convert.ToInt32(oCommonDAL.DecodeString(Request.QueryString["rn"].ToString()));
                            boolDecodeError = false;

                            DisplayUserInfo(vsIntUserRecNo);

                            btnCancel.Text    = "Close";
                            lblHead.Text      = "View User";
                            btnSave.Visible   = false;
                            btnClear.Visible  = false;
                            btnUpdate.Visible = false;
                            DisableControls();
                        }
                        else if (mode == "ADD")
                        {
                            btnSave.Visible   = true;
                            btnUpdate.Visible = false;
                            lblHead.Text      = "Add User";
                        }
                        else if (mode == "EDIT")
                        {
                            boolDecodeError = true;
                            vsIntUserRecNo  = Convert.ToInt32(oCommonDAL.DecodeString(Request.QueryString["rn"].ToString()));
                            boolDecodeError = false;

                            btnSave.Visible   = false;
                            btnUpdate.Visible = true;
                            DisplayUserInfo(vsIntUserRecNo);
                            lblHead.Text     = "Edit User";
                            btnClear.Visible = false;
                        }
                    }
                    else
                    {
                        // Response.Redirect("~/SessionOut.aspx", false);
                    }
                }
            }
            catch (Exception ex)
            {
                if (boolDecodeError == true)
                {
                    string title = "Message from System";
                    string msg   = "Something Wrong Happened.please try again.In case you face similar issue please contact our help desk Emailid: [email protected]";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "Message('" + title + "','btn-danger','" + msg + "');", true);

                    String FUNCTION_NAME = "Page_Load";
                    String MODULE_NAME   = "AddUsers";
                    String ERROR_TYPE    = "Application";
                    String ERROR_DESC    = ex.Message;
                    string lineNumber    = ex.StackTrace.Substring(ex.StackTrace.Length - 7, 7);
                    string url           = HttpContext.Current.Request.Url.AbsoluteUri;
                    OAp.InsertException(FUNCTION_NAME, MODULE_NAME, ERROR_TYPE, ERROR_DESC, url, lineNumber);
                }
                else
                {
                    string title = "Message from System";
                    string msg   = "Something Wrong Happened.please try again.In case you face similar issue please contact our help desk Emailid: [email protected]";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "Message('" + title + "','btn-danger','" + msg + "');", true);

                    String FUNCTION_NAME = "Page_Load";
                    String MODULE_NAME   = "AddUsers";
                    String ERROR_TYPE    = "Application";
                    String ERROR_DESC    = ex.Message;
                    string lineNumber    = ex.StackTrace.Substring(ex.StackTrace.Length - 7, 7);
                    string url           = HttpContext.Current.Request.Url.AbsoluteUri;
                    OAp.InsertException(FUNCTION_NAME, MODULE_NAME, ERROR_TYPE, ERROR_DESC, url, lineNumber);
                }
            }
        }
Ejemplo n.º 2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    if (Session["captcha"].ToString() != txtCaptcha.Text)
                    {
                        lblCaptcha.Text      = "Enter Correct Captca Code";
                        lblCaptcha.ForeColor = System.Drawing.Color.Red;
                        Clear();
                        CommonDAL.DisplayPopUpMessage(this, "Please Enter Captca.", "");
                    }
                    else
                    {
                        string username = Request.Form["txtUsername"];
                        string ted      = txtForgetUser.Value.ToString();
                        string DisplayName;
                        string LoginName;
                        string EmailID;
                        string Password;
                        if (txtForgetUser.Value.ToString() != "")
                        {
                            //FOR DIFFERENTCIATE BETWEEN CLIENT USER AND Authority USER(ADDED BY SACHIN 06-09-2015)
                            string   Name       = "Authority";
                            DateTime expiryDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                            ds = oUserBLL.GetForgetPasswordUserInfo(Name, txtForgetUser.Value.ToString().ToLower());
                            if (ds != null)
                            {
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    if (ds.Tables[0].Rows[0]["User_auth"] != DBNull.Value)
                                    {
                                        if (ds.Tables[0].Rows[0]["User_auth"].ToString() == "11")
                                        {
                                            //  CommonDAL.DisplayPopUpMessage(this, "User( " + txtUsername.Value.ToString() + " ) is not authorized for this Portal.Please Check username.", "");
                                            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModalHide", "$('body').removeClass('modal-open');$('.modal-backdrop').remove();$('#AuthorityLogin').hide();", true);
                                            string title = "Message from System";
                                            string msg   = "User( " + txtForgetUser.Value.ToString() + " ) is not authorized for this Portal.Please Check username.";
                                            ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "Message('" + title + "','btn-danger','" + msg + "');", true);
                                        }
                                        else if (ds.Tables[0].Rows[0]["User_auth"].ToString() == "1" || ds.Tables[0].Rows[0]["User_auth"].ToString() == "2")
                                        {
                                            //CommonDAL.DisplayPopUpMessage(this, "Dear User,<br/>Your UserName/Passowrd is Incorrect.<br/><b>Note: Too many bad attempts cause account locks.</b>", "");
                                            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModalHide", "$('body').removeClass('modal-open');$('.modal-backdrop').remove();$('#AuthorityLogin').hide();", true);
                                            string title = "Message from System";
                                            string msg   = "Dear User,<br/>Your UserName/Passowrd is Incorrect.<br/><b>Note: Too many bad attempts cause account locks.</b>";
                                            ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "Message('" + title + "','btn-danger','" + msg + "');", true);
                                        }
                                        else if (ds.Tables[0].Rows[0]["User_auth"].ToString() == "0")
                                        {
                                            CommonDAL.DisplayPopUpMessage(this, "Dear User,<br/>your account is locked.Please Contact to system administrator.", "");
                                            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModalHide", "$('body').removeClass('modal-open');$('.modal-backdrop').remove();$('#AuthorityLogin').hide();", true);
                                            string title = "Message from System";
                                            string msg   = "Dear User,<br/>your account is locked.Please Contact to system administrator.";
                                            ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "Message('" + title + "','btn-danger','" + msg + "');", true);
                                        }
                                        else
                                        {
                                            Session["UserRecNo"]   = ds.Tables[0].Rows[0]["USER_RECNO"].ToString();
                                            Session["LoginName"]   = ds.Tables[0].Rows[0]["LOGIN_NAME"].ToString();
                                            Session["DisplayName"] = ds.Tables[0].Rows[0]["DISPLAY_NAME"].ToString();
                                            //  Session["IIE_recno"] = ds.Tables[0].Rows[0]["Ind_area_recno"].ToString();
                                            //  Session["IIEName"] = ds.Tables[0].Rows[0]["Ind_area_name"].ToString();
                                            // Session["District_recno"] = ds.Tables[0].Rows[0]["District_Recno"].ToString();
                                            // Session["District_Name"] = ds.Tables[0].Rows[0]["District_Name"].ToString();
                                            Session["UserType"]  = ds.Tables[0].Rows[0]["ROLE_USER_TYPE"].ToString();
                                            Session["SessionID"] = Session.SessionID + DateTime.Now.ToString();
                                            Session["RoleRecNo"] = ds.Tables[0].Rows[0]["ROLE_RECNO"].ToString();
                                            if (ds != null && ds.Tables[0].Rows.Count > 0)
                                            {
                                                String Action_type = "Passsword Changed";
                                                DisplayName = ds.Tables[0].Rows[0]["DISPLAY_NAME"].ToString().Trim();
                                                LoginName   = ds.Tables[0].Rows[0]["LOGIN_NAME"].ToString().Trim();
                                                EmailID     = ds.Tables[0].Rows[0]["EMAILID"].ToString().Trim();
                                                Password    = ds.Tables[0].Rows[0]["PASSWORD"].ToString().Trim();
                                                GenerateMailFormat(DisplayName, LoginName, EmailID, oCommonDAL.DecodeString(Password), Action_type);

                                                CommonDAL.DisplayPopUpMessage(this, "Your Login Credentials Send to Your Rgistered Mail", "HomePage.aspx");
                                            }
                                            //Response.Redirect("~/HomePage.aspx", false);
                                        }
                                    }
                                }
                                else
                                {
                                    //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModalHide", "$('body').removeClass('modal-open');$('.modal-backdrop').remove();$('#AuthorityLogin').hide();", true);
                                    //string title = "Message from System";
                                    //string msg = "Dear User,<br/>Unable to recognize this user or Something wrong happened";
                                    //ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "Message('" + title + "','btn-danger','" + msg + "');", true);
                                    CommonDAL.DisplayPopUpMessage(this, "Dear User,Unable to recognize this user or Something wrong happened", "");
                                }
                            }
                            else
                            {
                                //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModalHide", "$('body').removeClass('modal-open');$('.modal-backdrop').remove();$('#AuthorityLogin').hide();", true);
                                //string title = "Message from System";
                                //string msg = "Dear User,<br/>Unable to recognize this user or Something wrong happened";
                                //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "Message('" + title + "','btn-danger','" + msg + "');", true);
                                CommonDAL.DisplayPopUpMessage(this, "Dear User,Unable to recognize this user or Something wrong happened", "");
                            }
                        }
                        else
                        {
                            CommonDAL.DisplayPopUpMessage(this, "User( " + txtForgetUser.Value.ToString() + " ) is not authorized for this Portal.Please Check username.", "");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModalHide", "$('body').removeClass('modal-open');$('.modal-backdrop').remove();$('#AuthorityLogin').hide();", true);
                //string title = "Message from System";
                //string msg = "Dear User,<br/>Something wrong happened. Unable to complete login process please try again with correct information.";
                //ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "Message('" + title + "','btn-danger','" + msg + "');", true);
                CommonDAL.DisplayPopUpMessage(this, "Dear User,Something wrong happened. Unable to complete Forget Password process please try again with correct information.", "");

                AppConstants OAp           = new AppConstants();
                String       FUNCTION_NAME = "btnSubmit_Click";
                String       MODULE_NAME   = "ForgetPassword.aspx";
                String       ERROR_TYPE    = "Application";
                String       ERROR_DESC    = ex.Message;
                string       lineNumber    = ex.StackTrace.Substring(ex.StackTrace.Length - 7, 7);
                string       url           = HttpContext.Current.Request.Url.AbsoluteUri;
                OAp.InsertException(FUNCTION_NAME, MODULE_NAME, ERROR_TYPE, ERROR_DESC, url, lineNumber);
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                int    userRecno       = Convert.ToInt32(lblUserId.Text);
                string createdBy       = "";
                string oldpassword     = string.Empty;
                string newpassword     = string.Empty;
                string confirmpassword = string.Empty;
                string DisplayName;
                string LoginName;
                string EmailID;
                string Password;

                if (Session["captcha"].ToString() != txtCaptcha.Text)
                {
                    lblCaptcha.Text      = "Enter Correct Captca Code";
                    lblCaptcha.ForeColor = System.Drawing.Color.Red;
                    Clear();
                    CommonDAL.DisplayPopUpMessage(this, "Please Enter Captca.", "");
                }
                else
                {
                    if (txtOldPassword.Text != "" && txtNewPassword.Text != "" && txtConfirmPassword.Text != "")
                    {
                        if (txtNewPassword.Text == txtConfirmPassword.Text)
                        {
                            oldpassword     = oCommonDAL.EncodeString(txtOldPassword.Text.Trim());
                            newpassword     = oCommonDAL.EncodeString(txtNewPassword.Text.Trim());
                            confirmpassword = oCommonDAL.EncodeString(txtConfirmPassword.Text.Trim());
                            string changepassword = "******";

                            int result = oUserBLL.UpdatePassword(userRecno, oldpassword, newpassword, changepassword, createdBy);

                            if (result > 0)
                            {
                                DataSet ds          = new DataSet();
                                String  Action_type = "Passsword Changed";
                                ds = oUserBLL.GetEmailId(Convert.ToInt32(lblUserId.Text));
                                if (ds != null && ds.Tables[0].Rows.Count > 0)
                                {
                                    DisplayName = ds.Tables[0].Rows[0]["DISPLAY_NAME"].ToString().Trim();
                                    LoginName   = ds.Tables[0].Rows[0]["LOGIN_NAME"].ToString().Trim();
                                    EmailID     = ds.Tables[0].Rows[0]["EMAILID"].ToString().Trim();
                                    Password    = ds.Tables[0].Rows[0]["PASSWORD"].ToString().Trim();
                                    GenerateMailFormat(DisplayName, LoginName, EmailID, oCommonDAL.DecodeString(Password), Action_type);

                                    DisplayPopUpMessage(this, "User Password Changed Successfully and an email has been sent to the user with all Important details.", "Default1.aspx");
                                }
                            }
                            else
                            {
                                string msg = "<script>alert('Old Password is Not Correct')</script>";
                                ScriptManager.RegisterStartupScript(this, typeof(Control), "alertmsg", msg, false);
                            }
                        }

                        else
                        {
                            string msg = "<script>alert('New Password and Confirm Password Need to be Same')</script>";
                            ScriptManager.RegisterStartupScript(this, typeof(Control), "alertmsg", msg, false);
                        }
                    }
                    else
                    {
                        string msg = "<script>alert('All Fields Are need to be filled ')</script>";
                        ScriptManager.RegisterStartupScript(this, typeof(Control), "alertmsg", msg, false);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    if ((Request.QueryString["rn"] != null) && (Request.QueryString["rn"].ToString() != ""))
                    {
                        vsIntUserRecNo = Convert.ToInt32(oCommonDAL.DecodeString(Request.QueryString["rn"].ToString()));

                        if ((Request.QueryString["Role"] != null) && (Request.QueryString["Role"].ToString() != ""))
                        {
                            vsUserRoleRecNo = Convert.ToInt32(oCommonDAL.DecodeString(Request.QueryString["Role"].ToString()));
                        }
                    }
                    else
                    {
                        if ((Request.QueryString["tn"] != null) && (Request.QueryString["tn"].ToString() != ""))
                        {
                            vsIntRoleRecNo = Convert.ToInt32(oCommonDAL.DecodeString(Request.QueryString["tn"].ToString()));
                        }
                        else
                        {
                            Response.Redirect("AssignUserRights.aspx");
                        }
                    }

                    if (Request.QueryString["md"] != null && Request.QueryString["md"].ToString() != string.Empty)
                    {
                        int intPageRights = Convert.ToInt32(oCommonDAL.DecodeString(Request.QueryString["md"].ToString()));
                        intPageRights = 1;

                        if (intPageRights == 1)
                        {
                            tblPageRights.Enabled = true;
                            btnAssign.Enabled     = true;
                        }
                        else if (intPageRights == 0)
                        {
                            tblPageRights.Enabled = false;
                            btnAssign.Enabled     = false;
                            btnCancel.Text        = "Close";
                        }
                        else
                        {
                            tblPageRights.Enabled = false;
                            btnAssign.Enabled     = false;
                            // Response.Redirect("~/UnderConstraction.aspx");
                        }
                    }
                    else
                    {
                        Response.Redirect("UserMaster.aspx");
                    }
                }
                DisplayMenuItems();
            }
            catch (Exception ex)
            {
                string title = "Message from System";
                string msg   = "<p>Dear User</p><br/> <p>Something went wrong. Please try later.</p>";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "Message('" + title + "','btn-danger','" + msg + "');", true);
            }
        }