private void CreateExtract_Click(System.Object sender, EventArgs e)
        {
            TFrmExtractNamingDialog ExtractNameDialog = new TFrmExtractNamingDialog(this);
            IPartnerUIConnectorsPartnerNewExtract PartnerExtractObject = TRemote.MPartner.Extracts.UIConnectors.PartnerNewExtract();
            int    ExtractId = 0;
            string ExtractName;
            string ExtractDescription;

            ExtractNameDialog.ShowDialog();

            if (ExtractNameDialog.DialogResult != System.Windows.Forms.DialogResult.Cancel)
            {
                /* Get values from the Dialog */
                ExtractNameDialog.GetReturnedParameters(out ExtractName, out ExtractDescription);
            }
            else
            {
                // dialog was cancelled, do not continue with extract generation
                return;
            }

            ExtractNameDialog.Dispose();

            this.Cursor = Cursors.WaitCursor;

            DataTable PartnerKeysTable = ((DevAge.ComponentModel.BoundDataView)grdApplications.DataSource).DataView.ToTable();

            // create empty extract with given name and description and store it in db
            if (PartnerExtractObject.CreateExtractFromListOfPartnerKeys(ExtractName, ExtractDescription, out ExtractId, PartnerKeysTable, 0, false))
            {
                this.Cursor = Cursors.Default;

                if (MessageBox.Show(
                        string.Format(
                            Catalog.GetString(
                                "Extract Created with {0} Partners.{1}{1}Do you want to open the 'Maintain Extract' screen now?"),
                            PartnerKeysTable.Rows.Count, "\n"),
                        Catalog.GetString("Create Extract"),
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    // now open Screen for new extract so user can add partner records manually
                    TFrmExtractMaintain frm = new TFrmExtractMaintain(this);
                    frm.ExtractId   = ExtractId;
                    frm.ExtractName = ExtractName;
                    frm.Show();
                }
            }
            else
            {
                this.Cursor = Cursors.Default;

                MessageBox.Show(Catalog.GetString("Creation of extract failed"),
                                Catalog.GetString("Generate Manual Extract"),
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Stop);
                return;
            }
        }
Пример #2
0
        /// <summary>
        /// Called from a delegate set up by me.
        /// </summary>
        /// <param name="ACalc"></param>
        public void GenerateExtract(TRptCalculator ACalc)
        {
            ACalc.GetParameters().Add("param_design_template", false);

            if (FDataGetter == null)
            {
                MessageBox.Show(Catalog.GetString("Fault: No Data Table available."), Catalog.GetString("GenerateExtract"));
                return;
            }

            if (!FDataGetter(ACalc))
            {
                return;
            }

            FExtractPartnerKeyName = SelectColumnNameForExract(FClientDataTable, FExtractPartnerKeyName);

            if (FExtractPartnerKeyName == "")
            {
                return;
            }

            Int32 partnerKeyColumnNum = FClientDataTable.Columns[FExtractPartnerKeyName].Ordinal;

            TFrmExtractNamingDialog ExtractNameDialog = new TFrmExtractNamingDialog(FPetraUtilsObject.GetForm());
            string ExtractName;
            string ExtractDescription;

            ExtractNameDialog.ShowDialog();

            if (ExtractNameDialog.DialogResult != System.Windows.Forms.DialogResult.Cancel)
            {
                /* Get values from the Dialog */
                ExtractNameDialog.GetReturnedParameters(out ExtractName, out ExtractDescription);
            }
            else
            {
                // dialog was cancelled, do not continue with extract generation
                return;
            }

            ExtractNameDialog.Dispose();

            FPetraUtilsObject.GetForm().UseWaitCursor = true;

            // Create extract with given name and description and store it
            int ExtractId = 0;
            IPartnerUIConnectorsPartnerNewExtract PartnerExtractObject = TRemote.MPartner.Extracts.UIConnectors.PartnerNewExtract();
            Boolean CreateOk = PartnerExtractObject.CreateExtractFromListOfPartnerKeys(
                ExtractName, ExtractDescription, out ExtractId, FClientDataTable, partnerKeyColumnNum, false);

            FPetraUtilsObject.GetForm().UseWaitCursor = false;

            if (CreateOk)
            {
                MessageBox.Show(String.Format(Catalog.GetString("Extract Created with {0} Partners."),
                                              FClientDataTable.Rows.Count),
                                Catalog.GetString("Generate Extract"));
            }
            else
            {
                MessageBox.Show(Catalog.GetString("Creation of extract failed"),
                                Catalog.GetString("Generate Extract"),
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Stop);
            }
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void tbtCreateExtractClick(System.Object sender, System.EventArgs e)
        {
            XmlDocument doc = Results.WriteXmlDocument(Parameters, true);
            DataTable   Tbl = new DataTable();

            Tbl.Columns.Add("PartnerKey", typeof(Int64));
            XmlNodeList Rows       = doc.SelectNodes("*/Element");
            XmlNode     FirstRow   = Rows[0];
            String      ColumnName = SelectColumnNameForExract(FirstRow);

            this.UseWaitCursor = true;

            foreach (XmlNode node in Rows)
            {
                XmlAttribute Attr = node.Attributes[ColumnName];

                if (Attr != null)
                {
                    Int64 intPartnerKey;

                    if (Int64.TryParse(Attr.Value, out intPartnerKey))
                    {
                        DataRow Row = Tbl.NewRow();
                        Row["PartnerKey"] = intPartnerKey;
                        Tbl.Rows.Add(Row);
                    }
                }
            }

            this.UseWaitCursor = false;

            if (Tbl.Rows.Count < 1)
            {
                MessageBox.Show(Catalog.GetString("Error - no Partner keys found"), Catalog.GetString("Generate Extract"));
                return;
            }

            TFrmExtractNamingDialog ExtractNameDialog = new TFrmExtractNamingDialog(this);
            string ExtractName;
            string ExtractDescription;

            ExtractNameDialog.ShowDialog();

            if (ExtractNameDialog.DialogResult != System.Windows.Forms.DialogResult.Cancel)
            {
                /* Get values from the Dialog */
                ExtractNameDialog.GetReturnedParameters(out ExtractName, out ExtractDescription);
            }
            else
            {
                // dialog was cancelled, do not continue with extract generation
                return;
            }

            ExtractNameDialog.Dispose();

            this.UseWaitCursor = true;

            // Create extract with given name and description and store it
            int ExtractId = 0;
            IPartnerUIConnectorsPartnerNewExtract PartnerExtractObject = TRemote.MPartner.Extracts.UIConnectors.PartnerNewExtract();
            Boolean CreateOk = PartnerExtractObject.CreateExtractFromListOfPartnerKeys(ExtractName, ExtractDescription, out ExtractId, Tbl, 0, false);

            this.UseWaitCursor = false;

            if (CreateOk)
            {
                MessageBox.Show(String.Format(Catalog.GetString("Extract Created with {0} Partners."),
                                              Tbl.Rows.Count),
                                Catalog.GetString("Generate Extract"));
            }
            else
            {
                MessageBox.Show(Catalog.GetString("Creation of extract failed"),
                                Catalog.GetString("Generate Extract"),
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Stop);
            }
        }