Ejemplo n.º 1
0
 public static object[,] GetTimetableData(string timetableid, int userid)
 {
     if (!TimetableField.Id.TestValue(timetableid))
     {
         return new object[, ] {
                    { "" }
         }
     }
     ;
     SqlQueryCondition[] sqlconditions = new SqlQueryCondition[] {
         new SqlQueryCondition(TimetableField.Id, SqlQueryConditionOperator.Equal, timetableid),
         new SqlQueryCondition(TimetableField.Owner, SqlQueryConditionOperator.Equal, userid)     //加入此条件防止非法查看他人课表
     };
     UserLogDAO.Insert(userid, "gettbdat{" + timetableid + "}");
     return(TimetableDAO.Select(new TimetableField[] { TimetableField.Data }, new SqlQueryCondition(sqlconditions, SqlQueryLogicalOperator.And)));
 }
Ejemplo n.º 2
0
 public static string AddTimetable(string timetablename, string data, int userid)
 {
     if (!TimetableField.Name.TestValue(timetablename) || !TimetableField.Data.TestValue(data))
     {
         return("数据错误 请联系管理员!");
     }
     SqlQueryCondition[] sqlconditions = new SqlQueryCondition[] {
         new SqlQueryCondition(TimetableField.Owner, SqlQueryConditionOperator.Equal, userid),
         new SqlQueryCondition(TimetableField.Name, SqlQueryConditionOperator.Equal, timetablename)
     };
     if (TimetableDAO.Select(new TimetableField[] { TimetableField.Id }, new SqlQueryCondition(sqlconditions, SqlQueryLogicalOperator.And)).Length != 0)
     {
         return("课表名重复!");
     }
     else
     {
         UserLogDAO.Insert(userid, "addtb{" + timetablename + "}");
         return("true:" + TimetableDAO.Insert(timetablename, userid, data)); //加上id一起返回
     }
 }
Ejemplo n.º 3
0
    public static string ActiveTimetable(string timetableid, int userid)
    {
        if (!TimetableField.Id.TestValue(timetableid))
        {
            return("");
        }
        SqlQueryCondition sqlcondition1 = new SqlQueryCondition(TimetableField.Id, SqlQueryConditionOperator.Equal, timetableid);
        SqlQueryCondition sqlcondition2 = new SqlQueryCondition(TimetableField.Status, SqlQueryConditionOperator.Equal, 1);
        SqlQueryCondition sqlcondition3 = new SqlQueryCondition(TimetableField.Owner, SqlQueryConditionOperator.Equal, userid); //加入此条件防止非法更改他人课表

        if (TimetableDAO.Select(new TimetableField[] { TimetableField.Id },
                                new SqlQueryCondition(new SqlQueryCondition[] { sqlcondition1, sqlcondition3 }, SqlQueryLogicalOperator.And)).Length != 0)
        {
            TimetableDAO.Update(new TimetableField[] { TimetableField.Status }, new object[] { 0 },
                                new SqlQueryCondition(new SqlQueryCondition[] { sqlcondition2, sqlcondition3 }, SqlQueryLogicalOperator.And));
            TimetableDAO.Update(new TimetableField[] { TimetableField.Status }, new object[] { 1 },
                                new SqlQueryCondition(new SqlQueryCondition[] { sqlcondition1 }, SqlQueryLogicalOperator.And));
        }
        UserLogDAO.Insert(userid, "acttb{" + timetableid + "}");
        return("true");
    }
Ejemplo n.º 4
0
    public static string RenameTimetable(string timetableid, string newname, int userid)
    {
        if (!TimetableField.Id.TestValue(timetableid) || !TimetableField.Name.TestValue(newname))
        {
            return("数据错误 请联系管理员!");
        }
        SqlQueryCondition sqlcondition1 = new SqlQueryCondition(TimetableField.Owner, SqlQueryConditionOperator.Equal, userid); //加入此条件防止非法更改他人课表
        SqlQueryCondition sqlcondition2 = new SqlQueryCondition(TimetableField.Id, SqlQueryConditionOperator.Equal, timetableid);
        SqlQueryCondition sqlcondition3 = new SqlQueryCondition(TimetableField.Name, SqlQueryConditionOperator.Equal, newname);

        if (TimetableDAO.Select(new TimetableField[] { TimetableField.Id },
                                new SqlQueryCondition(new SqlQueryCondition[] { sqlcondition1, sqlcondition3 }, SqlQueryLogicalOperator.And)).Length != 0)
        {
            return("课表名重复!");
        }
        else
        {
            TimetableDAO.Update(new TimetableField[] { TimetableField.Name }, new object[] { newname },
                                new SqlQueryCondition(new SqlQueryCondition[] { sqlcondition1, sqlcondition2 }, SqlQueryLogicalOperator.And));
            UserLogDAO.Insert(userid, "rntb{" + timetableid + '\r' + newname + "}");
            return("true");
        }
    }
Ejemplo n.º 5
0
 public static object[,] GetTimetables(int userid)
 {
     UserLogDAO.Insert(userid, "gettbs{}");
     TimetableField[] fields = new TimetableField[] { TimetableField.Id, TimetableField.Name, TimetableField.Status };
     return(TimetableDAO.Select(fields, new SqlQueryCondition(TimetableField.Owner, SqlQueryConditionOperator.Equal, userid)));
 }