コード例 #1
0
ファイル: WorkspaceViewModel.cs プロジェクト: shL2e/HRM
        private void LoadTodayAttendance()
        {
            TodayAttendanceList.Clear();
            try
            {
                var sqlData = new AttendanceQuery().SelectWithToday();
                while (sqlData.Read())
                {
                    AttendanceDTO dto = new AttendanceDTO
                    {
                        ATTENDANCE_BUSINESS_DAY = sqlData["businessday"].ToString(),
                        ATTENDANCE_NAME         = sqlData["name"].ToString(),
                        ATTENDANCE_IDNUMBER     = sqlData["idnumber"].ToString(),
                        ATTENDANCE_IN_TIME      = sqlData["in_time"].ToString(),
                        ATTENDANCE_OUT_TIME     = sqlData["out_time"].ToString(),
                        ATTENDANCE_OVERTIME     = sqlData["overtime"].ToString(),
                        ATTENDANCE_OFF_DAY      = sqlData["off_day"].ToString(),
                        ATTENDANCE_ETC          = sqlData["etc"].ToString()
                    };
                    TodayAttendanceList.Add(new AttendanceModel(dto));
                }
                sqlData.Close();
                SharedPreference.Instance.DBM.SqlConn.Close();

                var sqlData2 = new AttendanceQuery().SelectTwoWeeksAgo();
                while (sqlData2.Read())
                {
                    AttendanceDTO dto = new AttendanceDTO
                    {
                        ATTENDANCE_BUSINESS_DAY = sqlData2["businessday"].ToString(),
                        ATTENDANCE_NAME         = sqlData2["name"].ToString(),
                        ATTENDANCE_IDNUMBER     = sqlData2["idnumber"].ToString(),
                        ATTENDANCE_IN_TIME      = sqlData2["in_time"].ToString(),
                        ATTENDANCE_OUT_TIME     = sqlData2["out_time"].ToString(),
                        ATTENDANCE_OVERTIME     = sqlData2["overtime"].ToString(),
                        ATTENDANCE_OFF_DAY      = sqlData2["off_day"].ToString(),
                        ATTENDANCE_ETC          = sqlData2["etc"].ToString()
                    };
                    TodayAttendanceList.Add(new AttendanceModel(dto));
                }
                sqlData2.Close();
                SharedPreference.Instance.DBM.SqlConn.Close();
            }
            catch (Exception e)
            {
                SharedPreference.Instance.DBM.SqlConn.Close();

                MessageBox.Show("오늘 출결 상황을 읽어오지 못했습니다. 관리자에게 문의하세요.\n에러 내용 : " + e.Message);
            }
        }
コード例 #2
0
        private void LoadTodayAttendance(UserControl uc)
        {
            if (Conditions == "All")
            {
                SharedPreference.Instance.SelectedDept  = null;
                SharedPreference.Instance.SelectedStaff = null;

                TodayAttendanceList.Clear();
                var sqlData = new AttendanceQuery().SelectWithAllStaffAndDay(StartDate, EndDate);
                if (sqlData.HasRows)
                {
                    while (sqlData.Read())
                    {
                        AttendanceDTO dto = new AttendanceDTO
                        {
                            ATTENDANCE_BUSINESS_DAY = sqlData["businessday"].ToString(),
                            ATTENDANCE_NAME         = sqlData["name"].ToString(),
                            ATTENDANCE_IDNUMBER     = sqlData["idnumber"].ToString(),
                            ATTENDANCE_IN_TIME      = sqlData["in_time"].ToString(),
                            ATTENDANCE_OUT_TIME     = sqlData["out_time"].ToString(),
                            ATTENDANCE_OVERTIME     = sqlData["overtime"].ToString(),
                            ATTENDANCE_OFF_DAY      = sqlData["off_day"].ToString(),
                            ATTENDANCE_ETC          = sqlData["etc"].ToString()
                        };
                        TodayAttendanceList.Add(new AttendanceModel(dto));
                    }
                    sqlData.Close();
                    SharedPreference.Instance.DBM.SqlConn.Close();
                }
                else
                {
                    sqlData.Close();
                    SharedPreference.Instance.DBM.SqlConn.Close();
                }
            }
            else if (Conditions == "Selection")
            {
                if (SharedPreference.Instance.SelectedDept != null)
                {
                    TodayAttendanceList.Clear();

                    var sqlData = new AttendanceQuery().SelectWithDeptAndDay(SharedPreference.Instance.SelectedDept.DEPT_CODE, StartDate, EndDate);

                    if (SharedPreference.Instance.SelectedStaff != null)
                    {
                        sqlData.Close();
                        SharedPreference.Instance.DBM.SqlConn.Close();

                        sqlData = new AttendanceQuery().SelectWithIdnumberAndDay(SharedPreference.Instance.SelectedStaff.STAFF_IDNUMBER, StartDate, EndDate);
                    }

                    if (sqlData.HasRows)
                    {
                        while (sqlData.Read())
                        {
                            AttendanceDTO dto = new AttendanceDTO
                            {
                                ATTENDANCE_BUSINESS_DAY = sqlData["businessday"].ToString(),
                                ATTENDANCE_NAME         = sqlData["name"].ToString(),
                                ATTENDANCE_IDNUMBER     = sqlData["idnumber"].ToString(),
                                ATTENDANCE_IN_TIME      = sqlData["in_time"].ToString(),
                                ATTENDANCE_OUT_TIME     = sqlData["out_time"].ToString(),
                                ATTENDANCE_OVERTIME     = sqlData["overtime"].ToString(),
                                ATTENDANCE_OFF_DAY      = sqlData["off_day"].ToString(),
                                ATTENDANCE_ETC          = sqlData["etc"].ToString()
                            };
                            TodayAttendanceList.Add(new AttendanceModel(dto));
                        }
                    }
                    sqlData.Close();
                    SharedPreference.Instance.DBM.SqlConn.Close();
                }
                else
                {
                    MessageBox.Show("부서 또는 사원을 선택해주세요.");
                    Window.GetWindow(uc).DialogResult = false;
                }
            }
        }
