Exemplo n.º 1
0
        public List <RegisterCode> FindRegisterCode(int ManagerID)
        {
            SqlConnection MySqlConnection = new SqlConnection(ConnectionString);

            string MyCommandText = "select * from RegisterCode where ManagerID=" + ManagerID.ToString();

            SqlCommand MySqlCommand = new SqlCommand(MyCommandText, MySqlConnection);

            MySqlConnection.Open();

            SqlDataReader MySqlDataReader = MySqlCommand.ExecuteReader();

            RegisterCode        AnyRegisterCode   = null;
            List <RegisterCode> MyAllRegisterCode = new List <RegisterCode>();

            while (MySqlDataReader.Read())
            {
                AnyRegisterCode = new RegisterCode();

                AnyRegisterCode.ManagerID       = (int)MySqlDataReader["ManagerID"];
                AnyRegisterCode.RegisterCodeStr = (string)MySqlDataReader["RegisterCode"];
                AnyRegisterCode.LockID          = (string)MySqlDataReader["LockID"];
                AnyRegisterCode.Date            = (DateTime)MySqlDataReader["Date"];

                MyAllRegisterCode.Add(AnyRegisterCode);
            }

            MySqlDataReader.Close();

            MySqlConnection.Close();

            return(MyAllRegisterCode);
        }
Exemplo n.º 2
0
 public void UpdateRegisterCode(RegisterCode MyRegisterCode)
 {
     /*
      * SqlCommand MySqlCommand = new SqlCommand(commandText, MySqlConnection);
      *
      * MySqlConnection.Open();
      *
      * SqlCommand updatecmd = new SqlCommand("UPDATE Products set ProductName=@ProductName,CategoryID=@CategoryID,Price=@Price,InStore=@InStore,Description=@Description where ProductID=@ProductID", conn);
      *
      * updatecmd.Parameters.Add(new SqlParameter("@ProductName", pro.ProductName));
      *
      * updatecmd.Parameters.Add(new SqlParameter("CategoryID", pro.CategoryID));
      *
      * updatecmd.Parameters.Add(new SqlParameter("@Price", pro.Price));
      *
      * updatecmd.Parameters.Add(new SqlParameter("@InStore", pro.InStore));
      *
      * updatecmd.Parameters.Add(new SqlParameter("@Description", pro.Description));
      *
      * updatecmd.Parameters.Add(new SqlParameter("@ProductID", pro.ProductID));
      *
      * conn.Open();
      *
      * updatecmd.ExecuteNonQuery();
      *
      * conn.Close();
      */
 }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 public void DeleteRegisterCode(RegisterCode MyRegisterCode)
 {
     /*
      * //string ConnectionString = "Server=VMXPSP3_LGJ;database=CloudLock;uid=sa;pwd=123456";
      * SqlConnection MySqlConnection = new SqlConnection(ConnectionString);
      *
      * string MySQLViewName = "key" + MyLockKey.LockID;
      * string MyCommandText = "delete from  " + MySQLViewName + "  where Number=@Number";
      *
      * SqlCommand MySqlCommand = new SqlCommand(MyCommandText, MySqlConnection);
      *
      * MySqlCommand.Parameters.Add(new SqlParameter("@Number", MyLockKey.LockKeyID));
      *
      * MySqlConnection.Open();
      *
      * MySqlCommand.ExecuteNonQuery();
      *
      * MySqlConnection.Close();
      * */
 }
Exemplo n.º 5
0
        public RegisterCode FindRegisterCode(string LockID)
        {
            //--------------------------------------------------------------
            string NowDateStr = DateTime.Now.ToString();

            NowDateStr = NowDateStr.Substring(0, NowDateStr.IndexOf(" "));
            string AddSubNowDateStr = NowDateStr.Replace("-", "");
            string DateIDFlag       = "";

            AddSubNowDateStr = "(Select DATEADD(DAY,-3,'" + AddSubNowDateStr + "')) ";
            DateIDFlag       = " and Date>=" + AddSubNowDateStr;

            //ConnectionString = InConnectionString;
            SqlConnection MySqlConnection = new SqlConnection(ConnectionString);

            MySqlConnection.Open();
            //SqlConnection MySqlConnection = HelpTool.MySqlConnection;

            string MyCommandText = "select * from RegisterCode where LockID='" + LockID + "'" + DateIDFlag + " ORDER BY Date DESC";

            SqlCommand MySqlCommand = new SqlCommand(MyCommandText, MySqlConnection);


            SqlDataReader MySqlDataReader = MySqlCommand.ExecuteReader();

            RegisterCode AnyRegisterCode = null;

            while (MySqlDataReader.Read())
            {
                AnyRegisterCode                 = new RegisterCode();
                AnyRegisterCode.ManagerID       = (int)MySqlDataReader["ManagerID"];
                AnyRegisterCode.RegisterCodeStr = (string)MySqlDataReader["RegisterCode"];
                AnyRegisterCode.LockID          = (string)MySqlDataReader["LockID"];
                AnyRegisterCode.Date            = (DateTime)MySqlDataReader["Date"];
                break;
            }

            MySqlDataReader.Close();
            MySqlConnection.Close();
            return(AnyRegisterCode);
        }