Ejemplo n.º 1
0
    protected void Submit_Click(object sender, EventArgs e)
    {
        var query = ConfigurationManager.AppSettings["qryGetUserDetails"];
        var aUser = new User
        {
            LoginName     = txtUserName.Text.Trim(),
            LoginPassword = txtPassword.Text.Trim()
        };

        query = SqlHandler.AddConditionToQuery(query, new List <string> {
            "LoginName='" + aUser.LoginName + "'", "LoginPassword='******'"
        });
        var user = UserRepository.GetUser(query, ConfigurationManager.AppSettings["rmapGetUserDetails"]);

        if (user != null)
        {
            var jsonUser   = new JavaScriptSerializer().Serialize(user);
            var httpCookie = Response.Cookies["user"];
            if (httpCookie != null)
            {
                httpCookie.Value = jsonUser;
            }
            Response.Redirect("Default.aspx");
        }
        else
        {
            divMessage.Visible = true;
        }
    }
Ejemplo n.º 2
0
    void UpdatePanCard()
    {
        var panCardId = GetPanCardIdFromQueryString();

        if (string.IsNullOrEmpty(panCardId))
        {
            return;
        }
        var query = ConfigurationManager.AppSettings["qryUpdatePanCardDetails"];

        query = SqlHandler.AddConditionToQuery(query, new List <string> {
            "ID=" + panCardId
        });
        var panCard = GetPanCardValuesFromControls();

        panCard.ClientId = CurrentUser.UserRole.Role.ToLower() == "admin" ? Convert.ToInt32(ddlClient.SelectedValue) : GetPancardDetailsById().ClientId;
        var result = PanCardRepository.UpdatePanCard(query, panCard);

        divMessage.Visible = true;
        if (result != 0)
        {
            divMessage.Attributes["class"] = "bg-success";
            divMessage.InnerHtml           = "Updated!";
            hlPanImage.Text        = panCard.FilePath;
            hlPanImage.NavigateUrl = "PanCardImages/" + panCard.FilePath;
        }
        else
        {
            divMessage.Attributes["class"] = "bg-warning";
            divMessage.InnerHtml           = "Updated failed";
        }
    }
Ejemplo n.º 3
0
    void UpdateUser()
    {
        var userId = GetUserIdFromQueryString();

        if (string.IsNullOrEmpty(userId))
        {
            return;
        }
        var query = ConfigurationManager.AppSettings["qryUpdateUserDetails"];

        query = SqlHandler.AddConditionToQuery(query, new List <string> {
            "ID=" + userId
        });
        var user   = GetUserDetailsFromControls();
        var result = UserRepository.UpdateUser(query, user);

        divMessage.Visible = true;
        if (result != 0)
        {
            divMessage.Attributes["class"] = "bg-success";
            divMessage.InnerHtml           = "Updated!";
        }
        else
        {
            divMessage.Attributes["class"] = "bg-warning";
            divMessage.InnerHtml           = "Updated failed";
        }
    }
Ejemplo n.º 4
0
    protected IEnumerable <PanCard> GetAllPanCardDetails()
    {
        var query = ConfigurationManager.AppSettings["qryGetAllPanCardDetails"];

        if (CurrentUser.UserRole.Role.ToLower() != "admin")
        {
            query = SqlHandler.AddConditionToQuery(query, new List <string> {
                "p.CreatedById=" + CurrentUser.Id + " OR clientId=" + CurrentUser.Id
            });
        }
        return(PanCardRepository.GetAllPanCards(query, ConfigurationManager.AppSettings["rmapGetAllPanCardDetails"]));
    }
Ejemplo n.º 5
0
    User GetUserById()
    {
        var userId = GetUserIdFromQueryString();

        if (string.IsNullOrEmpty(userId))
        {
            return(null);
        }
        var query = ConfigurationManager.AppSettings["qryGetUserDetails"];

        query = SqlHandler.AddConditionToQuery(query, new string[] { "Users.ID=" + userId });
        return(UserRepository.GetUser(query, ConfigurationManager.AppSettings["rmapGetUserDetails"]));
    }
