예제 #1
0
        void initComboBox()
        {
            PipeDAL   pipeDAL   = new PipeDAL();
            ProDAL    proDal    = new ProDAL();
            int       proid     = proDal.getNowPro();
            DataTable pipedata  = pipeDAL.getPipeBaisc(proid);
            DataTable oilsdata  = new OilsDAL().getOilosData();
            DataTable pumpdata  = new PumpDAL().getPumpData();
            DataTable soildata  = new SoilDAL().getSoilData();
            DataTable otherdata = new OtherDAL().getOtherData();

            for (int i = 0; i < pipedata.Rows.Count; i++)
            {
                ComboBoxItem item = new ComboBoxItem();
                item.Content = pipedata.Rows[i]["pipe_name"];
                item.Tag     = pipedata.Rows[i]["pipe_id"];
                if (i == 0)
                {
                    item.IsSelected = true;
                }
                pipe.Items.Add(item);
            }
            for (int i = 0; i < oilsdata.Rows.Count; i++)
            {
                ComboBoxItem item = new ComboBoxItem();
                item.Content = oilsdata.Rows[i]["oils_name"];
                item.Tag     = oilsdata.Rows[i]["oils_id"] + " ";
                if (i == 0)
                {
                    item.IsSelected = true;
                }
                oils.Items.Add(item);
            }
        }
예제 #2
0
        public PiP_Add()
        {
            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            ProDAL  proDal  = new ProDAL();
            PipeDAL pipeDal = new PipeDAL();

            proid        = proDal.getNowPro();
            pipeid       = pipeDal.getMaxPipeId(proid) + 1;
            pipe_id.Text = pipeid + " ";
        }
예제 #3
0
 public void pipbutton_dele(object sender, RoutedEventArgs e)
 {
     if (pipe_grid.SelectedIndex >= 0)
     {
         int     projectid = int.Parse(data.Rows[pipe_grid.SelectedIndex]["project_id"] + " ");
         int     pipeid    = int.Parse(data.Rows[pipe_grid.SelectedIndex]["pipe_id"] + " ");
         PipeDAL pipeDAL   = new PipeDAL();
         pipeDAL.delPipeData(projectid, pipeid);
         initTable();
     }
     else
     {
         MessageBox.Show("没有选中项,无法删除");
     }
 }
예제 #4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Pipe     pipe     = new Pipe(proid, pipeid, start_spot.Text, end_spot.Text, pipe_name.Text, pipe_length.Text, pipe_outer_diameter.Text, wall_thickness.Text, pipe_depth.Text, transport_medium.Text, insulation_materials.Text, tank_type_a.Text, tank_type_b.Text, tank_capacity_a.Text, tank_capacity_b.Text, maximum_pressure.Text);
            IsNumber Isnumber = new IsNumber();

            if (Isnumber.isNumber(pipe_length.Text.Trim()) == false || Isnumber.isNumber(pipe_outer_diameter.Text.Trim()) == false || Isnumber.isNumber(wall_thickness.Text.Trim()) == false || Isnumber.isNumber(pipe_depth.Text.Trim()) == false || Isnumber.isNumber(tank_capacity_a.Text.Trim()) == false || Isnumber.isNumber(tank_capacity_b.Text.Trim()) == false || Isnumber.isNumber(maximum_pressure.Text.Trim()) == false)
            {
                MessageBox.Show("输格式入有误");
            }
            else
            {
                PipeDAL pipeDAL = new PipeDAL();
                pipeDAL.addPipeData(pipe);
                MessageBox.Show("添加成功");
                Close();
            }
        }
예제 #5
0
        public void recoveryData(int proid, int pipeid)
        {
            PipeDAL   dal  = new PipeDAL();
            DataTable data = dal.getSinglePipeData(proid, pipeid);

            Console.WriteLine(data.Rows[0]["pipe_id"]);
            pipe_id.Text              = data.Rows[0]["pipe_id"] + " ";
            start_spot.Text           = data.Rows[0]["start_spot"] + " ";
            end_spot.Text             = data.Rows[0]["end_spot"] + " ";
            pipe_name.Text            = data.Rows[0]["pipe_name"] + " ";
            pipe_length.Text          = data.Rows[0]["pipe_length"] + " ";
            pipe_outer_diameter.Text  = data.Rows[0]["pipe_outer_diameter"] + " ";
            wall_thickness.Text       = data.Rows[0]["wall_thickness"] + " ";
            pipe_depth.Text           = data.Rows[0]["pipe_depth"] + " ";
            transport_medium.Text     = data.Rows[0]["transport_medium"] + " ";
            insulation_materials.Text = data.Rows[0]["insulation_materials"] + " ";
            tank_type_a.Text          = data.Rows[0]["tank_type_a"] + " ";
            tank_capacity_a.Text      = data.Rows[0]["tank_capacity_a"] + " ";
            tank_type_b.Text          = data.Rows[0]["tank_type_b"] + " ";
            tank_capacity_b.Text      = data.Rows[0]["tank_capacity_b"] + " ";
            maximum_pressure.Text     = data.Rows[0]["maximum_pressure"] + " ";
        }
