コード例 #1
0
        /// <summary>
        /// 导出WeightSortData类型实例至XML/XLS文件
        /// </summary>
        /// <param name="sortData">WeightSortData类型</param>
        public static void ExportDataToDataFile(WeightSortData sortData)
        {
            if (sortData == null)
            {
                XLog.Write("没有数据不能导出");
                return;
            }

            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter           = "xml文件 (*.xml)|*.xml|Excel文件 (*.xls)|*.xls";
            dlg.OverwritePrompt  = true;
            dlg.FilterIndex      = 0;
            dlg.RestoreDirectory = true;
            dlg.FileName         = sortData.sortName;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string strFilePath = dlg.FileName;

                if (strFilePath.EndsWith(".xml"))
                {
                    List <string> lstContent = MainForm.GetDesignResultFlieContent(sortData);
                    CommonFunction.mWriteListStringToFile(strFilePath, lstContent);
                }

                if (strFilePath.EndsWith(".xls"))
                {
                    DataTable table  = MainForm.GetDesignResultTable(sortData);
                    int       result = XCommon.FileStatus.FileIsOpen(strFilePath);

                    if (result == 1)
                    {
                        MessageBox.Show("请关闭文件" + strFilePath + ",再导出");
                    }
                    else
                    {
                        CommonExcel commonExcel = new CommonExcel();
                        commonExcel.lstColumn = MainForm.GetDesignResultExcleCloumn();
                        commonExcel.CreateExcel("example", strFilePath, "sheet1", table);
                    }
                }

                XLog.Write("导出文件\"" + strFilePath + "\"成功");
            }
        }
コード例 #2
0
        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExport_Click(object sender, EventArgs e)
        {
            if (lstCalculateRatio == null || lstCalculateRatio.Count == 0)
            {
                MessageBox.Show("没有修正因子数据不能导出");
                return;
            }

            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter           = "xml文件 (*.xml)|*.xml|Excel文件 (*.xls)|*.xls";
            dlg.OverwritePrompt  = true;
            dlg.FilterIndex      = 0;
            dlg.RestoreDirectory = true;
            dlg.FileName         = zedGraphControlPic.GraphPane.Title.Text;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string strFilePath = dlg.FileName;

                if (strFilePath.EndsWith(".xml"))
                {
                    List <string> lstContent = GetFileContent(lstCalculateRatio);
                    CommonFunction.mWriteListStringToFile(strFilePath, lstContent);
                }

                if (strFilePath.EndsWith(".xls"))
                {
                    DataTable table  = GetExcelTable(lstCalculateRatio);
                    int       result = XCommon.FileStatus.FileIsOpen(strFilePath);

                    if (result == 1)
                    {
                        MessageBox.Show("请关闭文件" + strFilePath + ",再导出");
                    }
                    else
                    {
                        CommonExcel commonExcel = new CommonExcel();
                        commonExcel.lstColumn = GetExcelCloumn();
                        commonExcel.CreateExcel("example", strFilePath, "sheet1", table);
                    }
                }

                XLog.Write("导出文件\"" + strFilePath + "\"成功");
            }
        }
コード例 #3
0
        /// <summary>
        ///  导出事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExport_Click(object sender, EventArgs e)
        {
            if (treeViewParameterList.Nodes.Count == 0)
            {
                XLog.Write("没有数据不能导出");
                return;
            }

            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter           = "PMC文件 (*.PMC)|*.PMC|xls文件 (*.xls)|*.xls";
            dlg.FilterIndex      = 0;
            dlg.RestoreDirectory = true;
            dlg.FileName         = "ParameterCollection";

            List <ParaData> lstTempParaDagta = lstParaData;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string strFilePath = dlg.FileName;

                if (strFilePath.EndsWith(".PMC"))
                {
                    SaveFile(strFilePath, lstTempParaDagta);
                }
                if (strFilePath.EndsWith(".xls"))
                {
                    DataTable table  = GetTableData(lstTempParaDagta);
                    int       result = XCommon.FileStatus.FileIsOpen(strFilePath);

                    if (result == 1)
                    {
                        MessageBox.Show("请关闭文件" + strFilePath + ",再导出");
                    }
                    else
                    {
                        CommonExcel commonExcel = new CommonExcel();
                        commonExcel.lstColumn = GetColumnName();
                        commonExcel.CreateExcel("example", strFilePath, "sheet1", table);
                    }
                }

                XLog.Write("导出成功");
            }
        }
