Example #1
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)
            {
                OilsDAL dAL = new OilsDAL();
                Console.WriteLine(path);
                exportExcel exp = new exportExcel();
                exp.export(dAL.getOilosData(), path, "Oils");
                MessageBox.Show("导出完成");
            }
        }
Example #2
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;
            }
        }
Example #3
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;
            }
        }