예제 #6
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)
            {
                PipeDAL dAL = new PipeDAL();
                Console.WriteLine(path);
                exportExcel exp = new exportExcel();
                exp.export(dAL.getPipeBaisc(new ProDAL().getNowPro()), path, "Pipe");
                MessageBox.Show("导出完成");
            }
        }
예제 #7
0
        void getRes(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"] + "", "");

            //public WaterCharacteristics(Oils oil, Pipe pipe, Pump pump, double 全线总摩阻,
            //double[] 泵流量, double[] 泵扬程, double 当量粗糙度, double 流速, double 管道起点高程, double 管道终点高程)


            //获取输入框信息


            //WaterCharacteristics water = new WaterCharacteristics(oil, pip, pum, 500, q, H, 0.06, 1.5, 27, 150);

            WaterCharacteristics water = new WaterCharacteristics(oil, pip, pum,
                                                                  double.Parse(全线总摩阻.Text), q, H,
                                                                  double.Parse(当量粗糙度.Text),
                                                                  double.Parse(流速.Text),
                                                                  double.Parse(管道起点高程.Text),
                                                                  double.Parse(管道终点高程.Text));
            double 前站出站压力, 末站进站压力, 斜率, 沿程摩阻;

            water.getResult(out 前站出站压力, out 末站进站压力, out 斜率, out 沿程摩阻);
            Console.WriteLine("前站出站压力:{0}\n末站进站压力{1}\n斜率:{2}\n沿程摩阻:{3}", 前站出站压力, 末站进站压力, 斜率, 沿程摩阻);


            DataTable  dt1 = new DataTable();
            DataTable  dt2 = 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);
            dt2.Columns.Add(dc4);
            dt2.Columns.Add(dc5);
            dt2.Columns.Add(dc6);
            //以上代码完成了DataTable的构架,但是里面是没有任何数据的
            DataRow dr1 = dt1.NewRow();
            DataRow dr2 = dt2.NewRow();

            dr1["油品名称"]   = oilsdata.Rows[0]["oils_name"] + "";
            dr1["前站出站压力"] = 前站出站压力;
            dr1["末站进站压力"] = 末站进站压力;
            dr2["沿程摩阻"]   = 沿程摩阻;
            dr2["管道总压降"]  = Math.Round(Math.Abs(前站出站压力 - 末站进站压力), 4);
            dr2["斜率"]     = 斜率;
            dt1.Rows.Add(dr1);
            dt2.Rows.Add(dr2);
            table1.IsReadOnly  = true;
            table1.ItemsSource = null;
            table1.ItemsSource = dt1.DefaultView;
            table2.IsReadOnly  = true;
            table2.ItemsSource = null;
            table2.ItemsSource = dt2.DefaultView;

            //设置x,y
            x = (double)(int.Parse(pum.InPressure) + 斜率 * double.Parse(pip.Length));
            y = (double)(int.Parse(pip.Length));
            m = (double)(double.Parse(pum.InPressure));
            Console.WriteLine(x + "  " + y);
            res.Visibility = Visibility.Visible;
            Simon.Children.Clear();
            CreateChartSpline("水力坡降线", y, x, m);

            /*
             * PipeWork pw = new PipeWork();
             * double 扬程 = pw.getHead(30,123,270, 754,1.5,518, 1.08E-06,0.06,580);
             * Console.WriteLine("扬程:{0}",扬程);
             * double 系统工作流量 = pw.getSystemWorkFlow(30, 1, q, H, 150, 27, 270, 754, 1.08E-06, 518, 0.06, 1.5, 580, 123, 50, 15000);
             * Console.WriteLine("系统工作流量{0}", 系统工作流量);
             */
        }