コード例 #4
0
        /// <summary>
        /// 导出事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExport_Click(object sender, EventArgs e)
        {
            if (selNode == null || selNode.Level == 0)
            {
                XLog.Write("请选择重重心包线设计数据");
                return;
            }

            SaveFileDialog dlg = new SaveFileDialog();
            dlg.Filter = "xml文件 (*.xml)|*.xml|Excle文件 (*.xls)|*.xls";
            dlg.FilterIndex = 0;
            dlg.RestoreDirectory = true;
            dlg.FileName = selNode.Text;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string strFilePath = dlg.FileName;

                if (strFilePath.EndsWith(".xml"))
                {
                    List<string> lstContent = GetListContent();
                    CommonFunction.mWriteListStringToFile(strFilePath, lstContent);
                }
                if (strFilePath.EndsWith(".xls"))
                {
                    DataTable table = GetTableExcleData();
                    int result = XCommon.FileStatus.FileIsOpen(strFilePath);

                    if (result == 1)
                    {
                        MessageBox.Show("请关闭文件" + strFilePath + ",再导出");
                    }
                    else
                    {
                        CommonExcel commonExcel = new CommonExcel();
                        commonExcel.lstColumn = GetExcleColumn(); ;

                        commonExcel.CreateExcel("example", strFilePath, "sheet1", table);
                    }
                }

                XLog.Write("导入文件\"" + strFilePath + "\"成功");
            }
        }
コード例 #5
0
        /// <summary>
        /// 导出重心数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExportCoreData_Click(object sender, EventArgs e)
        {
            if (treeCoreEnvelope.Nodes.Count == 0)
            {
                XLog.Write("没有数据不能导出");
                return;
            }
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.Filter = "xml文件 (*.xml)|*.xml|Excel文件 (*.xls)|*.xls";
            dlg.FilterIndex = 0;
            dlg.RestoreDirectory = true;
            dlg.FileName = txtDesignDataName.Text;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string strFilePath = dlg.FileName;
                if (strFilePath.EndsWith(".xml"))
                {
                    List<string> lstContent = MainForm.GetCoreEnvelopeDesignFileContent(gridCoreEnvelope);
                    CommonFunction.mWriteListStringToFile(strFilePath, lstContent);
                }
                if (strFilePath.EndsWith(".xls"))
                {
                    DataTable table = MainForm.GetCoreEnvelopeDesignResultTable(gridCoreEnvelope);
                    int result = XCommon.FileStatus.FileIsOpen(strFilePath);

                    if (result == 1)
                    {
                        MessageBox.Show("请关闭文件" + strFilePath + ",再导出");
                    }
                    else
                    {
                        CommonExcel commonExcel = new CommonExcel();
                        commonExcel.lstColumn = MainForm.GetCoreEnvelopeDesignResultExcleCloumn();
                        commonExcel.CreateExcel("example", strFilePath, "sheet1", table);
                    }
                }
                XLog.Write("导出文件\"" + strFilePath + "\"成功");
            }
        }
