private void PrintGrid(TStandardFormPrint.TPrintUsing APrintApplication, bool APreviewMode)
        {
            TFormDataKeyDescriptionList recordList = new TFormDataKeyDescriptionList();
            DataView FieldOrderView = new DataView(FMainDS.PDataLabelUse);

            FieldOrderView.RowFilter = String.Format("p_use_c = '{0}'", Context);
            recordList.Title         = "Local Data Field Order For " + Context;

            String Key    = Catalog.GetString("Name");
            String Descr  = Catalog.GetString("GroupHeading");
            String Field3 = Catalog.GetString("Description");

            recordList.KeyTitle         = Key;
            recordList.DescriptionTitle = Descr;
            recordList.Field3Title      = Field3;

            foreach (DataRowView FieldOrderViewRow in FieldOrderView)
            {
                TFormDataKeyDescription record = new TFormDataKeyDescription();

                record.Key         = FieldOrderViewRow[Key].ToString();
                record.Description = FieldOrderViewRow[Descr].ToString();
                record.Field3      = FieldOrderViewRow[Field3].ToString();
                recordList.Add(record);
            }

            TStandardFormPrint.PrintRecordList(recordList,
                                               3,
                                               APrintApplication,
                                               FieldOrderView.Count,
                                               FieldOrderView,
                                               "",
                                               APreviewMode);
        }
        private void PrintGrid(TStandardFormPrint.TPrintUsing APrintApplication, bool APreviewMode)
        {
            PPartnerAttributeTypeTable typeTable = (PPartnerAttributeTypeTable)TDataCache.TMPartner.
                                                   GetCacheablePartnerTable(TCacheablePartnerTablesEnum.ContactTypeList);
            DataView typeDataView = new DataView(typeTable);

            typeDataView.Sort = PPartnerAttributeTypeTable.GetCategoryCodeDBName();

            TFormDataKeyDescriptionList recordList = new TFormDataKeyDescriptionList();

            recordList.Title            = "Contact Categories and Types";
            recordList.KeyTitle         = Catalog.GetString("Contact Category");
            recordList.DescriptionTitle = Catalog.GetString("Contact Type");
            recordList.Field3Title      = Catalog.GetString("Description");

            PPartnerAttributeTypeRow typeRow;

            foreach (DataRowView typeRowView in typeDataView)
            {
                TFormDataKeyDescription record = new TFormDataKeyDescription();

                typeRow            = (PPartnerAttributeTypeRow)typeRowView.Row;
                record.Key         = typeRow.CategoryCode;
                record.Description = typeRow.AttributeType;
                record.Field3      = typeRow.Description;
                recordList.Add(record);
            }

            TStandardFormPrint.PrintRecordList(recordList, 3, APrintApplication, typeDataView.Count, typeDataView, "", APreviewMode);
        }