예제 #8
0
        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("导出完成");
            }
        }
예제 #9
0
        void getRes(object sender, RoutedEventArgs e)
        {
            PipeDAL      pipeDal  = new PipeDAL();
            ComboBoxItem 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"] + "", "", "", "", "", "", "", "", "");

            //find oil
            OilsDAL   oilsDAL  = new OilsDAL();
            DataTable oilsdata = oilsDAL.getOilosData();
            Oils      oilB     = null;
            Oils      oilA     = null;

            Console.WriteLine(pipedata.Rows[0]["tank_type_a"] + "");
            for (int i = 0; i < oilsdata.Rows.Count; i++)
            {
                Console.WriteLine(oilsdata.Rows[i]["oils_name"] + "");
                if (((string)pipedata.Rows[0]["tank_type_a"]).Trim().Equals(((string)oilsdata.Rows[i]["oils_name"]).Trim()))
                {
                    Console.WriteLine("lalallalal  aaaa ");
                    oilA = new Oils()
                    {
                        Name = oilsdata.Rows[i]["oils_name"] + "",
                        // Density = "754",
                        Density = oilsdata.Rows[i]["oils_density"] + "",
                        //  Viscosity = "1.08E-06",
                        Viscosity = oilsdata.Rows[i]["oils_viscosity"] + "",
                        //    OutputByYear = "270",
                        OutputByYear = oilsdata.Rows[i]["output_year"] + "",
                        //  MasFlow = "600",
                        MasFlow = oilsdata.Rows[i]["mass_flow"] + "",
                        //  Volume_concentration = "0.01"
                        Volume_concentration = oilsdata.Rows[i]["volume_concentration"] + "",
                    };
                }

                if (((string)pipedata.Rows[0]["tank_type_b"]).Trim().Equals(((string)oilsdata.Rows[i]["oils_name"]).Trim()))
                {
                    Console.WriteLine("lalallalal  bbbbb ");
                    oilB = new Oils()
                    {
                        Name = oilsdata.Rows[i]["oils_name"] + "",
                        // Density = "754",
                        Density = oilsdata.Rows[i]["oils_density"] + "",
                        //  Viscosity = "1.08E-06",
                        Viscosity = oilsdata.Rows[i]["oils_viscosity"] + "",
                        //    OutputByYear = "270",
                        OutputByYear = oilsdata.Rows[i]["output_year"] + "",
                        //  MasFlow = "600",
                        MasFlow = oilsdata.Rows[i]["mass_flow"] + "",
                        //  Volume_concentration = "0.01"
                        Volume_concentration = oilsdata.Rows[i]["volume_concentration"] + "",
                    };
                }
            }
            if (oilA == null || oilB == null)
            {
                MessageBox.Show("请确认管道的油灌类型的数据存在数据库中");
            }
            else
            {
                //public MixedOilQuantity(Oils oilA, Oils oilB, Pipe pipe, double 切割浓度, double 流速)
                MixedOilQuantity mq = new MixedOilQuantity(oilA, oilB, pip,
                                                           double.Parse(切割浓度.Text),
                                                           double.Parse(流速.Text));
                double 混油量 = mq.getResult();
                Console.WriteLine("----------------------------------------------------------");
                Console.WriteLine("混油量:{0}", 混油量);
                list.Items.Clear();
                ListViewItem viewitem1 = new ListViewItem();
                viewitem1.Content = "混油A:  " + oilA.Name;
                list.Items.Add(viewitem1);
                ListViewItem viewitem2 = new ListViewItem();
                viewitem2.Content = "混油B:  " + oilB.Name;
                res.Content       = 混油量 + "m3";
                resa.Visibility   = Visibility.Visible;
            }
        }