コード例 #6
0
        /// <summary>
        /// 导出WeightSortData类型实例至XML/XLS文件
        /// </summary>
        /// <param name="sortData">WeightSortData类型</param>
        public static void ExportDataToDataFile(WeightSortData sortData)
        {
            if (sortData == null)
            {
                XLog.Write("没有数据不能导出");
                return;
            }

            SaveFileDialog dlg = new SaveFileDialog();
            dlg.Filter = "xml文件 (*.xml)|*.xml|Excel文件 (*.xls)|*.xls";
            dlg.OverwritePrompt = true;
            dlg.FilterIndex = 0;
            dlg.RestoreDirectory = true;
            dlg.FileName = sortData.sortName;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string strFilePath = dlg.FileName;

                if (strFilePath.EndsWith(".xml"))
                {
                    List<string> lstContent = MainForm.GetDesignResultFlieContent(sortData);
                    CommonFunction.mWriteListStringToFile(strFilePath, lstContent);
                }

                if (strFilePath.EndsWith(".xls"))
                {
                    DataTable table = MainForm.GetDesignResultTable(sortData);
                    int result = XCommon.FileStatus.FileIsOpen(strFilePath);

                    if (result == 1)
                    {
                        MessageBox.Show("请关闭文件" + strFilePath + ",再导出");
                    }
                    else
                    {
                        CommonExcel commonExcel = new CommonExcel();
                        commonExcel.lstColumn = MainForm.GetDesignResultExcleCloumn();
                        commonExcel.CreateExcel("example", strFilePath, "sheet1", table);
                    }
                }

                XLog.Write("导出文件\"" + strFilePath + "\"成功");
            }
        }
コード例 #7
0
        /// <summary>
        ///  导出事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExport_Click(object sender, EventArgs e)
        {
            if (treeViewParameterList.Nodes.Count == 0)
            {
                XLog.Write("没有数据不能导出");
                return;
            }

            SaveFileDialog dlg = new SaveFileDialog();
            dlg.Filter = "PMC文件 (*.PMC)|*.PMC|xls文件 (*.xls)|*.xls";
            dlg.FilterIndex = 0;
            dlg.RestoreDirectory = true;
            dlg.FileName = "ParameterCollection";

            List<ParaData> lstTempParaDagta = lstParaData;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string strFilePath = dlg.FileName;

                if (strFilePath.EndsWith(".PMC"))
                {
                    SaveFile(strFilePath, lstTempParaDagta);
                }
                if (strFilePath.EndsWith(".xls"))
                {
                    DataTable table = GetTableData(lstTempParaDagta);
                    int result = XCommon.FileStatus.FileIsOpen(strFilePath);

                    if (result == 1)
                    {
                        MessageBox.Show("请关闭文件" + strFilePath + ",再导出");
                    }
                    else
                    {
                        CommonExcel commonExcel = new CommonExcel();
                        commonExcel.lstColumn = GetColumnName();
                        commonExcel.CreateExcel("example", strFilePath, "sheet1", table);
                    }
                }

                XLog.Write("导出成功");
            }
        }
