private bool DataValidation() { DaysTLTP.Hide(MBTN); HoursTLTP.Hide(HoursLBL); var ret = true; if (!_dutyDays.Contains(true)) { DaysTLTP.ToolTipTitle = "Duty Days"; DaysTLTP.Show("Please choose at least one day", MBTN); ret = false; } return(ret); }
private void AddBTN_Click(object sender, EventArgs e) { if (DataValidation()) { if (Button.Equals("ADD")) { var res = Scheduling.AddDutyDetail(Aid, TimeInHrBX.Text, TimeInMinBX.Text, TimeInAMPMBX.Text, TimeOutHrBX.Text, TimeOutMinBX.Text, TimeOutAMPMBX.Text, new Scheduling.Days(_dutyDays[1], _dutyDays[2], _dutyDays[3], _dutyDays[4], _dutyDays[5], _dutyDays[6], _dutyDays[0]), DateEffective.Value, DateDismissedCheck.Checked ? DateDismissed.Value : new DateTime(9999, 12, 31)); if (res.Equals(">")) { HoursTLTP.ToolTipTitle = "Duty Details"; HoursTLTP.Show("The specified schedule overlaps one of the current duty details.", HoursLBL, 2000); } else { Refer.LoadPage(); CloseBTN.Tag = "1"; Close(); } } else if (Button.Equals("UPDATE") && RylMessageBox.ShowDialog("Editing this Duty Details will reset all connected attendance records.\nAre you sure you want to continue?", "Update Duty Details", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { var res = Scheduling.UpdateDutyDetail(Did, TimeInHrBX.Text, TimeInMinBX.Text, TimeInAMPMBX.Text, TimeOutHrBX.Text, TimeOutMinBX.Text, TimeOutAMPMBX.Text, new Scheduling.Days(_dutyDays[1], _dutyDays[2], _dutyDays[3], _dutyDays[4], _dutyDays[5], _dutyDays[6], _dutyDays[0])); if (DateDismissedCheck.Checked && DateEffective.Checked) { Scheduling.UpdateDutyDetailDates(Did, DateEffective.Value, DateDismissed.Value); } if (!DateDismissedCheck.Checked) { Scheduling.CancelDismissal(Did); } if (res.Equals("<")) { if (RylMessageBox.ShowDialog( "The schedule is less than 8hrs. Do you still want to add the details?", "Duty Hours", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { Refer.LoadPage(); CloseBTN.Tag = "1"; Close(); } } else if (res.Equals(">")) { if (RylMessageBox.ShowDialog( "The schedule is more than 8hrs. Do you still want to add the details?", "Duty Hours", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { Refer.LoadPage(); CloseBTN.Tag = "1"; Close(); } } else if (res.Equals("olap")) { HoursTLTP.ToolTipTitle = "Duty Details"; HoursTLTP.Show("The specified schedule overlaps one of the current duty details.", HoursLBL, 2000); } else { Refer.LoadPage(); CloseBTN.Tag = "1"; Close(); } } } }