예제 #1
0
        //--------------------------------------------------------------
        public PrimeAccount FindAccount(string InLoginName)
        {
            //再完善...
            SqlConnection MySqlConnection = new SqlConnection(ConnectionString);

            string MyCommandText = "select * from PrimeAccount where LoginName='" + InLoginName + "'";

            SqlCommand MySqlCommand = new SqlCommand(MyCommandText, MySqlConnection);

            MySqlConnection.Open();

            SqlDataReader MySqlDataReader = MySqlCommand.ExecuteReader();

            PrimeAccount AnyPrimeAccount = null;

            while (MySqlDataReader.Read())
            {
                AnyPrimeAccount = new PrimeAccount();

                //AnyCustomer.CustomerID = (int)MySqlDataReader["CustomerID"];
                //AnyCustomer.CustomerName = (string)MySqlDataReader["CustomerName"];
                //AnyCustomer.LoginName = (string)MySqlDataReader["LoginName"];
                //AnyCustomer.Password = (string)MySqlDataReader["Password "];
                //AnyCustomer.MobileID = (string)MySqlDataReader["MobileID"];
                //AnyCustomer.CreateTime = (DateTime)MySqlDataReader["CreateTime"];
            }

            MySqlDataReader.Close();

            MySqlConnection.Close();

            return(AnyPrimeAccount);
        }
예제 #2
0
        public int UpdateAccount(PrimeAccount MyAccount)
        {
            //再完善...
            int           MyReturnCode    = 1;
            SqlConnection MySqlConnection = new SqlConnection(ConnectionString);
            string        MyCommandText   = "UPDATE PrimeAccount set PassWord = @PassWord where AccountID = @AccountID";
            //SqlCommand updatecmd = new SqlCommand("UPDATE Products set ProductName=@ProductName,CategoryID=@CategoryID,Price=@Price,InStore=@InStore,Description=@Description where ProductID=@ProductID", conn);


            SqlCommand MySqlCommand = new SqlCommand(MyCommandText, MySqlConnection);

            MySqlCommand.Parameters.Add(new SqlParameter("@AccountID", MyAccount.AccountID));
            MySqlCommand.Parameters.Add(new SqlParameter("@PassWord", MyAccount.PassWord));



            MySqlConnection.Open();
            if (MySqlCommand.ExecuteNonQuery() > 0)
            {
                MyReturnCode = 0;                                    //成功返回:0,否则返回:1
            }
            MySqlConnection.Close();

            return(MyReturnCode);
        }
예제 #3
0
        //-----------------------------------------------------------
        public int InsertAccount(PrimeAccount MyAccount, ref string NewAccountID)
        {
            //注册账号函数
            int MyReturnCode = 1;

            if (string.IsNullOrEmpty(MyAccount.LoginName))
            {
                return(MyReturnCode = 1);                                          //登录名为空
            }
            if (string.IsNullOrEmpty(MyAccount.PassWord))
            {
                return(MyReturnCode = 2);                                         //密码为空
            }
            if (CheckPrimeAccount(MyAccount.LoginName) != null)
            {
                return(MyReturnCode = 3);                                              //重复注册
            }
            NewAccountID        = GetMobileID();
            MyAccount.AccountID = NewAccountID;

            SqlConnection MySqlConnection = new SqlConnection(ConnectionString);

            string MyCommandText = "insert into PrimeAccount (AccountID,LoginName, PassWord) values (@AccountID,@LoginName, @PassWord)";

            SqlCommand MySqlCommand = new SqlCommand(MyCommandText, MySqlConnection);

            MySqlCommand.Parameters.Add(new SqlParameter("@AccountID", MyAccount.AccountID));
            MySqlCommand.Parameters.Add(new SqlParameter("@LoginName", MyAccount.LoginName));
            MySqlCommand.Parameters.Add(new SqlParameter("@PassWord", MyAccount.PassWord));


            MySqlConnection.Open();
            if (MySqlCommand.ExecuteNonQuery() > 0)
            {
                MyReturnCode = 0;                                    //插成功返回:0,否则返回:1
            }
            MySqlConnection.Close();

            return(MyReturnCode);
        }
예제 #4
0
        private PrimeAccount CheckPrimeAccount(string InLoginName)
        {
            SqlConnection MySqlConnection = new SqlConnection(ConnectionString);
            string        MyCommandText   = "select * from PrimeAccount where LoginName='" + InLoginName + "'";
            SqlCommand    MySqlCommand    = new SqlCommand(MyCommandText, MySqlConnection);

            MySqlConnection.Open();
            SqlDataReader MySqlDataReader = MySqlCommand.ExecuteReader();

            PrimeAccount AnyPrimeAccount = null;

            while (MySqlDataReader.Read())
            {
                AnyPrimeAccount = new PrimeAccount();
                //AnyPrimeAccount.AccountID = (string)MySqlDataReader["AccountID"];
                //AnyPrimeAccount.LoginName = (string)MySqlDataReader["LoginName"];
                break;
            }
            MySqlDataReader.Close();

            MySqlConnection.Close();
            return(AnyPrimeAccount);
        }