//**==========================================================================================
//**
//** FILE : Admin.cs
//** Author: Stevan Rodrigues
//**
//**==========================================================================================
//**
//** (c) The contents of this file , and of any file or document derived from it , are copyright
//** to SiteBuilders . Unlicensed alteration, change or copying in any form,
//** whether written, by photocopy, by print or by any other methods of reproduction is
//** strictly prohibited.
//**
//**==========================================================================================
using System;
using Company.ThreeTierDemo.Components.Interface;
using WebChamps.Components.Parent;
using Microsoft.ApplicationBlocks.Data;
//*********************************************************************
//
// Company.ThreeTierDemo.Components.Data Namespace
//
//*********************************************************************
namespace Company.ThreeTierDemo.Components.Data
{
//*********************************************************************
//
// Class: Admin
//
//Description: This class belongs to Data Access tier which encapsulates
// all data logic necessary to add/update/query/delete records
// of Admin_Tb within database.
//
//*********************************************************************
public class Admin : DataObject
{
//*********************************************************************
//
// ShowAdmin Method
//
// The ShowAdmin_Tb method Shows the specified content from
// the Admin_Tb database table.
// Other relevant sources:
// File : ProcShowAdmin_Tb.sql - ProcShowAdmin_Tb Stored Procedure
//
//*********************************************************************
public static System.Data.DataSet ShowAdmin()
{
System.Data.DataSet MsDataSet;
System.Data.SqlClient.SqlParameter[] MsSqlParameter = {};
try
{
// Fill the Dataset object with records
MsDataSet = SqlHelper.ExecuteDataset(ConnectionString, System.Data.CommandType.StoredProcedure, "ProcShowAdmin_Tb", MsSqlParameter);
return MsDataSet;
}
catch (System.Exception ex)
{
throw new WebChamps.Components.Web.AppException("An error occurred while executing the Company.ThreeTierDemo.Components.Data.Admin.ShowAdmin", ex);
}
finally
{
//Some action
}
}
//*********************************************************************
//
// SelectAdmin Method
//
// The SelectAdmin_Tb method Selects the specified content from
// the Admin_Tb database table.
// Other relevant sources:
// File : ProcSelectAdmin_Tb.sql - ProcSelectAdmin_Tb Stored Procedure
//
//*********************************************************************
public static System.Data.SqlClient.SqlDataReader SelectAdmin(Int32 AdminId)
{
System.Data.SqlClient.SqlDataReader MsDataReader;
System.Data.SqlClient.SqlParameter[] MsSqlParameter = {
new System.Data.SqlClient.SqlParameter( "@AdminId", AdminId)
};
try
{
MsDataReader = SqlHelper.ExecuteReader(ConnectionString, "ProcSelectAdmin_Tb", MsSqlParameter);
return MsDataReader;
}
catch (System.Exception ex)
{
throw new WebChamps.Components.Web.AppException("An error occurred while executing the Company.ThreeTierDemo.Components.Data.Admin.SelectAdmin", ex);
}
finally
{
//Some action
}
}
//*********************************************************************
//
// AddAdmin Method
//
// The AddAdmin_Tb method Adds the specified content from
// the Admin_Tb database table.
// Other relevant sources:
// File : ProcAddAdmin_Tb.sql - ProcAddAdmin_Tb Stored Procedure
//
//*********************************************************************
public static Int32 AddAdmin(IAdmin ParamAdmin, String Username)
{
System.Data.SqlClient.SqlParameter[] MsSqlParameter = {
new System.Data.SqlClient.SqlParameter( "@AdminId", ParamAdmin.AdminId),
new System.Data.SqlClient.SqlParameter( "@FirstName", ParamAdmin.FirstName ),
new System.Data.SqlClient.SqlParameter( "@LastName", ParamAdmin.LastName ),
new System.Data.SqlClient.SqlParameter( "@Username", ParamAdmin.Username ),
new System.Data.SqlClient.SqlParameter( "@Password", ParamAdmin.Password ),
new System.Data.SqlClient.SqlParameter( "@AddedDate", System.DateTime.Now),
new System.Data.SqlClient.SqlParameter( "@UpdatedDate", System.DateTime.Now),
new System.Data.SqlClient.SqlParameter( "@EditUsername", Username ),
new System.Data.SqlClient.SqlParameter("ReturnValue", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, 0, 0, System.String.Empty, System.Data.DataRowVersion.Default, null)
};
try
{
SqlHelper.ExecuteNonQuery(ConnectionString, "ProcAddAdmin_Tb", MsSqlParameter);
return System.Convert.ToInt32(MsSqlParameter[8].Value);
}
catch (System.Exception ex)
{
throw new WebChamps.Components.Web.AppException("An error occurred while executing the Company.ThreeTierDemo.Components.Data.Admin.AddAdmin", ex);
}
finally
{
//Some action
}
}
//*********************************************************************
//
// UpdateAdmin Method
//
// The UpdateAdmin_Tb method Updates the specified content from
// the Admin_Tb database table.
// Other relevant sources:
// File : ProcUpdateAdmin_Tb.sql - ProcUpdateAdmin_Tb Stored Procedure
//
//*********************************************************************
public static Int32 UpdateAdmin(IAdmin ParamAdmin, String Username)
{
System.Data.SqlClient.SqlParameter[] MsSqlParameter = {
new System.Data.SqlClient.SqlParameter( "@AdminId", ParamAdmin.AdminId),
new System.Data.SqlClient.SqlParameter( "@FirstName", ParamAdmin.FirstName ),
new System.Data.SqlClient.SqlParameter( "@LastName", ParamAdmin.LastName ),
new System.Data.SqlClient.SqlParameter( "@Username", ParamAdmin.Username ),
new System.Data.SqlClient.SqlParameter( "@Password", ParamAdmin.Password ),
new System.Data.SqlClient.SqlParameter( "@UpdatedDate", System.DateTime.Now),
new System.Data.SqlClient.SqlParameter( "@EditUsername", Username ),
new System.Data.SqlClient.SqlParameter("ReturnValue", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, 0, 0, System.String.Empty, System.Data.DataRowVersion.Default, null)
};
try
{
SqlHelper.ExecuteNonQuery(ConnectionString, "ProcUpdateAdmin_Tb", MsSqlParameter);
return System.Convert.ToInt32(MsSqlParameter[7].Value);
}
catch (System.Exception ex)
{
throw new WebChamps.Components.Web.AppException("An error occurred while executing the Company.ThreeTierDemo.Components.Data.Admin.UpdateAdmin", ex);
}
finally
{
//Some action
}
}
//*********************************************************************
//
// DeleteAdmin Method
//
// The DeleteAdmin_Tb method Deletes the specified content from
// the Admin_Tb database table.
// Other relevant sources:
// File : ProcDeleteAdmin_Tb.sql - ProcDeleteAdmin_Tb Stored Procedure
//
//*********************************************************************
public static Int32 DeleteAdmin(Int32 AdminId, String Username)
{
System.Data.SqlClient.SqlParameter[] MsSqlParameter = {
new System.Data.SqlClient.SqlParameter( "@AdminId", AdminId),
new System.Data.SqlClient.SqlParameter( "@DeletedDate", System.DateTime.Now),
new System.Data.SqlClient.SqlParameter( "@EditUsername", Username ),
new System.Data.SqlClient.SqlParameter("ReturnValue", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, 0, 0, System.String.Empty, System.Data.DataRowVersion.Default, null)
};
try
{
SqlHelper.ExecuteNonQuery(ConnectionString, "ProcDeleteAdmin_Tb", MsSqlParameter);
return System.Convert.ToInt32(MsSqlParameter[3].Value);
}
catch (System.Exception ex)
{
throw new WebChamps.Components.Web.AppException("An error occurred while executing the Company.ThreeTierDemo.Components.Data.Admin.DeleteAdmin", ex);
}
finally
{
//Some action
}
}
}
}