예제 #1
0
        private void button_editCfgFile_Click(object sender, EventArgs e)
        {
            string strError = "";

            string strLocalFileName = this.textBox_cfgFileName.Text;

            if (string.IsNullOrEmpty(strLocalFileName) == false)
            {
            }
            else
            {
                string strNumber = this.GetTypeNumber();
                if (string.IsNullOrEmpty(strNumber) == true)
                {
                    strError = "请先指定报表类型,才能创建新的配置文件";
                    goto ERROR1;
                }

                string strFileName = strNumber + ".xml";
                strLocalFileName = Path.Combine(this.CfgFileDir, strFileName);
            }

            ReportDefForm dlg = new ReportDefForm();

            MainForm.SetControlFont(dlg, this.Font, false);
            dlg.AppInfo = Program.MainForm.AppInfo;

            Program.MainForm.AppInfo.LinkFormState(dlg, "ReportDefForm_state");
            dlg.CfgFileName = strLocalFileName;
            dlg.UiState     = Program.MainForm.AppInfo.GetString("reportapply_form", "reportdefform_ui_state", "");
            dlg.ShowDialog(this);
            Program.MainForm.AppInfo.SetString("reportapply_form", "reportdefform_ui_state", dlg.UiState);
            Program.MainForm.AppInfo.UnlinkFormState(dlg);

            if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }

            this.textBox_cfgFileName.Text = strLocalFileName;
            AutoFillReportName();
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
예제 #2
0
        void FillReportTypeList()
        {
            if (this.comboBox_reportType.Items.Count > 0)
            {
                return;
            }

            string        strCfgDir = Path.Combine(Program.MainForm.UserDir, "report_def");
            DirectoryInfo di        = new DirectoryInfo(strCfgDir);

            List <FileInfo> array = new List <FileInfo>();

            array.AddRange(di.GetFiles("???.xml"));
            array.AddRange(di.GetFiles("????.xml"));
            FileInfo[] fis = array.ToArray();
            Array.Sort(fis, new FileInfoCompare());

            foreach (FileInfo fi in fis)
            {
                ReportConfigStruct config = null;

                string strError = "";
                string strName  = "";
                // 从报表配置文件中获得各种配置信息
                // return:
                //      -1  出错
                //      0   没有找到配置文件
                //      1   成功
                int nRet = ReportDefForm.GetReportConfig(fi.FullName,
                                                         out config,
                                                         out strError);
                if (nRet == -1 || nRet == 0)
                {
                    strName = strError;
                }
                else
                {
                    string strNumber = "";
                    StringUtil.ParseTwoPart(config.TypeName, " ", out strNumber, out strName);
                }

                this.comboBox_reportType.Items.Add(Path.GetFileNameWithoutExtension(fi.Name) + "\t" + strName);
            }
        }
예제 #3
0
        private void button_editCfgFile_Click(object sender, EventArgs e)
        {
            string strError = "";

            string strLocalFileName = this.textBox_cfgFileName.Text;
            if (string.IsNullOrEmpty(strLocalFileName) == false)
            {
            }
            else
            {
                string strNumber = this.GetTypeNumber();
                if (string.IsNullOrEmpty(strNumber) == true)
                {
                    strError = "请先指定报表类型,才能创建新的配置文件";
                    goto ERROR1;
                }

                string strFileName = strNumber + ".xml";
                strLocalFileName = Path.Combine(this.CfgFileDir, strFileName);
            }

            ReportDefForm dlg = new ReportDefForm();

            MainForm.SetControlFont(dlg, this.Font, false);
            dlg.AppInfo = this.MainForm.AppInfo;

            this.MainForm.AppInfo.LinkFormState(dlg, "ReportDefForm_state");
            dlg.CfgFileName = strLocalFileName;
            dlg.UiState = this.MainForm.AppInfo.GetString("reportapply_form", "reportdefform_ui_state", "");
            dlg.ShowDialog(this);
            this.MainForm.AppInfo.SetString("reportapply_form", "reportdefform_ui_state", dlg.UiState);
            this.MainForm.AppInfo.UnlinkFormState(dlg);

            if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                return;

            this.textBox_cfgFileName.Text = strLocalFileName;
            AutoFillReportName();
            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }
예제 #4
0
        // 自动增全报表配置
        // return:
        //      -1  出错
        //      >=0 新增的报表类型个数
        public int AutoAppend(
            out string strError)
        {
            strError = "";

            string strCfgFileDir = Path.Combine(this.MainForm.UserDir, "report_def");   //  Path.Combine(this.MainForm.UserDir, "report_def");

            DirectoryInfo di = new DirectoryInfo(strCfgFileDir);

            FileInfo[] fis = di.GetFiles("???.xml");
            Array.Sort(fis, new FileInfoCompare());

            List <string> types = new List <string>();

            foreach (FileInfo fi in fis)
            {
                string strName = Path.GetFileNameWithoutExtension(fi.Name);

                ListViewItem dup = ListViewUtil.FindItem(this.listView_reports, strName, COLUMN_REPORT_TYPE);
                if (dup != null)
                {
                    continue;
                }

                types.Add(strName);
            }

            int nCount = 0;
            int i      = 0;

            foreach (string strType in types)
            {
                string strFileName      = strType + ".xml";
                string strLocalFilePath = Path.Combine(this.MainForm.UserDir, "report_def\\" + strFileName);

                ReportConfigStruct config = null;

                // 从报表配置文件中获得各种配置信息
                // return:
                //      -1  出错
                //      0   没有找到配置文件
                //      1   成功
                int nRet = ReportDefForm.GetReportConfig(strLocalFilePath,
                                                         out config,
                                                         out strError);
                if (nRet == -1 || nRet == 0)
                {
                    return(-1);
                }

                string strReportName = "";
                if (string.IsNullOrEmpty(config.TypeName) == false &&
                    config.TypeName.Length > 3)
                {
                    strReportName = config.TypeName.Substring(3).Trim();
                }
                else
                {
                    strReportName = strType + "_" + (i + 1).ToString();
                }

                string strNameTable = "";
                if (strType == "102")
                {
                    strNameTable = "";  // TODO: 根据现有数据创建名称表
                }
                ListViewItem item = new ListViewItem();
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_NAME, strReportName);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_FREQ, config.CreateFreq);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_TYPE, strType);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_CFGFILE, strLocalFilePath);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_NAMETABLE, strNameTable);
                this.listView_reports.Items.Add(item);

                i++;
                nCount++;
            }

            return(nCount);
        }
