Exemple #1
0
        private void ParseDataToContainer()
        {
            // 2018.09.21 Alex - QueryParams - Begin
            var modelList = (List <CUSTOMRP.BLL.AppHelper.QueryParamsObject>)Session[strSessionKeyQueryParams];
            var newList   = new List <CUSTOMRP.BLL.AppHelper.QueryParamsObject>();

            foreach (var x in modelList)
            {
                //throw new Exception(x.paramName);
                //string checkboxVal = Request.Form[String.Format("{0}_select", x.ParamName)];
                //if (!String.IsNullOrEmpty(checkboxVal))
                //{
                string fieldVal;
                switch (x.Type)
                // 2018.09.21 Alex - Get by POST values (<name> tag) - Begin
                {
                case "bool":
                    fieldVal = Request.Form[String.Format("{0}_optradio", x.ParamName)];
                    break;

                case "enum":
                    fieldVal = Request.Form[String.Format("{0}_autocomplete", x.ParamName.Split('$')[0])];
                    break;

                default:
                    fieldVal = Request.Form[String.Format("{0}_field", x.ParamName)];
                    break;
                    // 2018.09.21 Alex - Get by POST values (<name> tag) - End
                }
                if (!String.IsNullOrEmpty(fieldVal))
                {
                    x.Value = fieldVal;
                    newList.Add(x);
                }
                //}
            }
            container.queryParams = newList;

            // 2018.09.21 Alex - QueryParams - End

            for (int i = 0; i < container.criteriaColumn.Count(); i++)
            {
                Fields     cn = container.criteriaColumn[i];
                ColumnInfo ci = columninfos.Where(x => x.ColName == cn.ColumnName).FirstOrDefault();

                if (myReport == null)
                {
                    myReport = container.GetReportModel(me, columninfos);
                }

                CUSTOMRP.Model.REPORTCOLUMN rc = myReport.ReportColumns.Where(x => x.COLUMNNAME == cn.ColumnName && x.ColumnFunc == REPORTCOLUMN.ColumnFuncs.Criteria).FirstOrDefault();
                if (rc == null)
                {
                    rc = new REPORTCOLUMN()
                    {
                        COLUMNNAME  = cn.ColumnName,
                        DISPLAYNAME = ci.DisplayName,
                        COLUMNTYPE  = 1,
                        COLUMNFUNC  = 2,
                        HIDDEN      = false,
                    };
                    myReport.ReportColumns.Add(rc);
                }
                rc.DATATYPE = (ci != null) ? ci.DataType : "String";
                string postData = Request.Form[String.Format("ContentPlaceHolder1_ctl{0:00}_Label1rd1", i)]; // (modelList == null || modelList.Count == 0) ? i : i + 1)
                if (!String.IsNullOrEmpty(postData))                                                         // has value
                {
                    rc.CRITERIA2 = postData;
                    switch (postData)
                    {
                    case "r1":
                    {
                        rc.CRITERIA3 = Request.Form[String.Format("ContentPlaceHolder1_ctl{0:00}_Label1ddl1", i)];
                        rc.CRITERIA4 = Request.Form[String.Format("ContentPlaceHolder1_ctl{0:00}_Label1tb1", i)];

                        cn.Operator = rc.CRITERIA3;
                        cn.Value1   = rc.CRITERIA4;
                    }
                    break;

                    case "r2":
                    {
                        rc.CRITERIA3 = Request.Form[String.Format("ContentPlaceHolder1_ctl{0:00}_Label1tb2", i)];
                        rc.CRITERIA4 = Request.Form[String.Format("ContentPlaceHolder1_ctl{0:00}_Label1tb3", i)];

                        cn.Operator = "BETWEEN";
                        cn.Value1   = rc.CRITERIA3;
                        cn.Value2   = rc.CRITERIA4;
                    }
                    break;

                    case "r3":
                    {
                        rc.CRITERIA3 = "";
                        rc.CRITERIA4 = "";

                        cn.Operator = "EMPTY";
                        cn.Value1   = rc.CRITERIA3;
                        cn.Value2   = rc.CRITERIA4;
                    }
                    break;
                    }
                }
                ReportCriteria temp = rc;
                CUSTOMRP.BLL.AppHelper.ParseParam(me.ID, ref temp);
            }

            Session[rpexcel.strSessionKeyMyReport] = myReport;
            Session[rpexcel.strSessionKeyReportParameterContainer] = container;
        }
