Exemple #1
0
    public void OrderMove(bool up)
    {
        string sqlSelect = string.Format(
            " SELECT TOP 1 [Id], [Order] " +
            " FROM TBL_WoodlandLife_Courses " +
            " WHERE [Order] {0} {1} " +
            " AND [Type] = {2} " +
            " ORDER BY [Order] {3} ",

            up ? "<" : ">",
            SqlInject.Int(Order),
            SqlInject.Int((int)CourseType),
            up ? "DESC" : "ASC"
            );

        DataTable table = DB.Query(sqlSelect);

        if (table.Rows.Count == 1)
        {
            DataRow swapRow = table.Rows[0];

            string sqlSwap = string.Format(
                " UPDATE TBL_WoodlandLife_Courses SET [Order]={0} WHERE ID={1}; " +
                " UPDATE TBL_WoodlandLife_Courses SET [Order]={2} WHERE ID={3}; ",
                SqlInject.Int(this.Order),
                SqlInject.String(swapRow["Id"].ToString()),
                SqlInject.Int(int.Parse(swapRow["Order"].ToString())),
                SqlInject.Guid(this.Id)
                );

            DB.NonQuery(sqlSwap);
        }
    }
Exemple #2
0
    protected void SaveNew()
    {
        string sqlGetMaxOrder = " SELECT MAX([Order]) AS MaxOrder FROM TBL_WoodlandLife_Courses ";

        try
        {
            Order = 10 + int.Parse(DB.Query(sqlGetMaxOrder).Rows[0]["MaxOrder"].ToString());
        }
        catch { }

        string sql = string.Format(
            " INSERT INTO TBL_WoodlandLife_Courses " +
            " ( [ID], [Published], [Title], [TitleEncoded], [ContentHtml], [Length], [Type], [Location], [Order] ) " +
            " VALUES " +
            " ( {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8} ) ",
            SqlInject.Guid(Id),
            SqlInject.Bool(Published),
            SqlInject.String(Title),
            SqlInject.String(TitleEncoded),
            SqlInject.String(ContentHtml),
            SqlInject.String(Length),
            SqlInject.Int((int)CourseType),
            SqlInject.Int((int)Location),
            SqlInject.Int(Order)
            );

        JuggleDrumManager.DB.NonQuery(sql);
    }
Exemple #3
0
    public void Save()
    {
        string sql = "SELECT Id FROM TBL_WoodlandLife_Courses WHERE [ID]=" + SqlInject.Guid(Id);

        if (DB.Query(sql).Rows.Count > 0)
        {
            SaveExisting();
        }
        else
        {
            SaveNew();
        }
    }
Exemple #4
0
    protected void SaveExisting()
    {
        string sql = string.Format(
            " UPDATE TBL_WoodlandLife_Courses " +
            " SET [Published]={1}, [Title]={2}, [TitleEncoded]={3}, [ContentHtml]={4}, [Length]={5}, [Type]={6}, [Location]={7}, [Order]={8} " +
            " WHERE [ID]={0} ",
            SqlInject.Guid(Id),
            SqlInject.Bool(Published),
            SqlInject.String(Title),
            SqlInject.String(TitleEncoded),
            SqlInject.String(ContentHtml),
            SqlInject.String(Length),
            SqlInject.Int((int)CourseType),
            SqlInject.Int((int)Location),
            SqlInject.Int(Order)
            );

        JuggleDrumManager.DB.NonQuery(sql);
    }