Ejemplo n.º 1
0
        protected void ASPxButton1_Click(object sender, EventArgs e)
        {
            if (ASPxHiddenField1.Get("dashboardState") != null && ASPxHiddenField1.Get("filterItems") != null)
            {
                string   dashboardStateJson = ASPxHiddenField1.Get("dashboardState").ToString();
                string[] parameters         = ASPxHiddenField1.Get("filterItems").ToString().Split('|');

                MemoryStream resultStream = new MemoryStream();
                using (PdfDocumentProcessor documentProcessor = new PdfDocumentProcessor()) {
                    documentProcessor.CreateEmptyDocument(resultStream);
                    for (int i = 0; i < parameters.Length; i++)
                    {
                        DashboardState dashboardState = new DashboardState();
                        dashboardState.LoadFromJson(dashboardStateJson);
                        var filterItemState = dashboardState.Items.Where(item => item.ItemName == "comboBoxDashboardItem1").FirstOrDefault();
                        if (filterItemState != null)
                        {
                            filterItemState.MasterFilterValues.Clear();
                            filterItemState.MasterFilterValues.Add(new object[] { parameters[i] });
                        }
                        DashboardPdfExportOptions pdfOptions = new DashboardPdfExportOptions();
                        pdfOptions.ShowTitle = DevExpress.Utils.DefaultBoolean.False;
                        ASPxDashboardExporter exporter = new ASPxDashboardExporter(ASPxDashboard1);
                        using (MemoryStream stream = new MemoryStream())
                        {
                            exporter.ExportToPdf("Dashboard1", stream, new System.Drawing.Size(1024, 768), dashboardState, pdfOptions);
                            documentProcessor.AppendDocument(stream);
                        }
                    }
                }

                resultStream.Seek(0, SeekOrigin.Begin);
                Page.Response.Clear();
                Page.Response.ContentType = "application/pdf";
                Response.BinaryWrite(resultStream.ToArray());
                Page.Response.End();
            }
        }
Ejemplo n.º 2
0
    protected void ASPxGridView1_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
    {
        ASPxGridView1.ClearSort();
        for (int i = 0; i < ((ASPxGridView)sender).Columns.Count; i++)
        {
            if (((ASPxGridView)sender).Columns[i] is GridViewDataColumn)
            {
                GridViewDataColumn col = ((ASPxGridView)sender).Columns[i] as GridViewDataColumn;
                if (ASPxHiddenField1.Contains("clientColumnNamesunit" + col.FieldName))
                {
                    Dictionary <string, object> dict = ASPxHiddenField1.Get("clientColumnNamesunit" + col.FieldName) as Dictionary <string, object>;
                    string sortOrder = dict["Order"] as string;
                    string FieldName = dict["FieldName"] as string;

                    if (sortOrder == null || FieldName == null)
                    {
                        object previousField;
                        if (dict.TryGetValue("ClearSort", out previousField))
                        {
                            ((GridViewDataColumn)((ASPxGridView)sender).Columns[(string)previousField]).UnSort();
                        }
                        continue;
                    }

                    if (sortOrder == "A")
                    {
                        ((GridViewDataColumn)((ASPxGridView)sender).Columns[FieldName]).SortAscending();
                    }
                    else
                    {
                        ((GridViewDataColumn)((ASPxGridView)sender).Columns[FieldName]).SortDescending();
                    }
                }
            }
        }
    }