Exemple #2
0
        protected void Page_Init(object sender, EventArgs e)
        {
            if (Session[rpexcel.strSessionKeyMyReport] != null)
            {
                myReport = (CUSTOMRP.Model.REPORT)Session[rpexcel.strSessionKeyMyReport];
            }

            if (myReport == null)
            {
                if (!String.IsNullOrEmpty(Request.QueryString["id"]))
                {
                    int id = Int32.Parse(Request.QueryString["id"]);
                    myReport = WebHelper.bllReport.GetModel(me.ID, id);

                    if (myReport == null)
                    {
                        Common.JScript.AlertAndRedirect(Code.AppNum.ErrorMsg.parameter_error, "rplist.aspx");
                        Response.End();
                    }
                }
            }

            if (Session[rpexcel.strSessionKeyColumnInfo] != null)
            {
                columninfos = (List <CUSTOMRP.Model.ColumnInfo>)Session[rpexcel.strSessionKeyColumnInfo];
            }

            if (Session[rpexcel.strSessionKeyReportParameterContainer] != null)
            {
                container = (ReportParameterContainer)Session[rpexcel.strSessionKeyReportParameterContainer];
                //v1.0.0 - Cheong - 2015/07/13 - Patch SEQ
                if (myReport != null)
                {
                    foreach (CUSTOMRP.Model.REPORTCOLUMN rc in myReport.ReportColumns)
                    {
                        rc.SEQ = -1;
                    }
                    CUSTOMRP.Model.REPORTCOLUMN l_ReportColumn = null;
                    int contentSEQ = 1;
                    foreach (Fields f in container.contentColumn)
                    {
                        l_ReportColumn = myReport.ReportColumns.Where(x => x.COLUMNFUNC == 1 && x.DisplayName == f.DisplayName).FirstOrDefault();
                        if (l_ReportColumn != null)
                        {
                            l_ReportColumn.SEQ = contentSEQ;
                            contentSEQ++;
                        }
                    }
                    //v1.0.0 - Cheong - 2016/03/23 - Preserve order on criteria and group columns
                    int criteriaSEQ = 1;
                    foreach (Fields f in container.criteriaColumn)
                    {
                        l_ReportColumn = myReport.ReportColumns.Where(x => x.COLUMNFUNC == 2 && x.DisplayName == f.DisplayName).FirstOrDefault();
                        if (l_ReportColumn != null)
                        {
                            l_ReportColumn.SEQ = criteriaSEQ;
                            criteriaSEQ++;
                        }
                    }
                    int sortonSEQ = 1;
                    foreach (Fields f in container.sortonColumn)
                    {
                        l_ReportColumn = myReport.ReportColumns.Where(x => x.COLUMNFUNC == 3 && x.DisplayName == f.DisplayName).FirstOrDefault();
                        if (l_ReportColumn != null)
                        {
                            l_ReportColumn.SEQ = sortonSEQ;
                            sortonSEQ++;
                        }
                    }
                    //v1.0.0 - Cheong - 2016/03/23 - Preserve order on criteria and group columns
                    int groupSEQ = 1;
                    foreach (Fields f in container.groupColumn)
                    {
                        l_ReportColumn = myReport.ReportColumns.Where(x => x.COLUMNFUNC == 6 && x.DisplayName == f.DisplayName).FirstOrDefault();
                        if (l_ReportColumn != null)
                        {
                            l_ReportColumn.SEQ = groupSEQ;
                            groupSEQ++;
                        }
                    }
                    myReport.ReportColumns.OrderBy(x => x.COLUMNFUNC).ThenBy(x => x.SEQ);
                }
            }
            else if (!ReportParameterContainer.LoadReport(myReport.ID, me, out container, out columninfos)) // try load default from table
            {
                Response.Redirect("rplist.aspx");
            }
        }
Exemple #3
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
        }
Exemple #4
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);
                }
            }
        }