Ejemplo n.º 1
0
        private IActionResult CheckFlag(DBQueryStatus flag, bool isSingleRequest, string info)
        {
            switch (flag)
            {
            case DBQueryStatus.INTERNAL_ERROR: return(DatabaseError(ServerAction.General_ViewStudent, string.Join("", info, ":", flag)));

            case DBQueryStatus.MORE_RESULTS:
                if (isSingleRequest)
                {
                    DatabaseError(ServerAction.General_ViewStudent, string.Join("", info, ":", flag));
                }
                return(null);

            default: return(null);
            }
        }
Ejemplo n.º 2
0
        public static DBQueryStatus CreateData <T>(T data, out T dataOut) where T : DataTableObject <T>, new()
        {
            DataBaseIO output = new DataBaseIO();

            data.ObjectId = Cryptography.RandomString(10, false);
            data.WriteObject(output, false);
            DBQueryStatus rst = _DBRequestInternal(data.Table, DBVerbs.Create, null, output, out DataBaseIO[] inputs);

            if (rst == DBQueryStatus.INTERNAL_ERROR)
            {
                dataOut = null;
                return(rst);
            }
            T t = new T();

            t.ReadFields(inputs[0]);
            dataOut = t;
            return(rst);
        }
Ejemplo n.º 3
0
        private void CheckMyStudents_Shown(object sender, EventArgs e)
        {
            if (CurrentUser.UserGroup.IsBusManager)
            {
                SchoolBusObject busObject = new SchoolBusObject();
                DBQueryStatus   resultX   = DataBaseOperation.QueryMultipleData <SchoolBusObject>(new DBQuery().WhereEqualTo("TeacherObjectID", CurrentUser.ObjectId), out List <SchoolBusObject> result);

                switch (resultX)
                {
                case DBQueryStatus.NO_RESULTS:
                    MessageBox.Show("没有找到你管理的校车");
                    return;

                case DBQueryStatus.ONE_RESULT:
                    break;

                case DBQueryStatus.MORE_RESULTS:
                    MessageBox.Show("找到了多个和你绑定的校车(这不可能……),目前只会显示其中第一项");
                    break;

                default: { MessageBox.Show("出现内部错误:" + resultX.ToString()); return; }
                }
                busObject           = result[0];
                myID.Text           = busObject.ObjectId;
                myDirection.Text    = busObject.BusName;
                LeavingChecked.Text = busObject.LSChecked.ToString();
                ExpNumber.Text      = "尚未加载";
                BackNumber.Text     = "尚未加载";
                ExDescription.Text  = "加载完成";
                Application.DoEvents();
                StudentDataGrid.AutoResizeColumns();
            }
            else if (CurrentUser.UserGroup.IsAdmin)
            {
                MessageBox.Show("管理员用户请到管理页面进行查询和修改记录", "管理员通知", MessageBoxButtons.OK);
            }
            else
            {
                MessageBox.Show("你不是校车老师,只有校车老师和管理员能编辑数据", "只读模式", MessageBoxButtons.OK);
                Close();
            }
        }
Ejemplo n.º 4
0
        private void LoadAll_Click(object sender, EventArgs e)
        {
            studentDataObjectBindingSource.Clear();
            DBQuery query = new DBQuery();

            query.WhereEqualTo("BusID", myID.Text);
            DBQueryStatus resultX = DataBaseOperation.QueryMultipleData <StudentObject>(query, out List <StudentObject> result);

            if (resultX >= 0)
            {
                foreach (StudentObject item in result)
                {
                    studentDataObjectBindingSource.Add(item);
                }
                ExpNumber.Text      = result.Count.ToString();
                LeaveNumber.Text    = CountTicks(4).ToString();
                LeavingChecked.Text = CountTicks(5).ToString();
                BackNumber.Text     = CountTicks(6).ToString();
            }
            StudentDataGrid.AutoResizeColumns();
        }
Ejemplo n.º 5
0
        public static DBQueryStatus QueryMultiple <T>(DBQuery query, out List <T> Result, int queryLimit = 1000, int skip = 0) where T : DataTableObject <T>, new()
        {
            query.Limit(query._Limit == -1 ? queryLimit : query._Limit);
            query.Skip(query._Skip == -1 ? skip : query._Skip);
            DBQueryStatus databaseOperationResult = _DBRequestInternal(new T().Table, DBVerbs.QueryMulti, query, null, out DataBaseIO[] inputs);

            if (databaseOperationResult >= 0)
            {
                Result = new List <T>();
                foreach (DataBaseIO item in inputs)
                {
                    T t = new T();
                    t.ReadFields(item);
                    Result.Add(t);
                }
            }
            else
            {
                Result = null;
            }
            return(databaseOperationResult);
        }
