예제 #1
0
파일: SignBUS.cs 프로젝트: Celint/Schedule
    public static string SignOut(string sno, string sequence, string remark)
    {
        if (!ScheduleField.Sequence.TestValue(sequence) || !ScheduleField.SignOutRemark.TestValue(remark))
        {
            return("数据格式或长度错误 请联系管理员!");
        }
        DateTime nowtime = DateTime.Now;

        SqlQueryCondition[] sqlconditions1 = new SqlQueryCondition[] {
            new SqlQueryCondition(UserField.StudentNmber, SqlQueryConditionOperator.Equal, sno),
            new SqlQueryCondition(UserField.Status, SqlQueryConditionOperator.Equal, 1)
        };
        object[,] user = UserDAO.Select(new UserField[] { UserField.Id, UserField.Name }, new SqlQueryCondition(sqlconditions1, SqlQueryLogicalOperator.And));
        if (user.Length == 0)
        {
            return("未找到该用户的信息,请检查学号是否填写正确!");
        }
        SqlQueryCondition[] sqlconditions2 = new SqlQueryCondition[] {
            new SqlQueryCondition(ScheduleField.Date, SqlQueryConditionOperator.Equal, nowtime),
            new SqlQueryCondition(ScheduleField.Sequence, SqlQueryConditionOperator.Equal, sequence),
            new SqlQueryCondition(ScheduleField.Attendant, SqlQueryConditionOperator.Equal, user[0, 0])
        };
        object[,] schedule = ScheduleDAO.Select(new ScheduleField[] { ScheduleField.Id, ScheduleField.SignInTime, ScheduleField.SignOutTime },
                                                new SqlQueryCondition(sqlconditions2, SqlQueryLogicalOperator.And));
        if (schedule.Length == 0)
        {
            return("未找到你的值班信息,请检查班次是否错误!");
        }
        if (schedule[0, 1] == DBNull.Value)
        {
            return("你还未进行入站签到,请先入站签到!");
        }
        if (schedule[0, 2] != DBNull.Value)
        {
            return("你已对此班签出!");
        }
        if (nowtime.TimeOfDay < dutytimes[sequence].EndTime - aheadtime)
        {
            return("此时签出太早了,请晚点再来!");
        }
        if (nowtime.TimeOfDay > dutytimes[sequence].EndTime + gracetime)
        {
            return("你来晚了,签出时间已过!");
        }
        ScheduleDAO.Update(new ScheduleField[] { ScheduleField.SignOutTime, ScheduleField.SignOutRemark }, new object[] { nowtime.TimeOfDay, remark },
                           new SqlQueryCondition(ScheduleField.Id, SqlQueryConditionOperator.Equal, schedule[0, 0]));
        UserLogDAO.Insert((int)user[0, 0], "signout{" + sequence + '\r' + remark + "}");
        return("true\n" + user[0, 1].ToString() + " 第" + sequence + "班 " + nowtime.ToLongTimeString() + "签出");
    }