예제 #1
0
        public TerInfo GetTerInfo(string terName)
        {
            TerInfo terInfo = null;


            SqlConnection cn = new SqlConnection(cnStr);


            try
            {
                cn.Open();
                SqlCommand sqlCommand = new SqlCommand("getTerInfo", cn);
                sqlCommand.CommandType = CommandType.StoredProcedure;
                //add params
                SqlParameter param = new SqlParameter("@Name", terName);
                sqlCommand.Parameters.Add(param);

                SqlDataReader myDataReader = sqlCommand.ExecuteReader(CommandBehavior.CloseConnection);
                while (myDataReader.Read())
                {
                    terInfo = new TerInfo(myDataReader.GetString(0), myDataReader.GetDouble(1), myDataReader.GetDouble(2), myDataReader.GetString(3), myDataReader.GetDouble(4), myDataReader.GetDouble(5),
                                          myDataReader.GetDouble(6), myDataReader.GetDouble(7), myDataReader.GetDouble(8), myDataReader.GetDouble(9), myDataReader.GetDouble(10), myDataReader.GetDouble(11),
                                          myDataReader.GetDouble(12), myDataReader.GetDouble(13), myDataReader.GetDouble(14), myDataReader.GetDouble(15), myDataReader.GetDouble(16), myDataReader.GetDouble(17));
                }

                return(terInfo);
            }
            catch (SqlException ex)
            {
                LogFileManager.ObjLog.error(ex.Message);
                return(null);

                throw ex;
            }
            finally
            {
                cn.Close();
            }
        }
예제 #2
0
        public void AddTerInfo(TerInfo terInfo)
        {
            //string cnStr = ConfigurationManager.ConnectionStrings["sqlProviderParallelTask"].ConnectionString;

            SqlConnection cn = new SqlConnection(cnStr);


            try
            {
                cn.Open();
                SqlCommand sqlCommand = new SqlCommand("addTerInfo", cn);
                sqlCommand.CommandType = CommandType.StoredProcedure;
                //add params
                SqlParameter param1 = new SqlParameter("@Name", terInfo.name);
                sqlCommand.Parameters.Add(param1);

                SqlParameter param2 = new SqlParameter("@OriginX", terInfo.originX);
                sqlCommand.Parameters.Add(param2);

                SqlParameter param3 = new SqlParameter("@OriginY", terInfo.originY);
                sqlCommand.Parameters.Add(param3);

                SqlParameter param4 = new SqlParameter("@Path", terInfo.path);
                sqlCommand.Parameters.Add(param4);

                SqlParameter param5 = new SqlParameter("@Zmin", terInfo.Zmin);
                sqlCommand.Parameters.Add(param5);

                SqlParameter param6 = new SqlParameter("@Zmax", terInfo.Zmax);
                sqlCommand.Parameters.Add(param6);

                SqlParameter param7 = new SqlParameter("@Vertex1X", terInfo.Vertex1X);
                sqlCommand.Parameters.Add(param7);

                SqlParameter param8 = new SqlParameter("@Vertex1Y", terInfo.Vertex1Y);
                sqlCommand.Parameters.Add(param8);

                SqlParameter param9 = new SqlParameter("@Vertex1Z", terInfo.Vertex1Z);
                sqlCommand.Parameters.Add(param9);

                SqlParameter param10 = new SqlParameter("@Vertex2X", terInfo.Vertex2X);
                sqlCommand.Parameters.Add(param10);

                SqlParameter param11 = new SqlParameter("@Vertex2Y", terInfo.Vertex2Y);
                sqlCommand.Parameters.Add(param11);

                SqlParameter param12 = new SqlParameter("@Vertex2Z", terInfo.Vertex2Z);
                sqlCommand.Parameters.Add(param12);

                SqlParameter param13 = new SqlParameter("@Vertex3X", terInfo.Vertex3X);
                sqlCommand.Parameters.Add(param13);

                SqlParameter param14 = new SqlParameter("@Vertex3Y", terInfo.Vertex3Y);
                sqlCommand.Parameters.Add(param14);

                SqlParameter param15 = new SqlParameter("@Vertex3Z", terInfo.Vertex3Z);
                sqlCommand.Parameters.Add(param15);

                SqlParameter param16 = new SqlParameter("@Vertex4X", terInfo.Vertex4X);
                sqlCommand.Parameters.Add(param16);

                SqlParameter param17 = new SqlParameter("@Vertex4Y", terInfo.Vertex4Y);
                sqlCommand.Parameters.Add(param17);

                SqlParameter param18 = new SqlParameter("@Vertex4Z", terInfo.Vertex4Z);
                sqlCommand.Parameters.Add(param18);



                sqlCommand.ExecuteNonQuery();
            }

            catch (SqlException ex)
            {
                LogFileManager.ObjLog.error(ex.Message);
                throw ex;
            }
            finally
            {
                cn.Close();
            }
        }