Beispiel #1
0
        public void button_export(object sender, RoutedEventArgs e)
        {
            string path           = string.Empty;
            var    openFileDialog = new Microsoft.Win32.OpenFileDialog()
            {
                Filter = "Files (*.xlsx*)|*.xls*"//如果需要筛选txt文件("Files (*.txt)|*.txt")
            };
            var result = openFileDialog.ShowDialog();

            if (result == true)
            {
                path = openFileDialog.FileName;
            }
            if (path.Length > 0)
            {
                OtherDAL dAL = new OtherDAL();
                Console.WriteLine(path);
                exportExcel exp = new exportExcel();
                exp.export(dAL.getOtherData(), path, "Other");
                MessageBox.Show("导出完成");
            }
        }
        public void button_export(object sender, RoutedEventArgs e)
        {
            OilsDAL      oilsDal  = new OilsDAL();
            ComboBoxItem item     = (ComboBoxItem)oils.SelectedItem;
            DataTable    oilsdata = oilsDal.getSingleOilosData(int.Parse(item.Tag + ""));
            Oils         oil      = new Oils()
            {
                //Density = "754",
                Density = oilsdata.Rows[0]["oils_density"] + "",
                //Viscosity = "1.08e-6",
                Viscosity = oilsdata.Rows[0]["oils_viscosity"] + "",
                //OutputByYear = "270",
                OutputByYear = oilsdata.Rows[0]["output_year"] + "",
            };


            double[] q = new double[] { 300, 500, 600 };
            double[] H = new double[] { 650, 600, 550 };

            PipeDAL pipeDal = new PipeDAL();

            item = (ComboBoxItem)pipe.SelectedItem;
            ProDAL    proDal   = new ProDAL();
            int       proid    = proDal.getNowPro();
            DataTable pipedata = pipeDal.getSinglePipeData(proid, int.Parse(item.Tag + ""));
            Pipe      pip      = new Pipe(1, 1, "", "", "", pipedata.Rows[0]["pipe_length"] + ""
                                          , pipedata.Rows[0]["pipe_outer_diameter"] + "", pipedata.Rows[0]["wall_thickness"] + "", "", "", "", "", "", "", "", "");

            PumpDAL pumpDal = new PumpDAL();

            item = (ComboBoxItem)pump.SelectedItem;
            DataTable            pumpdata = pumpDal.getSinglePumpData(int.Parse(item.Tag + ""));
            Pump                 pum = new Pump("", 1, "", "", "", "", "", pumpdata.Rows[0]["in_pressure"] + "", "");
            WaterCharacteristics water = new WaterCharacteristics(oil, pip, pum, 500, q, H, 0.06, 1.5, 27, 150);
            double               前站出站压力, 末站进站压力, 斜率, 沿程摩阻;

            water.getResult(out 前站出站压力, out 末站进站压力, out 斜率, out 沿程摩阻);
            Console.WriteLine("前站出站压力:{0}\n末站进站压力{1}\n斜率:{2}\n沿程摩阻:{3}", 前站出站压力, 末站进站压力, 斜率, 沿程摩阻);
            DataTable  dt1 = new DataTable();
            DataColumn dc1 = new DataColumn("油品名称", Type.GetType("System.String"));
            DataColumn dc2 = new DataColumn("前站出站压力", Type.GetType("System.String"));
            DataColumn dc3 = new DataColumn("末站进站压力", Type.GetType("System.String"));
            DataColumn dc4 = new DataColumn("管道总压降", Type.GetType("System.String"));
            DataColumn dc5 = new DataColumn("沿程摩阻", Type.GetType("System.String"));
            DataColumn dc6 = new DataColumn("斜率", Type.GetType("System.String"));

            dt1.Columns.Add(dc1);
            dt1.Columns.Add(dc2);
            dt1.Columns.Add(dc3);
            dt1.Columns.Add(dc4);
            dt1.Columns.Add(dc5);
            dt1.Columns.Add(dc6);
            //以上代码完成了DataTable的构架,但是里面是没有任何数据的
            DataRow dr1    = dt1.NewRow();

            dr1["油品名称"]   = oilsdata.Rows[0]["oils_name"] + "";
            dr1["前站出站压力"] = 前站出站压力;
            dr1["末站进站压力"] = 末站进站压力;
            dr1["沿程摩阻"]   = 沿程摩阻;
            dr1["管道总压降"]  = Math.Round(Math.Abs(前站出站压力 - 末站进站压力), 4);
            dr1["斜率"]     = 斜率;
            dt1.Rows.Add(dr1);
            string path    = string.Empty;
            var    openFileDialog = new Microsoft.Win32.OpenFileDialog()
            {
                Filter = "Files (*.xlsx*)|*.xls*"//如果需要筛选txt文件("Files (*.txt)|*.txt")
            };
            var result = openFileDialog.ShowDialog();

            if (result == true)
            {
                path = openFileDialog.FileName;
            }
            if (path.Length > 0)
            {
                SoilDAL dAL = new SoilDAL();
                Console.WriteLine(path);
                exportExcel exp = new exportExcel();
                exp.export(dt1, path, "Wateranalyze");
                MessageBox.Show("导出完成");
            }
        }
        public void button_export(object sender, RoutedEventArgs e)
        {
            OilsDAL      oilsDal  = new OilsDAL();
            ComboBoxItem item     = (ComboBoxItem)oils.SelectedItem;
            DataTable    oilsdata = oilsDal.getSingleOilosData(int.Parse(item.Tag + ""));
            Oils         oil      = new Oils()
            {
                //Density = "754",
                Density = oilsdata.Rows[0]["oils_density"] + "",
                //Viscosity = "1.08e-6",
                Viscosity = oilsdata.Rows[0]["oils_viscosity"] + "",
                //OutputByYear = "270",
                OutputByYear = oilsdata.Rows[0]["output_year"] + "",
                //    MasFlow = "600",
                //    Volume_concentration = "0.01"
                MasFlow = oilsdata.Rows[0]["mass_flow"] + "",
                Volume_concentration = oilsdata.Rows[0]["volume_concentration"] + ""
            };

            double[] q       = new double[] { 300, 500, 600 };
            double[] H       = new double[] { 650, 600, 550 };
            PipeDAL  pipeDal = new PipeDAL();

            item = (ComboBoxItem)pipe.SelectedItem;
            ProDAL    proDal   = new ProDAL();
            int       proid    = proDal.getNowPro();
            DataTable pipedata = pipeDal.getSinglePipeData(proid, int.Parse(item.Tag + ""));
            Pipe      pip      = new Pipe(1, 1, "", "", "", pipedata.Rows[0]["pipe_length"] + ""
                                          , pipedata.Rows[0]["pipe_outer_diameter"] + "", pipedata.Rows[0]["wall_thickness"] + "", "", "", "", "", "", "", "", "");
            PumpDAL pumpDal = new PumpDAL();

            item = (ComboBoxItem)pump.SelectedItem;
            DataTable pumpdata = pumpDal.getSinglePumpData(int.Parse(item.Tag + ""));
            Pump      pum = new Pump("", 1, "", "", "", "", "", pumpdata.Rows[0]["in_pressure"] + "", pumpdata.Rows[0]["out_pressure"] + "");
            PipeWork  pw = new PipeWork(oil, pip, pum, q, H, 0.06, 1.5, 27, 150, 30);
            double    扬程, 系统工作流量, A, B;

            pw.getResult(out 系统工作流量, out 扬程, out A, out B);
            DataTable  dt1 = new DataTable();
            DataColumn dc1 = new DataColumn("管道名", Type.GetType("System.String"));
            DataColumn dc2 = new DataColumn("扬程", Type.GetType("System.String"));
            DataColumn dc3 = new DataColumn("工作流量", Type.GetType("System.String"));

            dt1.Columns.Add(dc1);
            dt1.Columns.Add(dc2);
            dt1.Columns.Add(dc3);
            DataRow dr1 = dt1.NewRow();

            dr1["管道名"]  = pipedata.Rows[0]["pipe_name"] + "";
            dr1["扬程"]   = 扬程;
            dr1["工作流量"] = 系统工作流量;
            dt1.Rows.Add(dr1);
            string path           = string.Empty;
            var    openFileDialog = new Microsoft.Win32.OpenFileDialog()
            {
                Filter = "Files (*.xlsx*)|*.xls*"//如果需要筛选txt文件("Files (*.txt)|*.txt")
            };
            var result = openFileDialog.ShowDialog();

            if (result == true)
            {
                path = openFileDialog.FileName;
            }
            if (path.Length > 0)
            {
                SoilDAL dAL = new SoilDAL();
                Console.WriteLine(path);
                exportExcel exp = new exportExcel();
                exp.export(dt1, path, "Wipeanalyze");
                MessageBox.Show("导出完成");
            }
        }