public DataTable getDailyTimeRecordByDate(string pEmployeeNo, DateTime pFromDate, DateTime pToDate) { return(loDailyTimeRecord.getDailyTimeRecordByDate(pEmployeeNo, pFromDate, pToDate)); }
private void btnSave_Click(object sender, EventArgs e) { try { if (dtpStartDate.Value.Date < _StarDate.Date || dtpStartDate.Value.Date > _EndDate.Date) { MessageBoxUI _mb = new MessageBoxUI("Start Date must be within Date Range!", GlobalVariables.Icons.Warning, GlobalVariables.Buttons.OK); _mb.showDialog(); dtpStartDate.Focus(); return; } if (dtpEndDate.Value.Date > _EndDate.Date || dtpEndDate.Value.Date < _StarDate.Date) { MessageBoxUI _mb = new MessageBoxUI("End Date must be within Date Range!", GlobalVariables.Icons.Warning, GlobalVariables.Buttons.OK); _mb.showDialog(); dtpEndDate.Focus(); return; } if (dtpEndDate.Value.Date < dtpStartDate.Value.Date) { MessageBoxUI _mb = new MessageBoxUI("End Date must not be lesser than Start Date!", GlobalVariables.Icons.Warning, GlobalVariables.Buttons.OK); _mb.showDialog(); dtpEndDate.Focus(); return; } if (dtpStartDate.Value.Date > dtpEndDate.Value.Date) { MessageBoxUI _mb = new MessageBoxUI("Start Date must not be greater than End Date!", GlobalVariables.Icons.Warning, GlobalVariables.Buttons.OK); _mb.showDialog(); dtpStartDate.Focus(); return; } string _shiftSchedule = ""; if (chkBreak.Checked) { _shiftSchedule = string.Format("{0:hh:mm tt}", dtpTimeIn.Value) + ";" + string.Format("{0:hh:mm tt}", dtpBreakOut.Value) + ";" + string.Format("{0:hh:mm tt}", dtpBreakIn.Value) + ";" + string.Format("{0:hh:mm tt}", dtpTimeOut.Value) + ";ND=" + (chkNextDay.Checked ? "Y" : "N"); } else { _shiftSchedule = string.Format("{0:hh:mm tt}", dtpTimeIn.Value) + ";;;" + string.Format("{0:hh:mm tt}", dtpTimeOut.Value) + ";ND=" + (chkNextDay.Checked ? "Y" : "N"); } loDailyTimeRecord.updateDTRShiftSchedule(_EmployeeNo, dtpStartDate.Value, dtpEndDate.Value, _shiftSchedule); #region "UPDATE DTR TI,BO,BI,TO" foreach (DataRow _drDTR in loDailyTimeRecord.getDailyTimeRecordByDate(_EmployeeNo, dtpStartDate.Value, dtpEndDate.Value).Rows) { try { if (_drDTR["RawDTR"].ToString() != "") { string[] _dtr = _drDTR["RawDTR"].ToString().Split(';'); foreach (string dtr in _dtr) { string[] _shift = _drDTR["ShiftSchedule"].ToString().Split(';'); string _shiftTI = ""; string _shiftBO = ""; string _shiftBI = ""; string _shiftTO = ""; try { _shiftTI = _shift[0]; _shiftBO = _shift[1]; _shiftBI = _shift[2]; _shiftTO = _shift[3]; } catch { continue; } if (dtr != "") { string[] _raw = dtr.Split('='); if (_raw[0].ToString() == "TI") { insertTimeIn(_drDTR["DailyTimeRecordId"].ToString(), _raw[1].ToString()); string _late1 = "00:00"; try { _late1 = string.Format("{0:HH:mm}", DateTime.Parse(DateTime.Parse(_raw[1].ToString()).TimeOfDay.Subtract(DateTime.Parse(_shiftTI).TimeOfDay).ToString())); } catch { _late1 = "00:00"; } if (_late1 != "00:00") { insertLate1(_drDTR["DailyTimeRecordId"].ToString(), _late1); } } else if (_raw[0].ToString() == "BO") { insertBreakOut(_drDTR["DailyTimeRecordId"].ToString(), _raw[1].ToString()); string _undertime1 = "00:00"; try { _undertime1 = string.Format("{0:HH:mm}", DateTime.Parse(DateTime.Parse(_shiftBO).TimeOfDay.Subtract(DateTime.Parse(_raw[1].ToString()).TimeOfDay).ToString())); } catch { _undertime1 = "00:00"; } if (_undertime1 != "00:00") { insertUndertime1(_drDTR["DailyTimeRecordId"].ToString(), _undertime1); } } else if (_raw[0].ToString() == "BI") { /*if (_drDTR["BreakIn"].ToString() == "") * { * foreach (DataRow _drEmpDTR in loDailyTimeRecord.getDailyTimeRecord(_EmployeeNo, DateTime.Parse(_drDTR["Date"].ToString())).Rows) * { * if (_drEmpDTR["BreakIn"].ToString() == "") * {*/ insertBreakIn(_drDTR["DailyTimeRecordId"].ToString(), _raw[1].ToString()); string _late2 = "00:00"; try { _late2 = string.Format("{0:HH:mm}", DateTime.Parse(DateTime.Parse(_raw[1].ToString()).TimeOfDay.Subtract(DateTime.Parse(_shiftBI).TimeOfDay).ToString())); } catch { _late2 = "00:00"; } if (_late2 != "00:00") { insertLate2(_drDTR["DailyTimeRecordId"].ToString(), _late2); } /*} * } * }*/ } else if (_raw[0].ToString() == "TO") { insertTimeOut(_drDTR["DailyTimeRecordId"].ToString(), _raw[1].ToString()); string _undertime2 = "00:00"; try { _undertime2 = string.Format("{0:HH:mm}", DateTime.Parse(DateTime.Parse(_shiftTO).TimeOfDay.Subtract(DateTime.Parse(_raw[1].ToString()).TimeOfDay).ToString())); } catch { _undertime2 = "00:00"; } if (_undertime2 != "00:00") { insertUndertime2(_drDTR["DailyTimeRecordId"].ToString(), _undertime2); } } } } } } catch { continue; } } #endregion "" _lFromSave = true; MessageBoxUI _mb1 = new MessageBoxUI("Shift Schedule has been successfully changed!", GlobalVariables.Icons.Save, GlobalVariables.Buttons.OK); _mb1.showDialog(); this.Close(); } catch { } }