Ejemplo n.º 1
0
        /// <summary>
        /// 窗体加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmTemplateSetting_Load(object sender, EventArgs e)
        {
            FillTreeViewNodes();
            var filePath = BillPrintHelper.GetDefaultTemplatePath();

            if (!string.IsNullOrEmpty(filePath))
            {
                if (File.Exists(filePath))
                {
                    txtFileFullPath.Text = filePath;
                    _report.Clear();
                    _report.LoadFromFile(filePath);
                    axGRDesigner1.Report        = _report;
                    axGRDesigner1.DefaultAction = false;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 选中节点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (treeView1.SelectedNode.Level == 0)
            {
                return;
            }
            var path = GetSelectPath();

            if (File.Exists(path))
            {
                _report.Clear();
                _report.LoadFromFile(GetSelectPath());
                axGRDesigner1.Report        = _report;
                axGRDesigner1.DefaultAction = false;
            }
            else
            {
                XtraMessageBox.Show(@"未找到模板文件", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 3
0
        private void DefineReport()
        {
            Report.Clear();

            //定义报表主对象的属性
            Report.Font.Point = 9;

            //定义页眉
            DefinePageHeader();

            //定义页脚
            DefinePageFooter();

            //定义报表头
            DefineReportHeader();

            //定义明细网格
            DefineDetailGrid();
        }
Ejemplo n.º 4
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "Msg001", "")))
            {
                return;
            }
            bool          IsOk   = true;
            GridppReport  Report = new GridppReport();
            IGRMemoBox    memoBox;
            IGRStaticBox  staticBox;
            IGRGroup      group = null;
            GRFieldType   ft;
            IGRField      grField;
            IGRColumn     grCol;
            IGRFieldBox   fieldBox;
            IGRSummaryBox sumBox;
            GRSummaryFun  grSum;
            string        groupField     = "";
            string        fn             = "";
            string        fnEx           = "";
            string        fr             = "";
            string        FirstFieldName = "";
            bool          IsFirstField   = true;
            int           l         = 0;
            byte          DateFlag  = 0;
            string        DateField = "";

            if (radioButton3.Checked && (cbbTime2.SelectedIndex >= 0))
            {
                DateFlag  = 1;
                DateField = ((TCommonType)cbbTime2.Items[cbbTime2.SelectedIndex]).id;
            }
            else if (radioButton2.Checked && (cbbTime1.SelectedIndex >= 0))
            {
                DateFlag  = 2;
                DateField = ((TCommonType)cbbTime1.Items[cbbTime1.SelectedIndex]).id;
            }
            else if (radioButton4.Checked && (cbbTime3.SelectedIndex >= 0))
            {
                DateFlag  = 3;
                DateField = ((TCommonType)cbbTime3.Items[cbbTime3.SelectedIndex]).id;
            }
            try
            {
                Report.Clear();
                Report.Font.Point           = 9;
                Report.Printer.LeftMargin   = 0.5;
                Report.Printer.TopMargin    = 0.5;
                Report.Printer.RightMargin  = 0.5;
                Report.Printer.BottomMargin = 0.5;
                //页眉
                Report.InsertPageHeader();
                Report.PageHeader.Height = 0.8;
                staticBox           = Report.PageHeader.Controls.Add(GRControlType.grctStaticBox).AsStaticBox;
                staticBox.Dock      = GRDockStyle.grdsLeft;
                staticBox.Name      = "StaticBoxCommany";
                staticBox.TextAlign = GRTextAlign.grtaBottomLeft;
                staticBox.Width     = 9;
                memoBox             = Report.PageHeader.Controls.Add(GRControlType.grctMemoBox).AsMemoBox;
                memoBox.Dock        = GRDockStyle.grdsRight;
                memoBox.Text        = "[#SystemVar(CurrentDateTime)#] [#SystemVar(PageNumber)#]/[#SystemVar(PageCount)#]";
                memoBox.TextAlign   = GRTextAlign.grtaBottomRight;
                memoBox.Width       = 9;
                //页尾
                Report.InsertReportFooter();
                Report.get_ReportFooter(1).Height = 0;
                //报表头
                Report.InsertReportHeader();
                Report.get_ReportHeader(1).Height       = 0.8;
                Report.get_ReportHeader(1).RepeatOnPage = true;
                IGRLine line = Report.get_ReportHeader(1).Controls.Add(GRControlType.grctLine).AsLine;
                line.Dock            = GRDockStyle.grdsTop;
                staticBox            = Report.get_ReportHeader(1).Controls.Add(GRControlType.grctStaticBox).AsStaticBox;
                staticBox.Name       = "MainTitleBox";
                staticBox.Center     = GRCenterStyle.grcsHorizontal;
                staticBox.ForeColor  = Pub.ColorToOleColor(Color.Red);
                staticBox.TextAlign  = GRTextAlign.grtaBottomCenter;
                staticBox.Font.Bold  = true;
                staticBox.Font.Point = 16;
                staticBox.Text       = SelectReportName;
                staticBox.Height     = 0.71;
                staticBox.Dock       = GRDockStyle.grdsTop;
                staticBox            = Report.get_ReportHeader(1).Controls.Add(GRControlType.grctStaticBox).AsStaticBox;
                if (DateField != "")
                {
                    Report.get_ReportHeader(1).Height = 1.4;
                    staticBox.Name       = "StaticBoxDate";
                    staticBox.Center     = GRCenterStyle.grcsHorizontal;
                    staticBox.TextAlign  = GRTextAlign.grtaMiddleCenter;
                    staticBox.Font.Point = 9;
                    staticBox.Text       = SelectReportName;
                    staticBox.Height     = 0.5;
                    staticBox.Dock       = GRDockStyle.grdsBottom;
                }
                //明细网格
                Report.InsertDetailGrid();
                Report.DetailGrid.BorderColor             = Pub.ColorToOleColor(Color.FromArgb(192, 192, 192));
                Report.DetailGrid.ColLineColor            = Pub.ColorToOleColor(Color.FromArgb(192, 192, 192));
                Report.DetailGrid.RowLineColor            = Pub.ColorToOleColor(Color.FromArgb(192, 192, 192));
                Report.DetailGrid.ColumnTitle.Height      = 0.61;
                Report.DetailGrid.ColumnContent.Height    = 0.61;
                Report.DetailGrid.ColumnTitle.RepeatStyle = GRRepeatStyle.grrsOnPage;
                //分组
                if (GetGridCount(gpGrid) > 0)
                {
                    group = Report.DetailGrid.Groups.Add();
                    group.Header.Height = 0.61;
                    for (int i = 0; i < gpGrid.RowCount; i++)
                    {
                        if ((bool)gpGrid[0, i].EditedFormattedValue)
                        {
                            fn = gpGrid[2, i].Value.ToString();
                            if (fn == "")
                            {
                                fn = gpGrid[1, i].Value.ToString();
                            }
                            groupField = groupField + fn + ";";
                        }
                    }
                    groupField = groupField.Substring(0, groupField.Length - 1);
                }
                for (int i = 0; i < fdGrid.RowCount; i++)
                {
                    if ((bool)fdGrid[0, i].EditedFormattedValue)
                    {
                        fn = fdGrid[1, i].Value.ToString();
                        fr = "";
                        switch (fdGrid[3, i].Value.ToString().ToLower())
                        {
                        case "string":
                            ft = GRFieldType.grftString;
                            break;

                        case "datetime":
                            ft = GRFieldType.grftDateTime;
                            break;

                        case "byte":
                            ft = GRFieldType.grftInteger;
                            fr = "0;;#";
                            break;

                        case "double":
                            ft = GRFieldType.grftCurrency;
                            fr = "¥#,##0.00";
                            break;

                        default:
                            ft = GRFieldType.grftString;
                            break;
                        }
                        grField        = Report.DetailGrid.Recordset.AddField(fn, ft);
                        grField.Format = fr;
                        fnEx           = fdGrid[2, i].Value.ToString();
                        if (fnEx == "")
                        {
                            fnEx = fn;
                        }
                        grField.Name        = fnEx;
                        grField.DBFieldName = fn;
                        string tmp = groupField + ";";
                        if (tmp.IndexOf(fnEx + ";") == -1)
                        {
                            grCol = Report.DetailGrid.AddColumn(fnEx, fn, fnEx, 2);
                            grCol.TitleCell.Text      = fnEx;
                            grCol.TitleCell.BackColor = Pub.ColorToOleColor(Color.FromArgb(128, 255, 128));
                            grCol.TitleCell.TextAlign = GRTextAlign.grtaMiddleCenter;
                            if (IsFirstField)
                            {
                                FirstFieldName = fnEx;
                                IsFirstField   = false;
                            }
                        }
                    }
                }
                //分组
                if ((groupField != "") && (group != null))
                {
                    group.ByFields = groupField;
                    l = 0;
                    for (int i = 0; i < gpGrid.RowCount; i++)
                    {
                        if ((bool)gpGrid[0, i].EditedFormattedValue)
                        {
                            fn = gpGrid[2, i].Value.ToString();
                            if (fn == "")
                            {
                                fn = gpGrid[1, i].Value.ToString();
                            }
                            fieldBox           = group.Header.Controls.Add(GRControlType.grctFieldBox).AsFieldBox;
                            fieldBox.DataField = fn;
                            fieldBox.Left      = l;
                            fieldBox.Top       = 0;
                            fieldBox.Width     = 2;
                            fieldBox.Height    = 0.61;
                            fieldBox.ForeColor = Pub.ColorToOleColor(Color.FromArgb(0, 0, 128));
                            l += 2;
                        }
                    }
                }
                //合计
                if (GetGridCount(smGrid) > 0)
                {
                    Report.get_ReportFooter(1).Height = 0.61;
                    staticBox             = Report.get_ReportFooter(1).Controls.Add(GRControlType.grctStaticBox).AsStaticBox;
                    staticBox.Name        = "StaticBoxSum";
                    staticBox.Text        = Pub.GetResText(formCode, staticBox.Name, "");
                    staticBox.Font.Bold   = true;
                    staticBox.BorderColor = Pub.ColorToOleColor(Color.FromArgb(192, 192, 192));
                    staticBox.Left        = 0;
                    staticBox.Height      = 0.61;
                    staticBox.AlignColumn = FirstFieldName;
                    staticBox.Width       = 2;
                    if (groupField != "")
                    {
                        group.Footer.Height   = 0.61;
                        staticBox             = group.Footer.Controls.Add(GRControlType.grctStaticBox).AsStaticBox;
                        staticBox.Name        = "StaticBoxSumMin";
                        staticBox.Text        = Pub.GetResText(formCode, staticBox.Name, "");
                        staticBox.Font.Bold   = true;
                        staticBox.BorderColor = Pub.ColorToOleColor(Color.FromArgb(192, 192, 192));
                        staticBox.Left        = 0;
                        staticBox.Height      = 0.61;
                        staticBox.AlignColumn = FirstFieldName;
                        staticBox.Width       = 2;
                    }
                    for (int i = 0; i < smGrid.RowCount; i++)
                    {
                        if ((bool)smGrid[0, i].EditedFormattedValue)
                        {
                            fn = smGrid[2, i].Value.ToString();
                            if (fn == "")
                            {
                                fn = smGrid[1, i].Value.ToString();
                            }
                            sumBox = Report.get_ReportFooter(1).Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox;
                            switch (smGrid[3, i].Value.ToString().ToLower())
                            {
                            case "byte":
                            case "double":
                                grSum = GRSummaryFun.grsfSum;
                                break;

                            default:
                                grSum = GRSummaryFun.grsfCount;
                                break;
                            }
                            sumBox.SummaryFun  = grSum;
                            sumBox.DataField   = fn;
                            sumBox.AlignColumn = fn;
                            if (groupField != "")
                            {
                                sumBox             = group.Footer.Controls.Add(GRControlType.grctSummaryBox).AsSummaryBox;
                                sumBox.SummaryFun  = grSum;
                                sumBox.DataField   = fn;
                                sumBox.AlignColumn = fn;
                            }
                        }
                    }
                }
                string OrderFields = "";
                for (int i = 0; i < orGrid.RowCount; i++)
                {
                    if ((bool)orGrid[0, i].EditedFormattedValue)
                    {
                        OrderFields = OrderFields + orGrid[1, i].Value.ToString() + ",";
                    }
                }
                if (OrderFields != "")
                {
                    OrderFields = OrderFields.Substring(0, OrderFields.Length - 1);
                }
                string sql = Pub.GetSQL(DBCode.DB_000001, new string[] { "603", ReportTable, SelectReportName,
                                                                         SelectTableName, OrderFields, DateFlag.ToString(), DateField });
                db.ExecSQL(sql);
                string reportData = Report.SaveToStr();
                db.UpdateTextData(Pub.GetSQL(DBCode.DB_000001, new string[] { "303", ReportTable,
                                                                              SelectReportName }), "ReportData", reportData);
                ReportName = SelectReportName;
            }
            catch (Exception E)
            {
                IsOk = false;
                Pub.ShowErrorMsg(E);
            }
            if (!IsOk)
            {
                return;
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }