using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Big.Lito.Data.DataModel; using Big.Lito.Data.Sql; namespace Big.Lito.Data.DataAccess { using System.Data; using System.Data.SqlClient; class ProcessLevelsSQL : ConnectionSQL, IProcessLevelsSQL { /// /// Method to get all club members /// /// Data table public DataRow GetProcessLevelsById(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.sqlGetProgressById; 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 all club members /// /// Data table public DataRow GetProcessLevelsByName(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.sqlGetProcessLevelsByName; comm.Connection = sqlCon; comm.CommandText = cmdString; comm.Parameters.AddWithValue("@Name", 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 get all club members /// /// Data table public DataTable GetAllProcessLevels() { DataTable dataTable = new DataTable(); return dataTable; } /// /// Method to create new member /// /// club member model /// true or false public bool AddProcessLevels(ProcessLevelsModel processLevels) { string connectionString = this.ConnectionString; using (SqlConnection sqlCon = new SqlConnection(connectionString)) { using (SqlCommand comm = new SqlCommand()) { string cmdString = Scripts.SqlInsertProcessLevel; comm.Connection = sqlCon; comm.CommandText = cmdString; comm.Parameters.AddWithValue("@name", processLevels.Name); comm.Parameters.AddWithValue("@start", processLevels.Start); comm.Parameters.AddWithValue("@end", processLevels.End); try { sqlCon.Open(); comm.ExecuteNonQuery(); } catch (SqlException e) { // do something with the exception // don't hide it } } } return true; } /// /// Method to update club member details /// /// club member /// public bool UpdateProcessLevels(ProcessLevelsModel processLevels) { string connectionString = this.ConnectionString; using (SqlConnection sqlCon = new SqlConnection(connectionString)) { using (SqlCommand comm = new SqlCommand()) { string cmdString = Scripts.sqlUpdateProcessLevelsByName; comm.Connection = sqlCon; comm.CommandText = cmdString; comm.Parameters.AddWithValue("@name", processLevels.Name); comm.Parameters.AddWithValue("@start", processLevels.Start); comm.Parameters.AddWithValue("@end", processLevels.End); try { sqlCon.Open(); comm.ExecuteNonQuery(); } catch (SqlException e) { // do something with the exception // don't hide it } } } return true; } /// /// Method to delete a club member /// /// member id /// true / false public bool DeleteProcessLevels(int id) { string connectionString = this.ConnectionString; using (SqlConnection sqlCon = new SqlConnection(connectionString)) { using (SqlCommand comm = new SqlCommand()) { string cmdString = Scripts.SqlDeleteProgress; comm.Connection = sqlCon; comm.CommandText = cmdString; comm.Parameters.AddWithValue("@Id", id); try { sqlCon.Open(); comm.ExecuteNonQuery(); } catch (SqlException e) { // do something with the exception // don't hide it } } } return true; } } }