private void Inquire_Click(object sender, RoutedEventArgs e)
        {
            //TODO : 계정 권한에 따라 접근을 거부하는 코드 필요.
            string accType = ParentWindow.Client.AccountType;

            if (!AuthorityChecker.CheckAuthority(accType, null, null, AccessType.Inquire, ObjectToAccess.Accounts))
            {
                MessageBox.Show("데이터에 접근할 권한이 없습니다.\n\n대기중인 계정 목록을 조회하려면 전 학년 총괄 관리자여야 합니다.",
                                "권한 없음", MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }

            ParentWindow.ChildManager.TryToShow <LoadingWindow>("서버와 통신 중...", (WaitCallback)((o) =>
            {
                ParentWindow.Dispatcher.BeginInvoke((Action)(() =>
                {
                    TcpDataSetRequirement dataReq = new TcpDataSetRequirement(new string[] { "[교사 ID]", "[성명]", "[계정 구분]" }, "[교사 목록]",
                                                                              $"[가입 허가 여부]=True", "[성명]");
                    ParentWindow.Client.RequestDataSet(dataReq);

                    RecentTeachersReq = dataReq;
                })).Wait();
            }));

            this.IsEnabled = false;
        }
Exemple #2
0
        private void UpdateServerData()
        {
            if (mEdited.Count == 0)
            {
                MessageBox.Show("변경사항이 없으므로 저장할 데이터가 없습니다.", "저장하지 않음", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            string accType = ParentWindow.Client.AccountType;

            if (!AuthorityChecker.CheckAuthority(accType, mCurrentGrade, mCurrentClass, AccessType.Edit, ObjectToAccess.Attendance))
            {
                MessageBox.Show("데이터를 수정할 권한이 없습니다.\n\n특정 학급의 출석부를 수정하려면 그 학급의 담임이여야 합니다.",
                                "권한 없음", MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }

            foreach (int index in mEdited)
            {
                TcpDataUpdate update = new TcpDataUpdate();
                update.TableName = "출석부";
                update.Setter.Add($"[{mCurrentPeriod}교시]", ((int)StrToAttDict[mTable.Rows[index]["출석상태"].ToString()]).ToString());
                update.Where = $"[일자]=#{mOriginal.Rows[index]["일자"]}# AND [학년]={mOriginal.Rows[index]["학년"].ToString().ToSQLString()} AND [반]={mOriginal.Rows[index]["반"].ToString().ToSQLString()} AND [번호]={mOriginal.Rows[index]["번호"].ToString().ToSQLString()}";

                ParentWindow.Client.UpdateData(update);
            }

            mEdited.Clear();
            Save.IsEnabled   = false;
            Cancel.IsEnabled = false;
            mOriginal        = mTable.Copy();
        }
Exemple #3
0
        private void SetAttState(List <int> rows, string state)
        {
            if (rows == null || rows?.Count == 0)
            {
                return;
            }

            string accType = ParentWindow.Client.AccountType;

            if (!AuthorityChecker.CheckAuthority(accType, mCurrentGrade, mCurrentClass, AccessType.Edit, ObjectToAccess.Attendance))
            {
                MessageBox.Show("데이터를 수정할 권한이 없습니다.\n\n특정 학급의 출석부를 수정하려면 그 학급의 담임이여야 합니다.",
                                "권한 없음", MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }

            foreach (int index in rows)
            {
                mTable.Rows[index]["출석상태"] = state;

                mEdited.Add(index);
            }

            Save.IsEnabled   = true;
            Cancel.IsEnabled = true;
        }
Exemple #4
0
        private void Inquire_Click(object sender, RoutedEventArgs e)
        {
            if (FirstDateControl.SelectedDate == null || SecondDateControl.SelectedDate == null)
            {
                ParentWindow.Dispatcher.Invoke(() => MessageBox.Show("기간을 설정해주십시오.", "기간 입력 없음", MessageBoxButton.OK, MessageBoxImage.Error));
                return;
            }

            if (FirstDateControl.SelectedDate.Value > SecondDateControl.SelectedDate.Value)
            {
                ParentWindow.Dispatcher.Invoke(() => MessageBox.Show("기간이 올바르게 입력되지 않았습니다. 첫번째날이 두번째날보다 나중이여선 안됩니다.", "기간 입력 오류", MessageBoxButton.OK, MessageBoxImage.Error));
                return;
            }

            string gradeStr = null, classStr = null;

            ParentWindow.Dispatcher.BeginInvoke((Action)(() =>
            {
                gradeStr = ParentWindow.GradeCombo.Text;
                classStr = ParentWindow.ClassCombo.Text;
            })).Wait();

            //TODO : 계정 권한에 따라 접근을 거부하는 코드 필요.
            string accType = ParentWindow.Client.AccountType;

            if (!AuthorityChecker.CheckAuthority(accType, gradeStr, classStr, AccessType.Inquire, ObjectToAccess.StudentList))
            {
                MessageBox.Show("데이터에 접근할 권한이 없습니다.\n\n특정 학급의 출석부와 학생 명단을 조회하려면 그 학급의 담임이거나, 전 학년 총괄 관리자여야 합니다.",
                                "권한 없음", MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }

            ToExcel.IsEnabled = false;

            mCurrentGrade  = gradeStr;
            mCurrentClass  = classStr;
            mCurrentFirst  = FirstDateControl.SelectedDate.Value;
            mCurrentSecond = SecondDateControl.SelectedDate.Value;

            InquiredText.Text = $"{mCurrentFirst.ToShortDateString()} ~ {mCurrentSecond.ToShortDateString()}";

            ParentWindow.ChildManager.TryToShow <LoadingWindow>("서버와 통신 중...", (WaitCallback)((o) =>
            {
                // 해당 기간에 맞는 학생명단 요청
                ParentWindow.Dispatcher.BeginInvoke((Action)(() =>
                {
                    TcpDataSetRequirement dataReq = new TcpDataSetRequirement(new string[] { "*" }, "[학생 명단]",
                                                                              $"[등록 날짜]<{SecondDateControl.SelectedDate.Value.ToSQLString()} AND [학년]={mCurrentGrade.ToSQLString()} AND [반]={mCurrentClass.ToSQLString()}", "Val([번호])");
                    ParentWindow.Client.RequestDataSet(dataReq);

                    RecentStuListReq = dataReq;
                })).Wait();
            }));

            this.IsEnabled = false;
        }
        private void Inquire_Click(object sender, RoutedEventArgs e)
        {
            string gradeStr = null, classStr = null;

            ParentWindow.Dispatcher.BeginInvoke((Action)(() =>
            {
                gradeStr = ParentWindow.GradeCombo.Text;
                classStr = ParentWindow.ClassCombo.Text;
            })).Wait();

            //TODO : 계정 권한에 따라 접근을 거부하는 코드 필요.
            string accType = ParentWindow.Client.AccountType;

            if (!AuthorityChecker.CheckAuthority(accType, gradeStr, classStr, AccessType.Inquire, ObjectToAccess.Attendance))
            {
                MessageBox.Show("데이터에 접근할 권한이 없습니다.\n\n특정 학급의 출석부를 조회하려면 그 학급의 담임이거나, 전 학년 총괄 관리자여야 합니다.",
                                "권한 없음", MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }

            MessageBoxResult?checkResult = CheckSave(true);

            if (checkResult != null)
            {
                if (checkResult.Value != MessageBoxResult.Yes && checkResult.Value != MessageBoxResult.No)
                {
                    return;
                }
            }

            if (DateControl.SelectedDate == null)
            {
                return;
            }

            mCurrentGrade = gradeStr;
            mCurrentClass = classStr;

            ParentWindow.ChildManager.TryToShow <LoadingWindow>("서버와 통신 중...", (WaitCallback)((o) =>
            {
                // 해당 날짜, 반에 대한 출석부가 생성되었는지 확인
                ParentWindow.Dispatcher.BeginInvoke((Action)(() =>
                {
                    TcpDataSetRequirement dataReq = new TcpDataSetRequirement(new string[] { "*" }, "[출석부]",
                                                                              $"[일자]={DateControl.SelectedDate.Value.ToSQLString()} AND [학년]={mCurrentGrade.ToSQLString()} AND [반]={mCurrentClass.ToSQLString()}", "Val([번호])");
                    ParentWindow.Client.RequestDataSet(dataReq);

                    RecentAttReq = dataReq;
                })).Wait();
            }));

            this.IsEnabled = false;
        }
Exemple #6
0
        private void AcceptChecked_Click(object sender, RoutedEventArgs e)
        {
            List <int> rowIndexes = GetCheckedRows();

            if (rowIndexes == null ? true : rowIndexes.Count == 0)
            {
                MessageBox.Show("체크된 항목이 없습니다.", "항목 없음", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
                return;
            }

            string accType = ParentWindow.Client.AccountType;

            if (!AuthorityChecker.CheckAuthority(accType, null, null, AccessType.Edit, ObjectToAccess.Accounts))
            {
                MessageBox.Show("데이터를 수정할 권한이 없습니다.\n\n대기중인 계정 목록을 수정하려면 전 학년 총괄 관리자여야 합니다.",
                                "권한 없음", MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }

            MessageBoxResult qResult = MessageBox.Show($"총 {rowIndexes.Count} 개의 계정이 수정됩니다.\n계속하시겠습니까?", "준비 완료", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (qResult == MessageBoxResult.Yes)
            {
                foreach (int index in rowIndexes)
                {
                    TcpDataUpdate update = new TcpDataUpdate();
                    update.TableName = "[교사 목록]";
                    update.Setter.Add("[가입 허가 여부]", "True");
                    update.Where = $"[교사 ID]={mTable.Rows[index]["교사ID"].ToString().ToSQLString()}";

                    ParentWindow.Client.UpdateData(update);
                }

                Clear();
                this.Dispatcher.Invoke(() =>
                {
                    Inquire.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                });
            }
            else
            {
                return;
            }
        }
        private void DataGridRow_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            //TODO : 계정 권한에 따라 접근을 거부하는 코드 필요.
            string accType = ParentWindow.Client.AccountType;

            if (!AuthorityChecker.CheckAuthority(accType, mCurrentGrade, mCurrentClass, AccessType.Edit, ObjectToAccess.StudentList))
            {
                MessageBox.Show("데이터를 수정할 권한이 없습니다.\n\n특정 학급의 학생 명단을 수정하려면 그 학급의 담임이여야 합니다.",
                                "권한 없음", MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }

            if (!IsTableEmpty)
            {
                DataRow selectedRow;

                try
                {
                    selectedRow = mTable.Rows[MainDataGrid.SelectedIndex];
                }
                catch (Exception)
                {
                    ParentWindow.Dispatcher.Invoke(() => MessageBox.Show("수정하고자 하는 학생을 정확히 선택해주십시오.", "학생 선택 실패", MessageBoxButton.OK, MessageBoxImage.Warning));
                    return;
                }

                List <string> numsList = new List <string>();
                foreach (DataRow row in mTable.Rows)
                {
                    numsList.Add(row["번호"].ToString());
                }

                string[] existNumbers = numsList.ToArray();

                ParentWindow.Dispatcher.Invoke(() => mChildManager.TryToShow <EditStudentsWindow>((EventHandler)((o, ev) =>
                {
                    this.Dispatcher.Invoke(() => this.IsEnabled = true);
                    ParentWindow.Dispatcher.Invoke(() => ParentWindow.IsEnabled = true);
                }), this, existNumbers, mCurrentGrade, mCurrentClass, selectedRow, MainDataGrid.SelectedIndex));

                this.IsEnabled = false;
                ParentWindow.Dispatcher.Invoke(() => ParentWindow.IsEnabled = false);
            }
        }
        private void Inquire_Click(object sender, RoutedEventArgs e)
        {
            string gradeStr = null, classStr = null;

            ParentWindow.Dispatcher.BeginInvoke((Action)(() =>
            {
                gradeStr = ParentWindow.GradeCombo.Text;
                classStr = ParentWindow.ClassCombo.Text;
            })).Wait();

            //TODO : 계정 권한에 따라 접근을 거부하는 코드 필요.
            string accType = ParentWindow.Client.AccountType;

            if (!AuthorityChecker.CheckAuthority(accType, gradeStr, classStr, AccessType.Inquire, ObjectToAccess.StudentList))
            {
                MessageBox.Show("데이터에 접근할 권한이 없습니다.\n\n특정 학급의 학생 명단을 조회하려면 그 학급의 담임이거나, 전 학년 총괄 관리자여야 합니다.",
                                "권한 없음", MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }

            ToExcel.IsEnabled = false;

            mCurrentGrade = gradeStr;
            mCurrentClass = classStr;

            // 정해진 기간중 근태 불량 상태가 있는 출석부만 조회.
            ParentWindow.ChildManager.TryToShow <LoadingWindow>("서버와 통신 중...", (WaitCallback)((o) =>
            {
                ParentWindow.Dispatcher.BeginInvoke((Action)(() =>
                {
                    TcpDataSetRequirement dataReq = new TcpDataSetRequirement(new string[] { "*" }, "[학생 명단]",
                                                                              $"[학년]={mCurrentGrade.ToSQLString()} AND [반]={mCurrentClass.ToSQLString()}", "Val([번호])");
                    ParentWindow.Client.RequestDataSet(dataReq);

                    RecentStuListReq = dataReq;
                })).Wait();
            }));

            this.IsEnabled = false;
        }
        private void ProcessAndShowData(DataTable dataTable)
        {
            mTable = new DataTable();

            mTable.Columns.Add(new DataColumn("교사ID", typeof(string)));
            mTable.Columns.Add(new DataColumn("성명", typeof(string)));
            mTable.Columns.Add(new DataColumn("계정구분", typeof(string)));

            foreach (DataRow row in dataTable.Rows)
            {
                DataRow newRow = mTable.NewRow();

                newRow["교사ID"] = row["교사 ID"];
                newRow["성명"]   = row["성명"];
                newRow["계정구분"] = AuthorityChecker.ToDescription(row["계정 구분"].ToString());

                mTable.Rows.Add(newRow);
            }

            MainDataGrid.DataContext = mTable;
        }
        private void AddStu_Click(object sender, RoutedEventArgs e)
        {
            //TODO : 계정 권한에 따라 접근을 거부하는 코드 필요.
            string accType = ParentWindow.Client.AccountType;

            if (!AuthorityChecker.CheckAuthority(accType, mCurrentGrade, mCurrentClass, AccessType.Edit, ObjectToAccess.StudentList))
            {
                MessageBox.Show("데이터를 수정할 권한이 없습니다.\n\n특정 학급의 학생 명단을 수정하려면 그 학급의 담임이여야 합니다.",
                                "권한 없음", MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }

            string[] existNumbers;
            if (IsTableEmpty)
            {
                existNumbers = new string[] { };
            }
            else
            {
                List <string> numsList = new List <string>();
                foreach (DataRow row in mTable.Rows)
                {
                    numsList.Add(row["번호"].ToString());
                }

                existNumbers = numsList.ToArray();
            }

            ParentWindow.Dispatcher.Invoke(() => mChildManager.TryToShow <AddStudentsWindow>((EventHandler)((o, ev) =>
            {
                this.Dispatcher.Invoke(() => this.IsEnabled = true);
                ParentWindow.Dispatcher.Invoke(() => ParentWindow.IsEnabled = true);
            }), this, existNumbers, mCurrentGrade, mCurrentClass));

            this.IsEnabled = false;
            ParentWindow.Dispatcher.Invoke(() => ParentWindow.IsEnabled = false);
        }
        private void SetAttState(List <int> rows, string state)
        {
            if (rows == null || rows?.Count == 0)
            {
                return;
            }

            string accType = ParentWindow.Client.AccountType;

            if (!AuthorityChecker.CheckAuthority(accType, mCurrentGrade, mCurrentClass, AccessType.Edit, ObjectToAccess.Attendance))
            {
                MessageBox.Show("데이터를 수정할 권한이 없습니다.\n\n특정 학급의 출석부를 수정하려면 그 학급의 담임이여야 합니다.",
                                "권한 없음", MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }

            if (EditMultipleRadio.IsChecked == true)
            {
                int periodCount = int.Parse(PeriodCount.Text);

                foreach (int index in rows)
                {
                    for (int period = 0; period <= periodCount; ++period)
                    {
                        mTable.Rows[index][$"{period}교시"] = state;
                    }

                    mEdited.Add(index);
                }
            }
            else
            {
                // 무단 결석 : 뒤에 있는 교시도 수정.
                // 무단 지각 : 앞에 있는 교시도 수정.
                // 무단 조퇴 : 뒤에 있는 교시도 수정.

                int period       = int.Parse(EditOne_Period.Text);
                int endOfPeriods = int.Parse(PeriodCount.Text);

                if (endOfPeriods < period)
                {
                    ParentWindow.Dispatcher.Invoke(() => MessageBox.Show(ParentWindow, "수정하려는 교시가 이 날의 교시수보다 큽니다.", "교시가 범위를 벗어남", MessageBoxButton.OK, MessageBoxImage.Warning));

                    Save.IsEnabled   = true;
                    Cancel.IsEnabled = true;
                    return;
                }

                foreach (int index in rows)
                {
                    switch (StrToAttDict[state])
                    {
                    case AttEnum.Absent:
                    case AttEnum.EarlyLeft:
                        for (int i = period; i <= endOfPeriods; ++i)
                        {
                            mTable.Rows[index][$"{i}교시"] = state;
                        }
                        break;

                    case AttEnum.Late:
                        for (int i = 0; i <= period; ++i)
                        {
                            mTable.Rows[index][$"{i}교시"] = state;
                        }
                        break;

                    default:
                        mTable.Rows[index][$"{period}교시"] = state;
                        break;
                    }

                    mEdited.Add(index);
                }
            }

            Save.IsEnabled   = true;
            Cancel.IsEnabled = true;
        }
        private void Inquire_Click(object sender, RoutedEventArgs e)
        {
            if (FirstDateControl.SelectedDate == null || SecondDateControl.SelectedDate == null)
            {
                ParentWindow.Dispatcher.Invoke(() => MessageBox.Show("기간을 설정해주십시오.", "기간 입력 없음", MessageBoxButton.OK, MessageBoxImage.Error));
                return;
            }

            if (FirstDateControl.SelectedDate.Value > SecondDateControl.SelectedDate.Value)
            {
                ParentWindow.Dispatcher.Invoke(() => MessageBox.Show("기간이 올바르게 입력되지 않았습니다. 첫번째날이 두번째날보다 나중이여선 안됩니다.", "기간 입력 오류", MessageBoxButton.OK, MessageBoxImage.Error));
                return;
            }

            if (MessageBox.Show("전교의 벌점을 조회하는 과정은 오래 걸릴 수 있습니다.\n계속하시겠습니까?", "전교 조회 전 경고", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)
            {
                return;
            }

            //TODO : 계정 권한에 따라 접근을 거부하는 코드 필요.
            string accType = ParentWindow.Client.AccountType;

            if (!AuthorityChecker.CheckAuthority(accType, null, null, AccessType.Inquire, ObjectToAccess.Attendance))
            {
                MessageBox.Show("데이터에 접근할 권한이 없습니다.\n\n전교의 출석부를 조회하려면 전 학년 총괄 관리자여야 합니다.",
                                "권한 없음", MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }

            mCurrentFirst  = FirstDateControl.SelectedDate.Value;
            mCurrentSecond = SecondDateControl.SelectedDate.Value;

            InquiredText.Text = $"{mCurrentFirst.ToShortDateString()} ~ {mCurrentSecond.ToShortDateString()}";

            mLoading = new LoadingWindow("출석부를 가져오는 중...");
            double top = 0, left = 0;

            ParentWindow.Dispatcher.BeginInvoke((Action)(() =>
            {
                top = ParentWindow.Top + ParentWindow.Height / 2 - mLoading.Height / 2;
                left = ParentWindow.Left + ParentWindow.Width / 2 - mLoading.Width / 2;
            })).Wait();

            mLoading.Top   = top;
            mLoading.Left  = left;
            mLoading.Owner = ParentWindow;

            mLoading.Show();

            // 해당 기간에 맞는 불량사항 있는 출석부 모두 요청
            ParentWindow.Dispatcher.BeginInvoke((Action)(() =>
            {
                TcpDataSetRequirement dataReq = new TcpDataSetRequirement(new string[] { "*" }, "[출석부]",
                                                                          $"[일자] BETWEEN {mCurrentFirst.ToSQLString()} AND {mCurrentSecond.ToSQLString()} AND ({ONLY_FAULTS_WHERE})", null);
                ParentWindow.Client.RequestDataSet(dataReq);

                RecentAttReq = dataReq;
            }));

            this.IsEnabled = false;
        }