Exemple #3
0
        private void PrintGrid(TStandardFormPrint.TPrintUsing APrintApplication, bool APreviewMode)
        {
            DataView EsrDataView = new DataView(TRemote.MFinance.Gift.WebConnectors.GetEsrDefaults());

            TFormDataKeyDescriptionList recordList = new TFormDataKeyDescriptionList();

            recordList.Title = "ESR Defaults";

            recordList.KeyTitle         = Catalog.GetString("ESR Key");
            recordList.DescriptionTitle = Catalog.GetString("Substitute");
            recordList.Field3Title      = Catalog.GetString("Motivation Group");
            recordList.Field4Title      = Catalog.GetString("Motivation Detail");

            foreach (DataRowView typeRowView in EsrDataView)
            {
                TFormDataKeyDescription record = new TFormDataKeyDescription();

                record.Key         = typeRowView[0].ToString();
                record.Description = typeRowView[1].ToString();
                record.Field3      = typeRowView[2].ToString();
                record.Field4      = typeRowView[3].ToString();
                recordList.Add(record);
            }

            TStandardFormPrint.PrintRecordList(recordList,
                                               4,
                                               APrintApplication,
                                               EsrDataView.Count,
                                               EsrDataView,
                                               "",
                                               APreviewMode);
        }
        private void PrintGrid(TStandardFormPrint.TPrintUsing APrintApplication, bool APreviewMode)
        {
            if (MessageBox.Show(this, Catalog.GetString("You are about to print a combined table of regions and ranges. Do you want to proceed?"),
                                Catalog.GetString("Printing"), MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                DataTable RegionsAndRangesTable    = TRemote.MPartner.Mailroom.WebConnectors.GetPostCodeRegionsAndRanges();
                DataView  regionsAndRangesDataView = new DataView(RegionsAndRangesTable);

                TFormDataKeyDescriptionList recordList = new TFormDataKeyDescriptionList();
                recordList.Title = "Regions and Ranges";

                recordList.KeyTitle         = Catalog.GetString("Region");
                recordList.DescriptionTitle = Catalog.GetString("Region Description");
                recordList.Field3Title      = Catalog.GetString("Range");
                recordList.Field4Title      = Catalog.GetString("From");
                recordList.Field5Title      = Catalog.GetString("To");

                foreach (DataRowView typeRowView in regionsAndRangesDataView)
                {
                    TFormDataKeyDescription record = new TFormDataKeyDescription();

                    record.Key         = typeRowView[0].ToString();
                    record.Description = typeRowView[1].ToString();
                    record.Field3      = typeRowView[2].ToString();
                    record.Field4      = typeRowView[3].ToString();
                    record.Field5      = typeRowView[4].ToString();
                    recordList.Add(record);
                }

                TStandardFormPrint.PrintRecordList(recordList,
                                                   5,
                                                   APrintApplication,
                                                   regionsAndRangesDataView.Count,
                                                   regionsAndRangesDataView,
                                                   "",
                                                   APreviewMode);
            }
        }
Exemple #5
0
        /// <summary>
        /// Print the data that is shown in a grid
        /// </summary>
        /// <param name="APrintApplication">The print application to use - either Word or Excel</param>
        /// <param name="APreviewOnly">True if preview, False to print without preview</param>
        /// <param name="AModule">The module that is making the call</param>
        /// <param name="ATitleText">Title for the page</param>
        /// <param name="AGrid">A grid displaying data</param>
        /// <param name="AGridColumnOrder">Zero-based grid column number order for column titles</param>
        /// <param name="ATableColumnOrder">Zero-based table column order that matches the grid columns</param>
        /// <param name="ABaseFilter">A filter that is always applied to the grid even when it is apparently showing all rows</param>
        public static void PrintGrid(TPrintUsing APrintApplication, bool APreviewOnly, TModule AModule, string ATitleText, TSgrdDataGrid AGrid,
                                     int[] AGridColumnOrder, int[] ATableColumnOrder, string ABaseFilter = "")
        {
            TFormDataKeyDescriptionList recordList = new TFormDataKeyDescriptionList();

            List <TFormData> formDataList = new List <TFormData>();
            string           msgTitle     = Catalog.GetString("Print");

            int numColumns = Math.Min(AGridColumnOrder.GetLength(0), ATableColumnOrder.GetLength(0));

            // Title of the document
            recordList.Title = ATitleText;

            // First two columns: key and description
            recordList.KeyTitle         = AGrid.Columns[AGridColumnOrder[0]].HeaderCell.ToString();
            recordList.DescriptionTitle = AGrid.Columns[AGridColumnOrder[1]].HeaderCell.ToString();

            // Other columns
            recordList.Field3Title = numColumns > 2 ? AGrid.Columns[AGridColumnOrder[2]].HeaderCell.ToString() : string.Empty;
            recordList.Field4Title = numColumns > 3 ? AGrid.Columns[AGridColumnOrder[3]].HeaderCell.ToString() : string.Empty;
            recordList.Field5Title = numColumns > 4 ? AGrid.Columns[AGridColumnOrder[4]].HeaderCell.ToString() : string.Empty;

            // Look at each data row and set values for key, description and other columns and add to the Form Data list
            DataView dv = ((DevAge.ComponentModel.BoundDataView)AGrid.DataSource).DataView;

            for (int i = 0; i < dv.Count; i++)
            {
                TFormDataKeyDescription record = new TFormDataKeyDescription();
                DataRowView             drv    = dv[i];

                record.Key         = GetPrintableText(AGrid, AGridColumnOrder[0], drv.Row[ATableColumnOrder[0]]);
                record.Description = GetPrintableText(AGrid, AGridColumnOrder[1], drv.Row[ATableColumnOrder[1]]);
                record.Field3      = numColumns > 2 ? GetPrintableText(AGrid, AGridColumnOrder[2], drv.Row[ATableColumnOrder[2]]) : string.Empty;
                record.Field4      = numColumns > 3 ? GetPrintableText(AGrid, AGridColumnOrder[3], drv.Row[ATableColumnOrder[3]]) : string.Empty;
                record.Field5      = numColumns > 4 ? GetPrintableText(AGrid, AGridColumnOrder[4], drv.Row[ATableColumnOrder[4]]) : string.Empty;
                recordList.Add(record);
            }

            formDataList.Add(recordList);

            // Work out the template file name to use.  This is based on the number of columns and any special preferences passed in.
            // For the present time the options are limited!
            string formName = "OM Print Grid ";

            formName += (APrintApplication == TPrintUsing.Excel ? "X" : "W");

            if (numColumns <= 4)
            {
                formName += "P";        // Portrait
            }
            else
            {
                formName += "L";        // Landscape
            }

            // Get the template from the db or file system
            string templatePath = GetTemplatePath(AModule, APrintApplication, formName);

            // Tell the user if we didn't find it - and quit
            if (templatePath.Length == 0)
            {
                MessageBox.Show(Catalog.GetString("Could not find the template to use for printing."), msgTitle);
                return;
            }
#if USING_TEMPLATER
            string targetDir = TTemplaterAccess.GetFormLetterBaseDirectory(TModule.mPartner);
            TTemplaterAccess.AppendUserAndDateInfo(ref targetDir, Path.GetFileNameWithoutExtension(templatePath));

            // Set up the last few data items
            recordList.PrintedBy = UserInfo.GUserInfo.UserID;
            recordList.Date      = StringHelper.DateToLocalizedString(DateTime.Now, true, true);
            recordList.Filename  = Path.Combine(targetDir, ATitleText + Path.GetExtension(templatePath));

            // And the sub-title
            int nGridRowsData     = AGrid.Rows.Count - 1;
            int nFullViewRowsData = new DataView(dv.Table, ABaseFilter, "", DataViewRowState.CurrentRows).Count;

            if (nGridRowsData == nFullViewRowsData)
            {
                recordList.SubTitle = String.Format(
                    Catalog.GetString("The table below shows all {0} rows of data in the data table."), nGridRowsData);
            }
            else
            {
                recordList.SubTitle = String.Format(
                    Catalog.GetString("The table below shows a filtered selection of {0} out of {1} rows of data in the complete data table."),
                    nGridRowsData, nFullViewRowsData);
            }

            // Send to Templater to print!
            try
            {
                bool   allDocumentsOpened;
                bool   printOnCompletion;
                string outputPath = TTemplaterAccess.PrintTemplaterDocument(TModule.mPartner,
                                                                            formDataList,
                                                                            templatePath,
                                                                            false,
                                                                            APreviewOnly,
                                                                            !APreviewOnly,
                                                                            out allDocumentsOpened,
                                                                            out printOnCompletion,
                                                                            targetDir,
                                                                            ATitleText);

                if (printOnCompletion)
                {
                    string[] files = null;

                    if (Directory.Exists(outputPath))
                    {
                        files = Directory.GetFiles(outputPath);
                    }

                    if ((files == null) || (files.Length != 1))
                    {
                        // Where has it gone??
                        string msg = string.Format(Catalog.GetString(
                                                       "Unexpectedly failed to find the document to print in the folder{0}'{1}'"),
                                                   Environment.NewLine, outputPath);
                        MessageBox.Show(msg, Catalog.GetString("Print Error"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    string printerName;

                    // request print information from user
                    using (PrintDialog pd = new PrintDialog())
                    {
                        if (pd.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }

                        // Remember this for use lower down
                        printerName = String.Format("\"{0}\"", pd.PrinterSettings.PrinterName);
                    }

                    TTemplaterAccess.RunPrintJob(printerName, files[0]);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Catalog.GetString("An error occurred while trying to print the document.  The error message was: ") + ex.Message,
                                msgTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
#endif
        }
Exemple #6
0
        /// <summary>
        /// Print the data that is shown in a grid
        /// </summary>
        /// <param name="APrintApplication">The print application to use - either Word or Excel</param>
        /// <param name="APreviewOnly">True if preview, False to print without preview</param>
        /// <param name="ATitleText">Title for the page</param>
        /// <param name="AGrid">A grid displaying data</param>
        /// <param name="AGridColumnOrder">Zero-based grid column number order for column titles</param>
        /// <param name="ATableColumnOrder">Zero-based table column order that matches the grid columns</param>
        /// <param name="ABaseFilter">A filter that is always applied to the grid even when it is apparently showing all rows</param>
        public static void PrintGrid(TPrintUsing APrintApplication, bool APreviewOnly, string ATitleText, TSgrdDataGrid AGrid,
                                     int[] AGridColumnOrder, int[] ATableColumnOrder, string ABaseFilter = "")
        {
            //TFrmSelectPrintFields TFrmSelectPFields = new TFrmSelectPrintFields();
            TFormDataKeyDescriptionList recordList = new TFormDataKeyDescriptionList();

            int numColumns = Math.Min(AGridColumnOrder.GetLength(0), ATableColumnOrder.GetLength(0));

            // Title of the document
            recordList.Title = ATitleText;

            // First column: key by default (or diffrent when sort order was changed by user)
            recordList.KeyTitle = AGrid.Columns[AGridColumnOrder[0]].HeaderCell.ToString();

            // Second column: description by default (or diffrent when sort order was changed by user)
            recordList.DescriptionTitle = numColumns > 1 ? AGrid.Columns[AGridColumnOrder[1]].HeaderCell.ToString() : string.Empty;

            // Other columns
            recordList.Field3Title  = numColumns > 2 ? AGrid.Columns[AGridColumnOrder[2]].HeaderCell.ToString() : string.Empty;
            recordList.Field4Title  = numColumns > 3 ? AGrid.Columns[AGridColumnOrder[3]].HeaderCell.ToString() : string.Empty;
            recordList.Field5Title  = numColumns > 4 ? AGrid.Columns[AGridColumnOrder[4]].HeaderCell.ToString() : string.Empty;
            recordList.Field6Title  = numColumns > 5 ? AGrid.Columns[AGridColumnOrder[5]].HeaderCell.ToString() : string.Empty;
            recordList.Field7Title  = numColumns > 6 ? AGrid.Columns[AGridColumnOrder[6]].HeaderCell.ToString() : string.Empty;
            recordList.Field8Title  = numColumns > 7 ? AGrid.Columns[AGridColumnOrder[7]].HeaderCell.ToString() : string.Empty;
            recordList.Field9Title  = numColumns > 8 ? AGrid.Columns[AGridColumnOrder[8]].HeaderCell.ToString() : string.Empty;
            recordList.Field10Title = numColumns > 9 ? AGrid.Columns[AGridColumnOrder[9]].HeaderCell.ToString() : string.Empty;

            // Look at each data row and set values for key, description and other columns and add to the Form Data list
            DataView dv = ((DevAge.ComponentModel.BoundDataView)AGrid.DataSource).DataView;

            for (int i = 0; i < dv.Count; i++)
            {
                TFormDataKeyDescription record = new TFormDataKeyDescription();
                DataRowView             drv    = dv[i];

                //GetStringToSymbol converts a "True" to a check symbol and a "False" to ""if the Type is System.Boolean
                record.Key =
                    GetStringOrSymbol(GetPrintableText(AGrid,
                                                       AGridColumnOrder[0],
                                                       drv.Row[ATableColumnOrder[0]]), drv.Row[ATableColumnOrder[0]].GetType());
                record.Description = numColumns > 1 ? GetStringOrSymbol(GetPrintableText(AGrid,
                                                                                         AGridColumnOrder[1],
                                                                                         drv.Row[ATableColumnOrder[1]]), drv.Row[ATableColumnOrder[1]].GetType()) : string.Empty;
                record.Field3 = numColumns > 2 ? GetStringOrSymbol(GetPrintableText(AGrid,
                                                                                    AGridColumnOrder[2],
                                                                                    drv.Row[ATableColumnOrder[2]]), drv.Row[ATableColumnOrder[2]].GetType()) : string.Empty;
                record.Field4 = numColumns > 3 ? GetStringOrSymbol(GetPrintableText(AGrid,
                                                                                    AGridColumnOrder[3],
                                                                                    drv.Row[ATableColumnOrder[3]]), drv.Row[ATableColumnOrder[3]].GetType()) : string.Empty;
                record.Field5 = numColumns > 4 ? GetStringOrSymbol(GetPrintableText(AGrid,
                                                                                    AGridColumnOrder[4],
                                                                                    drv.Row[ATableColumnOrder[4]]), drv.Row[ATableColumnOrder[4]].GetType()) : string.Empty;
                record.Field6 = numColumns > 5 ? GetStringOrSymbol(GetPrintableText(AGrid,
                                                                                    AGridColumnOrder[5],
                                                                                    drv.Row[ATableColumnOrder[5]]), drv.Row[ATableColumnOrder[5]].GetType()) : string.Empty;
                record.Field7 = numColumns > 6 ? GetStringOrSymbol(GetPrintableText(AGrid,
                                                                                    AGridColumnOrder[6],
                                                                                    drv.Row[ATableColumnOrder[6]]), drv.Row[ATableColumnOrder[6]].GetType()) : string.Empty;
                record.Field8 = numColumns > 7 ? GetStringOrSymbol(GetPrintableText(AGrid,
                                                                                    AGridColumnOrder[7],
                                                                                    drv.Row[ATableColumnOrder[7]]), drv.Row[ATableColumnOrder[7]].GetType()) : string.Empty;
                record.Field9 = numColumns > 8 ? GetStringOrSymbol(GetPrintableText(AGrid,
                                                                                    AGridColumnOrder[8],
                                                                                    drv.Row[ATableColumnOrder[8]]), drv.Row[ATableColumnOrder[8]].GetType()) : string.Empty;
                record.Field10 = numColumns > 9 ? GetStringOrSymbol(GetPrintableText(AGrid,
                                                                                     AGridColumnOrder[9],
                                                                                     drv.Row[ATableColumnOrder[9]]), drv.Row[ATableColumnOrder[9]].GetType()) : string.Empty;
                recordList.Add(record);
            }

            PrintRecordList(recordList, numColumns, APrintApplication, AGrid.Rows.Count - 1, dv, ABaseFilter, APreviewOnly);
        }