Ejemplo n.º 3
0
    protected void ASPxCallbackPanel1_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
    {
        if (e.Parameter.Trim() == "quick")
        {
            if (tbQuick.Text.Trim() != "")
            {
                ObjectDataSource1.SelectParameters["strWhere"].DefaultValue = " and H_CONTENT like '%" + tbQuick.Text.Trim() + "%'";
            }
            else
            {
                ObjectDataSource1.SelectParameters["strWhere"].DefaultValue = " and 1=1";
            }
            ASPxGridView1.DataSourceID = "ObjectDataSource1";
            ObjectDataSource1.DataBind();
        }
        if (e.Parameter.Trim() == "base")
        {
            string strwhere = "";
            if (deBegin.Date <= deEnd.Date)
            {
                strwhere += " and to_char(HAZARDS.OPENINGTIME,'yyyy-mm-dd') between '" + deBegin.Date.ToString("yyyy-MM-dd") + "' and '" + deEnd.Date.ToString("yyyy-MM-dd") + "'";
            }
            if (cbbZY.Text.Trim() != "")
            {
                strwhere += " and a.infoid=" + ASPxHiddenField1.Get("ZYkey").ToString();
            }
            if (cbbDW.SelectedIndex > -1)
            {
                //strwhere+=" and "
            }
            if (cbbFXkind.SelectedIndex > -1)
            {
                strwhere += " and HAZARDS.Risk_Typesnumber=" + cbbFXkind.SelectedItem.Value.ToString();
            }
            if (cbbFXlevel.SelectedIndex > -1)
            {
                strwhere += " and c.infoid=" + cbbFXlevel.SelectedItem.Value.ToString();
            }
            if (cbbSG.SelectedIndex > -1)
            {
                strwhere += " and HAZARDS.Accident_Typenumber=" + cbbSG.SelectedItem.Value.ToString();
            }
            if (tbGZ.Text.Trim() != "")
            {
                strwhere += " and b.WORKTASK" + (cbbGZway.SelectedIndex == 0 ? "='" : " like '%") + tbGZ.Text.Trim() + (cbbGZway.SelectedIndex == 0 ? "'" : "%'");
            }
            if (tbGX.Text.Trim() != "")
            {
                strwhere += " and PROCESS.NAME" + (cbbGXway.SelectedIndex == 0 ? "='" : " like '%") + tbGX.Text.Trim() + (cbbGXway.SelectedIndex == 0 ? "'" : "%'");
            }
            if (tbBM.Text.Trim() != "" && tbBMchild.Text.Trim() != "")
            {
                strwhere += " and (HAZARDS.H_NUMBER like '%" + tbBM.Text.Trim() + "%'" + (cbbBMchild.SelectedIndex == 0 ? " and" : " or") + " HAZARDS.H_NUMBER like '%" + tbBMchild.Text.Trim() + "%')";
            }
            if (tbBM.Text.Trim() != "" && tbBMchild.Text.Trim() == "")
            {
                strwhere += " and HAZARDS.H_NUMBER like '%" + tbBM.Text.Trim() + "%'";
            }
            if (tbBM.Text.Trim() == "" && tbBMchild.Text.Trim() != "")
            {
                strwhere += " and HAZARDS.H_NUMBER like '%" + tbBMchild.Text.Trim() + "%'";
            }

            if (tbWXY.Text.Trim() != "" && tbWXYchild.Text.Trim() != "")
            {
                strwhere += " and (H_CONTENT like '%" + tbWXY.Text.Trim() + "%'" + (cbbWXYchild.SelectedIndex == 0 ? " and" : " or") + " H_CONTENT like '%" + tbWXYchild.Text.Trim() + "%')";
            }
            if (tbWXY.Text.Trim() != "" && tbWXYchild.Text.Trim() == "")
            {
                strwhere += " and H_CONTENT like '%" + tbWXY.Text.Trim() + "%'";
            }
            if (tbWXY.Text.Trim() == "" && tbWXYchild.Text.Trim() != "")
            {
                strwhere += " and H_CONTENT like '%" + tbWXYchild.Text.Trim() + "%'";
            }

            if (tbHG.Text.Trim() != "" && tbHGchild.Text.Trim() != "")
            {
                strwhere += " and (H_CONSEQUENCES like '%" + tbHG.Text.Trim() + "%'" + (cbbHGchild.SelectedIndex == 0 ? " and" : " or") + " H_CONSEQUENCES like '%" + tbHGchild.Text.Trim() + "%')";
            }
            if (tbHG.Text.Trim() != "" && tbHGchild.Text.Trim() == "")
            {
                strwhere += " and H_CONSEQUENCES like '%" + tbHG.Text.Trim() + "%'";
            }
            if (tbHG.Text.Trim() == "" && tbHGchild.Text.Trim() != "")
            {
                strwhere += " and H_CONSEQUENCES like '%" + tbHGchild.Text.Trim() + "%'";
            }

            ObjectDataSource1.SelectParameters["strWhere"].DefaultValue = strwhere;
            ASPxGridView1.DataSourceID = "ObjectDataSource1";
            ObjectDataSource1.DataBind();
        }
        if (e.Parameter.Trim() == "cs")
        {
            ObjectDataSource1.SelectParameters["strWhere"].DefaultValue = " and M_STANDARDS like '%" + tbCSsearch.Text.Trim() + "%' or M_MEASURES like '%" + tbCSsearch.Text.Trim() + "%'";
            ASPxGridView1.DataSourceID = "ObjectDataSource1";
            ObjectDataSource1.DataBind();
        }
    }