//using System.Data.SqlClient; using Big.Lito.Data.DataModel; using Big.Lito.Data.Sql; namespace Big.Lito.Data.DataAccess { //using System; using System.Data; using System.Data.SqlClient; public class HeightmapSQL : ConnectionSQL, IHeightmapSQL { /// /// Method to get club member by Id /// /// member id /// Data row public DataRow GetHeightmapByProjectId(int id) { DataTable dataTable = new DataTable(); DataRow dataRow; string connectionString = this.ConnectionString; using (SqlConnection sqlCon = new SqlConnection(connectionString)) { using (SqlCommand comm = new SqlCommand()) { string cmdString = Scripts.sqlGetHeightmapByProjectId; comm.Connection = sqlCon; comm.CommandText = cmdString; comm.Parameters.AddWithValue("@Id", id); try { SqlDataAdapter sd = new SqlDataAdapter(); sd.SelectCommand = comm; sd.Fill(dataTable); //sqlCon.Open(); //comm.ExecuteNonQuery(); } catch (SqlException e) { // do something with the exception // don't hide it } // Get the datarow from the table dataRow = dataTable.Rows.Count > 0 ? dataTable.Rows[0] : null; } } return dataRow; } /// /// Method to get project by name /// /// project name /// Data row public DataRow GetHeightmapByProjectName(string name) { DataTable dataTable = new DataTable(); DataRow dataRow; string connectionString = this.ConnectionString; using (SqlConnection sqlCon = new SqlConnection(connectionString)) { using (SqlCommand comm = new SqlCommand()) { string cmdString = Scripts.sqlGetHeightmapByProjectName; comm.Connection = sqlCon; comm.CommandText = cmdString; comm.Parameters.AddWithValue("@ProjectName", name); try { SqlDataAdapter sd = new SqlDataAdapter(); sd.SelectCommand = comm; sd.Fill(dataTable); //sqlCon.Open(); //comm.ExecuteNonQuery(); } catch (SqlException e) { // do something with the exception // don't hide it } // Get the datarow from the table dataRow = dataTable.Rows.Count > 0 ? dataTable.Rows[0] : null; } } return dataRow; } /// /// Method to update project /// /// project /// true / false public bool UpdateProject(HeightmapModel heightmapModel) { string connectionString = this.ConnectionString; using (SqlConnection sqlCon = new SqlConnection(connectionString)) { using (SqlCommand comm = new SqlCommand()) { string cmdString = Scripts.SqlUpdateHeightMap; comm.Connection = sqlCon; comm.CommandText = cmdString; comm.Parameters.AddWithValue("@Id", heightmapModel.Id); comm.Parameters.AddWithValue("@ProjectName", heightmapModel.ProjectName); comm.Parameters.AddWithValue("@HighLevelBrightness", heightmapModel.HighLevelBrightness); comm.Parameters.AddWithValue("@LowLevelBrightness", heightmapModel.LowLevelBrightness); comm.Parameters.AddWithValue("@NSlices", heightmapModel.NSlices); comm.Parameters.AddWithValue("@MaxSlices", heightmapModel.MaxSlices); comm.Parameters.AddWithValue("@Repeats", heightmapModel.Repeats); comm.Parameters.AddWithValue("@NSlicesTexture", heightmapModel.NSlicesTexture); comm.Parameters.AddWithValue("@BorderSize", heightmapModel.BorderSize); comm.Parameters.AddWithValue("@PictureWidth", heightmapModel.PictureWidth); try { sqlCon.Open(); comm.ExecuteNonQuery(); } catch (SqlException e) { // do something with the exception // don't hide it } } } return true; } } }