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); } }
public Pum_Add() { InitializeComponent(); WindowStartupLocation = WindowStartupLocation.CenterScreen; PumpDAL pumpdal = new PumpDAL(); id = pumpdal.getMaxPumpId() + 1; pumpId.Text = id + " "; }
public void button_dele(object sender, RoutedEventArgs e) { if (table.SelectedIndex >= 0) { int id = int.Parse(data.Rows[table.SelectedIndex]["pump_id"] + " "); PumpDAL dal = new PumpDAL(); dal.delPumData(id); initTable(); } else { MessageBox.Show("没有选中项,无法删除"); } }
public void recoveryData(int id) { PumpDAL dal = new PumpDAL(); DataTable data = dal.getSinglePumpData(id); pumpId.Text = data.Rows[0]["pump_id"] + " "; name.Text = data.Rows[0]["name"] + " "; head.Text = data.Rows[0]["head"] + " "; power.Text = data.Rows[0]["displacement"] + " "; displacement.Text = data.Rows[0]["power"] + " "; suctionPressure.Text = data.Rows[0]["suction_pressure"] + " "; runTime.Text = data.Rows[0]["running_time"] + " "; inPressure.Text = data.Rows[0]["in_pressure"] + " "; outPressure.Text = data.Rows[0]["out_pressure"] + " "; }
private void Button_build(object sender, RoutedEventArgs e) { IsNumber Isnumber = new IsNumber(); Pump pump = new Pump(name.Text, id, head.Text, displacement.Text, power.Text, suctionPressure.Text, runTime.Text, inPressure.Text, outPressure.Text); if (Isnumber.isNumber(head.Text.Trim()) == false || Isnumber.isNumber(displacement.Text.Trim()) == false || Isnumber.isNumber(power.Text.Trim()) == false || Isnumber.isNumber(suctionPressure.Text.Trim()) == false || Isnumber.isNumber(runTime.Text.Trim()) == false || Isnumber.isNumber(inPressure.Text.Trim()) == false || Isnumber.isNumber(outPressure.Text.Trim()) == false) { MessageBox.Show("输入格式有误"); } else { PumpDAL pumpdal = new PumpDAL(); pumpdal.addPumpData(pump); MessageBox.Show("添加成功"); Close(); } }
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) { PumpDAL dAL = new PumpDAL(); Console.WriteLine(path); exportExcel exp = new exportExcel(); exp.export(dAL.getPumpData(), path, "Pump"); MessageBox.Show("导出完成"); } }
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}", 系统工作流量); */ }
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("导出完成"); } }
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 + " " + 系统工作流量); }
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("导出完成"); } }
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; }