You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

266 lines
9.5 KiB

using RS.DBUtility;
using RS.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RS.SQLServerDAL
{
public class SToolsManage
{
#region 操作员管理
/// <summary>
/// 查询 操作员信息
/// </summary>
/// <returns></returns>
public DataTable SelOperator()
{
DataTable dtResult = null;
try
{
DataTable dtJobOrderInfo = new DataTable();
StringBuilder selectString = new StringBuilder();
selectString.AppendLine("SELECT * FROM `tb_operator`" + " ");
MySqlHelper sHelper = new MySqlHelper();
dtJobOrderInfo = sHelper.QuerySql(selectString.ToString());
if (dtJobOrderInfo != null)
{
if (dtJobOrderInfo.Rows.Count > 0)
{
DataView dv = dtJobOrderInfo.DefaultView;
dtResult = dv.ToTable();
}
}
}
catch (Exception ex)
{
ex.ToString();
}
return dtResult;
}
public List<string> SelOperatorName(out int len)
{
List<string> list = new List<string>();
ToolsOperators toolsOperators = new ToolsOperators();
int length = 0;
try
{
DataTable dtJobOrderInfo = new DataTable();
StringBuilder selectString = new StringBuilder();
selectString.AppendLine("SELECT operator_num FROM `tb_operator`" + " ");
MySqlHelper sHelper = new MySqlHelper();
dtJobOrderInfo = sHelper.QuerySql(selectString.ToString());
if (dtJobOrderInfo != null)
{
length=dtJobOrderInfo.Rows.Count;
for (int i = 0; i < dtJobOrderInfo.Rows.Count; i++)
{
toolsOperators.operatorNum = (dtJobOrderInfo.Rows[i]["operator_num"] == null) ? "" : dtJobOrderInfo.Rows[i]["operator_num"].ToString();
list.Add(toolsOperators.operatorNum);
}
//if (dtJobOrderInfo.Rows.Count > 0)
//{
//}
}
}
catch (Exception ex)
{
ex.ToString();
}
len = length;
return list;
}
/// <summary>
/// 保存
/// </summary>
/// <param name="stationType"></param>
/// <returns></returns>
public bool SaveToolsOperators(string operatorNum)
{
bool dtResult = false;
try
{
StringBuilder selectString = new StringBuilder();
selectString.AppendLine("INSERT INTO tb_operator(operator_num)" + " ");
selectString.AppendLine("VALUES(" + " ");
selectString.AppendLine(" '" + operatorNum + "') ");
MySqlHelper sHelper = new MySqlHelper();
dtResult = sHelper.ExecuteBNonQuerySQL(selectString.ToString());
}
catch (Exception ex)
{
ex.ToString();
}
return dtResult;
}
/// <summary>
/// 删除操作员
/// </summary>
/// <param name="stationType"></param>
/// <returns></returns>
public bool DeleteToolsOperators(string operatorNum)
{
bool dtResult = false;
try
{
StringBuilder selectString = new StringBuilder();
selectString.AppendLine("DELETE FROM tb_operator" + " ");
selectString.AppendLine("WHERE operator_num='" + operatorNum + "'" + " ");
MySqlHelper sHelper = new MySqlHelper();
dtResult = sHelper.ExecuteBNonQuerySQL(selectString.ToString());
}
catch (Exception ex)
{
ex.ToString();
}
return dtResult;
}
#endregion 操作员管理
#region 客户端登录账号管理
/// <summary>
/// 查询 客户端登录账号(属于同一个分组的所有用户)
/// </summary>
/// <returns></returns>
public DataTable SelUserManage(string userGroup)
{
DataTable dtResult = null;
try
{
DataTable dtJobOrderInfo = new DataTable();
StringBuilder selectString = new StringBuilder();
selectString.AppendLine("SELECT user_name,user_pw" + " ");
selectString.AppendLine("FROM `tb_usermanager`" + " ");
selectString.AppendLine("WHERE user_group= '" + userGroup + "'"+" ");
MySqlHelper sHelper = new MySqlHelper();
dtJobOrderInfo = sHelper.QuerySql(selectString.ToString());
if (dtJobOrderInfo != null)
{
if (dtJobOrderInfo.Rows.Count > 0)
{
DataView dv = dtJobOrderInfo.DefaultView;
dtResult = dv.ToTable();
}
}
}
catch (Exception ex)
{
ex.ToString();
}
return dtResult;
}
/// <summary>
/// 保存用户
/// </summary>
/// <param name="newObject"></param>
/// <returns></returns>
public bool SaveUserManage(ToolsUsersManage newObject)
{
bool dtResult = false;
ToolsOperators toolsOperators = new ToolsOperators();
try
{
//StringBuilder 可变字符串
StringBuilder selectString = new StringBuilder();
selectString.AppendLine("INSERT INTO tb_usermanager(user_name,user_pw,user_group)" + " ");
selectString.AppendLine("VALUES(" + " ");
selectString.AppendLine(" '" + newObject.userName + "',");
selectString.AppendLine(" '" + newObject.userPw + "',");
selectString.AppendLine(" '" + newObject.userGroup + "'");
selectString.AppendLine( "); ");
MySqlHelper sHelper = new MySqlHelper();
dtResult = sHelper.ExecuteBNonQuerySQL(selectString.ToString());
}
catch (Exception ex)
{
ex.ToString();
}
return dtResult;
}
public bool SelUserName(string userName,string user_group)
{
bool dtResult = false;
try
{
DataTable dtJobOrderInfo = new DataTable();
StringBuilder selectString = new StringBuilder();
selectString.AppendLine("SELECT * FROM `tb_usermanager`" + " ");
selectString.AppendLine("WHERE user_name= '" + userName + "'" + " ");
selectString.AppendLine("and user_group= '" + user_group + "'" + " ");
MySqlHelper sHelper = new MySqlHelper();
dtJobOrderInfo = sHelper.QuerySql(selectString.ToString());
if (dtJobOrderInfo != null)
{
if (dtJobOrderInfo.Rows.Count > 0)
{
dtResult = true;
}
}
}
catch (Exception ex)
{
ex.ToString();
}
return dtResult;
}
/// <summary>
/// 根据 用户名删除用户
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
public bool DeleteUserInfo(string userName,string userGrouping)
{
bool isSuccess=false;
try
{
StringBuilder selectString = new StringBuilder();
selectString.AppendLine("DELETE FROM tb_usermanager " + " ");
selectString.AppendLine("WHERE user_name = '" + userName + "'" + " ");
selectString.AppendLine("and user_group = '" + userGrouping + "'" + " ");
MySqlHelper sHelper = new MySqlHelper();
isSuccess = sHelper.ExecuteBNonQuerySQL(selectString.ToString());
}
catch (Exception ex)
{
ex.ToString();
}
return isSuccess;
}
/// <summary>
/// 根据用户名修改密码
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
public bool ModifyUserInfo(string userName,string userPw,string userGrouping)
{
bool isSuccess = false;
try
{
StringBuilder selectString = new StringBuilder();
selectString.AppendLine("UPDATE tb_usermanager SET user_pw = '" + userPw + "'" + " ");
selectString.AppendLine("WHERE user_name = '" + userName + "' " + " ");
selectString.AppendLine("and user_group = '" + userGrouping + "' " + " ");
MySqlHelper sHelper = new MySqlHelper();
isSuccess = sHelper.ExecuteBNonQuerySQL(selectString.ToString());
}
catch (Exception ex)
{
ex.ToString();
}
return isSuccess;
}
#endregion 客户端登录账号管理
}
}