using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DataLinkMesWork;

//using SystemFramework;

namespace bizFacade
{
    public partial class BaseDataSystemMES
    {
        /// <summary>
        /// MES_操作者_登录_增加
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="userName"></param>
        public static void UserNameLoginInsert(string opName,string userName)
        {
            string procedureName;
            procedureName = "MES_操作者_登录_增加";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@操作者工号", userName);
            DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }
        /// <summary>
        /// MES_操作者_用户_增加  2013-01-23 王可心
        /// </summary>
        /// <param name="userName"></param>
       /// <param name="user"></param>
        static public bool UserNameTableInsert(string userName, string user)
        {
            string procedureName;
            procedureName = "MES_操作者_用户_增加";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@操作者工号", userName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@操作者姓名", user);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);

        }
        /// <summary>
        /// MES_操作者_用户_修改
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="passwordNew"></param>
        public static void UserNameTableUpdate(string userName,string password,string passwordNew)
        {
            string sql;
            sql =  "exec MES_操作者_用户_修改 '" + userName + "','" + password + "','"+passwordNew+"'";
            DataAccess.ExecuteSQL(sql);
        }
        /// <summary>
        /// MES_操作者_用户_设置初始秘密
        /// </summary>
        /// <param name="userName"></param>
        static public bool UserNameTableUpdateInitPassword(string userName)
        {
            string procedureName;
            procedureName = "MES_操作者_用户_设置初始秘密";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@操作者工号", userName);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);

        }
        /// <summary>
        /// MES_操作者_用户_查询
        /// 执行后，返回count(*)
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        public static int UserNameTableSelect(string userName, string password)
        {
            int count;
            string sql;
            sql =  "exec MES_操作者_用户_查询 '"+ userName + "','" + password + "'";
            DataAccess.ExecuteOutNum(sql, out  count);
            return count;
        }
        /// <summary>
        /// MES_操作者_用户_增加用_查询
        /// 执行后，返回count(*)
        /// </summary>
        /// <param name="userName"></param>
       
        public static int UserNameTableSelectForInsert(string userName)
        {
            int count;
            string sql;
            sql = "exec MES_操作者_用户_增加用_查询 '" + userName + "'";
            DataAccess.ExecuteOutNum(sql, out  count);
            return count;
        }


        /// <summary>
        /// MES_操作者_用户_删除  2013-01-23 王可心 删除该用户
        /// </summary>
        /// <param name="userName">用户工号</param>
        static public bool UserNameTableSelectForDelete(string userName)
        {
            string procedureName;
            procedureName = "MES_操作者_用户_删除";
            SqlParameter[] thisParms = new SqlParameter[1];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@操作者工号", userName);
           return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
        }

        /// <summary>
        /// MES_操作者_用户_姓名_修改  2013-01-23 王可心
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="user"></param>
        static public bool UserNameTableAlter(string userName, string user)
        {
            string procedureName;
            procedureName = "MES_操作者_用户_姓名_修改";
            SqlParameter[] thisParms = new SqlParameter[2];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@操作者工号", userName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@操作者姓名", user);
            return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);

        }
    }
}
