Exemplo n.º 1
0
        public bool addOilsData(Oils data)
        {
            bool   IsSuccess = false;
            string sql       = "insert into tb_oils values(@a,@b,@c,@d,@e,@f,@g)";

            SqlParameter[] spm =
            {
                new SqlParameter("@a", SqlDbType.Int),
                new SqlParameter("@b", SqlDbType.VarChar),
                new SqlParameter("@c", SqlDbType.VarChar),
                new SqlParameter("@d", SqlDbType.VarChar),
                new SqlParameter("@e", SqlDbType.VarChar),
                new SqlParameter("@f", SqlDbType.VarChar),
                new SqlParameter("@g", SqlDbType.VarChar),
            };
            spm[0].Value = data.OilsId;
            spm[1].Value = data.Name;
            spm[2].Value = data.Density;
            spm[3].Value = data.Viscosity;
            spm[4].Value = data.MasFlow;
            spm[5].Value = data.OutputByYear;
            spm[6].Value = data.Volume_concentration;

            if (SqlHelper.ExecuteNonQuery(sql, spm) > 0)
            {
                IsSuccess = true;
            }
            return(IsSuccess);
        }
Exemplo n.º 2
0
        public CyclicnumAlgor(Oils oilA, Oils oilB, Pipe pipe, double A油品费用, double B油品费用, double 混入B油罐中A体积量, double 混入A油罐中B体积量, double 流速, double 年工作时间, double 单位有效容积储罐的经营费用, double 单位有效容积储罐的建设费用, double 投资年回收系数)
        {
            aPrice = A油品费用;
            bPrice = B油品费用;
            JZ     = 单位有效容积储罐的建设费用;
            E      = 投资年回收系数;
            G      = 单位有效容积储罐的经营费用;
            D      = 年工作时间;
            Qm     = double.Parse(oilA.MasFlow) / D;
            M      = new double[]
            {
                double.Parse(oilA.OutputByYear),
                double.Parse(oilB.OutputByYear)
            };
            v    = 流速;
            ρA   = double.Parse(oilA.Density);
            ρB   = double.Parse(oilB.Density);
            kAPB = double.Parse(oilB.Volume_concentration);
            kBPA = double.Parse(oilA.Volume_concentration);
            vPB  = 混入A油罐中B体积量;
            vPA  = 混入B油罐中A体积量;
            d    = double.Parse(pipe.OuterDiameter) - 2 * double.Parse(pipe.WallThickness);
            L    = double.Parse(pipe.Length);

            Va = double.Parse(oilA.Viscosity);
            Vb = double.Parse(oilB.Viscosity);
            Re = v * d / 1000 / ((Va + Vb) / 2);
        }
Exemplo n.º 3
0
 public PowerCost(Oils oils, Pipe pipe, Pump pump, double[] 泵流量, double[] 泵扬程, double 年工作时间, double 电机效率, double 管道起点高程, double 管道终点高程, double 电费, double 流速, double 当量粗糙度, double 重力加速度, double 首站进站压力)
 {
     g      = 重力加速度;
     D      = 年工作时间;
     v      = 流速;
     e      = 当量粗糙度;
     g      = 重力加速度;
     Hs1    = 首站进站压力;
     q      = 泵流量;
     H      = 泵扬程;
     Q      = double.Parse(oils.OutputByYear) * 10000000 / 24 / 3600 / 350 / double.Parse(oils.Density);
     ν      = double.Parse(oils.Viscosity);
     L      = double.Parse(pipe.Length);
     d      = double.Parse(pipe.OuterDiameter) - 2 * double.Parse(pipe.WallThickness);
     ed     = 电费;
     tj     = double.Parse(oils.OutputByYear) / (double.Parse(oils.MasFlow) / 350);
     ηee    = 电机效率;
     Z      = 管道终点高程 - 管道起点高程;
     Gpe    = double.Parse(oils.OutputByYear) * 10000000 / D / 24 / 3600;
     Ppeout = double.Parse(pump.OutPressure);
     Ppein  = double.Parse(pump.InPressure);
     Npe    = double.Parse(pump.Power);
     ε      = 2 * e / d;
     Re     = v * d / 1000 / ν;
 }
Exemplo n.º 4
0
 public MixedOilQuantity(Oils oilA, Oils oilB, Pipe pipe, double 切割浓度, double 流速)
 {
     Va  = double.Parse(oilA.Viscosity);
     Vb  = double.Parse(oilB.Viscosity);
     L   = double.Parse(pipe.Length);
     d   = double.Parse(pipe.OuterDiameter) - 2 * double.Parse(pipe.WallThickness);
     v   = 流速;
     Ka  = (int)(切割浓度 * 100);
     νpj = (Va + Vb) / 2;
     Re  = v * d / 1000 / νpj;
 }