예제 #10
0
        void getRes(object sender, RoutedEventArgs e)
        {
            double[]     q        = new double[] { 400, 500, 600 };
            double[]     H        = new double[] { 650, 600, 550 };
            double[]     高程1      = new double[] { 30, 70 };
            double[]     高程2      = new double[] { 30, 120, 70 };
            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"] + "",
            };
            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"] + "", "", "", "", "", "", "", "", "");

            StationPumpPlan fspp1 = new StationPumpPlan(oil, pip, q, H, 高程1, 1,
                                                        double.Parse(当量粗糙度.Text),
                                                        double.Parse(流速.Text),
                                                        3,
                                                        double.Parse(首站进站压力.Text));

            StationPumpPlan fspp2 = new StationPumpPlan(oil, pip, q, H, 高程2, 2,
                                                        double.Parse(当量粗糙度.Text),
                                                        double.Parse(流速.Text),
                                                        3,
                                                        double.Parse(首站进站压力.Text));

            double 总扬程, 总降压, 站间距;
            bool   是否合理;

            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);
            站间距 = fspp1.getResult(out 总扬程, out 总降压, out 是否合理);
            Console.WriteLine("一个泵站 两个泵: 总扬程{0}\t总降压{1}\t站间距:{2}\t是否合理:{3}", 总扬程, 总降压, 站间距, 是否合理 ? "合理" : "不合理");
            DataRow dr1 = dt1.NewRow();

            dr1["泵站数"]  = "一个泵站";
            dr1["泵数"]   = "两个泵";
            dr1["总扬程"]  = 总扬程;
            dr1["总压降"]  = 总降压;
            dr1["站间距"]  = 站间距;
            dr1["是否合理"] = 是否合理 ? "合理" : "不合理";
            dt1.Rows.Add(dr1);
            站间距 = fspp2.getResult(out 总扬程, out 总降压, out 是否合理);
            Console.WriteLine("两个泵站 两个泵: 总扬程{0}\t总降压{1}\t站间距:{2}\t是否合理:{3}", 总扬程, 总降压, 站间距, 是否合理 ? "合理" : "不合理");
            DataRow dr2 = dt1.NewRow();

            dr2["泵站数"]  = "两个泵站";
            dr2["泵数"]   = "两个泵";
            dr2["总扬程"]  = 总扬程;
            dr2["总压降"]  = 总降压;
            dr2["站间距"]  = 站间距;
            dr2["是否合理"] = 是否合理 ? "合理" : "不合理";
            dt1.Rows.Add(dr2);
            table.IsReadOnly  = true;
            table.ItemsSource = null;
            table.ItemsSource = dt1.DefaultView;
            resa.Visibility   = Visibility.Visible;
        }
예제 #11
0
        void getRes(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"] + "");


            //public PipeWork(Oils oil, Pipe pipe, Pump pump, double[] 泵流量, double[] 泵扬程, double 当量粗糙度,
            //    double 流速, double 管道起点高程, double 管道终点高程, double 首站进站压力)


            PipeWork pw = new PipeWork(oil, pip, pum, q, H,
                                       double.Parse(当量粗糙度.Text),
                                       double.Parse(流速.Text),
                                       double.Parse(管道起点高程.Text),
                                       double.Parse(管道终点高程.Text),
                                       double.Parse(首站进站压力.Text));


            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);
            table1.IsReadOnly  = true;
            table1.ItemsSource = null;
            table1.ItemsSource = dt1.DefaultView;
            res.Visibility     = Visibility.Visible;
            Simon.Children.Clear();
            CreateChartSpline("水力坡降线", A, B);

            Console.WriteLine(A + "   " + B + "   " + 系统工作流量);
        }
예제 #12
0
        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("导出完成");
            }
        }
예제 #13
0
        void getRes(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-06",
                Viscosity = oilsdata.Rows[0]["oils_viscosity"] + "",
                //    OutputByYear = "270",
                OutputByYear = oilsdata.Rows[0]["output_year"] + "",
                //  MasFlow = "600",
                MasFlow = oilsdata.Rows[0]["mass_flow"] + "",
                //  Volume_concentration = "0.01"
                Volume_concentration = oilsdata.Rows[0]["volume_concentration"] + "",
            };
            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]["power"] + "", "", "", pumpdata.Rows[0]["in_pressure"] + "", pumpdata.Rows[0]["out_pressure"] + "");

            OtherDAL otherDAL = new OtherDAL();

            item = (ComboBoxItem)other.SelectedItem;
            DataTable otherdata = otherDAL.getSingleOtherData(int.Parse(item.Tag + ""));

            //  PowerCost pc = new PowerCost(oil, pip, pum, 350, 0.87, 27, 150, double.Parse(otherdata.Rows[0]["cost_operating"] + ""), 1.5, 0.06, 9.8, 30);
            double[] q = new double[] { 300, 500, 600 };
            double[] H = new double[] { 650, 600, 550 };

            ////public PowerCost(Oils oils, Pipe pipe, Pump pump, double[] 泵流量, double[] 泵扬程,
            //double 年工作时间, double 电机效率, double 管道起点高程, double 管道终点高程,
            //    double 电费, double 流速, double 当量粗糙度, double 重力加速度, double 首站进站压力)
            PowerCost pc = new PowerCost(oil, pip, pum, q, H,
                                         double.Parse(年工作时间.Text),
                                         double.Parse(电机效率.Text),
                                         double.Parse(管道起点高程.Text),
                                         double.Parse(管道终点高程.Text),
                                         double.Parse(otherdata.Rows[0]["cost_operating"] + ""),
                                         double.Parse(流速.Text),
                                         double.Parse(当量粗糙度.Text),
                                         double.Parse(重力加速度.Text),
                                         double.Parse(首站进站压力.Text));



            double 运行能耗 = pc.getResult();

            Console.WriteLine("----------------------------------------------------------");
            Console.WriteLine("运行能耗:{0}", 运行能耗);

            res.Content = 运行能耗 + "元";

            resa.Visibility = Visibility.Visible;
        }
