private void PART_DialogSaveButton_Click(object sender, RoutedEventArgs e) { SetAppointment(); var _app = _appointment; ScheduleEntity se = new ScheduleEntity() { id = cf.userID, subject = _app.Subject, date = CDateTime.GetDateTimeFormat(_app.Start, "yyyymmdd"), start = CDateTime.GetDateTimeFormat(_app.Start, "yyyymmddhhnnss"), end = CDateTime.GetDateTimeFormat(_app.End, "yyyymmddhhnnss"), body = _app.Body, _id = _hidid.Text }; //데이터 재 취득 (반환처리로 하지 않으면 비동기식으로 처리되어 리스트를 먼저 가져올 수 있다.) var rtn = DateControl(se); //데이터 재 취득 if (rtn != null) { DateControl2(); } if (_parentWindow is Window) { _parentWindow.Tag = "true"; ((Window)_parentWindow).Close(); } else { ((C1Window)_parentWindow).DialogResult = MessageBoxResult.OK; } }
private async void GetList() { try { overTimeReason.Content = ""; WorkEntity we = new WorkEntity() { id = cf.userID }; String result = await new CallWebApi().CallPostApiWorks("workInfoFind", we); //토큰에러 if (result.Equals("TokenError")) { } Works workList = JsonConvert.DeserializeObject <Works>(result); if (workList.accesstoken != null && workList.accesstoken.Length > 0) { cf.accesstoken = workList.accesstoken; result = await new CallWebApi().CallPostApiWorks("workInfoFind", we); workList = JsonConvert.DeserializeObject <Works>(result); } DataTable dt; dt = new DataTable(); dt.Columns.Add("workDate"); dt.Columns.Add("workTimeS"); dt.Columns.Add("workTimeE"); dt.Columns.Add("workHour"); dt.Columns.Add("workOverTIme"); dt.Columns.Add("status"); var _targerWorkList = workList.workList .Where(w => Int32.Parse(w.workDate) >= Int32.Parse(sDate.Content.ToString()) && Int32.Parse(w.workDate) <= Int32.Parse(eDate.Content.ToString()) && w.workHour > 0 ).ToList <WorkEntity>(); for (int i = 0; i < _targerWorkList.Count; i++) { WorkEntity item = _targerWorkList[i]; //근무시작시간 DateTime workStart = CDateTime.GetDateFrom_yyyyMMddHHmmss(item.workTimeS.Trim()); //근무종료시간 DateTime workEnd = CDateTime.GetDateFrom_yyyyMMddHHmmss(item.workTimeE.Trim()); //총근무시간 int spanMinute = item.workHour; //야근시간 int overTime = item.workOver; //상태값 String status = ""; switch (item.status) { case "1": status = "처리완료"; break; case "2": status = "반려"; break; default: status = "미처리"; break; } dt.Rows.Add(new string[] { CDateTime.ToYYYYMMDD(item.workDate, true), Convert.ToInt32(item.workTimeS.Substring(8, 2)) + "시 " + Convert.ToInt32(item.workTimeS.Substring(10, 2)) + "분", Convert.ToInt32(item.workTimeE.Substring(8, 2)) + "시 " + Convert.ToInt32(item.workTimeE.Substring(10, 2)) + "분", (spanMinute / 60).ToString() + "시간 " + (spanMinute % 60) + "분", overTime < 0?"없음": (overTime / 60).ToString() + "시간 " + (overTime % 60) + "분", status }); } ; WorkDataGrid.ItemsSource = dt.DefaultView; } catch (Exception ex) { throw ex; } }
private async void regWorkData(String workDate, String _sDateTime, String _eDateTime, int sTime, int eTime) { try { MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow; ClientConfig cf = InitSetting.CConf; //18:00이후 인경우만 처리(저녁) int _dinnerTime = 0; if (!(bool)cheDinner.IsChecked) { if (sTime <= 180000 && eTime > 190000) { _dinnerTime = 60; } } //12:00이후 인경우만 처리 (점심) int _lunchTime = 0; if (sTime <= 120000 && eTime > 130000) { _lunchTime = 60; } WorkEntity we = new WorkEntity() { id = cf.userID, workDate = workDate }; String result = await new CallWebApi().CallPostApiWorks("workInfoFind", we); Works workList = JsonConvert.DeserializeObject <Works>(result); //같은 날자에 등록되어 있는 자료가 있음. if (workList.workList.Count > 0) { var totalWorkHour = workList.workList .Where(w => ( ( ( double.Parse(w.workTimeS) <= double.Parse(_sDateTime) && double.Parse(w.workTimeE) > double.Parse(_sDateTime) ) || ( double.Parse(w.workTimeS) < double.Parse(_eDateTime) && double.Parse(w.workTimeE) >= double.Parse(_eDateTime) ) ) && w.workHour > 0 ) ).ToList <WorkEntity>(); if (totalWorkHour.Count > 0) { //MessageBox.Show("등록된 자료중에 시간이 중복되는 자료가 있습니다."); await window.ShowMessageAsync("알림창", "등록된 자료중에 시간이 중복되는 자료가 있습니다."); return; } } //저장할 항목 we.workTimeS = _sDateTime; we.workTimeE = _eDateTime; we.dinnerTime = _dinnerTime; we.lunchTime = _lunchTime; DateTime workStart = CDateTime.GetDateFrom_yyyyMMddHHmmss(_sDateTime); DateTime workEnd = CDateTime.GetDateFrom_yyyyMMddHHmmss(_eDateTime); TimeSpan TS = new TimeSpan(workEnd.Ticks - workStart.Ticks); //총근무시간 int spanMinute = (int)TS.TotalMinutes - _dinnerTime - _lunchTime; we.workHour = spanMinute; /* * 야근시간계산법 * 야근시간(기본 8시간 근무시) * 18시 이후에 근무하는 것은 기본적으로 야근으로 처리 * 주말이나 휴일 근무일 경우 모드 연장근무로 처리 */ int overTime = spanMinute - 480; if (sTime >= 180000) { overTime = spanMinute; } var _day = CDateTime.GetDayOfWeekHangul(workStart); if ((bool)cheHoly.IsChecked || _day.Equals("토") || _day.Equals("일")) { overTime = spanMinute; } we.workOver = overTime <= 0 ? 0 : overTime; //오버타임인데 이유가 없을 경우 if (overTime > 0 && overTimeReason.Content.ToString().Trim().Length == 0) { MainWindow mw = (MainWindow)Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive); pop_inputReason popup = new pop_inputReason(); popup.Owner = mw; mw.Opacity = 0.8; popup.ShowDialog(); if (cf.overtimeReason.Trim() == "") { await window.ShowMessageAsync("알림창", "야근이유가 등록되지 않았습니다."); return; } } we.overTimeReason = cf.overtimeReason; if (overTime > 0) { we.status = "0"; } else { we.status = "1"; } //등록처리 result = await new CallWebApi().CallPostApiWorks("workInfoAdd", we); var rtn = JsonConvert.DeserializeObject <Dictionary <string, string> >(result); foreach (KeyValuePair <string, string> item in rtn) { if (item.Key.Equals("result") && item.Value.Equals("NG")) { if (window != null) { await window.ShowMessageAsync("알림창", "등록에 실패하였습니다. 관리자에게 문의 부탁드립니다."); } break; } else { if (window != null) { if (overTime > 0) { await window.ShowMessageAsync("알림창", "등록었습니다. 야근이 있는 경우 승인 후 야근시간이 반영되어 집니다."); } else { await window.ShowMessageAsync("알림창", "등록되었습니다."); } } break; } } GetList(); cf.overtimeReason = ""; } catch { } }
private void Btn_work_Click(object sender, RoutedEventArgs e) { ClientConfig cf = InitSetting.CConf; System.Windows.Controls.Primitives.ToggleButton toggleSwitch = sender as System.Windows.Controls.Primitives.ToggleButton; if (cf.workStatus != null && cf.workStatus.Equals("1")) { MessageBoxResult result = MessageBox.Show("퇴근처리 하시겠습니까?", "근무설정", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { MessageBoxResult result2 = MessageBox.Show("기본 18시 퇴근으로 처리하시겠습니까?(아니오일 경우 현재시간으로 설정되어 집니다." , "근무설정", MessageBoxButton.YesNo, MessageBoxImage.Question); //파일처리 string[] param = new string[1]; if (result2 == MessageBoxResult.Yes) { param[0] = DateTime.Now.ToString("yyyyMMdd") + "180000"; } else { param[0] = DateTime.Now.ToString("yyyyMMddHHmm") + "00"; } txt_status.Content = "퇴근"; txt_status.Foreground = new SolidColorBrush(Colors.Red); cf.workStatus = "0"; cf.workEndLastTime = param[0]; InitSetting.ConfigWriteProfile(param, 2); //데이터베이스 등록처리 DateTime sdt = CDateTime.GetDateFrom_yyyyMMddHHmmss(cf.workStartLastTime); DateTime edt = CDateTime.GetDateFrom_yyyyMMddHHmmss(cf.workEndLastTime); String workDate = CDateTime.GetDateFrom_yyyyMMddHHmmss(cf.workStartLastTime).ToString("yyyyMMdd"); String _sDateTime = sdt.ToString("yyyyMMdd") + sdt.TimeOfDay.ToString().Replace(":", ""); String _eDateTime = edt.ToString("yyyyMMdd") + edt.TimeOfDay.ToString().Replace(":", ""); int sTime = Int32.Parse(sdt.TimeOfDay.ToString().Replace(":", "").Substring(0, 4) + "00"); int eTime = Int32.Parse(edt.TimeOfDay.ToString().Replace(":", "").Substring(0, 4) + "00"); //데이터베이스 등록처리 regWorkData(workDate, _sDateTime, _eDateTime, sTime, eTime); cheDinner.IsChecked = false; } else { toggleSwitch.IsChecked = true; } } else { MessageBoxResult result = MessageBox.Show("출근처리 하시겠습니까?", "근무설정", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { MessageBoxResult result2 = MessageBox.Show("기본 9시 출근으로 처리하시겠습니까?(아니오일 경우 현재시간으로 설정되어 집니다." , "근무설정", MessageBoxButton.YesNo, MessageBoxImage.Question); txt_status.Content = "근무"; txt_status.Foreground = new SolidColorBrush(Colors.Blue); cf.workStatus = "1"; //기본파일 등록처리 string[] param = new string[2]; if (result2 == MessageBoxResult.Yes) { param[0] = DateTime.Now.ToString("yyyyMMdd") + "090000"; } else { param[0] = DateTime.Now.ToString("yyyyMMddHHmm") + "00"; } param[1] = string.Empty; cf.workStartLastTime = param[0]; cf.workEndLastTime = ""; InitSetting.ConfigWriteProfile(param, 1); } else { toggleSwitch.IsChecked = false; } DateControl2(); } }
private async void regWorkData(String workDate, String _sDateTime, String _eDateTime, int sTime, int eTime) { try { MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow; ClientConfig cf = InitSetting.CConf; //18:00이후 인경우만 처리(저녁) int _dinnerTime = 0; if (sTime <= 180000 && eTime > 190000) { _dinnerTime = 60; } //12:00이후 인경우만 처리 (점심) int _lunchTime = 0; if (sTime <= 120000 && eTime > 130000) { _lunchTime = 60; } WorkEntity we = new WorkEntity() { id = cf.userID, workDate = workDate }; String result = await new CallWebApi().CallPostApiWorks("workInfoFind", we); Works workList = JsonConvert.DeserializeObject <Works>(result); //같은 날자에 등록되어 있는 자료가 있음. if (workList.workList.Count > 0) { var totalWorkHour = workList.workList .Where(w => ( ( double.Parse(w.workTimeS) <= double.Parse(_sDateTime) && double.Parse(w.workTimeE) > double.Parse(_sDateTime) ) || ( double.Parse(w.workTimeS) < double.Parse(_eDateTime) && double.Parse(w.workTimeE) >= double.Parse(_eDateTime) ) ) ).ToList <WorkEntity>(); if (totalWorkHour.Count > 0) { MessageBox.Show("등록된 자료중에 시간이 중복되는 자료가 있습니다."); return; } } //저장할 항목 we.workTimeS = _sDateTime; we.workTimeE = _eDateTime; we.dinnerTime = _dinnerTime; we.lunchTime = _lunchTime; DateTime workStart = CDateTime.GetDateFrom_yyyyMMddHHmmss(_sDateTime); DateTime workEnd = CDateTime.GetDateFrom_yyyyMMddHHmmss(_eDateTime); TimeSpan TS = new TimeSpan(workEnd.Ticks - workStart.Ticks); //총근무시간 int spanMinute = (int)TS.TotalMinutes - _dinnerTime - _lunchTime; we.workHour = spanMinute; //야근시간 int overTime = spanMinute - 480; we.workOver = overTime <= 0 ? 0 : overTime; if (overTime > 0) { we.status = "0"; } else { we.status = "1"; } //등록처리 result = await new CallWebApi().CallPostApiWorks("workInfoAdd", we); var rtn = JsonConvert.DeserializeObject <Dictionary <string, string> >(result); foreach (KeyValuePair <string, string> item in rtn) { if (item.Key.Equals("result") && item.Value.Equals("NG")) { if (window != null) { this.Show(); await window.ShowMessageAsync("알림창", "등록에 실패하였습니다. 관리자에게 문의 부탁드립니다."); } break; } else { if (window != null) { if (overTime > 0) { this.Show(); cf.workStatus = "0"; await window.ShowMessageAsync("알림창", "등록었습니다. 야근이 있는 경우 승인 후 야근시간이 반영되어 집니다."); } else { cf.workStatus = "0"; _uc_dashboard = new uc_DashBoard(); uc_Class.Uc_Link(Contents_Border, _uc_dashboard); } } break; } } cf.overtimeReason = ""; } catch { } }
//타이머 처리 private void DispatcherTimer_Tick(object sender, EventArgs e) { ClientConfig cf = InitSetting.CConf; if (cf.workStatus == null) { cf.workStatus = "0"; } string format = "yyyy년 MM월 dd일"; string _strDate = DateTime.Now.ToString(format); format = " HH시 mm분 ss초"; string _strTime = DateTime.Now.ToString(format); labDate.Content = _strDate; labTime.Content = _strTime; var sb = new StringBuilder(); //일정알림처리 (근무시일경우만) if (cf.autoAlarm.Equals("0") && cf.workStatus.Equals("1")) { if (cf.scheduleList != null) { foreach (var _item in cf.scheduleList) { TimeSpan ts = _item.Start - DateTime.Now.AddMinutes(5); if (ts.TotalSeconds < 0 && ts.TotalSeconds > -1) { sb.Append(CDateTime.GetDateTimeFormat(_item.Start, "yyyy-mm-dd hh:nn:ss")) .Append(" ") .Append(_item.Subject) .Append("[") .Append(_item.Body) .Append("] ") .Append(" 5분전입니다"); _vm2.ShowWarning(sb.ToString()); } } } } //09시가 되었는데 근무가 처리 안되었을 경우 (월~금) //60초동안 클릭을 안할 경우 출근안함으로 처리 //cf.status => 1: 근무 , 0:퇴근 if (!(DateTime.Now.DayOfWeek.Equals(DayOfWeek.Saturday) && DateTime.Now.DayOfWeek.Equals(DayOfWeek.Sunday))) { if (DateTime.Now.ToString("HHmmss").Equals("090000") && cf.workStatus.Equals("0")) { var result = System.Windows.Forms.AutoClosingMessageBox.Show( text: "9시입니다. 근무를 시작하시겠습니까?", caption: "근무설정", timeout: 60000, buttons: System.Windows.Forms.MessageBoxButtons.YesNo, defaultResult: System.Windows.Forms.DialogResult.No); if (result == System.Windows.Forms.DialogResult.Yes) { //기본파일 등록처리 string[] param = new string[2]; param[0] = DateTime.Now.ToString("yyyyMMdd") + "090000"; param[1] = string.Empty; cf.workStartLastTime = param[0]; cf.workEndLastTime = ""; cf.workStatus = "1"; InitSetting.ConfigWriteProfile(param, 1); _uc_dashboard = new uc_DashBoard(); uc_Class.Uc_Link(Contents_Border, _uc_dashboard); btn_DashBoard.Focus(); } } //18시가 되었을 때 퇴근알림 처리 else if (DateTime.Now.ToString("HHmmss").Equals("180000") && cf.workStatus.Equals("1")) { var result = System.Windows.Forms.AutoClosingMessageBox.Show( text: "18시입니다. 퇴근 하시겠습니까?", caption: "근무설정", timeout: 60000, buttons: System.Windows.Forms.MessageBoxButtons.YesNo, defaultResult: System.Windows.Forms.DialogResult.No); if (result == System.Windows.Forms.DialogResult.Yes) { string[] param = new string[1]; param[0] = DateTime.Now.ToString("yyyyMMdd") + "180000"; cf.workEndLastTime = param[0]; InitSetting.ConfigWriteProfile(param, 2); //데이터베이스 등록처리 DateTime sdt = CDateTime.GetDateFrom_yyyyMMddHHmmss(cf.workStartLastTime); DateTime edt = CDateTime.GetDateFrom_yyyyMMddHHmmss(cf.workEndLastTime); String workDate = CDateTime.GetDateFrom_yyyyMMddHHmmss(cf.workStartLastTime).ToString("yyyyMMdd"); String _sDateTime = sdt.ToString("yyyyMMdd") + sdt.TimeOfDay.ToString().Replace(":", ""); String _eDateTime = edt.ToString("yyyyMMdd") + edt.TimeOfDay.ToString().Replace(":", ""); int sTime = Int32.Parse(sdt.TimeOfDay.ToString().Replace(":", "").Substring(0, 4) + "00"); int eTime = Int32.Parse(edt.TimeOfDay.ToString().Replace(":", "").Substring(0, 4) + "00"); //데이터베이스 등록처리 regWorkData(workDate, _sDateTime, _eDateTime, sTime, eTime); } } else if (DateTime.Now.ToString("HHmmss").Equals("093000") || DateTime.Now.ToString("HHmmss").Equals("133000") && cf.workStatus.Equals("1")) { _vm.ShowInformation("오전 9시30분에서 11시30분 / 오후 13시30분 ~ 오후 17시30분은 업무 집중시간입니다."); } //if(cf.workStatus.Equals("1") && Int32.Parse(DateTime.Now.ToString("HHmmss")) > 183000) //{ // if(DateTime.Now.ToString("mmss").Equals("0000")) { // _vm.ShowInformation("현재 연장근무중입니다. 업무 빨리 하시고 퇴근하세요."); // } //} } }
//데이터 확인 private void checkData() { ClientConfig cf = InitSetting.CConf; if (!cf.workStartLastTime.Equals("") && cf.workEndLastTime.Equals("")) //퇴근처리가 안된 데이터가 존재 { //오늘 날짜와 같을 경우 if (cf.workStartLastTime.Substring(0, 8).Equals(DateTime.Now.ToString("yyyyMMdd"))) { MessageBoxResult result = MessageBox.Show("출근되어 있습니다. 계속 근무하고 계십니까?", "근무설정", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { cf.workStatus = "1"; } else { DateTime sdt = CDateTime.GetDateFrom_yyyyMMddHHmmss(cf.workStartLastTime); DateTime edt = DateTime.Now; String workDate = CDateTime.GetDateFrom_yyyyMMddHHmmss(cf.workStartLastTime).ToString("yyyyMMdd"); String _sDateTime = sdt.ToString("yyyyMMdd") + sdt.TimeOfDay.ToString().Replace(":", ""); String _eDateTime = edt.ToString("yyyyMMdd") + edt.TimeOfDay.ToString().Replace(":", ""); int sTime = Int32.Parse(sdt.TimeOfDay.ToString().Replace(":", "").Substring(0, 4) + "00"); int eTime = Int32.Parse(edt.TimeOfDay.ToString().Replace(":", "").Substring(0, 4) + "00"); regWorkData(workDate, _sDateTime, _eDateTime, sTime, eTime); string[] param = new string[2]; param[0] = string.Empty; param[1] = string.Empty; cf.workStartLastTime = ""; cf.workEndLastTime = ""; cf.workStatus = "0"; InitSetting.ConfigWriteProfile(param, 1); return; } } else { MessageBox.Show("전에 퇴근처리되지 않은 데이터가 유효기간(1일)이 지나 삭제되었습니다. " + "데이터 확인 후 수동으로 등록 부탁드립니다."); string[] param = new string[2]; param[0] = string.Empty; param[1] = string.Empty; cf.workStartLastTime = ""; cf.workEndLastTime = ""; cf.workStatus = "0"; InitSetting.ConfigWriteProfile(param, 1); return; } } }
private async void showDashBoard() { try { WorkEntity we = new WorkEntity() { id = cf.userID }; String result = await new CallWebApi().CallPostApiWorks("workInfoFind", we); Works workList = JsonConvert.DeserializeObject <Works>(result); IEnumerable <WorkEntity> totalOverTimeSum = workList.workList .Where(w => w.status.Equals("1")) .GroupBy(g => g.id) .Select(s => new WorkEntity { workOver = s.Sum(x => x.workOver) }); if (totalOverTimeSum != null) { foreach (WorkEntity _sums in totalOverTimeSum) { lb_totalOverTime.Content = (_sums.workOver / 60).ToString() + "시간 " + (_sums.workOver % 60) + "분"; } } var _targerWorkList = workList.workList .Where(w => Int32.Parse(w.workDate) >= Int32.Parse(sDate.Content.ToString()) && Int32.Parse(w.workDate) <= Int32.Parse(eDate.Content.ToString()) && w.status.Equals("1") ).ToList <WorkEntity>(); int _totalWorkTime = 0; int _totlaOverTime = 0; for (int i = 0; i < _targerWorkList.Count; i++) { WorkEntity item = _targerWorkList[i]; _totalWorkTime += item.workHour; _totlaOverTime += item.workOver; } _totlaOverTime = 720 - _totlaOverTime; leftOverTime.Content = (_totlaOverTime / 60).ToString() + "시간 " + (_totlaOverTime % 60) + "분"; lb_workTime.Content = "누적근무시간 : " + (_totalWorkTime / 60).ToString() + "시간 " + (_totalWorkTime % 60) + "분"; workChart.Value = Math.Round(((double)_totalWorkTime / (52 * 60)) * 100); ScheduleEntity se = new ScheduleEntity() { id = cf.userID, date = CDateTime.GetDateTimeFormat(DateTime.Now, "yyyymmdd") }; var result3 = Task.Run(() => new CallWebApi().CallPostApiSchedules("scheduleFind", se)); Schedule scheduleList = JsonConvert.DeserializeObject <Schedule>(await result3); cf.scheduleList = new List <AppointmentBusinessObject>(); foreach (ScheduleEntity _item in scheduleList.scheduleList) { AppointmentBusinessObject newObject = new AppointmentBusinessObject(); newObject.Subject = _item.subject; newObject.Start = CDateTime.GetDateFrom_yyyyMMddHHmmss(_item.start); newObject.End = CDateTime.GetDateFrom_yyyyMMddHHmmss(_item.end); newObject.Body = _item.body; cf.scheduleList.Add(newObject); } } catch (Exception ex) { //MessageBox.Show("관리자에게 문의 부탁드립니다."); _vm.ShowError("관리자에게 문의 부탁드립니다."); } }
private void Btn_workTimeReg_Click(object sender, RoutedEventArgs e) { String _workDate = ""; String _sDateTime = ""; String _eDateTime = ""; if (workDate.Text.Equals("")) { //MessageBox.Show("일자를 입력하여 주시기 바랍니다."); _vm.ShowError("일자를 입력하여 주시기 바랍니다."); workDate.Focus(); return; } else { _workDate = workDate.Text.Replace("-", ""); } if (vacationReason.Text.Equals("")) { //MessageBox.Show("휴가사유를 입력하여 주시기 바랍니다."); _vm.ShowError("휴가사유를 입력하여 주시기 바랍니다."); vacationReason.Focus(); return; } //직접입력 if (cbVacationKb.SelectedIndex == 0) { //시간입력 체크 System.DateTime?sdt = startTime.SelectedDateTime; System.DateTime?edt = endTime.SelectedDateTime; if (sdt == null || edt == null) { //MessageBox.Show("시간이 입력되지 않았습니다."); _vm.ShowError("시간이 입력되지 않았습니다."); return; } _sDateTime = sdt?.ToString("yyyyMMdd") + sdt?.TimeOfDay.ToString().Replace(":", ""); _eDateTime = edt?.ToString("yyyyMMdd") + edt?.TimeOfDay.ToString().Replace(":", ""); } else if (cbVacationKb.SelectedIndex == 1) { _sDateTime = _workDate + "130000"; _eDateTime = _workDate + "180000"; } else { _sDateTime = _workDate + "090000"; _eDateTime = _workDate + "170000"; } DateTime workStart = CDateTime.GetDateFrom_yyyyMMddHHmmss(_sDateTime); DateTime workEnd = CDateTime.GetDateFrom_yyyyMMddHHmmss(_eDateTime); TimeSpan TS = new TimeSpan(workEnd.Ticks - workStart.Ticks); //총근무시간 int spanMinute = (int)TS.TotalMinutes; if (Int32.Parse(_leftTimeCheck.Content.ToString()) < spanMinute) { //MessageBox.Show("야근 총 시간보다 더 많은 시간을 입력할 수 없습니다."); _vm.ShowError("야근 총 시간보다 더 많은 시간을 입력할 수 없습니다."); return; } //데이터베이스 등록처리 regWorkData(_workDate, _sDateTime, _eDateTime); }
private async void GetList() { try { WorkEntity we = new WorkEntity() { id = cf.userID }; String result = await new CallWebApi().CallPostApiWorks("workInfoFind", we); Works workList = JsonConvert.DeserializeObject <Works>(result); DataTable dt; dt = new DataTable(); dt.Columns.Add("workDate"); dt.Columns.Add("workTimeS"); dt.Columns.Add("workTimeE"); dt.Columns.Add("workOverTIme"); dt.Columns.Add("status"); var _targerWorkList = workList.workList .Where(w => w.workHour == 0 ).ToList <WorkEntity>(); for (int i = 0; i < _targerWorkList.Count; i++) { WorkEntity item = _targerWorkList[i]; //근무시작시간 DateTime workStart = CDateTime.GetDateFrom_yyyyMMddHHmmss(item.workTimeS); //근무종료시간 DateTime workEnd = CDateTime.GetDateFrom_yyyyMMddHHmmss(item.workTimeE); //야근시간 int overTime = item.workOver * -1; //상태값 String status = ""; switch (item.status) { case "1": status = "처리완료"; break; case "2": status = "반려"; break; default: status = "미처리"; break; } dt.Rows.Add(new string[] { CDateTime.ToYYYYMMDD(item.workDate, true), Convert.ToInt32(item.workTimeS.Substring(8, 2)) + "시 " + Convert.ToInt32(item.workTimeS.Substring(10, 2)) + "분", Convert.ToInt32(item.workTimeE.Substring(8, 2)) + "시 " + Convert.ToInt32(item.workTimeE.Substring(10, 2)) + "분", overTime.ToString() + "분", status }); } ; WorkDataGrid.ItemsSource = dt.DefaultView; } catch { } }
private async void regWorkData(String workDate, String _sDateTime, String _eDateTime) { try { MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow; ClientConfig cf = InitSetting.CConf; //18:00이후 인경우만 처리(저녁) int _dinnerTime = 0; //12:00이후 인경우만 처리 (점심) int _lunchTime = 0; WorkEntity we = new WorkEntity() { id = cf.userID, workDate = workDate }; //저장할 항목 we.workTimeS = _sDateTime; we.workTimeE = _eDateTime; we.dinnerTime = _dinnerTime; we.lunchTime = _lunchTime; DateTime workStart = CDateTime.GetDateFrom_yyyyMMddHHmmss(_sDateTime); DateTime workEnd = CDateTime.GetDateFrom_yyyyMMddHHmmss(_eDateTime); TimeSpan TS = new TimeSpan(workEnd.Ticks - workStart.Ticks); //총근무시간 int spanMinute = (int)TS.TotalMinutes - _dinnerTime - _lunchTime; we.workHour = 0; //야근시간 int overTime = spanMinute * -1; we.workOver = overTime; we.overTimeReason = vacationReason.Text; we.status = "0"; //등록처리 String result = await new CallWebApi().CallPostApiWorks("workInfoAdd", we); var rtn = JsonConvert.DeserializeObject <Dictionary <string, string> >(result); foreach (KeyValuePair <string, string> item in rtn) { if (item.Key.Equals("result") && item.Value.Equals("NG")) { if (window != null) { await window.ShowMessageAsync("알림창", "등록에 실패하였습니다. 관리자에게 문의 부탁드립니다."); } break; } else { if (window != null) { await window.ShowMessageAsync("알림창", "등록었습니다. 승인 후 시간이 반영되어 집니다."); } break; } } GetList(); cf.overtimeReason = ""; } catch { } }