예제 #1
0
 private static HtmlTableCell FindTdByName(string controlName, HtmlTable tblABM)
 {
     if (tblABM.FindControl("td" + controlName) != null && tblABM.FindControl("td" + controlName) is HtmlTableCell)
     {
         return((HtmlTableCell)tblABM.FindControl("td" + controlName));
     }
     else
     {
         return(null);
     }
 }
예제 #2
0
 private static ucComboBox FindComboBoxByName(string controlName, HtmlTable tblABM)
 {
     if (tblABM.FindControl("uc" + controlName) != null && tblABM.FindControl("uc" + controlName) is ucComboBox)
     {
         return((ucComboBox)tblABM.FindControl("uc" + controlName));
     }
     else
     {
         return(null);
     }
 }
예제 #3
0
 private static ASPxTextBox FindTextBoxByName(string controlName, HtmlTable tblABM)
 {
     if (tblABM.FindControl("tx" + controlName) != null && tblABM.FindControl("tx" + controlName) is ASPxTextBox)
     {
         return((ASPxTextBox)tblABM.FindControl("tx" + controlName));
     }
     else
     {
         return(null);
     }
 }
예제 #4
0
 private static Control FindControlByName(string controlName, HtmlTable tblABM)
 {
     if (tblABM.FindControl(controlName) != null && tblABM.FindControl(controlName) is Control)
     {
         return((Control)tblABM.FindControl(controlName));
     }
     else
     {
         return(null);
     }
 }
예제 #5
0
 private static HtmlTableRow FindTrByName(string controlName, HtmlTable tblABM)
 {
     if (tblABM.FindControl("tr" + controlName) != null && tblABM.FindControl("tr" + controlName) is HtmlTableRow)
     {
         return((HtmlTableRow)tblABM.FindControl("tr" + controlName));
     }
     else
     {
         return(null);
     }
 }
예제 #6
0
    private void Sub(string sysnumber, HtmlTable tb, string ckName, string txtName, ref string strAnswer)
    {
        string[] SelectOpiton = new string[] { "A", "B", "C", "D", "E" };
        for (int i = 0; i <= SelectOpiton.Length; i++)
        {
            HtmlInputCheckBox cbk = tb.FindControl(ckName + (i + 1)) as HtmlInputCheckBox;
            if (cbk != null)
            {
                if (cbk.Checked)
                {
                    strAnswer = strAnswer + SelectOpiton[i].ToString() + ",";
                }

                AddQuestionAnswer(sysnumber, SelectOpiton[i], ((TextBox)tb.FindControl(txtName + (i + 1))).Text, i);
            }
        }
    }
예제 #7
0
 //给table赋值
 private void SetTableValue(string cbkName, string txtName, string answer, DataTable dt, HtmlTable tb)
 {
     for (int k = 0; k <= dt.Rows.Count - 1; k++)
     {
         TextBox txt = ((TextBox)tb.FindControl(txtName + (k + 1)));
         if (txt != null)
         {
             txt.Text = dt.Rows[k]["AnswerValue"].ToString();
             string[] answers   = answer.Split(',');
             string   answerKye = dt.Rows[k]["AnswerKey"].ToString();
             foreach (string key in answers)
             {
                 if (key == answerKye)
                 {
                     ((HtmlInputCheckBox)tb.FindControl(cbkName + (k + 1))).Checked = true;
                 }
             }
         }
     }
 }
예제 #8
0
        protected void SetMenuShowByUserPurview(HtmlTable tblMenu, System.Web.UI.Control ctlParent, ArrayList lstUserPurview)
        {
            foreach (System.Web.UI.Control ctl in ctlParent.Controls)
            {
                if (ctl is HyperLink)
                {
                    HyperLink    linkCurrent = ctl as HyperLink;
                    HtmlTableRow trCurrent   = tblMenu.FindControl("tr" + linkCurrent.ID.Replace("link", String.Empty)) as HtmlTableRow;
                    if (lstUserPurview.BinarySearch(linkCurrent.Text) > -1)
                    {
                        trCurrent.Visible = true;
                    }
                    else
                    {
                        trCurrent.Visible = false;
                    }
                }

                SetMenuShowByUserPurview(tblMenu, ctl, lstUserPurview);
            }
        }