Ejemplo n.º 6
0
 public DBBackupStatusNotifyer(DBQueryStatus dbQueryStatus, int interval)
     : base(interval)
 {
     _dbQueryStatus = dbQueryStatus;
 }
        private void LoadExistStudents_Click(object sender, EventArgs e)
        {
            StudentData.Enabled = false;
            studentDataBindSourc.Clear();
            DBQuery ClassQuery = new DBQuery();

            ClassQuery.WhereEqualTo("objectId", CurrentUser.ClassList[0]);
            DBQueryStatus resultCode = DataBaseOperation.QueryMultipleData <ClassObject>(ClassQuery, out List <ClassObject> result);

            if (resultCode <= 0)
            {
                MessageBox.Show("没找到你想要的班级,这,,不应该吧。", "很失望?");
                return;
            }
            CurrentClass  = result[0];
            ClsID.Text    = CurrentClass.ObjectId;
            ClsDpt.Text   = CurrentClass.CDepartment;
            ClsGrade.Text = CurrentClass.CGrade;
            ClsNum.Text   = CurrentClass.CNumber;
            ClsTID.Text   = CurrentClass.TeacherID;
            if (string.IsNullOrEmpty(CurrentClass.TeacherID))
            {
                MessageBox.Show("嗯,找到了匹配的班级,但好像没有老师绑定这个班。" +
                                "\r\n" +
                                "~快去叫他使用小板凳吧。" +
                                "\r\n\r\n" +
                                "如果你是这个班的老师的话,先去\"设置\"页绑定一下你的班级!", "孤儿班级");
                ClsTName.Text     = "";
                ClsTPhoneNum.Text = "";
            }
            else
            {
                DBQuery TeacherDataQuery = new DBQuery();
                TeacherDataQuery.WhereEqualTo("objectId", CurrentClass.TeacherID);
                if (DataBaseOperation.QueryMultipleData(TeacherDataQuery, out List <UserObject> teacherresult) <= 0)
                {
                    MessageBox.Show("这不应该,这个班级有老师管理,但是查不到老师的任何信息。", "班主任溜了?");
                    ClsTName.Text     = "";
                    ClsTPhoneNum.Text = "";
                }
                else
                {
                    ClsTName.Text     = teacherresult[0].RealName;
                    ClsTPhoneNum.Text = teacherresult[0].PhoneNumber;
                }
            }
            Application.DoEvents();

            //if (MessageBox.Show("找到了班级,是否继续列出班里坐校车的学生?", "要继续吗", MessageBoxButtons.YesNo) == DialogResult.No)
            //    return;
            DBQuery StudentsQuery = new DBQuery();

            StudentsQuery.WhereEqualTo("ClassID", CurrentClass.ObjectId);
            if (DataBaseOperation.QueryMultipleData(StudentsQuery, out List <StudentObject> results) <= 0)
            {
                MessageBox.Show("把数据库翻了个底朝天,还是没有这个班的学生", "学生去哪了?");
            }
            else
            {
                for (int i = 0; i < results.Count; i++)
                {
                    studentDataBindSourc.Add(results[i]);
                    if (!BusDataPair.ContainsValue(results[i].BusID))
                    {
                        MessageBox.Show("这就奇怪了,为啥校车列表里面没有这个学生的记录??" +
                                        $"\r\n 学生姓名:{results[i].StudentName }" +
                                        $" 奇怪的ID:{ results[i].BusID }");
                        StudentData.Rows[i].Cells[2].Value = "";
                    }
                    else
                    {
                        StudentData.Rows[i].Cells[2].Value = BusDataPair.ElementAt(BusDataPair.Values.ToList().IndexOf(results[i].BusID)).Key;
                    }
                }
            }
            DoLog($"成功加载了 {results.Count} 条数据");
            StudentData.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
            StudentData.Enabled = true;
        }
 public DBRestoreStatusNotifyer(DBQueryStatus dbQueryStatus, int interval)
     : base(interval)
 {
     _dbQueryStatus = dbQueryStatus;
 }
Ejemplo n.º 9
0
        public static DBQueryStatus DeleteData(string Table, string ObjectID)
        {
            DBQueryStatus result = _DBRequestInternal(Table, DBVerbs.Delete, new DBQuery().WhereEqualTo("objectId", ObjectID), null, out DataBaseIO[] inputs);

            return(result);
        }