Пример #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 Soil_Add()
        {
            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            SoilDAL dal = new SoilDAL();

            id          = dal.getMaxSoilId() + 1;
            soidId.Text = id + " ";
        }
Пример #3
0
        public void recoveryData(int id)
        {
            SoilDAL   dal  = new SoilDAL();
            DataTable data = dal.getSingelSoilData(id);

            soidId.Text   = data.Rows[0]["soil_id"] + " ";
            soilName.Text = data.Rows[0]["soil_name"] + " ";
            soilTemp.Text = data.Rows[0]["soil_temp"] + " ";
            soilDiff.Text = data.Rows[0]["soil_difference"] + " ";
        }
Пример #4
0
 public void button_dele(object sender, RoutedEventArgs e)
 {
     if (table.SelectedIndex >= 0)
     {
         int     id  = int.Parse(data.Rows[table.SelectedIndex]["soil_id"] + " ");
         SoilDAL dal = new SoilDAL();
         dal.delSoilData(id);
         initTable();
     }
     else
     {
         MessageBox.Show("没有选中项,无法删除");
     }
 }
Пример #5
0
        private void Button_build(object sender, RoutedEventArgs e)
        {
            IsNumber Isnumber = new IsNumber();

            Soil soil = new Soil(id, soilName.Text, soilTemp.Text, soilDiff.Text);

            if (Isnumber.isNumber(soilTemp.Text.Trim()) == false || Isnumber.isNumber(soilDiff.Text.Trim()) == false)
            {
                MessageBox.Show("输入格式有误");
            }
            else
            {
                SoilDAL dal = new SoilDAL();
                dal.addSoilData(soil);
                MessageBox.Show("添加成功");
                Close();
            }
        }
Пример #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)
            {
                SoilDAL dAL = new SoilDAL();
                Console.WriteLine(path);
                exportExcel exp = new exportExcel();
                exp.export(dAL.getSoilData(), path, "Soil");
                MessageBox.Show("导出完成");
            }
        }
Пример #7
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("导出完成");
            }
        }
Пример #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"] + "",
                //    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("导出完成");
            }
        }