Ejemplo n.º 1
0
        /// <summary>
        /// 判断教师用户是否存在。
        /// </summary>
        /// <param name="number">用户名</param>
        /// <param name="password">密码</param>
        /// <returns></returns>
        public static bool teacherExits(string number, string password)
        {
            password = DAL_Safety.getMD5(password);
            object obj = null;

            try
            {
                string           sql  = "select username from teacher where username=?1 and password=?2;";
                MySqlParameter[] para = new MySqlParameter[2];
                para[0] = new MySqlParameter("?1", number);
                para[1] = new MySqlParameter("?2", password);
                obj     = DAL_MysqlHelper.ExecuteScalar(sql, para);
            }
            catch (Exception e)
            {
                LogWriter.writeLine(@"C:\WEB_ASP\logs\DAL.log", "studentExits:" + e.Message);
                return(false);
            }
            if (Equals(obj, null))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 查询商品总数
 /// </summary>
 /// <returns></returns>
 public static int QueryGoodsCount()
 {
     try
     {
         string sql = "select count(*) from tb_goods;";
         int    ret = Int32.Parse(DAL_MysqlHelper.ExecuteScalar(sql).ToString());
         return(ret);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 判断用户是否存在(注册用)
 /// </summary>
 /// <param name="name">Name</param>
 /// <returns>bool</returns>
 public static bool QueryCustomerExists(string name)
 {
     try
     {
         string         sql  = "select customerName from tb_customer where customerName=?name;";
         MySqlParameter para = new MySqlParameter("?name", name);
         Object         obj  = DAL_MysqlHelper.ExecuteScalar(sql, para);
         if (Equals(obj, null))
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 判断用户输入的密保问题是否正确
 /// </summary>
 /// <param name="name">Name</param>
 /// <param name="answer">Answer(输入的答案)</param>
 /// <returns>bool</returns>
 public static bool QueryCustomerQuestionAnswerMathch(string name, string answer)
 {
     try
     {
         string           sql  = "select customerName from tb_customer where customerName=?name and customerAnswer=?answer;";
         MySqlParameter[] para = new MySqlParameter[2];
         para[0] = new MySqlParameter("?name", name);
         para[1] = new MySqlParameter("?answer", DAL_Safety.EncodeBase64(answer));
         Object obj = DAL_MysqlHelper.ExecuteScalar(sql, para);
         if (Equals(obj, null))
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 查询用户是否存在(登录用)
 /// </summary>
 /// <param name="name">Name</param>
 /// <param name="pass">Pass</param>
 /// <returns>bool</returns>
 public static bool QueryCustomerExists(string name, string pass)
 {
     try
     {
         string           sql  = "select customerName from tb_customer where customerName=?name and customerPass=?pass;";
         MySqlParameter[] para = new MySqlParameter[2];
         para[0] = new MySqlParameter("?name", name);
         para[1] = new MySqlParameter("?pass", DAL_Safety.GetMD5(pass));
         Object obj = DAL_MysqlHelper.ExecuteScalar(sql, para);
         if (Equals(obj, null))
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }