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 操作员管理 /// /// 查询 操作员信息 /// /// 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 SelOperatorName(out int len) { List list = new List(); 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; } /// /// 保存 /// /// /// 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; } /// /// 删除操作员 /// /// /// 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 客户端登录账号管理 /// /// 查询 客户端登录账号(属于同一个分组的所有用户) /// /// 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; } /// /// 保存用户 /// /// /// 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; } /// /// 根据 用户名删除用户 /// /// /// 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; } /// /// 根据用户名修改密码 /// /// /// 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 客户端登录账号管理 } }