Example #1
0
        private async void setLeftTime()
        {
            WorkEntity we = new WorkEntity()
            {
                id = cf.userID
            };

            String result    = await new CallWebApi().CallPostApiWorks("workInfoFind", we);
            Works  workList  = JsonConvert.DeserializeObject <Works>(result);
            int    _leftTime = 0;

            //같은 날자에 등록되어 있는 자료가 있음.
            if (workList.workList.Count > 0)
            {
                var totalWorkHour = workList.workList.Where(w => w.workOver != 0)
                                    .GroupBy(g => g.id)
                                    .Select(s => new
                {
                    totalHour = s.Sum(x => x.workOver)
                });


                if (totalWorkHour.Count() > 0)
                {
                    foreach (var item in totalWorkHour)
                    {
                        _leftTime = item.totalHour;
                    }
                }
            }

            leftTime.Content       = _leftTime + "분 사용가능";
            _leftTimeCheck.Content = _leftTime;
        }
Example #2
0
        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;
            }
        }
Example #3
0
        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 { }
        }
Example #4
0
        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
            {
            }
        }
Example #5
0
        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("관리자에게 문의 부탁드립니다.");
            }
        }
Example #6
0
        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 { }
        }