Exemplo n.º 5
0
        protected override void OnQueryChanged(string oldValue, string newValue)
        {
            base.OnQueryChanged(oldValue, newValue);

            if (string.IsNullOrWhiteSpace(newValue))
            {
                ItemsSource = null;
            }
            else
            {
                ItemsSource = Oils
                              .Where(o => o.Nume.ToLower().Contains(newValue.ToLower()))
                              .ToList <Oil>();
            }
        }
Exemplo n.º 6
0
        private void Button_build(object sender, RoutedEventArgs e)
        {
            Oils     oils     = new Oils(id, name.Text, density.Text, viscosity.Text, masFlow.Text, outputByYear.Text, volume_concentration.Text);
            IsNumber Isnumber = new IsNumber();

            if (Isnumber.isNumber(density.Text.Trim()) == false || Isnumber.isNumber(viscosity.Text.Trim()) == false || Isnumber.isNumber(masFlow.Text.Trim()) == false || Isnumber.isNumber(outputByYear.Text.Trim()) == false || Isnumber.isNumber(volume_concentration.Text.Trim()) == false)
            {
                MessageBox.Show("输入格式有误");
            }
            else
            {
                OilsDAL oilsdal = new OilsDAL();
                oilsdal.addOilsData(oils);
                MessageBox.Show("添加成功");
                Close();
            }
        }
Exemplo n.º 7
0
 public WaterCharacteristics(Oils oil, Pipe pipe, Pump pump, double 全线总摩阻, double[] 泵流量, double[] 泵扬程, double 当量粗糙度, double 流速, double 管道起点高程, double 管道终点高程)
 {
     Ma = double.Parse(oil.OutputByYear);
     H1 = double.Parse(pump.InPressure);
     hc = 全线总摩阻;
     q  = 泵流量;
     H  = 泵扬程;
     ρ  = double.Parse(oil.Density);
     L  = double.Parse(pipe.Length);
     e  = 当量粗糙度;
     ν  = double.Parse(oil.Viscosity);
     v  = 流速;
     d  = double.Parse(pipe.OuterDiameter) - 2 * double.Parse(pipe.WallThickness);
     Z  = 管道终点高程 - 管道起点高程;
     Q  = (double.Parse(oil.OutputByYear) * 10000000 / 350 / 24 / 3600) / ρ;
     ε  = 2 * e / d;
     Re = v * d / 1000 / ν;
 }
Exemplo n.º 8
0
 public PipeWork(Oils oil, Pipe pipe, Pump pump, double[] 泵流量, double[] 泵扬程, double 当量粗糙度, double 流速, double 管道起点高程, double 管道终点高程, double 首站进站压力)
 {
     Ma          = double.Parse(oil.OutputByYear);
     q           = 泵流量;
     H           = 泵扬程;
     ρ           = double.Parse(oil.Density);
     L           = double.Parse(pipe.Length);
     e           = 当量粗糙度;
     ν           = double.Parse(oil.Viscosity);
     v           = 流速;
     d           = double.Parse(pipe.OuterDiameter) - 2 * double.Parse(pipe.WallThickness);
     outPressure = double.Parse(pump.OutPressure);
     Zz          = 管道终点高程;
     Zq          = 管道起点高程;
     Z           = 管道终点高程 - 管道起点高程;
     Hs          = 首站进站压力;
     Q           = (Ma * 10000000 / 24 / 350 / 3600) / ρ;
     Re          = v * d / 1000 / ν;
     ε           = 2 * e / d;
 }
Exemplo n.º 9
0
        //保存高程差的值

        public StationPumpPlan(Oils oil, Pipe pipe, double[] 流量q, double[] 扬程H, double[] 管道高程, double 全线泵站数, double 当量粗糙度, double 流速, double 泵数, double 首站进站压力)
        {
            q = 流量q;
            H = 扬程H;
            Z = new double[管道高程.Length - 1];
            for (int i = 0; i < 管道高程.Length - 1; i++)
            {
                Z[i] = 管道高程[i + 1] - 管道高程[i];
            }
            Z_ = 管道高程[管道高程.Length - 1] - 管道高程[0];
            N  = 全线泵站数;
            L  = double.Parse(pipe.Length);
            d  = double.Parse(pipe.OuterDiameter) - 2 * double.Parse(pipe.WallThickness);
            ν  = double.Parse(oil.Viscosity);
            e  = 当量粗糙度;
            Q  = (double.Parse(oil.OutputByYear) * 10000000 / 24 / 350 / 3600) / double.Parse(oil.Density);
            Re = 流速 * d / 1000 / ν;
            ε  = 2 * e / d;
            n  = 泵数;
            H1 = 首站进站压力;
        }
Exemplo n.º 10
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;
            }
        }
Exemplo n.º 11
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;
        }
Exemplo n.º 12
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 + "   " + 系统工作流量);
        }
Exemplo n.º 13
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("导出完成");
            }
        }
Exemplo n.º 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;
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 16
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("导出完成");
            }
        }
Exemplo n.º 17
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}", 系统工作流量);
             */
        }
Exemplo n.º 18
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;
        }