Beispiel #1
0
        public int InsertRegisterCodeEx(RegisterCode MyRegisterCode)
        {
            //string ConnectionString = "Server=VMXPSP3_LGJ;database=CloudLock;uid=sa;pwd=123456";

            SqlConnection MySqlConnection = new SqlConnection(this.ConnectionString);

            //--1.-----------------------------------------------------------------------------------------------

            /*
             * int MyFlowID;
             * using (SqlCommand GetMaxcmd = new SqlCommand())
             * {
             * GetMaxcmd.CommandText = "select Max(FlowID) from LockFlow";//89765432BCDA820";
             * GetMaxcmd.Connection = MySqlConnection;
             * using (SqlDataReader MySqlDataReader = GetMaxcmd.ExecuteReader())
             * {
             * MySqlDataReader.Read();
             * MyFlowID = (int)MySqlDataReader.GetValue(0);
             *
             *
             * }
             * }
             * MyFlowID++;
             * MyLockFlow.FlowID = MyFlowID;
             */
            //--2.-----------------------------------------------------------------------------------------------
            RandomRegisterCode MyRandomRegisterCode = new RandomRegisterCode();

            MyRegisterCode.RegisterCodeStr = MyRandomRegisterCode.CreateRegsisterCode();

            string MyCommandText = "insert into RegisterCode (ManagerID, LockID,RegisterCode) values (@ManagerID, @LockID,@RegisterCode)";

            SqlCommand MySqlCommand = new SqlCommand(MyCommandText, MySqlConnection);

            MySqlCommand.Parameters.Add(new SqlParameter("@ManagerID", MyRegisterCode.ManagerID));
            MySqlCommand.Parameters.Add(new SqlParameter("@RegisterCode", MyRegisterCode.RegisterCodeStr));
            MySqlCommand.Parameters.Add(new SqlParameter("@LockID", MyRegisterCode.LockID));
            //MySqlCommand.Parameters.Add(new SqlParameter("@Date", MyRegisterCode.Date));

            MySqlConnection.Open();
            int RowCount = MySqlCommand.ExecuteNonQuery();

            //------------------------------------------------------------------------------------------------------
            MySqlConnection.Close();
            return(RowCount);
        }
Beispiel #2
0
        public string UpdateLockForSale(string LockID, int ManagerID)
        {
            RandomRegisterCode MyRandomRegisterCode = new RandomRegisterCode();
            string             NewRegisterCode      = MyRandomRegisterCode.CreateRegsisterCode();


            SqlConnection MySqlConnection = new SqlConnection(ConnectionString);

            MySqlConnection.Open();

            //SqlConnection MySqlConnection = HelpTool.MySqlConnection;

            string MyUpdateCMDText = "UpdateLockForSale";

            SqlCommand MySqlCommand = new SqlCommand(MyUpdateCMDText, MySqlConnection);

            MySqlCommand.CommandType = CommandType.StoredProcedure;

            MySqlCommand.Parameters.Add(new SqlParameter("@LockID", LockID));
            MySqlCommand.Parameters.Add(new SqlParameter("@ManagerID", ManagerID));
            MySqlCommand.Parameters.Add(new SqlParameter("@RegisterCode", NewRegisterCode));

            MySqlCommand.Parameters.Add(new SqlParameter("@ReturnValue", SqlDbType.Int));
            MySqlCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;


            int RowCount    = MySqlCommand.ExecuteNonQuery();
            int ReturnValue = (int)MySqlCommand.Parameters["@ReturnValue"].Value;

            MySqlConnection.Close();
            if (ReturnValue == 0)
            {
                return(NewRegisterCode);
            }
            else
            {
                return(null);
            }
        }