예제 #14
0
        void getRes(object sender, RoutedEventArgs e)
        {
            double[]     q        = new double[] { 400, 500, 600 };
            double[]     H        = new double[] { 650, 600, 550 };
            double[]     起点高程1    = new double[] { 0 };
            double[]     高程1      = new double[] { 30, 70 };
            double[]     高程2      = new double[] { 30, 120, 70 };
            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"] + "",
            };
            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"] + "", "", "", "", "", "", "", "", "");

            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"));

            dt1.Columns.Add(dc1);
            dt1.Columns.Add(dc2);
            dt1.Columns.Add(dc3);
            dt1.Columns.Add(dc4);
            dt1.Columns.Add(dc5);

            for (int i = 1; i < 5; i++)
            {
                ComboBoxItem    sss  = (ComboBoxItem)泵站.SelectedItem;
                StationPumpPlan fspp = null;

                //public StationPumpPlan(Oils oil, Pipe pipe, double[] 流量q, double[] 扬程H,
                //double[] 管道高程, double 全线泵站数, double 当量粗糙度, double 流速, double 泵数, double 首站进站压力)



                if (sss.Tag.Equals("1"))
                {
                    fspp = new StationPumpPlan(oil, pip, q, H, 高程1, int.Parse(sss.Tag + ""),
                                               double.Parse(当量粗糙度.Text),
                                               double.Parse(流速.Text),
                                               i,
                                               double.Parse(首站进站压力.Text));
                }
                else
                {
                    fspp = new StationPumpPlan(oil, pip, q, H, 高程1, int.Parse(sss.Tag + ""),
                                               double.Parse(当量粗糙度.Text),
                                               double.Parse(流速.Text),
                                               i,
                                               double.Parse(首站进站压力.Text));
                }
                double 总扬程, 总降压, 末站出站压力;
                bool   是否合理;
                fspp.getResult(out 总扬程, out 总降压, out 末站出站压力, out 是否合理);
                DataRow dr1 = dt1.NewRow();
                dr1["泵数"]     = i;
                dr1["总扬程"]    = 总扬程;
                dr1["总压降"]    = 总降压;
                dr1["末站出站压力"] = 末站出站压力;
                dr1["是否合理"]   = 是否合理 ? "合理" : "不合理";
                dt1.Rows.Add(dr1);
            }
            table.IsReadOnly  = true;
            table.ItemsSource = null;
            table.ItemsSource = dt1.DefaultView;
            resa.Visibility   = Visibility.Visible;
        }
