Ejemplo n.º 1
0
    protected void FillGrid()
    {
        Organisation org = IsValidFormOrgID() ? OrganisationDB.GetByID(GetFormOrgID()) : null;

        if (!IsValidFormOrgID())
        {
            lblHeading.Text = "Maintain Letters";
        }
        else if (org == null)
        {
            lblHeading.Text = "Maintain Default Letters";
        }
        else
        {
            lblHeading.Text         = "Maintain Letters For ";
            lnkToEntity.Text        = org.Name;
            lnkToEntity.NavigateUrl = "OrganisationDetailV2.aspx?type=view&id=" + org.OrganisationID;
        }

        DataTable dt = IsValidFormOrgID() ? LetterDB.GetDataTable_ByOrg(GetFormOrgID(), GetFormOrgID() == 0 ? Convert.ToInt32(Session["SiteID"]) : -1) : LetterDB.GetDataTable(Convert.ToInt32(Session["SiteID"]));

        Session["letter_data"] = dt;

        if (dt.Rows.Count > 0)
        {
            if (IsPostBack && Session["letter_sortexpression"] != null && Session["letter_sortexpression"].ToString().Length > 0)
            {
                DataView dataView = new DataView(dt);
                dataView.Sort        = Session["letter_sortexpression"].ToString();
                GrdLetter.DataSource = dataView;
            }
            else
            {
                GrdLetter.DataSource = dt;
            }


            try
            {
                GrdLetter.DataBind();
            }
            catch (Exception ex)
            {
                HideTableAndSetErrorMessage("", ex.ToString());
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdLetter.DataSource = dt;
            GrdLetter.DataBind();

            int TotalColumns = GrdLetter.Rows[0].Cells.Count;
            GrdLetter.Rows[0].Cells.Clear();
            GrdLetter.Rows[0].Cells.Add(new TableCell());
            GrdLetter.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdLetter.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }
    protected void PopulateLettersList()
    {
        DataTable letters = LetterDB.GetDataTable_ByOrg(0, Convert.ToInt32(Session["SiteID"]));

        // remove ones that dont exists
        for (int i = letters.Rows.Count - 1; i >= 0; i--)
        {
            Letter letter = LetterDB.LoadAll(letters.Rows[i]);
            if (!letter.FileExists(Convert.ToInt32(Session["SiteID"])))
            {
                letters.Rows.RemoveAt(i);
            }
        }

        lstLetters.DataSource     = letters;
        lstLetters.DataTextField  = "letter_docname";
        lstLetters.DataValueField = "letter_letter_id";
        lstLetters.DataBind();
    }
Ejemplo n.º 3
0
    protected void PopulateLettersList()
    {
        UserView userView = UserView.GetInstance();

        int orgID = (txtUpdateOrganisationID.Text.Length == 0) ? 0 : Convert.ToInt32(txtUpdateOrganisationID.Text);

        if (orgID == 0 && !userView.IsAdminView)
        {
            orgID = Convert.ToInt32(Session["OrgID"]);
        }
        bool      usingDeafultLetters = orgID == 0 || chkUseDefaultDocs.Checked; // || !LetterDB.OrgHasdocs(orgID);
        DataTable letters             = LetterDB.GetDataTable_ByOrg(usingDeafultLetters ? 0 : orgID, usingDeafultLetters ? Convert.ToInt32(Session["SiteID"]) : -1);

        lblSpaceBeforeUseDefaultDocsCheckbox.Visible = orgID != 0;
        chkUseDefaultDocs.Visible                    = orgID != 0;
        chkUseDefaultDocs.ForeColor                  = System.Drawing.Color.DarkOrchid;
        lblDefaultOrOrgSpecificDocs.Visible          = orgID == 0;
        lblSpaceBeforeUseDefaultDocsCheckbox.Visible = orgID == 0;
        if (usingDeafultLetters)
        {
            SetLabel(lblDefaultOrOrgSpecificDocs, "**Using Default Docs", System.Drawing.Color.Blue, false);
        }
        else
        {
            SetLabel(lblDefaultOrOrgSpecificDocs, "**Using Organisation Specific Docs", System.Drawing.Color.DarkOrchid, false);
        }

        // remove ones that dont exists
        for (int i = letters.Rows.Count - 1; i >= 0; i--)
        {
            Letter letter = LetterDB.LoadAll(letters.Rows[i]);
            if (!letter.FileExists(Convert.ToInt32(Session["SiteID"])))
            {
                letters.Rows.RemoveAt(i);
            }
        }

        lstLetters.DataSource     = letters;
        lstLetters.DataTextField  = "letter_docname";
        lstLetters.DataValueField = "letter_letter_id";
        lstLetters.DataBind();
    }
Ejemplo n.º 4
0
    protected void GrdTreatmentTemplateLetters_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        DataTable fields  = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Field", "field_id <> 0 AND has_offerings = 1", "descr", "field_id", "descr");
        DataTable letters = LetterDB.GetDataTable_ByOrg(0, Convert.ToInt32(Session["SiteID"]));

        DataTable dt = Session["treatment_template_letters_data"] as DataTable;

        bool tblEmpty = (dt.Rows.Count == 1 && dt.Rows[0][0] == DBNull.Value);

        // remove offering flds that are used
        if (!tblEmpty)
        {
            foreach (DataRow row in dt.Rows)
            {
                for (int i = 0; i < fields.Rows.Count; i++)
                {
                    if (Convert.ToInt32(fields.Rows[i]["field_id"]) == Convert.ToInt32(row["lettertreatmenttemplate_field_id"]))
                    {
                        fields.Rows.RemoveAt(i);
                    }
                }
            }
        }


        if (!tblEmpty && e.Row.RowType == DataControlRowType.DataRow)
        {
            bool      hasData   = dt.Rows[0][0].ToString() != string.Empty;
            Label     lblId     = (Label)e.Row.FindControl("lblId");
            DataRow[] foundRows = dt.Select("lettertreatmenttemplate_letter_treatment_template_id=" + lblId.Text);
            DataRow   thisRow   = foundRows[0];

            DropDownList ddlField = (DropDownList)e.Row.FindControl("ddlField");
            if (ddlField != null)
            {
                ddlField.DataSource     = fields;
                ddlField.DataTextField  = "descr";
                ddlField.DataValueField = "field_id";
                ddlField.DataBind();
                ddlField.SelectedValue = thisRow["lettertreatmenttemplate_field_id"].ToString();
            }

            DropDownList ddlFirstLetter = (DropDownList)e.Row.FindControl("ddlFirstLetter");
            if (ddlFirstLetter != null)
            {
                ddlFirstLetter.DataSource     = letters;
                ddlFirstLetter.DataTextField  = "letter_docname";
                ddlFirstLetter.DataValueField = "letter_letter_id";
                ddlFirstLetter.DataBind();
                ddlFirstLetter.SelectedValue = thisRow["lettertreatmenttemplate_first_letter_id"].ToString();
            }

            DropDownList ddlTreatmentNoteLetter = (DropDownList)e.Row.FindControl("ddlTreatmentNoteLetter");
            if (ddlTreatmentNoteLetter != null)
            {
                ddlTreatmentNoteLetter.DataSource     = letters;
                ddlTreatmentNoteLetter.DataTextField  = "letter_docname";
                ddlTreatmentNoteLetter.DataValueField = "letter_letter_id";
                ddlTreatmentNoteLetter.DataBind();
                ddlTreatmentNoteLetter.SelectedValue = thisRow["lettertreatmenttemplate_treatment_notes_letter_id"].ToString();
            }

            DropDownList ddlLastLetter = (DropDownList)e.Row.FindControl("ddlLastLetter");
            if (ddlLastLetter != null)
            {
                ddlLastLetter.DataSource     = letters;
                ddlLastLetter.DataTextField  = "letter_docname";
                ddlLastLetter.DataValueField = "letter_letter_id";
                ddlLastLetter.DataBind();
                ddlLastLetter.SelectedValue = thisRow["lettertreatmenttemplate_last_letter_id"].ToString();
            }

            DropDownList ddlLastLetterPT = (DropDownList)e.Row.FindControl("ddlLastLetterPT");
            if (ddlLastLetterPT != null)
            {
                ddlLastLetterPT.DataSource     = letters;
                ddlLastLetterPT.DataTextField  = "letter_docname";
                ddlLastLetterPT.DataValueField = "letter_letter_id";
                ddlLastLetterPT.DataBind();
                ddlLastLetterPT.SelectedValue = thisRow["lettertreatmenttemplate_last_letter_pt_id"].ToString();
            }

            DropDownList ddlLastLetterWhenReplacingEPC = (DropDownList)e.Row.FindControl("ddlLastLetterWhenReplacingEPC");
            if (ddlLastLetterWhenReplacingEPC != null)
            {
                ddlLastLetterWhenReplacingEPC.DataSource     = letters;
                ddlLastLetterWhenReplacingEPC.DataTextField  = "letter_docname";
                ddlLastLetterWhenReplacingEPC.DataValueField = "letter_letter_id";
                ddlLastLetterWhenReplacingEPC.DataBind();
                ddlLastLetterWhenReplacingEPC.SelectedValue = thisRow["lettertreatmenttemplate_last_letter_when_replacing_epc_id"].ToString();
            }


            Utilities.AddConfirmationBox(e);
            if ((e.Row.RowState & DataControlRowState.Edit) > 0)
            {
                Utilities.SetEditRowBackColour(e, System.Drawing.Color.LightGoldenrodYellow);
            }
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            if (fields.Rows.Count == 0)
            {
                if (GrdTreatmentTemplateLetters.FooterRow != null)
                {
                    GrdTreatmentTemplateLetters.FooterRow.Visible = false;
                }
                hideFotter = true;
            }
            else
            {
                DropDownList ddlField = (DropDownList)e.Row.FindControl("ddlNewField");
                ddlField.DataSource     = fields;
                ddlField.DataTextField  = "descr";
                ddlField.DataValueField = "field_id";
                ddlField.DataBind();

                DropDownList ddlFirstLetter = (DropDownList)e.Row.FindControl("ddlNewFirstLetter");
                ddlFirstLetter.DataSource     = letters;
                ddlFirstLetter.DataTextField  = "letter_docname";
                ddlFirstLetter.DataValueField = "letter_letter_id";
                ddlFirstLetter.DataBind();

                DropDownList ddlTreatmentNoteLetter = (DropDownList)e.Row.FindControl("ddlNewTreatmentNoteLetter");
                ddlTreatmentNoteLetter.DataSource     = letters;
                ddlTreatmentNoteLetter.DataTextField  = "letter_docname";
                ddlTreatmentNoteLetter.DataValueField = "letter_letter_id";
                ddlTreatmentNoteLetter.DataBind();

                DropDownList ddlLastLetter = (DropDownList)e.Row.FindControl("ddlNewLastLetter");
                ddlLastLetter.DataSource     = letters;
                ddlLastLetter.DataTextField  = "letter_docname";
                ddlLastLetter.DataValueField = "letter_letter_id";
                ddlLastLetter.DataBind();

                DropDownList ddlLastLetterPT = (DropDownList)e.Row.FindControl("ddlNewLastLetterPT");
                ddlLastLetterPT.DataSource     = letters;
                ddlLastLetterPT.DataTextField  = "letter_docname";
                ddlLastLetterPT.DataValueField = "letter_letter_id";
                ddlLastLetterPT.DataBind();

                DropDownList ddlLastLetterWhenReplacingEPC = (DropDownList)e.Row.FindControl("ddlNewLastLetterWhenReplacingEPC");
                ddlLastLetterWhenReplacingEPC.DataSource     = letters;
                ddlLastLetterWhenReplacingEPC.DataTextField  = "letter_docname";
                ddlLastLetterWhenReplacingEPC.DataValueField = "letter_letter_id";
                ddlLastLetterWhenReplacingEPC.DataBind();
            }
        }
    }