using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using HomeService.DBHelper;
namespace HomeService.Utility
{
public class RangeUtil
{
#region 获取信息的基本函数
///
/// 返回 某字段
///
///
public string GetStrSQL(string strfield, string strSQL)
{
DataSet DS = SqlHelper.ExecuteDataset(SqlHelper._connectionStringStr, strSQL);
if (DS.Tables[0].Rows.Count > 0)
{
strSQL = DS.Tables[0].Rows[0]["" + strfield + ""].ToString();
}
else
{
strSQL = "";
}
return strSQL;
}
///
/// 返回 数据集
///
///
public DataSet GetAllSQL(string strSQL)
{
DataSet DS = SqlHelper.ExecuteDataset(SqlHelper._connectionStringStr, strSQL);
try
{
if (DS.Tables[0].Rows.Count <= 0)
{
DS = null;
}
}
catch
{
DS = null;
}
return DS;
}
///
/// 返回所有 分公司代码
///
/// 用户GID
///
public String GetCORPID(string strUserID)
{
string str = "select COMPANYID from user_company where USERID='" + strUserID + "' and COMPANYID in (select GID from [company] where ISDELETED=0 and ISDISABLE=0)";
DataSet DS = SqlHelper.ExecuteDataset(SqlHelper._connectionStringStr, str);
if (DS.Tables[0].Rows.Count > 0)
{
str = DS.Tables[0].Rows[0]["COMPANYID"].ToString();
}
else
{
str = "";
}
return str;
}
///
/// 返回所有 分公司名称
///
/// 用户GID
///
public String GetCORPNAME(string strCompanyID)
{
string str = "select top 1 [NAME] from company where GID='" + strCompanyID + "'";
DataSet DS = SqlHelper.ExecuteDataset(SqlHelper._connectionStringStr, str);
if (DS.Tables[0].Rows.Count > 0)
{
str = DS.Tables[0].Rows[0]["NAME"].ToString();
}
else
{
str = "";
}
return str;
}
///
/// 返回有 分公司部门代码
///
/// 用户GID
///
public String GetDEPTGID(string strUserID)
{
string strcompanyid = GetCORPID(strUserID);
string str = "select GID from sys_dept where LINKID='" + strcompanyid + "' and DEPTNAME=(select top 1 DEPTNAME from user_baseinfo where USERID='" + strUserID + "')";
DataSet DS = SqlHelper.ExecuteDataset(SqlHelper._connectionStringStr, str);
if (DS.Tables[0].Rows.Count > 0)
{
str = DS.Tables[0].Rows[0]["GID"].ToString();
}
else
{
str = "";
}
return str;
}
///
/// 返回有 分公司部门名称
///
/// 用户GID
///
public String GetDEPTNAME(string strUserID)
{
string strcompanyid = GetCORPID(strUserID);
string str = "select top 1 DEPTNAME from user_baseinfo where USERID='" + strUserID + "' and COMPANYNAME=(select NAME from company where GID='" + strcompanyid + "')";
DataSet DS = SqlHelper.ExecuteDataset(SqlHelper._connectionStringStr, str);
if (DS.Tables[0].Rows.Count > 0)
{
str = DS.Tables[0].Rows[0]["DEPTNAME"].ToString();
}
else
{
str = "";
}
return str;
}
///
/// 返回所有 用户显示名称
///
/// 用户GID
///
public String GetSHOWNAME(string strUserID)
{
string str = "select SHOWNAME from [user] where GID='" + strUserID + "' and ISDELETED=0";
DataSet DS = SqlHelper.ExecuteDataset(SqlHelper._connectionStringStr, str);
if (DS.Tables[0].Rows.Count > 0)
{
str = DS.Tables[0].Rows[0]["SHOWNAME"].ToString();
}
else
{
str = "";
}
return str;
}
///
/// 返回所有 权限可视范围
///
/// 登录用户
/// 模块列表名
///
public String GetVISIBLERANGE(string strUserID, string strRange)
{
string str = "select VISIBLERANGE from VW_User_Authority where USERID='" + strUserID + "' and [NAME]='" + strRange + "' and ISDELETE=0";
DataSet DS = SqlHelper.ExecuteDataset(SqlHelper._connectionStringStr, str);
if (DS.Tables[0].Rows.Count > 0)
{
str = DS.Tables[0].Rows[0]["VISIBLERANGE"].ToString();
}
else
{
str = "";
}
return str;
}
///
/// 返回所有 权限可操作范围
///
/// 登录用户
/// 模块列表名
///
public String GetOPERATERANGE(string strUserID, string strRange)
{
string str = "select OPERATERANGE from VW_User_Authority where USERID='" + strUserID + "' and [NAME]='" + strRange + "' and ISDELETE=0";
DataSet DS = SqlHelper.ExecuteDataset(SqlHelper._connectionStringStr, str);
if (DS.Tables[0].Rows.Count > 0)
{
str = DS.Tables[0].Rows[0]["OPERATERANGE"].ToString();
}
else
{
str = "";
}
return str;
}
#endregion
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
}