コード例 #8
0
        /// <summary>
        /// 导出事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExport_Click(object sender, EventArgs e)
        {
            if (selNode == null || selNode.Level == 0)
            {
                XLog.Write("请选择重量设计数据");
                return;
            }

            SaveFileDialog dlg = new SaveFileDialog();
            dlg.Filter = "xml文件 (*.xml)|*.xml|Excle文件 (*.xls)|*.xls";
            dlg.FilterIndex = 0;
            dlg.RestoreDirectory = true;
            dlg.FileName = selNode.Text;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string strFilePath = dlg.FileName;

                if (strFilePath.EndsWith(".xml"))
                {
                    List<string> lstContent = GetListContent();
                    CommonFunction.mWriteListStringToFile(strFilePath, lstContent);
                    XLog.Write("导出文件\"" + strFilePath + "\"成功");
                }
                if (strFilePath.EndsWith(".xls"))
                {
                    if (lstDesignData.Count > 0)
                    {
                        WeightDesignData weightData = GetWeightDesignData(Convert.ToInt32(selNode.Name));

                        WeightSortData sortData = clsStringToWeightSortData(weightData.MainSystem_Name);
                        DataTable table = GetTableExcleData(weightData, sortData);
                        int result = XCommon.FileStatus.FileIsOpen(strFilePath);

                        if (result == 1)
                        {
                            MessageBox.Show("请关闭文件\"" + strFilePath + "\"再导出");
                        }
                        else
                        {
                            CommonExcel commonExcel = new CommonExcel();
                            commonExcel.lstColumn = GetExcleCloumn();
                            commonExcel.CreateExcel("example", strFilePath, "sheet1", table);
                            XLog.Write("导出文件\"" + strFilePath + "\"成功");
                        }
                    }
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// 导出重量数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExportWeightData_Click(object sender, EventArgs e)
        {
            WeightSortData tempWeightSort = new WeightSortData();
            if (strOperType == CommonMessage.operNew || strOperType == CommonMessage.operJYNew || strOperType == CommonMessage.operEdit)
            {
                tempWeightSort = clsStringToWeightSortData(weightDesinData.MainSystem_Name);
                if (tempWeightSort == null)
                {
                    XLog.Write("没有数据不能导出");
                    return;
                }
            }
            else
            {
                if (selNode == null || selNode.Level == 0)
                {
                    XLog.Write("请选择重量设计数据");
                    return;
                }
                WeightDesignData tempWeightDesinData = GetWeightDesignData(Convert.ToInt32(selNode.Name));
                tempWeightSort = clsStringToWeightSortData(tempWeightDesinData.MainSystem_Name);
            }

            if (tempWeightSort == null)
            {
                XLog.Write("没有数据不能导出");
                return;
            }

            SaveFileDialog dlg = new SaveFileDialog();
            dlg.Filter = "xml文件 (*.xml)|*.xml|Excel文件 (*.xls)|*.xls";
            dlg.FilterIndex = 0;
            dlg.RestoreDirectory = true;
            dlg.FileName = txtDesignDataName.Text;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string strFilePath = dlg.FileName;

                if (strFilePath.EndsWith(".xml"))
                {
                    List<string> lstContent = MainForm.GetDesignResultFlieContent(tempWeightSort);
                    CommonFunction.mWriteListStringToFile(strFilePath, lstContent);
                }

                if (strFilePath.EndsWith(".xls"))
                {
                    DataTable table = MainForm.GetDesignResultTable(tempWeightSort);
                    int result = XCommon.FileStatus.FileIsOpen(strFilePath);

                    if (result == 1)
                    {
                        MessageBox.Show("请关闭文件" + strFilePath + ",再导出");
                    }
                    else
                    {
                        CommonExcel commonExcel = new CommonExcel();
                        commonExcel.lstColumn = MainForm.GetDesignResultExcleCloumn();
                        commonExcel.CreateExcel("example", strFilePath, "sheet1", table);
                    }
                }

                XLog.Write("导出文件\"" + strFilePath + "\"成功");
            }
        }
コード例 #10
0
        /// <summary>
        /// 导出修正因子数据至数据文件
        /// </summary>
        /// <param name="sortData"></param>
        private void ExportRatioDataToDataFile(List<ParaData> lstPara)
        {
            if (lstPara == null || lstPara.Count == 0)
            {
                XLog.Write("没有数据不能导出");
                return;
            }

            SaveFileDialog dlg = new SaveFileDialog();
            dlg.Filter = "xml文件 (*.xml)|*.xml|Excel文件 (*.xls)|*.xls";
            dlg.OverwritePrompt = true;
            dlg.FilterIndex = 0;
            dlg.RestoreDirectory = true;
            dlg.FileName = lstPara[0].paraName.Substring(0, 4);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string strFilePath = dlg.FileName;

                if (strFilePath.EndsWith(".xml"))
                {
                    List<string> lstContent = GetFileContent(lstPara);
                    CommonFunction.mWriteListStringToFile(strFilePath, lstContent);
                }

                if (strFilePath.EndsWith(".xls"))
                {
                    DataTable table = GetExcelTable(lstPara);
                    int result = XCommon.FileStatus.FileIsOpen(strFilePath);

                    if (result == 1)
                    {
                        MessageBox.Show("请关闭文件" + strFilePath + ",再导出");
                    }
                    else
                    {
                        CommonExcel commonExcel = new CommonExcel();
                        commonExcel.lstColumn = GetExcelCloumn();
                        commonExcel.CreateExcel("example", strFilePath, "sheet1", table);
                    }
                }

                XLog.Write("导出文件\"" + strFilePath + "\"成功");
            }
        }
コード例 #11
0
 public void ExcelTest()
 {
     CommonExcel.MiniExcelExport();
 }