public void UpdateThamSoDauVao(ThamSoDauVao_class thamSoDauVao)
 {
     try
     {
         Connection.Open();
         SqlCommand cmd = new SqlCommand("UpdateThamSoDauVao", Connection);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@idLoaiDau", thamSoDauVao.IdLoaiDau);
         cmd.Parameters.AddWithValue("@seaWaterTemperature", thamSoDauVao.Temperature);
         cmd.Parameters.AddWithValue("@thoiGianMoPhong", thamSoDauVao.Thoigian);
         cmd.Parameters.AddWithValue("@upwardSeaWaterVelocity", thamSoDauVao.Upward_sea);
         cmd.Parameters.AddWithValue("@viTriDauThoatY", thamSoDauVao.Vitr_y);
         cmd.Parameters.AddWithValue("@viTriDauThoatX", thamSoDauVao.Vitri_x);
         cmd.Parameters.AddWithValue("@xWind", thamSoDauVao.X_wind);
         cmd.Parameters.AddWithValue("@yWind", thamSoDauVao.Y_wind);
         cmd.Parameters.AddWithValue("@seaSurfaceWaveStokesDriftXVelocity", thamSoDauVao.Drift_x);
         cmd.Parameters.AddWithValue("@seaSurfaceWaveStokesDriftYVelocity", thamSoDauVao.Drift_y);
         cmd.Parameters.AddWithValue("@khoiLuongDau", thamSoDauVao.Luongdau);
         cmd.Parameters.AddWithValue("@seaWaterSalinity", thamSoDauVao.Salinity);
         cmd.Parameters.AddWithValue("@seaSurfaceWaveSignificantHeight", thamSoDauVao.Sign_height);
         cmd.Parameters.AddWithValue("@xWaterVelocity", thamSoDauVao.X_water);
         cmd.Parameters.AddWithValue("@yWaterVelocity", thamSoDauVao.Y_water);
         cmd.Parameters.AddWithValue("@maThamSo", thamSoDauVao.Mathamso);
         cmd.ExecuteScalar();
         Connection.Close();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
示例#2
0
        public bool ThemThamSo(ThamSoDauVao_class input)
        {
            SqlCommand cmd = new SqlCommand("ThemThamSo", Connection);

            cmd.CommandType = CommandType.StoredProcedure;

            try
            {
                cmd.Parameters.Add(new SqlParameter("@mathamso", input.Mathamso));
                cmd.Parameters.Add(new SqlParameter("@x_water", input.X_water));
                cmd.Parameters.Add(new SqlParameter("@y_water", input.Y_water));
                cmd.Parameters.Add(new SqlParameter("@x_wind", input.X_wind));
                cmd.Parameters.Add(new SqlParameter("@y_wind", input.Y_wind));
                cmd.Parameters.Add(new SqlParameter("@upward_sea", input.Upward_sea));
                cmd.Parameters.Add(new SqlParameter("@sign_height", input.Sign_height));
                cmd.Parameters.Add(new SqlParameter("@drift_x", input.Drift_x));
                cmd.Parameters.Add(new SqlParameter("@drift_y", input.Drift_y));
                cmd.Parameters.Add(new SqlParameter("@temperature", input.Temperature));
                cmd.Parameters.Add(new SqlParameter("@salinity", input.Salinity));
                cmd.Parameters.Add(new SqlParameter("@idLoaiDau", input.IdLoaiDau));
                cmd.Parameters.Add(new SqlParameter("@vitri_x", input.Vitri_x));
                cmd.Parameters.Add(new SqlParameter("@vitri_y", input.Vitr_y));
                cmd.Parameters.Add(new SqlParameter("@luongdau", input.Luongdau));
                cmd.Parameters.Add(new SqlParameter("@thoigian", input.Thoigian));


                Connection.Open();
                Connection.InfoMessage += showResultFromSql;
                cmd.ExecuteNonQuery();
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi xảy ra");
                return(false);
            }
            finally
            {
                Connection.InfoMessage -= showResultFromSql;
                Connection.Close();
                cmd.Dispose();
            }
        }
示例#3
0
        public ThamSoDauVao_class LayThamSoDauVaoVoiMaKeHoach(int maKeHoach)
        {
            SqlCommand cmd = new SqlCommand("LayThamSoDauVaoVoiMaKeHoach", Connection);

            cmd.Parameters.AddWithValue("maKeHoach", maKeHoach);
            cmd.CommandType = CommandType.StoredProcedure;
            using (SqlDataAdapter adapter = new SqlDataAdapter(cmd))
            {
                DataTable table = new DataTable();
                adapter.Fill(table);
                if (table.Rows.Count > 0)
                {
                    ThamSoDauVao_class thamSoDauVao = new ThamSoDauVao_class()
                    {
                        Drift_x     = table.Rows[0].Field <double>((int)ThamSoDauVaoEnum.sea_surface_wave_stokes_drift_x_velocity),
                        Drift_y     = table.Rows[0].Field <double>((int)ThamSoDauVaoEnum.sea_surface_wave_stokes_drift_y_velocity),
                        IdLoaiDau   = table.Rows[0].Field <int>((int)ThamSoDauVaoEnum.idLoaiDau),
                        Luongdau    = table.Rows[0].Field <double>((int)ThamSoDauVaoEnum.khoiluongdau),
                        Mathamso    = table.Rows[0].Field <int>((int)ThamSoDauVaoEnum.idThamSo),
                        Salinity    = table.Rows[0].Field <double>((int)ThamSoDauVaoEnum.sea_water_salinity),
                        Sign_height = table.Rows[0].Field <double>((int)ThamSoDauVaoEnum.sea_surface_wave_significant_height),
                        Temperature = table.Rows[0].Field <double>((int)ThamSoDauVaoEnum.sea_water_temperature),
                        Thoigian    = table.Rows[0].Field <DateTime>((int)ThamSoDauVaoEnum.thoigianmophong),
                        Upward_sea  = table.Rows[0].Field <double>((int)ThamSoDauVaoEnum.upward_sea_water_velocity),
                        Vitri_x     = table.Rows[0].Field <int>((int)ThamSoDauVaoEnum.vitridauthatthoat_x),
                        Vitr_y      = table.Rows[0].Field <int>((int)ThamSoDauVaoEnum.vitridauthatthoat_y),
                        X_water     = table.Rows[0].Field <double>((int)ThamSoDauVaoEnum.x_water_velocity),
                        X_wind      = table.Rows[0].Field <double>((int)ThamSoDauVaoEnum.x_wind),
                        Y_water     = table.Rows[0].Field <double>((int)ThamSoDauVaoEnum.y_water_velocity),
                        Y_wind      = table.Rows[0].Field <double>((int)ThamSoDauVaoEnum.y_wind)
                    };
                    return(thamSoDauVao);
                }
                return(null);
            }
        }