示例#1
0
        public static BE.CommonPage[] SelectAll()
        {
            ArrayList commonPages = new ArrayList();

            BE.CommonPage commonPage;
            string        SQLQuery = "SELECT * FROM [CommonPage]  ";
            SqlCommand    command  = new SqlCommand();

            command.CommandText = SQLQuery;
            SqlDataReader reader = SQLHelper.ExecuteReader(command);

            while (reader.Read())
            {
                commonPage = new BE.CommonPage();

                commonPage.Id          = Convert.ToInt32(reader["Id"]);
                commonPage.Title       = Convert.ToString(reader["Title"]);
                commonPage.MenuCaption = Convert.ToString(reader["MenuCaption"]);
                commonPages.Add(commonPage);
            }


            reader.Close();
            reader.Dispose();
            return((BE.CommonPage[])commonPages.ToArray(typeof(BE.CommonPage)));
        }
示例#2
0
        public static bool Update(BE.CommonPage commonPage)
        {
            string SQLQuery = "UPDATE [CommonPage] SET Id = @Id, Title= @Title, MenuCaption= @MenuCaption WHERE [Id]=@Id ";

            SqlCommand command = new SqlCommand();

            command.CommandText = SQLQuery;

            AddParameters(command, commonPage);

            return(Convert.ToBoolean(SQLHelper.ExecuteNonQuery(command)));
        }
示例#3
0
        public static bool Insert(BE.CommonPage commonPage)
        {
            string SQLQuery = "INSERT INTO [CommonPage] ( id,title,menuCaption ) VALUES	(@id, @title, @menuCaption)";

            SqlCommand command = new SqlCommand();

            command.CommandText = SQLQuery;

            AddParameters(command, commonPage);

            return(Convert.ToBoolean(SQLHelper.ExecuteNonQuery(command)));
        }
示例#4
0
        public static bool Save(BE.CommonPage commonPage)
        {
            bool IsAffected = false;

            if (commonPage.State == BE.RowState.Added)
            {
                IsAffected = Insert(commonPage);
            }
            else if (commonPage.State == BE.RowState.Modified)
            {
                IsAffected = Update(commonPage);
            }
            else if (commonPage.State == BE.RowState.Deleted)
            {
                IsAffected = Delete(commonPage.Id);
            }
            return(IsAffected);
        }
示例#5
0
        public static BE.CommonPage Select(Int32 Id)
        {
            BE.CommonPage commonPage = new BE.CommonPage();
            string        SQLQuery   = "SELECT * FROM [CommonPage] WHERE [Id]=@Id ";

            SqlCommand command = new SqlCommand();

            command.CommandText = SQLQuery;
            command.Parameters.AddWithValue("@Id", Id);

            SqlDataReader reader = SQLHelper.ExecuteReader(command);

            reader.Read();

            commonPage.Id          = Convert.ToInt32(reader["Id"]);
            commonPage.Title       = Convert.ToString(reader["Title"]);
            commonPage.MenuCaption = Convert.ToString(reader["MenuCaption"]);

            reader.Close();
            reader.Dispose();
            return(commonPage);
        }
示例#6
0
 private static void AddParameters(SqlCommand command, BE.CommonPage commonPage)
 {
     command.Parameters.AddWithValue("@Id", commonPage.Id);
     command.Parameters.AddWithValue("@Title", commonPage.Title);
     command.Parameters.AddWithValue("@MenuCaption", commonPage.MenuCaption);
 }