예제 #15
0
        void getRes(object sender, RoutedEventArgs e)
        {
            PipeDAL      pipeDal  = new PipeDAL();
            ComboBoxItem 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"] + "", "", "", "", "", "", "", "", "");



            //find oil
            OilsDAL   oilsDAL  = new OilsDAL();
            DataTable oilsdata = oilsDAL.getOilosData();
            Oils      oilB     = null;
            Oils      oilA     = null;

            Console.WriteLine(pipedata.Rows[0]["tank_type_a"] + "");
            for (int i = 0; i < oilsdata.Rows.Count; i++)
            {
                Console.WriteLine(oilsdata.Rows[i]["oils_name"] + "");
                if (((string)pipedata.Rows[0]["tank_type_a"]).Trim().Equals(((string)oilsdata.Rows[i]["oils_name"]).Trim()))
                {
                    Console.WriteLine("lalallalal  aaaa ");
                    oilA = new Oils()
                    {
                        Name = oilsdata.Rows[i]["oils_name"] + "",
                        // Density = "754",
                        Density = oilsdata.Rows[i]["oils_density"] + "",
                        //  Viscosity = "1.08E-06",
                        Viscosity = oilsdata.Rows[i]["oils_viscosity"] + "",
                        //    OutputByYear = "270",
                        OutputByYear = oilsdata.Rows[i]["output_year"] + "",
                        //  MasFlow = "600",
                        MasFlow = oilsdata.Rows[i]["mass_flow"] + "",
                        //  Volume_concentration = "0.01"
                        Volume_concentration = oilsdata.Rows[i]["volume_concentration"] + "",
                    };
                }

                if (((string)pipedata.Rows[0]["tank_type_b"]).Trim().Equals(((string)oilsdata.Rows[i]["oils_name"]).Trim()))
                {
                    Console.WriteLine("lalallalal  bbbbb ");
                    oilB = new Oils()
                    {
                        Name = oilsdata.Rows[i]["oils_name"] + "",
                        // Density = "754",
                        Density = oilsdata.Rows[i]["oils_density"] + "",
                        //  Viscosity = "1.08E-06",
                        Viscosity = oilsdata.Rows[i]["oils_viscosity"] + "",
                        //    OutputByYear = "270",
                        OutputByYear = oilsdata.Rows[i]["output_year"] + "",
                        //  MasFlow = "600",
                        MasFlow = oilsdata.Rows[i]["mass_flow"] + "",
                        //  Volume_concentration = "0.01"
                        Volume_concentration = oilsdata.Rows[i]["volume_concentration"] + "",
                    };
                }
            }
            if (oilA == null || oilB == null)
            {
                MessageBox.Show("请确认管道的油灌类型的数据存在数据库中");
            }
            else
            {
                OtherDAL otherDAL = new OtherDAL();
                item = (ComboBoxItem)other.SelectedItem;
                DataTable otherdata = otherDAL.getSingleOtherData(int.Parse(item.Tag + ""));
                //public Cyclicnum(Oils oilA, Oils oilB, Pipe pipe, double A油品费用, double B油品费用, double 混入B油罐中A体积量,
                //    double 混入A油罐中B体积量, double 流速, double 年工作时间,
                //    double 单位有效容积储罐的经营费用, double 单位有效容积储罐的建设费用, double 投资年回收系数)
                //double 单位有效容积储罐的经营费用,double 单位有效容积储罐的建设费用,double 投资年回收系数
                //public Cyclicnum(Oils oilA, Oils oilB, Pipe pipe, double A油品费用, double B油品费用, double 混入B油罐中A体积量, double 混入A油罐中B体积量, double 流速, double 年工作时间, double 单位有效容积储罐的经营费用, double 单位有效容积储罐的建设费用, double 投资年回收系数)
                CyclicnumAlgor c = new CyclicnumAlgor(oilA, oilB, pip,
                                                      double.Parse(A油品费用.Text),
                                                      double.Parse(B油品费用.Text),
                                                      double.Parse(混入B油罐中A体积量.Text),
                                                      double.Parse(混入A油罐中B体积量.Text),
                                                      double.Parse(流速.Text),
                                                      double.Parse(年工作时间.Text),
                                                      double.Parse(otherdata.Rows[0]["cost_operating"] + ""), double.Parse(otherdata.Rows[0]["cost_build"] + ""), double.Parse(otherdata.Rows[0]["n_recovery"] + ""));
                double 最优循环次数 = c.getResult();
                Console.WriteLine("----------------------------------------------------------");
                Console.WriteLine("最优循环次数:{0}", 最优循环次数);
                list.Items.Clear();
                ListViewItem viewitem1 = new ListViewItem();
                viewitem1.Content = "混油A:  " + oilA.Name;
                list.Items.Add(viewitem1);
                ListViewItem viewitem2 = new ListViewItem();
                viewitem2.Content = "混油B:  " + oilB.Name;
                list.Items.Add(viewitem2);
                res.Content = 最优循环次数 + "次";

                resa.Visibility = Visibility.Visible;
            }
        }