public void recoveryData(int id) { OtherDAL dal = new OtherDAL(); DataTable data = dal.getSingleOtherData(id); otherId.Text = data.Rows[0]["other_id"] + " "; name.Text = data.Rows[0]["other_name"] + " "; buildCost.Text = data.Rows[0]["cost_build"] + " "; recoveryN.Text = data.Rows[0]["n_recovery"] + " "; operatingCost.Text = data.Rows[0]["cost_operating"] + " "; oilCost.Text = data.Rows[0]["cost_oil"] + " "; electricityCost.Text = data.Rows[0]["cost_electricity"] + " "; }
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; }
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; } }