예제 #5
0
        // 自动创建全部报表配置
        public int AutoCreate(
            string strLibraryCode,
            out string strError)
        {
            strError = "";

            this.Clear();

            // 基本参数
            this.comboBox_general_libraryCode.Text = strLibraryCode;

            // 创建每种类型的报表
#if NO
            string[] types = new string[] {
                "101",
                "102",
                "111",
                "121",
                "131",
                "201",
                "202",
                "212",
                "301",
                "441",
                "442",
                "443",
            };
#endif

            string strCfgFileDir = Path.Combine(this.MainForm.UserDir, "report_def");   //  Path.Combine(this.MainForm.UserDir, "report_def");

            DirectoryInfo di  = new DirectoryInfo(strCfgFileDir);
            FileInfo[]    fis = di.GetFiles("???.xml");
            Array.Sort(fis, new FileInfoCompare());

            List <string> types = new List <string>();
            foreach (FileInfo fi in fis)
            {
                types.Add(Path.GetFileNameWithoutExtension(fi.Name));
            }

            int i = 0;
            foreach (string strType in types)
            {
                // 从 dp2003.com 下载配置文件
                string strFileName      = strType + ".xml";
                string strLocalFilePath = Path.Combine(this.MainForm.UserDir, "report_def\\" + strFileName);

#if NO
                int nRet = DownloadDataFile(
                    this,
                    strFileName,
                    strCfgFileDir,
                    out strLocalFilePath,
                    out strError);
                if (nRet == -1)
                {
                    return(-1);
                }
#endif

                ReportConfigStruct config = null;

                // 从报表配置文件中获得各种配置信息
                // return:
                //      -1  出错
                //      0   没有找到配置文件
                //      1   成功
                int nRet = ReportDefForm.GetReportConfig(strLocalFilePath,
                                                         out config,
                                                         out strError);
                if (nRet == -1 || nRet == 0)
                {
                    return(-1);
                }

                string strReportName = "";
                if (string.IsNullOrEmpty(config.TypeName) == false &&
                    config.TypeName.Length > 3)
                {
                    strReportName = config.TypeName.Substring(3).Trim();
                }
                else
                {
                    strReportName = strType + "_" + (i + 1).ToString();
                }

                string strNameTable = "";
                if (strType == "102")
                {
                    strNameTable = "";  // TODO: 根据现有数据创建名称表
                }
                ListViewItem item = new ListViewItem();
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_NAME, strReportName);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_FREQ, config.CreateFreq);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_TYPE, strType);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_CFGFILE, strLocalFilePath);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_NAMETABLE, strNameTable);
                this.listView_reports.Items.Add(item);

                i++;
            }

            return(0);
        }
예제 #6
0
        // 自动填充面板上的 报表名和创建频率
        void AutoFillReportName()
        {
#if NO
            // 用配置文件中的 typeName 填充报表名称
            if (string.IsNullOrEmpty(this.textBox_reportName.Text) == false)
            {
                return;
            }
#endif

            string strError = "";

            string strLocalFilePath = this.textBox_cfgFileName.Text;

            if (string.IsNullOrEmpty(strLocalFilePath) == true)
            {
                return;
            }
            if (File.Exists(strLocalFilePath) == false)
            {
                return;
            }

#if NO
            string strTypeName = "";
            // 获得 typeName
            // return:
            //      -1  出错
            //      0   配置文件没有找到
            //      1   成功
            int nRet = ReportDefForm.GetReportTypeName(
                strLocalFilePath,
                out strTypeName,
                out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }
#endif
            ReportConfigStruct config = null;

            // 从报表配置文件中获得各种配置信息
            // return:
            //      -1  出错
            //      0   没有找到配置文件
            //      1   成功
            int nRet = ReportDefForm.GetReportConfig(strLocalFilePath,
                                                     out config,
                                                     out strError);
            if (nRet == -1 || nRet == 0)
            {
                goto ERROR1;
            }

            if (string.IsNullOrEmpty(config.TypeName) == false &&
                config.TypeName.Length > 3)
            {
                this.textBox_reportName.Text = config.TypeName.Substring(GetNumberPrefix(config.TypeName).Length).Trim();
            }

            if (string.IsNullOrEmpty(this.checkedComboBox_createFreq.Text) == true)
            {
                this.checkedComboBox_createFreq.Text = config.CreateFreq;
            }

            return;

ERROR1:
            MessageBox.Show(this, strError);
        }