コード例 #3
0
ファイル: WorkspaceViewModel.cs プロジェクト: shL2e/HRM
        public void InsertAttendance(SqlDataReader sqlData, AttendanceDTO dto, StreamPlayerControl streamPlayerControl)
        {
            var today = DateTime.Now;

            SqlDataReader sqlData2 = new AttendanceQuery().SelectWithIdnumberAndToday(dto.ATTENDANCE_IDNUMBER, today.ToString("yyyy-MM-dd"));

            // 오늘 이미 출근 기록이 있을 경우
            if (sqlData2.HasRows)
            {
                SharedPreference.Instance.DBM.SqlConn.Close();
                MessageBox.Show("오늘은 이미 출근 처리가 되어있습니다.");
            }
            else
            {
                try
                {
                    if (streamPlayerControl.IsPlaying)
                    {
                        var picture = streamPlayerControl.GetCurrentFrame();
                        var image   = new BitmapToBitmapImageConverter().Convert(picture, null, null, null);
                        var popup   = new CapturePopup();
                        //(popup.DataContext as CapturePopupViewModel).Message = "정상적으로 출근처리 되었습니다.\n즐거운 하루 되세요!";
                        //(popup.DataContext as CapturePopupViewModel).Image = image as BitmapImage;
                        if (WindowHelper.CreatePopup(popup, "출근", true) == true)
                        {
                            try
                            {
                                sqlData2.Close();
                                SharedPreference.Instance.DBM.SqlConn.Close();
                                new AttendanceQuery().Insert(dto);

                                TodayAttendanceList.Insert(0, new AttendanceModel(dto));

                                Defines.STAFF_PATH = Defines.CAPTURE_PATH + @"\Staff\" + SharedPreference.Instance.SelectedStaff.STAFF_NameAndIdnumber + @"\";
                                if (!Directory.Exists(Defines.STAFF_PATH))
                                {
                                    Directory.CreateDirectory(Defines.STAFF_PATH);
                                }
                                picture.Save(Defines.STAFF_PATH + today.ToString("yyyyMMdd") + "_Attendance_" + dto.ATTENDANCE_IDNUMBER + ".bmp");

                                try
                                {
                                    AttendanceLogDTO logDto = new AttendanceLogDTO()
                                    {
                                        ATTENDANCE_LOG_ADMIN       = "출근",
                                        ATTENDANCE_LOG_IDNUMBER    = SharedPreference.Instance.SelectedStaff.STAFF_IDNUMBER,
                                        ATTENDANCE_LOG_BUSINESSDAY = DateTime.Now.ToString("yyyy-MM-dd"),
                                        ATTENDANCE_LOG_WHAT        = "출근",
                                        ATTENDANCE_LOG_LOG         = "출근 시간: " + DateTime.Now.ToString("HH:mm:ss"),
                                        ATTENDANCE_LOG_REASON      = "당일 출근 기록",
                                        ATTENDANCE_LOG_UPDATE_DATE = DateTime.Now.ToString("yyyy-MM-dd")
                                    };

                                    new AttendanceLogQuery().Insert(logDto);
                                }
                                catch (Exception e)
                                {
                                    SharedPreference.Instance.DBM.SqlConn.Close();
                                    MessageBox.Show("기록을 남기는데 실패하셨습니다. 관리자에게 문의하세요.\n에러내용 : " + e.Message);
                                }
                            }
                            catch (Exception e)
                            {
                                sqlData2.Close();
                                SharedPreference.Instance.DBM.SqlConn.Close();
                                MessageBox.Show("출근 실패하셨습니다. 관리자에게 문의하세요.\n에러내용 : " + e.Message);
                            }
                        }
                    }
                    else
                    {
                        sqlData2.Close();
                        SharedPreference.Instance.DBM.SqlConn.Close();
                        MessageBox.Show("캠이 정상 작동중이지 않습니다. 관리자에게 문의하세요.");
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("출근 실패하셨습니다. 관리자에게 문의하세요.\n에러내용 : " + e.Message);
                }
            }
        }