Ejemplo n.º 6
0
    protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        var index = e.RowIndex;
        var row   = grvUsers.Rows[index];
        var label = row.FindControl("lblId") as Label;

        if (label != null)
        {
            var id         = Convert.ToInt32(label.Text);
            var query      = ConfigurationManager.AppSettings["qryDeleteUser"];
            var conditions = new List <string> {
                "ID=" + id
            };
            query = SqlHandler.AddConditionToQuery(query, conditions);
            UserRepository.UpdateUser(query, CurrentUser);
        }
        LoadUserGrid(0);
        ClientScript.RegisterClientScriptBlock(GetType(), "IsGridViewAction", "var isGridViewAction = true;", true);
    }
Ejemplo n.º 7
0
    protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        var index = e.RowIndex;
        var row   = grvPanDetails.Rows[index];
        var label = row.FindControl("lblId") as Label;

        if (label != null)
        {
            var id         = Convert.ToInt32(label.Text);
            var query      = ConfigurationManager.AppSettings["qryDeletePanCardDetails"];
            var conditions = new List <string> {
                "ID=" + id
            };
            query = SqlHandler.AddConditionToQuery(query, conditions);
            PanCardRepository.UpdatePanCard(query, new PanCard {
                UpdatedById = CurrentUser.Id
            });
        }
        grvPanDetails.BindGridView(GetPanCardDetailsBySearchTerms(), PageSize, 0, _columnIndexesToHide);
    }
Ejemplo n.º 8
0
    protected IEnumerable <PanCard> GetPanCardDetailsBySearchTerms()
    {
        var query      = ConfigurationManager.AppSettings["qryGetAllPanCardDetails"];
        var conditions = new List <string> ();

        if (chkApplicationNumber.Checked && txtApplicationNumber.Text.Trim() != "")
        {
            conditions.Add("ApplicationNumber='" + txtApplicationNumber.Text + "'");
        }
        if (chkName.Checked && txtName.Text.Trim() != "")
        {
            conditions.Add("CustomerName like '%" + txtName.Text + "%'");
        }
        if (chkDateOfBirth.Checked && dtDateOfBirth.Text.Trim() != "")
        {
            var dateOfBirth = DateTime.ParseExact(dtDateOfBirth.Text.Trim(), "dd/mm/yyyy", CultureInfo.InvariantCulture);
            conditions.Add("DateOfBirth=#" + dateOfBirth.ToString("yyyy/mm/dd") + "#");
        }
        if (chkFatherName.Checked && txtFatherName.Text.Trim() != "")
        {
            conditions.Add("FatherName like '%" + txtFatherName.Text + "%'");
        }
        if (chkPanEntryDate.Checked && dtPanEntryDate.Text.Trim() != "")
        {
            var panEntryDate = DateTime.ParseExact(dtPanEntryDate.Text.Trim(), "dd/mm/yyyy", CultureInfo.InvariantCulture);
            conditions.Add("datevalue(PanEntryDate)=#" + panEntryDate.ToString("yyyy/mm/dd") + "#");
        }
        if (CurrentUser.UserRole.Role.ToLower() == "admin" && chkClient.Checked)
        {
            conditions.Add("p.ClientId=" + ddlClient.SelectedItem.Value);
        }
        if (CurrentUser.UserRole.Role.ToLower() != "admin")
        {
            conditions.Add("(p.CreatedById=" + CurrentUser.Id + "OR clientId=" + CurrentUser.Id + ")");
        }
        query = SqlHandler.AddConditionToQuery(query, conditions);
        return(PanCardRepository.GetAllPanCards(query, ConfigurationManager.AppSettings["rmapGetAllPanCardDetails"]));
    }
    protected void Change_Click(object sender, EventArgs e)
    {
        var query = ConfigurationManager.AppSettings["qryChangePassword"].ToString();

        query = SqlHandler.AddConditionToQuery(query, new List <string> {
            "Id=" + CurrentUser.Id
        });
        var result = UserRepository.UpdateUser(query, new Model.User {
            LoginPassword = txtNewPassword.Text
        });

        divMessage.Visible = true;
        if (result != 0)
        {
            divMessage.Attributes["class"] = "bg-success";
            divMessage.InnerHtml           = "Password has been changed!";
            ClearControls();
        }
        else
        {
            divMessage.Attributes["class"] = "bg-warning";
            divMessage.InnerHtml           = "Error occurred!";
        }
    }