Esempio n. 1
0
        private void LoadCriteriaUIFromSession()
        {
            CUSTOMRP.Model.SOURCEVIEW mySV = WebHelper.bllSOURCEVIEW.GetModel(me.ID, container.SVID);

            foreach (Fields cn in container.criteriaColumn)
            {
                ColumnInfo columnInfo = columninfos.Where(x => x.ColName == cn.ColumnName).FirstOrDefault();
                if (columnInfo != null) // skip column if it no longer exists.
                {
                    CUSTOMRP.Model.REPORTCOLUMN col = myReport.ReportColumns.Where(x => x.ColumnFunc == REPORTCOLUMN.ColumnFuncs.Criteria && x.COLUMNNAME == cn.ColumnName).FirstOrDefault();

                    if ("String" == columnInfo.DataType)
                    {
                        Controls.CriteriaString control = (Controls.CriteriaString)Page.LoadControl("~/controls/CriteriaString.ascx");
                        control.ColumnName = columnInfo.ColName;
                        //v1.7.0 Ben 2017.12.20 - columnInfo.DisplayName is ColumnName if directly from clicking run (generated by GetColumnInfoForStoredProc). While cn.DisplayName is generated from 'container.criteriaColumn =...' in rpexcel.aspx which must be the actual
                        //control.DisplayName = columnInfo.DisplayName;
                        control.DisplayName = cn.DisplayName;
                        control.DBName      = me.DatabaseNAME;
                        control.SourceView  = mySV.TBLVIEWNAME;
                        control.SourceType  = mySV.SOURCETYPE;

                        //if ((!IsPostBack) && (col != null))
                        if (col != null)
                        {
                            control.op1    = col.CRITERIA2;
                            control.range1 = col.CRITERIA3;
                            control.range2 = col.CRITERIA4;
                        }

                        this.Panel1.Controls.Add(control);
                    }
                    if ("DateTime" == columnInfo.DataType)
                    {
                        Controls.CriteriaString control = (Controls.CriteriaString)Page.LoadControl("~/controls/CriteriaString.ascx");
                        control.ColumnName = columnInfo.ColName;
                        //v1.7.0 Ben 2017.12.20 - columnInfo.DisplayName is ColumnName if directly from clicking run (generated by GetColumnInfoForStoredProc). While cn.DisplayName is generated from 'container.criteriaColumn =...' in rpexcel.aspx which must be the actual
                        //control.DisplayName = columnInfo.DisplayName;
                        control.DisplayName = cn.DisplayName;
                        control.ControlType = "datetime";
                        control.DBName      = me.DatabaseNAME;
                        control.SourceView  = mySV.TBLVIEWNAME;
                        control.SourceType  = mySV.SOURCETYPE;

                        //if ((!IsPostBack) && (col != null))
                        if (col != null)
                        {
                            control.op1    = col.CRITERIA2;
                            control.range1 = col.CRITERIA3;
                            control.range2 = col.CRITERIA4;
                        }

                        this.Panel1.Controls.Add(control);
                    }
                    else if (("Int" == columnInfo.DataType) || ("Decimal" == columnInfo.DataType))
                    {
                        Controls.CriteriaNumber control = (Controls.CriteriaNumber)Page.LoadControl("~/Controls/CriteriaNumber.ascx");
                        control.ColumnName = columnInfo.ColName;
                        //v1.7.0 Ben 2017.12.20 - columnInfo.DisplayName is ColumnName if directly from clicking run (generated by GetColumnInfoForStoredProc). While cn.DisplayName is generated from 'container.criteriaColumn =...' in rpexcel.aspx which must be the actual
                        //control.DisplayName = columnInfo.DisplayName;
                        control.DisplayName = cn.DisplayName;
                        control.DBName      = me.DatabaseNAME;
                        control.SourceView  = mySV.TBLVIEWNAME;
                        control.SourceType  = mySV.SOURCETYPE;

                        //if ((!IsPostBack) && (col != null))
                        if (col != null)
                        {
                            control.op1    = col.CRITERIA2;
                            control.range1 = col.CRITERIA3;
                            control.range2 = col.CRITERIA4;
                        }

                        this.Panel1.Controls.Add(control);
                    }
                    else if ("Enum" == columnInfo.DataType)
                    {
                        Controls.CriteriaInt control = (Controls.CriteriaInt)Page.LoadControl("~/controls/CriteriaInt.ascx");
                        control.ColumnName = columnInfo.ColName;
                        //v1.7.0 Ben 2017.12.20 - columnInfo.DisplayName is ColumnName if directly from clicking run (generated by GetColumnInfoForStoredProc). While cn.DisplayName is generated from 'container.criteriaColumn =...' in rpexcel.aspx which must be the actual
                        //control.DisplayName = columnInfo.DisplayName;
                        control.DisplayName = cn.DisplayName;
                        CUSTOMRP.Model.RpEnum rp = new RpEnum();
                        Type a = rp.GetType().GetNestedType((mySV.SOURCEVIEWNAME + "_" + cn).ToUpper());
                        control.dt = Common.Utils.GetTableFEnum(a, "text", "value");

                        this.Panel1.Controls.Add(control);
                    }
                }
                //else
                //{
                //    // 2018.10.02 Alex - Name absent in model - Formulas
                //    Controls.CriteriaNumber control = (Controls.CriteriaNumber)Page.LoadControl("~/Controls/CriteriaNumber.ascx");
                //    control.ColumnName = cn.ColumnName;
                //    control.DisplayName = cn.DisplayName;
                //    HiddenField hf = new HiddenField();
                //    hf.Value = cn.Formula;
                //    control.Controls.Add(hf);
                //    this.Panel1.Controls.Add(control);
                //}
            }
            // Alex 2018.09.20 - Begin
            //
            //
            //
            var prefilterParams = new List <CUSTOMRP.BLL.AppHelper.QueryParamsObject>();
            var QueryParams     = CUSTOMRP.BLL.AppHelper.GetQueryParams(me.ID, me.DatabaseNAME, "qreport." + mySV.TBLVIEWNAME);
            //  mySV.TBLVIEWNAME may be a view or an sp

            //Controls.CriteriaQueryParamWrapper wrapper = (Controls.CriteriaQueryParamWrapper) Page.LoadControl("~/controls/CriteriaQueryParamWrapper.ascx");


            var dt = WebHelper.bllQUERYPARAMS.GetList(me.ID, myReport.ID).Tables[0].AsEnumerable().ToDictionary <DataRow, string, string>(rw => Convert.ToString(rw["NAME"]),
                                                                                                                                          rw => Convert.ToString(rw["VALUE"]));

            foreach (var x in QueryParams)
            {
                //Label label2 = new Label();
                //label2.Text = me.DatabaseNAME + " qreport." + mySV.TBLVIEWNAME + QueryParams.Count.ToString();
                //this.Panel1.Controls.Add(label2);

                Controls.CriteriaQueryParam qpControl = (Controls.CriteriaQueryParam)Page.LoadControl("~/controls/CriteriaQueryParam.ascx");
                qpControl.ID          = x.ParamName.Substring(12);
                qpControl.ColumnName  = x.ParamName.Substring(12);                                          // Real
                qpControl.DisplayName = qpControl.ColumnName.Replace("_", " ");                             // Display

                switch (x.SqlType)
                {
                case "bit":             // radio buttons
                    qpControl.ControlType = "bool";
                    break;

                case "date":            // calendar
                case "datetime":
                    qpControl.ControlType = "datetime";
                    break;

                case "int":             // <%=this.ControlType=="int" ? "type='number'" : "" %>
                    qpControl.ControlType = "int";
                    if (x.ParamName.Substring(12).Contains('$'))
                    {
                        qpControl.ControlType = "enum";
                        int separator = x.ParamName.IndexOf('$');                                                       // Separator is the $ sign
                        qpControl.ColumnName  = x.ParamName.Substring(12, separator - 12);                              // Real
                        qpControl.DisplayName = qpControl.ColumnName.Replace("_", " ");                                 // Display
                        String[] chopped = x.ParamName.Substring(12).Split('$');
                        qpControl.EnumArr = CUSTOMRP.BLL.AppHelper.QueryParamGetEnumValues(me.ID, me.DatabaseNAME, chopped[1], chopped[2].Replace("#", " "));
                    }
                    break;

                case "varchar":          // normal
                case "nvarchar":
                    qpControl.ControlType = "string";
                    if (x.ParamName.Substring(12).Contains('$'))
                    {
                        qpControl.ControlType = "enum";
                        int separator = x.ParamName.IndexOf('$');                                                       // Separator is the $ sign
                        qpControl.ColumnName  = x.ParamName.Substring(12, separator - 12);                              // Real
                        qpControl.DisplayName = qpControl.ColumnName.Replace("_", " ");                                 // Display
                        String[] chopped = x.ParamName.Substring(12).Split('$');
                        qpControl.EnumArr = CUSTOMRP.BLL.AppHelper.QueryParamGetEnumValues(me.ID, me.DatabaseNAME, chopped[1], chopped[2].Replace("#", " "));
                    }
                    break;
                }

                x.Type = qpControl.ControlType;
                if (x.Type == "enum")
                {
                    x.ParamName = x.ParamName.Substring(12);
                }
                else
                {
                    x.ParamName = qpControl.ColumnName;
                }

                prefilterParams.Add(x);
                this.PlaceHolder_QueryParamsWrapper.Controls.Add(qpControl);

                if (dt.Keys.Contains(qpControl.ColumnName))
                {
                    qpControl.Value = dt[qpControl.ColumnName];
                }
                //wrapper.Panel_QueryParams.Controls.Add(qpControl);
            }
            //if (QueryParams.Count > 0)
            //{
            //    this.PlaceHolder_QueryParamsWrapper.Controls.Add(wrapper);
            //}
            Session[strSessionKeyQueryParams] = prefilterParams;
            //
            //
            //
            // Alex 2018.09.20 - End
        }
