//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 SystemSettingsSQL : ConnectionSQL, ISystemSettingsSQL
{
///
/// Method to get club member by Id
///
/// member id
/// Data row
public DataRow GetSystemSettingsByProjectId(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 GetSystemSettingsByProjectName(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(SystemSettingsModel systemSettingsModel)
{
string connectionString = this.ConnectionString;
using (SqlConnection sqlCon = new SqlConnection(connectionString))
{
using (SqlCommand comm = new SqlCommand())
{
string cmdString = Scripts.SqlUpdateSystemSettings;
comm.Connection = sqlCon;
comm.CommandText = cmdString;
comm.Parameters.AddWithValue("@Id", systemSettingsModel.Id);
comm.Parameters.AddWithValue("@HomeDir", systemSettingsModel.HomeDir);
comm.Parameters.AddWithValue("@BlenderDir", systemSettingsModel.BlenderDir);
try
{
sqlCon.Open();
comm.ExecuteNonQuery();
}
catch (SqlException e)
{
// do something with the exception
// don't hide it
}
}
}
return true;
}
}
}