217 lines
7.1 KiB
C#
217 lines
7.1 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// Method to get all club members
|
|
/// </summary>
|
|
/// <returns>Data table</returns>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Method to get all club members
|
|
/// </summary>
|
|
/// <returns>Data table</returns>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Method to get all club members
|
|
/// </summary>
|
|
/// <returns>Data table</returns>
|
|
public DataTable GetAllProcessLevels()
|
|
{
|
|
DataTable dataTable = new DataTable();
|
|
|
|
return dataTable;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Method to create new member
|
|
/// </summary>
|
|
/// <param name="ProjectName">club member model</param>
|
|
/// <returns>true or false</returns>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Method to update club member details
|
|
/// </summary>
|
|
/// <param name="project">club member</param>
|
|
/// <returns></returns>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Method to delete a club member
|
|
/// </summary>
|
|
/// <param name="id">member id</param>
|
|
/// <returns>true / false</returns>
|
|
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;
|
|
}
|
|
|
|
}
|
|
|
|
}
|