예제 #9
0
        /// <summary>
        /// Generate filter according to each query item(along with filter description)
        /// </summary>
        public BusinessFilter GetBusinessFilter(out string filterDescription)
        {
            BusinessFilter queryFilter    = new BusinessFilter(this.BusinessObjectView.BusinessObjectName);
            HtmlTable      queryTable     = this.queryHolder.FindControl("__queryTable") as HtmlTable;
            AndOr          filterJunction = GetFilterJunction(queryTable);
            StringBuilder  queryDesc      = new StringBuilder();

            // queryTable的最后一行是queryType(满足全部、满足任一)
            for (int i = 0; i < queryTable.Rows.Count - 1; i++)
            {
                HtmlTableRow      queryItem = queryTable.FindControl("__queryitem_" + i.ToString()) as HtmlTableRow;
                HtmlInputCheckBox checkbox  = queryTable.FindControl("__checkbox_" + i.ToString()) as HtmlInputCheckBox;

                if (checkbox.Checked)
                {
                    LiteralControl      desc     = queryTable.FindControl("__desc_" + i.ToString()) as LiteralControl;
                    ViewItemDisplayType itemType = (ViewItemDisplayType)int.Parse(queryItem.Attributes["displayType"]);

                    if (itemType == ViewItemDisplayType.CheckBox)
                    {
                        // Filter
                        HtmlInputCheckBox boolCtl = queryTable.FindControl("__bool_" + i.ToString()) as HtmlInputCheckBox;

                        if (queryItem.Attributes["isVirtual"] != "true")
                        {
                            queryFilter.AddFilterItem(queryItem.Attributes["fieldName"],
                                                      Convert.ToInt32(boolCtl.Checked).ToString(), Operation.Equal, FilterType.NumberType, queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                        }
                        else
                        {
                            queryFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + "=" + Convert.ToInt32(boolCtl.Checked).ToString(), queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                        }

                        // Desc
                        queryDesc.AppendFormat("{0}:{1}.", desc.Text, boolCtl.Checked);
                    }
                    else if (itemType == ViewItemDisplayType.Literal)
                    {
                        // Filter
                        HtmlInputText textbox = queryTable.FindControl("__textbox_" + i.ToString()) as HtmlInputText;
                        if (textbox.Value != string.Empty)
                        {
                            GlobalFacade.PageContext pgCtx = GlobalFacade.SystemContext.GetContext().GetPageContext(this.openerId);
                            pgCtx.Parms.Clear();
                            RadioButtonList FuzzyEnquiry = queryTable.FindControl("__Fuzzytxt_" + i.ToString()) as RadioButtonList;
                            if (queryItem.Attributes["isVirtual"] != "true")
                            {
                                if (FuzzyEnquiry != null)
                                {
                                    if (FuzzyEnquiry.SelectedIndex == 0)
                                    {
                                        queryFilter.AddFilterItem(queryItem.Attributes["fieldName"], textbox.Value.Replace("'", "''"), Operation.Like, FilterType.StringType, queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                                    }
                                    else
                                    {
                                        queryFilter.AddFilterItem(queryItem.Attributes["fieldName"], textbox.Value.Replace("'", "''"), Operation.Equal, FilterType.StringType, queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                                    }
                                }
                                else
                                {
                                    queryFilter.AddFilterItem(queryItem.Attributes["fieldName"], textbox.Value.Replace("'", "''"), Operation.Like, FilterType.StringType, queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                                }
                            }
                            else
                            {
                                if (FuzzyEnquiry != null)
                                {
                                    if (FuzzyEnquiry.SelectedIndex == 0)
                                    {
                                        queryFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + " LIKE '%" + textbox.Value.Replace("'", "''") + "%'", queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                                    }
                                    else
                                    {
                                        queryFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + " = '" + textbox.Value.Replace("'", "''") + "'", queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                                    }
                                }
                                else
                                {
                                    queryFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + " LIKE '%" + textbox.Value.Replace("'", "''") + "%'", queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                                }
                            }

                            //							if(queryItem.Attributes["isVirtual"] != "true")
                            //								queryFilter.AddFilterItem(queryItem.Attributes["fieldName"],
                            //									textbox.Value.Replace("'", "''"), Operation.Like, FilterType.StringType, filterJunction);	// 2007-4-5, Tony, 将单引号替换成两个单引号,避免查询时报错
                            //							else
                            //							{
                            //								/* Andy Modify 2008-07-30 只有Client的Mobile、TelePhone、ChineseName、EnglishName用前匹配模糊查询 */
                            //								if(this.BusinessObjectView.BusinessObjectName.ToLower() == "client")
                            //								{
                            //									if( queryItem.Attributes["fieldName"].ToLower().Trim().IndexOf("mobile") == -1 &&
                            //										queryItem.Attributes["fieldName"].ToLower().Trim().IndexOf("telephone") == -1 &&
                            //										queryItem.Attributes["fieldName"].ToLower().Trim().IndexOf("chinesename") == -1 &&
                            //										queryItem.Attributes["fieldName"].ToLower().Trim().IndexOf("englishname") == -1)
                            //									{
                            //										queryFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + " LIKE '%" + textbox.Value.Replace("'", "''") + "%'", filterJunction);// 2007-4-5, Tony, 将单引号替换成两个单引号,避免查询时报错
                            //									}
                            //									else
                            //										queryFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + " LIKE '" + textbox.Value.Replace("'", "''") + "%'", filterJunction);
                            //								}
                            //								else
                            //									queryFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + " LIKE '%" + textbox.Value.Replace("'", "''") + "%'", filterJunction);// 2007-4-5, Tony, 将单引号替换成两个单引号,避免查询时报错
                            //							}

                            // Desc
                            queryDesc.AppendFormat("{0}:{1}.", desc.Text, textbox.Value);
                        }
                    }
                    else if (itemType == ViewItemDisplayType.DateTime)
                    {
                        // Filter
                        HtmlInputText  beginTime = queryTable.FindControl("__beginTime_" + i.ToString()) as HtmlInputText;
                        HtmlInputText  endTime   = queryTable.FindControl("__endTime_" + i.ToString()) as HtmlInputText;
                        BusinessFilter subFilter = new BusinessFilter(this.BusinessObjectView.BusinessObjectName);

                        if (queryItem.Attributes["isVirtual"] != "true")
                        {
                            if (beginTime.Value != string.Empty)
                            {
                                subFilter.AddFilterItem(queryItem.Attributes["fieldName"],
                                                        beginTime.Value, Operation.NotSmaller, FilterType.StringType, AndOr.AND);
                            }


                            if (endTime.Value != string.Empty)
                            {
                                subFilter.AddFilterItem(queryItem.Attributes["fieldName"],
                                                        endTime.Value, Operation.Smaller, FilterType.StringType, AndOr.AND);
                            }
                            //endTime.Value, Operation.NotLarger, FilterType.StringType, AndOr.AND);
                        }
                        else
                        {
                            if (beginTime.Value != string.Empty)
                            {
                                subFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + ">= '" + beginTime.Value + "'", AndOr.AND);
                            }

                            if (endTime.Value != string.Empty)
                            {
                                subFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + "< '" + endTime.Value + "'", AndOr.AND);
                            }
                            //subFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + "<= '" + endTime.Value + "'", AndOr.AND);
                        }
                        queryFilter.AddFilter(subFilter, queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);

                        if (beginTime.Value != string.Empty || endTime.Value != string.Empty)
                        {
                            // Desc
                            queryDesc.AppendFormat("{0}:从{1}至{2}.", desc.Text, beginTime.Value, endTime.Value);
                        }
                    }
                    else if (itemType == ViewItemDisplayType.SingleObject)
                    {
                        // Filter
                        GridPicker ucGridPicker = queryTable.FindControl("__ucGridPicker_" + i.ToString()) as GridPicker;
                        if (ucGridPicker.SelectedValue != string.Empty)
                        {
                            if (queryItem.Attributes["isVirtual"] != "true")
                            {
                                queryFilter.AddFilterItem(queryItem.Attributes["fieldName"], ucGridPicker.SelectedValue, Operation.Equal, FilterType.NumberType, queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                            }
                            else
                            {
                                queryFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + " = " + ucGridPicker.SelectedValue, queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                            }
                            // Desc
                            queryDesc.AppendFormat("{0}:{1}.", desc.Text, ucGridPicker.SelectedText);
                        }
                    }
                }
            }

            if (queryDesc.Length != 0)
            {
                filterDescription = queryDesc.AppendFormat("({0})", (filterJunction == AndOr.AND) ? "满足全部条件" : "满足任一条件").ToString();
            }
            else
            {
                filterDescription = string.Empty;
            }

            BusinessFilter parentQueryFilter = new BusinessFilter(this.BusinessObjectView.BusinessObjectName);

            parentQueryFilter.AddCustomerFilter("1=1", AndOr.AND);
            parentQueryFilter.AddFilter(queryFilter, AndOr.AND);

            this.SaveQueryStatus();
            return(parentQueryFilter);
        }
예제 #10
0
        private AndOr GetFilterJunction(HtmlTable queryTable)
        {
            RadioButtonList queryType = queryTable.FindControl("__queryType") as RadioButtonList;

            return((queryType.SelectedIndex == 1) ? AndOr.OR : AndOr.AND);
        }
예제 #11
0
        private void SaveQueryStatus()
        {
            if (!this.IsNeedQueryStatus())
            {
                return;
            }

            GlobalFacade.PageContext pgCtx = GlobalFacade.SystemContext.GetContext().GetPageContext(this.openerId);

            HtmlTable       queryTable = this.queryHolder.FindControl("__queryTable") as HtmlTable;
            RadioButtonList queryType  = queryTable.FindControl("__queryType") as RadioButtonList;

            pgCtx.Parms[queryType.UniqueID] = queryType.SelectedIndex;

            // queryTable的最后一行是queryType(满足全部、满足任一)
            for (int i = 0; i < queryTable.Rows.Count - 1; i++)
            {
                HtmlTableRow      queryItem = queryTable.FindControl("__queryitem_" + i.ToString()) as HtmlTableRow;
                HtmlInputCheckBox checkbox  = queryTable.FindControl("__checkbox_" + i.ToString()) as HtmlInputCheckBox;
                LiteralControl    desc      = queryTable.FindControl("__desc_" + i.ToString()) as LiteralControl;

                HtmlInputCheckBox boolCtl      = queryTable.FindControl("__bool_" + i.ToString()) as HtmlInputCheckBox;
                HtmlInputText     textbox      = queryTable.FindControl("__textbox_" + i.ToString()) as HtmlInputText;
                HtmlInputText     beginTime    = queryTable.FindControl("__beginTime_" + i.ToString()) as HtmlInputText;
                HtmlInputText     endTime      = queryTable.FindControl("__endTime_" + i.ToString()) as HtmlInputText;
                GridPicker        ucGridPicker = queryTable.FindControl("__ucGridPicker_" + i.ToString()) as GridPicker;

                //ViewItemDisplayType itemType = (ViewItemDisplayType)int.Parse(queryItem.Attributes["displayType"]);

                pgCtx.Parms[checkbox.UniqueID] = checkbox.Checked;

                if (boolCtl != null)
                {
                    pgCtx.Parms[boolCtl.UniqueID] = boolCtl.Checked;
                    continue;
                }

                if (textbox != null)
                {
                    pgCtx.Parms[textbox.UniqueID] = textbox.Value;

                    RadioButtonList FuzzyEnquiry = queryTable.FindControl("__Fuzzytxt_" + i.ToString()) as RadioButtonList;
                    if (FuzzyEnquiry != null)
                    {
                        pgCtx.Parms[FuzzyEnquiry.UniqueID] = Convert.ToInt32(FuzzyEnquiry.SelectedIndex);
                    }
                    continue;
                }

                if (beginTime != null && endTime != null)
                {
                    pgCtx.Parms[beginTime.UniqueID] = beginTime.Value;
                    pgCtx.Parms[endTime.UniqueID]   = endTime.Value;
                    continue;
                }

                if (ucGridPicker != null)
                {
                    pgCtx.Parms[ucGridPicker.UniqueID] = ucGridPicker.SelectedValue;
                    continue;
                }
            }
            GlobalFacade.SystemContext.GetContext().SavePageContext(this.openerId, pgCtx);
        }
예제 #12
0
    public void CreateCustomPager(GridViewRow PagerRow)
    {
        // Create custom pager inside the Grid's pagerTemplate.
        // An html table is used to format the custom pager.

        // No data to display.
        if (PagerRow == null)
        {
            return;
        }

        theGridViewRow = PagerRow;

        HtmlTable pagerInnerTable   = (HtmlTable)PagerRow.Cells[0].FindControl("pagerInnerTable");
        HtmlTable pagerCounterTable = (HtmlTable)PagerRow.Cells[0].FindControl("pagerCounterTable");

        //HtmlTable pagerNumberTable = (HtmlTable)PagerRow.Cells[0].FindControl("pagerNumberTable");

        if (pagerInnerTable != null)
        {
            // default dynamic cell position.
            // (after the pageCount, the "First" and the "Previous" cells).
            int insertCellPosition = 0;
            if (theGrid.PageIndex == 0)
            {
                LinkButton lnkFirstPage = (LinkButton)pagerInnerTable.FindControl("lnkFirstPage");
                LinkButton lnkPrevPage  = (LinkButton)pagerInnerTable.FindControl("lnkPrevPage");

                // The first page is currently displayed.
                // Hide First and Previous page navigation.
                //pagerInnerTable.Rows[0].Cells[1].Visible = false;
                //pagerInnerTable.Rows[0].Cells[2].Visible = false;
                lnkFirstPage.Enabled = false;
                lnkPrevPage.Enabled  = false;

                // Change the default dynamic cell to 1.
                //insertCellPosition = 0;
            }

            CalcFirstPageNumber();
            CalcLastPageNumber();

            //CreatePageNumbers(pagerNumberTable, insertCellPosition);

            int lastCellPosition = pagerInnerTable.Rows[0].Cells.Count - 1;
            if (theGrid.PageIndex == theGrid.PageCount - 1)
            {
                LinkButton lnkNextPage = (LinkButton)pagerInnerTable.FindControl("lnkNextPage");
                LinkButton lnkLastPage = (LinkButton)pagerInnerTable.FindControl("lnkLastPage");

                // The last page is currently displayed.
                // Hide Next and Last page navigation.
                //pagerInnerTable.Rows[0].Cells[lastCellPosition - 1].Visible = false;
                //pagerInnerTable.Rows[0].Cells[lastCellPosition].Visible = false;
                lnkNextPage.Enabled = false;
                lnkLastPage.Enabled = false;
            }

            //// Control the visibility of the page group links
            //if (theGrid.PageIndex < MaxVisiblePageNumbers)
            //{
            //    LinkButton lnkPrevPageGroup = (LinkButton)pagerNumberTable.FindControl("lnkPrevPageGroup");
            //    lnkPrevPageGroup.Visible = false;
            //}
            //if ((theGrid.PageIndex + MaxVisiblePageNumbers) > theGrid.PageCount)
            //{
            //    LinkButton lnkNextPageGroup = (LinkButton)pagerNumberTable.FindControl("lnkNextPageGroup");
            //    lnkNextPageGroup.Visible = false;
            //}

            UpdatePageCounter(pagerInnerTable);
        }
    }
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term(".moduleList." + m_sMODULE));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            this.Visible = (SplendidCRM.Security.GetUserAccess(m_sMODULE, "edit") >= 0);
            if (!this.Visible)
            {
                return;
            }

            try
            {
                // 06/09/2006 Paul.  Remove data binding in the user controls.  Binding is required, but only do so in the ASPX pages.
                //Page.DataBind();
                gID = Sql.ToGuid(Request["ID"]);
                if (!IsPostBack)
                {
                    Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]);
                    if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID))
                    {
                        DbProviderFactory dbf = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            string sSQL;
                            sSQL = "select *              " + ControlChars.CrLf
                                   + "  from vwPAYMENTS_Edit" + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                // 11/24/2006 Paul.  Use new Security.Filter() function to apply Team and ACL security rules.
                                Security.Filter(cmd, m_sMODULE, "edit");
                                if (!Sql.IsEmptyGuid(gDuplicateID))
                                {
                                    Sql.AppendParameter(cmd, gDuplicateID, "ID", false);
                                    gID = Guid.Empty;
                                }
                                else
                                {
                                    Sql.AppendParameter(cmd, gID, "ID", false);
                                }
                                con.Open();

                                if (bDebug)
                                {
                                    RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd));
                                }

                                using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                {
                                    if (rdr.Read())
                                    {
                                        ctlModuleHeader.Title = Sql.ToString(rdr["PAYMENT_NUM"]);
                                        SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title);
                                        Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title);
                                        ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title;

                                        this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr);
                                        DropDownList CURRENCY_ID = tblMain.FindControl("CURRENCY_ID") as DropDownList;
                                        if (CURRENCY_ID != null)
                                        {
                                            CURRENCY_ID.AutoPostBack          = true;
                                            CURRENCY_ID.SelectedIndexChanged += new EventHandler(CURRENCY_ID_Changed);
                                        }
                                        ctlAllocationsView.LoadLineItems(gID, gDuplicateID, con, rdr);
                                    }
                                    else
                                    {
                                        ctlAllocationsView.LoadLineItems(gID, gDuplicateID, con, null);

                                        // 11/25/2006 Paul.  If item is not visible, then don't allow save
                                        ctlEditButtons.DisableAll();
                                        ctlEditButtons.ErrorText = L10n.Term("ACL.LBL_NO_ACCESS");
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null);
                        DropDownList CURRENCY_ID = tblMain.FindControl("CURRENCY_ID") as DropDownList;
                        if (CURRENCY_ID != null)
                        {
                            CURRENCY_ID.AutoPostBack          = true;
                            CURRENCY_ID.SelectedIndexChanged += new EventHandler(CURRENCY_ID_Changed);
                        }
                        ctlAllocationsView.LoadLineItems(gID, gDuplicateID, null, null);

                        new DynamicControl(this, "PAYMENT_DATE").DateValue = DateTime.Today;

                        // 05/28/2007 Paul.  Prepopulate the Account.
                        Guid gPARENT_ID  = Sql.ToGuid(Request["PARENT_ID"]);
                        Guid gINVOICE_ID = gPARENT_ID;
                        if (!Sql.IsEmptyGuid(gPARENT_ID))
                        {
                            string sMODULE      = String.Empty;
                            string sPARENT_TYPE = String.Empty;
                            string sPARENT_NAME = String.Empty;
                            SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME);
                            if (!Sql.IsEmptyGuid(gPARENT_ID) && sMODULE == "Accounts")
                            {
                                new DynamicControl(this, "ACCOUNT_ID").ID     = gPARENT_ID;
                                new DynamicControl(this, "ACCOUNT_NAME").Text = sPARENT_NAME;
                            }
                            else if (!Sql.IsEmptyGuid(gINVOICE_ID))
                            {
                                // 05/282/007 Paul.  spPARENT_Get will not return Invoices, so get the hard way.
                                DbProviderFactory dbf = DbProviderFactories.GetFactory();
                                using (IDbConnection con = dbf.CreateConnection())
                                {
                                    string sSQL;
                                    sSQL = "select *              " + ControlChars.CrLf
                                           + "  from vwINVOICES_Edit" + ControlChars.CrLf;
                                    using (IDbCommand cmd = con.CreateCommand())
                                    {
                                        cmd.CommandText = sSQL;
                                        Security.Filter(cmd, "Invoices", "edit");
                                        Sql.AppendParameter(cmd, gINVOICE_ID, "ID", false);
                                        con.Open();

                                        if (bDebug)
                                        {
                                            RegisterClientScriptBlock("vwINVOICES_Edit", Sql.ClientScriptBlock(cmd));
                                        }

                                        using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                        {
                                            if (rdr.Read())
                                            {
                                                new DynamicControl(this, "ACCOUNT_ID").ID     = Sql.ToGuid(rdr["BILLING_ACCOUNT_ID"]);
                                                new DynamicControl(this, "ACCOUNT_NAME").Text = Sql.ToString(rdr["BILLING_ACCOUNT_NAME"]);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    // 12/02/2005 Paul.  When validation fails, the header title does not retain its value.  Update manually.
                    ctlModuleHeader.Title = Sql.ToString(ViewState["ctlModuleHeader.Title"]);
                    SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title);
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                ctlEditButtons.ErrorText = ex.Message;
            }
        }