コード例 #1
0
        //Simpan Layout Baru
        private void barButtonItem2_ItemClick(object sender, ItemClickEventArgs e)
        {
            frmSaveLayout frm = new frmSaveLayout();

            if (frm.ShowDialog(this) == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }

            using (new WaitCursor())
            {
                MemoryStream mst = new MemoryStream();
                xrDesignPanel1.Report.SaveLayout(mst);

                try
                {
                    if (SaveEval)
                    {
                        Dictionary <string, object> Filter = new Dictionary <string, object>();

                        if (_Evaluator != null)
                        {
                            foreach (KeyValuePair <string, object> Var in _Evaluator.Variables.VarDictionary)
                            {
                                Filter.Add(Var.Key, Var.Value);
                            }
                        }

                        DocPrintBrowseLayout.SaveNewFreeLayout(LayoutHeader + RptName,
                                                               frm.strText, mst, Filter);
                    }
                    else
                    {
                        DocPrintBrowseLayout.SaveNewLayout(LayoutHeader + RptName,
                                                           frm.strText, mst);
                    }

                    ((RepositoryItemComboBox)barEditItem3.Edit).Items
                    .Add(frm.strText);

                    barEditItem3.EditValue = frm.strText;

                    xrDesignPanel1.ReportState = ReportState.Opened;
                    xrDesignPanel1.FileName    = string.Empty;
                }
                finally { }
                //catch (Exception ex)
                //{
                //    XtraMessageBox.Show(ex.Message, "Error Menambah Layout",
                //        MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    return;
                //}
            }
        }
コード例 #2
0
        private void LayoutAction(int ActionId)
        {
            using (new WaitCursor())
            {
                MemoryStream mst;
                Dictionary <string, object> DictFormFilter = null;
                int i = comboBoxEdit1.SelectedIndex;

                if (i == 0 && (ActionId == 1 || ActionId == 3))
                {
                    XtraMessageBox.Show("(Layout Default) tidak dapat disimpan/ dihapus !",
                                        "Error Simpan Layout",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                switch (ActionId)
                {
                case 1:     //Simpan
                    if (XtraMessageBox.Show("Update Layout Laporan ?",
                                            "Konfirmasi Update Layout Laporan", MessageBoxButtons.YesNo,
                                            MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }

                    try
                    {
                        mst = new MemoryStream();
                        pivotGridControl1.SaveLayoutToStream(mst);
                        if (_FilterForm != null)
                        {
                            DictFormFilter = _FilterForm.FilterList;
                        }
                        DocBrowseLayout.SaveUpdateLayout(_ReportName,
                                                         comboBoxEdit1.Text, mst, textEdit1.Text, DictFormFilter);
                    }
                    catch (Exception ex)
                    {
                        XtraMessageBox.Show(ex.Message, "Error Update Layout",
                                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    break;

                case 2:     //Tambah
                    frmSaveLayout frm = new frmSaveLayout();
                    if (frm.ShowDialog(this) == DialogResult.Cancel)
                    {
                        return;
                    }

                    mst = new MemoryStream();
                    pivotGridControl1.SaveLayoutToStream(mst);
                    if (_FilterForm != null)
                    {
                        DictFormFilter = _FilterForm.FilterList;
                    }

                    try
                    {
                        DocBrowseLayout.SaveNewLayout(_ReportName,
                                                      frm.strText, mst, textEdit1.Text, DictFormFilter);
                        comboBoxEdit1.Properties.Items.Add(frm.strText);
                        comboBoxEdit1.SelectedIndex = comboBoxEdit1.Properties.Items.Count - 1;
                    }
                    catch (Exception ex)
                    {
                        XtraMessageBox.Show(ex.Message, "Error Menambah Layout",
                                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    break;

                case 3:     //Hapus
                    if (XtraMessageBox.Show("Hapus Layout Laporan ?",
                                            "Konfirmasi Hapus Layout Laporan", MessageBoxButtons.YesNo,
                                            MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }

                    try
                    {
                        DocBrowseLayout.DeleteLayout(_ReportName, comboBoxEdit1.Text);
                        int idx = comboBoxEdit1.SelectedIndex;
                        comboBoxEdit1.Properties.Items.RemoveAt(idx);
                        int Cnt = comboBoxEdit1.Properties.Items.Count;
                        if (idx < Cnt)
                        {
                            comboBoxEdit1.SelectedIndex = idx;
                        }
                        else
                        {
                            comboBoxEdit1.SelectedIndex = Cnt - 1;
                        }
                    }
                    catch (Exception ex)
                    {
                        XtraMessageBox.Show(ex.Message, "Error Hapus Layout",
                                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    break;
                }
            }
        }