コード例 #1
0
ファイル: New.aspx.cs プロジェクト: sgk-gh/pancard-management
    protected void Submit_Click(object sender, EventArgs e)
    {
        var query = ConfigurationManager.AppSettings["qryInsertPanCardDetails"];
        var id    = PanCardRepository.InsertPanCard(query, new PanCard
        {
            ApplicationNumber = txtApplicationNumber.Text,
            CouponNumber      = txtCouponNumber.Text,
            CustomerName      = txtName.Text,
            DateOfBirth       = DateTime.ParseExact(txtDateOfBirth.Text.Trim(), "dd/MM/yyyy", CultureInfo.InvariantCulture).Date,
            FatherName        = txtFatherName.Text,
            FilePath          = UploadAndGetPanCardImageFilePath(),
            PanEntryDate      = DateTime.Now,
            CreatedById       = CurrentUser.Id,
            ClientId          = CurrentUser.UserRole.Role.ToLower() == "admin" ? Convert.ToInt32(ddlClient.SelectedValue) : CurrentUser.Id
        });

        //Response.Redirect("Default.aspx");
        divMessage.Visible = true;
        if (id != 0)
        {
            divMessage.Attributes["class"] = "bg-success";
            divMessage.InnerHtml           = "New Pan Card added!";
            ClearControls();
        }
        else
        {
            divMessage.Attributes["class"] = "bg-warning";
            divMessage.InnerHtml           = "Error occurred!";
        }
    }
コード例 #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";
        }
    }
コード例 #3
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"]));
    }
コード例 #4
0
    PanCard GetPancardDetailsById()
    {
        var panCardId = GetPanCardIdFromQueryString();

        if (string.IsNullOrEmpty(panCardId))
        {
            return(null);
        }
        var query = string.Format(ConfigurationManager.AppSettings["qryGetPanCardDetails"], panCardId);

        return(PanCardRepository.GetPanCard(query, ConfigurationManager.AppSettings["rmapGetAllPanCardDetails"]));
    }
コード例 #5
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);
    }
コード例 #6
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"]));
    }