using System; using System.ComponentModel;
using System.Data.SqlClient; using System.Data; using
System.Data.SqlTypes;
namespace com.os.database { public partial class
os_database : Component
{ private SqlConnection sqlConn =
new SqlConnection(); string
s_sqlConn = (string)((new
System.Configuration.AppSettingsReader()).GetValue("sqlConn.ConnectionString",
typeof(string)));
public
os_database()
{ throw
new
System.NotImplementedException();
}
public DataSet
Get_ItemsRecords(string itemNameIn, string userloginId, string
permission)
{
SqlCommand cmd_itemList = new SqlCommand();
cmd_itemList.CommandText =
"[OS].[GET_ItemsRecords]";
cmd_itemList.CommandType =
CommandType.StoredProcedure;
cmd_itemList.Parameters.Clear();
SqlParameter sqlParaName = new SqlParameter("@itemName", SqlDbType.VarChar,
1000);
sqlParaName.Value =
formatWildCard(itemNameIn);
cmd_itemList.Parameters.Add(sqlParaName);
SqlParameter sqlParaUserID = new SqlParameter("@userloginid", SqlDbType.VarChar,
50);
sqlParaUserID.Value =
userloginId;
cmd_VRMList.Parameters.Add(sqlParaUserID);
SqlParameter sqlParaPermission = new SqlParameter("@permission",
SqlDbType.VarChar,
50);
sqlParaPermission.Value =
permission;
cmd_VRMList.Parameters.Add(sqlParaPermission);
DataSet
ds_itemList =
getDataSet(cmd_itemList);
return ds_itemList; }
public DataSet
Get_AuthenticatedUserDetails(string
userid)
{
SqlCommand cmd_UserDetails = new SqlCommand();
cmd_UserDetails.CommandText =
"[OS].[GET_AuthenticatedUserDetails]";
cmd_UserDetails.CommandType =
CommandType.StoredProcedure;
cmd_UserDetails.Parameters.Clear();
return
getDataSet(cmd_UserDetails); }
private DataSet
getDataSet(SqlCommand cmd)
{
this.sqlConn.ConnectionString =
this.s_sqlConn;
cmd.Connection =
sqlConn;
cmd.Connection.Open();
SqlDataAdapter da = new
SqlDataAdapter(cmd);
DataSet ds = new
DataSet();
da.Fill(ds);
cmd.Connection.Close();
return ds; }
private Boolean
executeNotQuery(SqlCommand cmd)
{
this.sqlConn.ConnectionString =
this.s_sqlConn;
cmd.Connection =
sqlConn;
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();
return true; }
/* Method to format the WildCard
of the search to comply with the database
wildcard */
private String
formatWildCard(String original)
{ return
original.Replace('*', '%'); }
public DataSet
Get_OS_Permission(string
userlogin)
{
SqlCommand cmd_Permission = new SqlCommand();
cmd_Permission.CommandText =
"[OS].Get_OS_Permission";
cmd_Permission.CommandType =
CommandType.StoredProcedure;
cmd_Permission.Parameters.Clear();
SqlParameter sqlPara = new SqlParameter("@UserLogin", SqlDbType.VarChar,
50);
sqlPara.Value =
userlogin;
cmd_Permission.Parameters.Add(sqlPara);
DataSet
ds_Permission = getDataSet(cmd_Permission);
return
ds_Permission; }
public DataSet
Get_TableColumns(String tableName)
{
SqlCommand cmd_Column = new SqlCommand();
cmd_Column.CommandText =
"[OS].[GET_TableColumns]";
cmd_Column.CommandType =
CommandType.StoredProcedure;
cmd_Column.Parameters.Clear();
SqlParameter sqlPara = new SqlParameter("@tableName", SqlDbType.VarChar,
-1);
sqlPara.Value =
tableName;
cmd_Column.Parameters.Add(sqlPara);
DataSet
ds_Column =
getDataSet(cmd_Column);
return ds_Column; }
public DataSet
Get_RoleRecords(string roleDescriptionIn, SqlBoolean
isActiveIn)
{
SqlCommand cmd_RoleList = new SqlCommand();
cmd_RoleList.CommandText =
"[Common].[GET_RoleRecords]";
cmd_RoleList.CommandType =
CommandType.StoredProcedure;
cmd_RoleList.Parameters.Clear();
SqlParameter sqlParaRoleDescription = new SqlParameter("@roleDescriptionIn",
SqlDbType.VarChar,
300);
sqlParaRoleDescription.Value =
formatWildCard(roleDescriptionIn);
cmd_RoleList.Parameters.Add(sqlParaRoleDescription);
SqlParameter sqlParaIsActive = new SqlParameter("@isActiveIn",
SqlDbType.Bit);
sqlParaIsActive.Value =
isActiveIn;
cmd_RoleList.Parameters.Add(sqlParaIsActive);
DataSet
ds_RoleList =
getDataSet(cmd_RoleList);
return ds_RoleList; }
}
}
|