Exemplo n.º 1
0
        void ofd_FileOk(object sender, CancelEventArgs e)
        {
            using (new WaitCursor())
            {
                OpenFileDialog ofd = sender as OpenFileDialog;

                try
                {
                    xReport Rpt = (xReport)xrDesignPanel1.Report;
                    Stream  ms  = ofd.OpenFile();
                    Rpt.LoadLayout(ms);
                    ms.Close();
                    Rpt.DataSource = xrDesignPanel1.Report.DataSource;
                    xrDesignPanel1.OpenReport(Rpt);
                    xrDesignPanel1.FileName = string.Empty;
                    xrDesignPanel1.Report.ScriptReferences = new string[] { GetType().Assembly.Location };
                    xrDesignPanel1.Report.DataSource       = _DataSource;
                    fieldListDockPanel1.UpdateDataSource(_DesignerHost);
                    OriginalPrintControl = BaseWinFramework.mdiRibbonPrintController.PrintControl;
                    //xrDesignPanel1.Report.DataSource = null;
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show(ex.Message, "Error Membuka Laporan",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 2
0
        private void UpdateLayout(string NewLayout)
        {
            MemoryStream LayoutData;

            if (NewLayout == strTanpaLayout)
            {
                LayoutData = msTanpaLayout;
            }
            else
            {
                DocPrintBrowseLayout.GetLayoutData(
                    LayoutHeader + RptName, NewLayout, out LayoutData);
            }

            if (LayoutData == null)
            {
                return;
            }
            //xReport Rpt = new xReport(_Evaluator);
            xReport Rpt = (xReport)xrDesignPanel1.Report;

            Rpt.LoadLayout(LayoutData);
            Rpt.DataSource = _DataSource;
            xrDesignPanel1.Report.DataSource = _DataSource;
            fieldListDockPanel1.UpdateDataSource(_DesignerHost);
            //xrDesignPanel1.Report.DataSource = null;
            xrDesignPanel1.OpenReport(Rpt);
            xrDesignPanel1.FileName = string.Empty;
            xrDesignPanel1.Report.ScriptReferences = new string[] { GetType().Assembly.Location };
            OriginalPrintControl = BaseWinFramework.mdiRibbonPrintController.PrintControl;
        }
 private void NewDesign(xReport rpt)
 {
     xrDesignPanel1.FileName = string.Empty;
     rpt.Bands.Clear();
     rpt.Bands.Add(XtraReport.CreateBand(BandKind.Detail));
     xrDesignPanel1.OpenReport(rpt);
     xrDesignPanel1.Report.ScriptReferences = new string[] { GetType().Assembly.Location };
     xrDesignPanel1.ReportState             = ReportState.Opened;
 }
Exemplo n.º 4
0
 private void NewDesign(xReport rpt)
 {
     xrDesignPanel1.FileName = string.Empty;
     rpt.Bands.Clear();
     rpt.Bands.Add(XtraReport.CreateBand(BandKind.Detail));
     xrDesignPanel1.OpenReport(rpt);
     xrDesignPanel1.Report.ScriptReferences = new string[] { GetType().Assembly.Location };
     xrDesignPanel1.ReportState             = ReportState.Opened;
     OriginalPrintControl = BaseWinFramework.mdiRibbonPrintController.PrintControl;
 }
Exemplo n.º 5
0
        // Dari Dokumen
        public void ShowForm(Form MdiParent, string ReportName,
                             BusinessEntity DataSource, Evaluator Evaluator)
        {
            SaveEval = false;
            try
            {
                xrDesignPanel1.SetCommandVisibility(ReportCommand.AddNewDataSource, CommandVisibility.None);

                _Evaluator = Evaluator ?? BaseFactory
                             .CreateInstance <Evaluator>();
                LayoutHeader = "D_";
                IDataDictionary ds = new ReportSingleEntity(DataSource);

                Text = "Desain Cetak " + ReportName;
                xReport rpt = new xReport(_Evaluator);
                rpt.PaperKind  = PaperKind.A4;
                rpt.DataSource = ds;

                RptName = ReportName;
                NewDesign(rpt);
                msTanpaLayout = new MemoryStream();
                rpt.SaveLayout(msTanpaLayout);

                if (MdiParent != null)
                {
                    this.MdiParent = MdiParent;
                }

                List <string> ListLayout = DocPrintBrowseLayout
                                           .GetListLayout(LayoutHeader + RptName);
                ((RepositoryItemComboBox)barEditItem3.Edit)
                .Items.AddRange(ListLayout);
                barEditItem3.EditValue = strTanpaLayout;
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Error Baca Layout Laporan",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
                Show();
            }
        }
Exemplo n.º 6
0
        //Cetak
        private void barButtonItem7_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            using (new WaitCursor())
            {
                try
                {
                    List <string> ListPrintLayout = DocPrintBrowseLayout.GetListLayout("L_" + _ReportName);

                    if (ListPrintLayout.Count == 0)
                    {
                        XtraMessageBox.Show("Layout Cetak Laporan tidak ditemukan !",
                                            "Error Cetak Laporan",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    string Layout;
                    if (ListPrintLayout.Count == 1)
                    {
                        Layout = ListPrintLayout[0];
                    }
                    else
                    {
                        Layout = frmCetak.ShowForm(ListPrintLayout, CurrPrintLayoutId, "Cetak Laporan");
                        if (Layout.Length == 0)
                        {
                            return;
                        }
                    }
                    MemoryStream LayoutData;
                    DocPrintBrowseLayout.GetLayoutData("L_" + _ReportName, Layout, out LayoutData);

                    xReport Rpt = new xReport(_Evaluator);
                    Rpt.DataSource = pivotGridControl1.DataSource;
                    Rpt.LoadLayout(LayoutData);

                    new frmPreview().ShowForm(MdiParent, _ReportName, Rpt);
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show(ex.Message, "Error Cetak Laporan",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Exemplo n.º 7
0
        // Dari Laporan Bebas
        public void ShowForm3(Form MdiParent, string ReportName,
                              Evaluator Evaluator)
        {
            SaveEval = true;
            try
            {
                fieldListDockPanel1.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden;
                xrDesignPanel1.SetCommandVisibility(ReportCommand.AddNewDataSource, CommandVisibility.None);
                _Evaluator   = Evaluator ?? BaseFactory.CreateInstance <Evaluator>();
                LayoutHeader = "F_";
                Text         = "Desain Cetak " + ReportName;
                xReport rpt = new xReport(Evaluator);
                rpt.PaperKind = PaperKind.A4;
                RptName       = ReportName;
                NewDesign(rpt);
                msTanpaLayout = new MemoryStream();
                rpt.SaveLayout(msTanpaLayout);
                if (MdiParent != null)
                {
                    this.MdiParent = MdiParent;
                }

                List <string> ListLayout = DocPrintBrowseLayout
                                           .GetListLayout(LayoutHeader + ReportName);
                ((RepositoryItemComboBox)barEditItem3.Edit)
                .Items.AddRange(ListLayout);
                barEditItem3.EditValue = strTanpaLayout;
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Error Baca Layout Laporan",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
                Show();
            }
        }
        private void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e)
        {
            using (new WaitCursor())
            {
                BaseWinFramework.WinForm.AutoLockEntity.LockForm(re, this);

                try
                {
                    MemoryStream ms;
                    Dictionary <string, object> QueryFormFilter =
                        new Dictionary <string, object>();
                    DocPrintBrowseLayout.GetFreeLayoutData("F_" + _ReportName,
                                                           comboBoxEdit1.Text, out ms, QueryFormFilter);

                    if (_FilterForm != null)
                    {
                        try
                        {
                            if (re != null)
                            {
                                if (LoadFilter)
                                {
                                    re.SetPersistanceField(QueryFormFilter);
                                }
                                else
                                {
                                    LoadFilter = true;
                                }
                                re.GetVariables(QueryFormFilter);
                                re.DataChanged();
                            }
                            else
                            {
                                if (QueryFormFilter != null)
                                {
                                    _FilterForm.FilterList = QueryFormFilter;
                                }
                                QueryFormFilter = _FilterForm.FilterList;
                            }
                        }
                        catch (Exception ex)
                        {
                            XtraMessageBox.Show(ex.Message,
                                                "Error Baca Filter Data",
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Exclamation);
                        }

                        if (re != null)
                        {
                            _DataSource = re.GetDataSource();
                            if (_DataSource == null)
                            {
                                string            SqlQuery;
                                string            SqlOrder;
                                List <FieldParam> ListParam = new List <FieldParam>();
                                re.GetDataSource(out SqlQuery, out SqlOrder,
                                                 ListParam);
                                if (SqlQuery.Length > 0)
                                {
                                    if (SqlOrder.Length > 0)
                                    {
                                        SqlQuery = string.Concat("SELECT * FROM (",
                                                                 SqlQuery, ") x ORDER BY ", SqlOrder);
                                    }
                                    _DataSource = re.Dp.OpenDataTable(SqlQuery, ListParam);
                                }
                            }
                            re.GetVariables(QueryFormFilter);
                        }
                        else
                        {
                            _DataSource = null;
                        }

                        foreach (KeyValuePair <string, object> Filter in QueryFormFilter)
                        {
                            Type tp = Filter.Value.GetType();
                            if (Filter.Key != "DataSource")
                            {
                                if (Filter.Key == "DataSourceOrder" ||
                                    Filter.Key == "DataSourceParams")
                                {
                                    continue;
                                }
                                if (tp == typeof(string))
                                {
                                    _Evaluator.Variables.Add(Filter.Key, (string)Filter.Value);
                                }
                                else if (tp == typeof(int) ||
                                         tp == typeof(decimal) ||
                                         tp == typeof(Single) ||
                                         tp == typeof(double) ||
                                         tp.IsEnum)
                                {
                                    _Evaluator.Variables.Add(Filter.Key, Convert.ToDecimal(Filter.Value));
                                }
                                else if (tp == typeof(bool))
                                {
                                    _Evaluator.Variables.Add(Filter.Key, (bool)Filter.Value);
                                }
                                else if (tp == typeof(DateTime))
                                {
                                    _Evaluator.Variables.Add(Filter.Key, (DateTime)Filter.Value);
                                }
                                else
                                {
                                    _Evaluator.ObjValues.Add(Filter.Key, Filter.Value);
                                }
                            }
                            else if (tp == typeof(string))
                            {
                                string SqlQuery = ((string)Filter.Value).Trim();
                                object SqlOrder;
                                if (QueryFormFilter.TryGetValue("DataSourceOrder", out SqlOrder))
                                {
                                    SqlQuery = string.Concat("SELECT * FROM (",
                                                             SqlQuery, ") x ORDER BY ", (string)SqlOrder);
                                }

                                if (SqlQuery.Length > 0)
                                {
                                    object p;

                                    QueryFormFilter.TryGetValue("DataSourceParams", out p);
                                    if (p != null)
                                    {
                                        List <FieldParam> ListParam = p as List <FieldParam>;
                                        if (ListParam != null)
                                        {
                                            _DataSource = _EntityForm.DataPersistance
                                                          .OpenDataTable(SqlQuery, ListParam);
                                        }
                                        else
                                        {
                                            _DataSource = _EntityForm.DataPersistance
                                                          .OpenDataTable(SqlQuery, p as FieldParam[]);
                                        }
                                    }
                                    else
                                    {
                                        _DataSource = _EntityForm.DataPersistance
                                                      .OpenDataTable(SqlQuery);
                                    }
                                }
                            }
                            else
                            {
                                _DataSource = Filter.Value;
                            }
                        }
                    }
                    xReport Rpt = new xReport(_Evaluator);
                    if (_DataSource != null)
                    {
                        if (_DataSource.GetType().Name == "DataTable")
                        {
                            Rpt.DataSource = _DataSource;
                        }
                        else
                        {
                            IList ds = _DataSource as IList;
                            if (ds == null)
                            {
                                ds = new BindingList <object>();
                                ds.Add(_DataSource);
                            }
                            Rpt.DataSource = ds;
                        }
                    }
                    if (ms != null)
                    {
                        Rpt.LoadLayout(ms);
                        //Rpt.ScriptReferences = new string[] { GetType().Assembly.Location };
                        printControl1.PrintingSystem = Rpt.PrintingSystem;
                        Rpt.CreateDocument();
                    }
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show(ex.Message,
                                        "Error Baca Layout Laporan", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                }
            }
        }