Esempio n. 2
0
        private void LoadCriteriaUIFromSession()
        {
            CUSTOMRP.Model.SOURCEVIEW mySV = WebHelper.bllSOURCEVIEW.GetModel(me.ID, container.SVID);

            // Alex 2018.09.20 - Begin
            //
            //
            //
            var prefilterParams = new List <CUSTOMRP.BLL.AppHelper.QueryParamsObject>();
            var QueryParams     = CUSTOMRP.BLL.AppHelper.GetQueryParams(me.ID, me.DatabaseNAME, "qreport." + mySV.TBLVIEWNAME);

            //  mySV.TBLVIEWNAME may be a view or an sp

            foreach (var x in QueryParams)
            {
                //Label label2 = new Label();
                //label2.Text = me.DatabaseNAME + " qreport." + mySV.TBLVIEWNAME + QueryParams.Count.ToString();
                //this.Panel1.Controls.Add(label2);

                Controls.CriteriaQueryParam qpControl = (Controls.CriteriaQueryParam)Page.LoadControl("~/controls/CriteriaQueryParam.ascx");
                qpControl.ID          = x.ParamName.Substring(12);
                qpControl.ColumnName  = x.ParamName.Substring(12);                                          // Real
                qpControl.DisplayName = qpControl.ColumnName.Replace("_", " ");                             // Display

                switch (x.SqlType)
                {
                case "bit":             // radio buttons
                    qpControl.ControlType = "bool";
                    break;

                case "date":            // calendar
                case "datetime":
                    qpControl.ControlType = "datetime";
                    break;

                case "int":             // <%=this.ControlType=="int" ? "type='number'" : "" %>
                    qpControl.ControlType = "int";
                    if (x.ParamName.Substring(12).Contains('$'))
                    {
                        qpControl.ControlType = "enum";
                        int separator = x.ParamName.IndexOf('$');                                                       // Separator is the $ sign
                        qpControl.ColumnName  = x.ParamName.Substring(12, separator - 12);                              // Real
                        qpControl.DisplayName = qpControl.ColumnName.Replace("_", " ");                                 // Display
                        String[] chopped = x.ParamName.Substring(12).Split('$');
                        qpControl.EnumArr = CUSTOMRP.BLL.AppHelper.QueryParamGetEnumValues(me.ID, me.DatabaseNAME, chopped[1], chopped[2].Replace("#", " "));
                    }
                    break;

                case "varchar":          // normal
                case "nvarchar":
                    qpControl.ControlType = "string";
                    if (x.ParamName.Substring(12).Contains('$'))
                    {
                        qpControl.ControlType = "enum";
                        int separator = x.ParamName.IndexOf('$');                                                       // Separator is the $ sign
                        qpControl.ColumnName  = x.ParamName.Substring(12, separator - 12);                              // Real
                        qpControl.DisplayName = qpControl.ColumnName.Replace("_", " ");                                 // Display
                        String[] chopped = x.ParamName.Substring(12).Split('$');
                        qpControl.EnumArr = CUSTOMRP.BLL.AppHelper.QueryParamGetEnumValues(me.ID, me.DatabaseNAME, chopped[1], chopped[2].Replace("#", " "));
                    }
                    break;
                }

                x.Type = qpControl.ControlType;
                if (x.Type == "enum")
                {
                    x.ParamName = x.ParamName.Substring(12);
                }
                else
                {
                    x.ParamName = qpControl.ColumnName;
                }

                //if (!prefilterParams.Contains(tmpModel))
                prefilterParams.Add(x);

                this.PlaceHolder_QueryParamsWrapper.Controls.Add(qpControl);
            }
            Session[strSessionKeyQueryParams] = prefilterParams;
            //
            //
            //
            // Alex 2018.09.20 - End


            foreach (Fields cn in container.criteriaColumn)
            {
                var theColumm = columninfos.Where(x => x.ColName == cn.ColumnName);
                if (theColumm.Count() > 0)
                {
                    ColumnInfo columnInfo           = theColumm.First();
                    CUSTOMRP.Model.REPORTCOLUMN col = myReport.ReportColumns.Where(x => x.ColumnFunc == REPORTCOLUMN.ColumnFuncs.Criteria && x.COLUMNNAME == cn.ColumnName).FirstOrDefault();

                    if ("String" == columnInfo.DataType)
                    {
                        Controls.CriteriaString control = (Controls.CriteriaString)Page.LoadControl("~/controls/CriteriaString.ascx");
                        control.ColumnName  = columnInfo.ColName;
                        control.DisplayName = columnInfo.DisplayName;

                        if ((!IsPostBack) && (col != null))
                        {
                            control.op1    = col.CRITERIA2;
                            control.range1 = col.CRITERIA3;
                            control.range2 = col.CRITERIA4;
                        }

                        this.Panel1.Controls.Add(control);
                    }
                    if ("DateTime" == columnInfo.DataType)
                    {
                        Controls.CriteriaString control = (Controls.CriteriaString)Page.LoadControl("~/controls/CriteriaString.ascx");
                        control.ColumnName  = columnInfo.ColName;
                        control.DisplayName = columnInfo.DisplayName;
                        control.ControlType = "datetime";

                        if ((!IsPostBack) && (col != null))
                        {
                            control.op1    = col.CRITERIA2;
                            control.range1 = col.CRITERIA3;
                            control.range2 = col.CRITERIA4;
                        }

                        this.Panel1.Controls.Add(control);
                    }
                    else if (("Int" == columnInfo.DataType) || ("Decimal" == columnInfo.DataType))
                    {
                        Controls.CriteriaNumber control = (Controls.CriteriaNumber)Page.LoadControl("~/Controls/CriteriaNumber.ascx");
                        control.ColumnName  = columnInfo.ColName;
                        control.DisplayName = columnInfo.DisplayName;

                        if ((!IsPostBack) && (col != null))
                        {
                            control.op1    = col.CRITERIA2;
                            control.range1 = col.CRITERIA3;
                            control.range2 = col.CRITERIA4;
                        }

                        this.Panel1.Controls.Add(control);
                    }
                    else if ("Enum" == columnInfo.DataType)
                    {
                        Controls.CriteriaInt control = (Controls.CriteriaInt)Page.LoadControl("~/controls/CriteriaInt.ascx");
                        control.ColumnName  = columnInfo.ColName;
                        control.DisplayName = columnInfo.DisplayName;
                        CUSTOMRP.Model.RpEnum rp = new RpEnum();
                        Type a = rp.GetType().GetNestedType((mySV.SOURCEVIEWNAME + "_" + cn).ToUpper());
                        control.dt = Common.Utils.GetTableFEnum(a, "text", "value");

                        this.Panel1.Controls.Add(control);
                    }
                }
                else
                {
                    throw new Exception("no citerias column :" + cn.ColumnName);
                }
            }
        }