Exemple #1
0
        private void ConfirmBTN_Click(object sender, EventArgs e)
        {
            if (NumberOfGuards < _gidS.Length)
            {
                var rs = RylMessageBox.ShowDialog(
                    "The number of guards you've assigned is \n more than what the client requested \n Continue?",
                    "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (rs == DialogResult.Yes)
                {
                    Scheduling.AddAssignment(Rid, _gidS);
                    Close();
                    Refer.Close();
                }
            }
            else if (NumberOfGuards > _gidS.Length)
            {
                var rs = RylMessageBox.ShowDialog("The number of guards you've assigned is not enough. Do you still want to assign the selected guards?", "Warning",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (rs == DialogResult.Yes)
                {
                    Scheduling.AddAssignment(Rid, _gidS);
                    Close();
                    Refer.Close();
                }
            }
            else
            {
                Scheduling.AddAssignment(Rid, _gidS);
                Close();
                Refer.Close();
            }

            RylMessageBox.ShowDialog("The guards selected are now assigned to the clients.", "Assign Guards",
                                     MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemple #2
0
 public static void EditHoliday(int hid, string desc, int type, int trans)
 {
     RylMessageBox.ShowDialog("This function is now deprecated. Use other EditHoliday function instead.", "Warning", MessageBoxButtons.OK);
     //string q = @"UPDATE `msadb`.`holiday` SET `desc`='{0}', type='{2}' where hid='{1}';";
     //q = String.Format(q,  desc, hid, type);
     // SQLTools.ExecuteNonQuery(q);
 }
Exemple #3
0
 private void BonusAddBTN_Click_1(object sender, EventArgs e)
 {
     if (BonusAddBTN.Text.Equals("ADJUST"))
     {
         var view = new PayrollAddAdjustments {
             Pid      = Gid,
             Location = new Point(Location.X + 350, Location.Y),
             Pay      = _pay,
             Refer    = this,
             Period   = "for " + PeriodCMBX.Text
         };
         view.ShowDialog();
     }
     else
     {
         if (RylMessageBox.ShowDialog("Are you sure you want to unapprove this payroll? This will recalculate the values.\nAre you sure you want to continue?", "Unapprove Payroll", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             _pay.RollbackApproval();
             BonusAddBTN.Text = "ADJUST";
             ApproveBTN.Text  = "APPROVE";
             LoadDetails();
             LoadComputations();
         }
     }
 }
Exemple #4
0
 private void ApproveBTN_Click(object sender, EventArgs e)
 {
     if (ApproveBTN.Text.Equals("APPROVE"))
     {
         if (_pay.NetPay < 0)
         {
             RylMessageBox.ShowDialog(
                 "Payroll net pay cannot be negative. Please make necessary adjustments", "Approve Payroll",
                 MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             _pay.Approve();
             LoadDetails();
             LoadComputations();
             CheckButtons();
             Reference.PayLoadEmployeeList();
         }
     }
     else
     {
         try {
             var view = new ReportsPreview {
                 Location      = Location,
                 Names         = EmpListGRD.SelectedRows[0].Cells[1].Value.ToString(),
                 Mode          = 5,
                 Pay           = _pay,
                 PayrollPeriod = PeriodCMBX.Text
             };
             view.ShowDialog();
         }
         catch (Exception exception) { Console.WriteLine(exception); }
     }
 }
Exemple #5
0
 private void SaveBTN_Click(object sender, EventArgs e)
 {
     if (SaveBTN.Text.Equals("SAVE"))
     {
         if (Account.ChangePassword(int.Parse(UsersGRD.SelectedRows[0].Cells[0].Value.ToString()), NewBX.Text.Replace("'", string.Empty),
                                    CurrentBX.Text.Replace("'", string.Empty)))
         {
             Account.ChangeUsername(int.Parse(UsersGRD.SelectedRows[0].Cells[0].Value.ToString()),
                                    UsernameBX.Text.Replace("'", string.Empty));
             LoadUsers();
             CancelBTN.PerformClick();
             RylMessageBox.ShowDialog("Account Details Changed", "Accounts Details",
                                      MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             RylMessageBox.ShowDialog("Current Password is incorrect", "Accounts Details",
                                      MessageBoxButtons.OK, MessageBoxIcon.Error);
             NewBX.Clear();
             CurrentBX.Clear();
         }
     }
     else
     {
         Account.CreateUser(UsernameBX.Text.Replace("'", string.Empty), NewBX.Text.Replace("'", string.Empty), AdminRDBTN.Checked ? 1 : 2);
         LoadUsers();
         CancelBTN.PerformClick();
         RylMessageBox.ShowDialog("User was added", "Users",
                                  MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #6
0
 private void TaxSaveBTN_Click(object sender, EventArgs e)
 {
     if (RylMessageBox.ShowDialog("Are you sure you want to adjust the current Tax rates? Unsaved changes will be lost.",
                                  "Withholding Tax Rates", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         try {
             RatesSaver.CreateWithTaxQuery(TaxDateDTPKR.Value);
             foreach (DataGridViewRow row in TaxExemptionGRD.Rows)
             {
                 var bracket =
                     RatesSaver.CreateWithTaxBracket(
                         double.Parse(row.Cells[1].Value.ToString().Split('+')[0].Trim(' ')),
                         int.Parse(row.Cells[1].Value.ToString().Split('+')[1].Trim(' ').Split('%')[0]));
                 for (var i = 2; i < TaxExemptionGRD.ColumnCount; i++)
                 {
                     RatesSaver.AddToWithTaxQuery(bracket, TaxExemptionGRD.Columns[i].HeaderText,
                                                  double.Parse(row.Cells[i].Value.ToString()));
                 }
             }
             RatesSaver.ExecuteWithTaxQuery();
             TaxEditingMode(false);
             LoadTaxPage();
         }
         catch (Exception ex) {
             ShowErrorBox("Withholding Tax", ex.Message);
         }
     }
 }
Exemple #7
0
 private void MultCancelPendingBTN_Click(object sender, EventArgs e)
 {
     if (RylMessageBox.ShowDialog("Are you sure you want to cancel the pending rates?", "Cancel Rates", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         RatesSaver.DeleteRate(((ComboBoxSss)MultipliersDateCMBX.SelectedItem).Id);
         LoadRatesMult();
     }
 }
Exemple #8
0
 private void CloseBTN_Click(object sender, EventArgs e)
 {
     if (RylMessageBox.ShowDialog("Are you sure you want to stop editing? Unsaved changes will be lost.", "Stop Editing?",
                                  MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         Close();
     }
 }
Exemple #9
0
 private void SSSCancelBTN_Click(object sender, EventArgs e)
 {
     if (RylMessageBox.ShowDialog("Are you sure you want to cancel the pending rates?", "Cancel Rates", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         RatesSaver.DeleteContrib(((ComboBoxSss)SSSDateCMBX.SelectedItem).Id);
         LoadSssPage();
     }
 }
Exemple #10
0
 private void BasicPayCancelBTN_Click(object sender, EventArgs e)
 {
     if (RylMessageBox.ShowDialog("Are you sure you want to cancel the pending rates?", "Cancel Rates", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         RatesSaver.DeleteBasicPay(int.Parse(BasicPayGRD.SelectedRows[0].Cells[0].Value.ToString()));
         LoadBasicPayPage();
     }
 }
Exemple #11
0
 private void TaxCancelBTN_Click(object sender, EventArgs e)
 {
     if (RylMessageBox.ShowDialog("Are you sure you want to cancel the adjustment?",
                                  "Withholding Tax Rates", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         TaxEditingMode(false);
         LoadTaxPage();
     }
 }
Exemple #12
0
 private void MultCancelBTN_Click(object sender, EventArgs e)
 {
     if (RylMessageBox.ShowDialog("Are you sure you want to cancel the adjustment? Unsaved changes will be lost.",
                                  "Rates Multipliers", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         MultEditMode(false);
         LoadRatesMult();
     }
 }
Exemple #13
0
 private void RemoveBTN_Click(object sender, EventArgs e)
 {
     if (RylMessageBox.ShowDialog("Are your sure you want to delete this user?", "Delete User",
                                  MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         Account.DeleteUser(int.Parse(UsersGRD.SelectedRows[0].Cells[0].Value.ToString()));
         LoadUsers();
     }
 }
Exemple #14
0
 private void SSSReset_Click(object sender, EventArgs e)
 {
     if (RylMessageBox.ShowDialog(
             "Are you sure you want to cancel the adjustments on the current SSS Contribution rates? Unsaved changes will be lost.",
             "SSS Contribution", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         LoadSssPage();
         EditingMode(false);
     }
 }
Exemple #15
0
 private void Payroll_ConfigSSS_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (!CloseBTN.Visible &&
         RylMessageBox.ShowDialog(
             "You are still editing. Any unsaved changes will be lost.\nAre you sure you want to close this page?",
             "Cancel Changes?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes ||
         CloseBTN.Visible)
     {
         Refer.Close();
     }
 }
Exemple #16
0
 private void AddBTN_Click(object sender, EventArgs e)
 {
     if (RylMessageBox.ShowDialog("Are you sure you want to adjust the default rates?",
                                  "Default Rates", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         try {
             Payroll.SetBonusDefaults(double.Parse(GlobalPHICBX.Value.ToString("N2")),
                                      double.Parse(GlobalHDMFBX.Value.ToString("N2")),
                                      double.Parse(GlobalCashBondBX.Value.ToString("N2")),
                                      double.Parse(GlobalColaBX.Value.ToString("N2")),
                                      double.Parse(GlobalEmergencyBX.Value.ToString("N2")));
             GlobalCancelBTN.PerformClick();
         }
         catch (Exception ex) {
             ShowErrorBox("Global Rates", ex.Message);
         }
     }
 }
Exemple #17
0
        private void PayslipSaveTo_Click(object sender, EventArgs e)
        {
            var savefile = new SaveFileDialog {
                FileName = "Payslip for " + Names,
                Filter   = "Portable Document Format (.pdf)|*.pdf"
            };

            if (savefile.ShowDialog() == DialogResult.OK)
            {
                try {
                    var r = new Reports();
                    r.ExportToPayslipPDFOne(Payroll.GetApprovedPayrollsList(new int[] { Pay.GID }), savefile.FileName);
                }
                catch {
                    RylMessageBox.ShowDialog("The payslip was not exported.", "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #18
0
 private void Payroll_ConfHolidays_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (!CloseBTN.Visible)
     {
         if (RylMessageBox.ShowDialog("Are you sure you want to stop editing? Unsaved changes will be lost.", "Stop Editing?",
                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
         {
             Refer.Close();
         }
         else
         {
             e.Cancel = true;
         }
     }
     else
     {
         Refer.Close();
     }
 }
Exemple #19
0
 private void MultSaveBTN_Click(object sender, EventArgs e)
 {
     if (RylMessageBox.ShowDialog("Are you sure you want to adjust the current rates multipliers?",
                                  "Rates Multipliers", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         try {
             Payroll.SetRates(MultDTPKR.Value, double.Parse(RatesL2.Value.ToString("N2")),
                              double.Parse(RatesL3.Value.ToString("N2")), double.Parse(RatesL4.Value.ToString("N2")),
                              double.Parse(RatesL5.Value.ToString("N2")),
                              double.Parse(RatesL6.Value.ToString("N2")), double.Parse(RatesL7.Value.ToString("N2")),
                              double.Parse(RatesL8.Value.ToString("N2")), double.Parse(RatesL9.Value.ToString("N2")));
             MultEditMode(false);
             LoadRatesMult();
         }
         catch (Exception ex) {
             ShowErrorBox("Rates Multipliers", ex.Message);
         }
     }
 }
Exemple #20
0
 private void Clients_Edit_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape)
     {
         if (IsEmpty() == false)
         {
             var rs = RylMessageBox.ShowDialog("Cancel Chnages? \nAny unsaved changes will be lost.",
                                               "Stop Editing?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (rs == DialogResult.Yes)
             {
                 Close();
             }
         }
         else
         {
             Close();
         }
     }
 }
Exemple #21
0
        private void DismissBTN_Click(object sender, EventArgs e)
        {
            if (DataValidation())
            {
                var giDs = new int[GuardsGRD.RowCount];
                for (var i = 0; i < GuardsGRD.RowCount; i++)
                {
                    giDs[i] = int.Parse(GuardsGRD.Rows[i].Cells[0].Value.ToString());
                }

                if (EnableIncidentCHKBX.Checked)
                {
                    Scheduling.AddUnassignmentRequest(Cid, giDs, IncidentTypeCMBX.SelectedIndex, Login.UserName,
                                                      DateDTPKR.Value,
                                                      LocationBX.Text.Replace("'", string.Empty), DescriptionBX.Text.Replace("'", string.Empty),
                                                      DateEffective.Value);

                    try {
                        _iid = int.Parse(SQLTools.getLastInsertedId("IncidentReport", "IID"));
                    }
                    catch { }
                    try {
                        foreach (DataGridViewRow row in DepsGRD.Rows)
                        {
                            InsertDependent(GetRelationshipIndex(row.Cells[4].Value.ToString()),
                                            row.Cells[1].Value.ToString().Replace("'", string.Empty),
                                            row.Cells[2].Value.ToString().Replace("'", string.Empty),
                                            row.Cells[3].Value.ToString().Replace("'", string.Empty));
                        }
                    }
                    catch { }
                }
                else
                {
                    Scheduling.AddUnassignmentRequestNoIncident(Cid, giDs, DateEffective.Value);
                }
                RylMessageBox.ShowDialog("Your Request has been added", "Request Added", MessageBoxButtons.OK,
                                         MessageBoxIcon.Information);
                Reference.SchedLoadSidePnl();
                Close();
            }
        }
Exemple #22
0
        private void LoadData() {
            try {
                var data = Scheduling.GetIncidentReport(Rid);
                if (data.Rows[0][0].ToString().Equals("")) {
                    RylMessageBox.ShowDialog("No Incident Report found", "Incident Report", MessageBoxButtons.OK,
                        MessageBoxIcon.Information);
                    Close();
                }
                TypeDateLBL.Text = "Type: " + data.Rows[0][0] + "          Event Date: " + data.Rows[0][1];
                LocationLBL.Text = data.Rows[0][2].ToString();
                DescriptionBX.Text = data.Rows[0][3].ToString();

                CertifiersGRD.DataSource = Scheduling.GetIncidentInvolved(Rid);
                CertifiersGRD.Columns[0].Width = 270;
                CertifiersGRD.Columns[1].Width = 100;
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #23
0
        private bool DataValidation()
        {
            var ret = true;

            if (GuardsGRD.RowCount == 0)
            {
                RylMessageBox.ShowDialog("There are no guards to be dismissed \nThis request will be canceled",
                                         "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
                GuardsPNL.Show();
                ReportPNL.Hide();
                GuardsLBL.ForeColor = _dark;
                ReportLBL.ForeColor = _light;
                ret = false;
            }
            if (EnableIncidentCHKBX.Checked)
            {
                if (LocationBX.Text.Equals(""))
                {
                    ShowToolTipOnBx(LocationTLTP, "Event Location", "Where did this incident happen?", LocationBX);
                    ret = false;
                }
                if (DescriptionBX.Text.Equals(""))
                {
                    ShowToolTipOnBx(DescriptionTLTP, "Event Description", "What happened in this incident?",
                                    DescriptionBX);
                    ret = false;
                }
                if (!ret)
                {
                    GuardsPNL.Hide();
                    ReportPNL.Show();
                    GuardsLBL.ForeColor = _light;
                    ReportLBL.ForeColor = _dark;
                }
            }
            return(ret);
        }
Exemple #24
0
 private void SSSSaveBTN_Click(object sender, EventArgs e)
 {
     if (SSSGRD.Rows.Count == 0)
     {
         RylMessageBox.ShowDialog("You don't have any rates configured",
                                  "SSS Contribution", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         if (RylMessageBox.ShowDialog("Are you sure you want to adjust the current SSS Contribution rates?",
                                      "SSS Contribution", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             try {
                 Payroll.SetSssContrib(SSSGRD, SSSDateTimePKR.Value);
                 LoadSssPage();
                 EditingMode(false);
             }
             catch (Exception ex) {
                 ShowErrorBox("SSS Contribution", ex.Message);
             }
         }
     }
 }
Exemple #25
0
 private void AddBTN_Click(object sender, EventArgs e)
 {
     if (DataValidation())
     {
         if (_cid.Equals("-1"))
         {
             RylMessageBox.ShowDialog("Please select a client", "Request a guard", MessageBoxButtons.OK,
                                      MessageBoxIcon.Error);
         }
         else
         {
             Scheduling.AddAssignmentRequest(int.Parse(_cid), AssStreetNoBX.Text.Replace("'", string.Empty), AssStreetNameBX.Text.Replace("'", string.Empty),
                                             AssBrgyBX.Text.Replace("'", string.Empty), AssCityBX.Text.Replace("'", string.Empty), ContractStartDTPKR.Value, ContractEndDTPKR.Value,
                                             (int)NeededBX.Value);
             Reference.SchedLoadPage();
             RylMessageBox.ShowDialog("Your request is now pending for approval",
                                      "Request Added",
                                      MessageBoxButtons.OK, MessageBoxIcon.Information
                                      );
             Close();
         }
     }
 }
Exemple #26
0
        private void RefreshData()
        {
            if (_attendance.GetAttendance_View().Rows.Count > 0)
            {
                foreach (DataRow row in _attendance.GetAttendance().Rows)
                {
                    DaysGRD.Rows.Add(row[0], row[2], row[5].ToString().Split(':')[0], ":",
                                     row[5].ToString().Split(':')[1].Split(' ')[0], row[5].ToString().Split(':')[1].Split(' ')[1],
                                     row[6].ToString().Split(':')[0], ":", row[6].ToString().Split(':')[1].Split(' ')[0],
                                     row[6].ToString().Split(':')[1].Split(' ')[1], "0");
                }
                DaysGRD.CurrentCell = DaysGRD.Rows[0].Cells[1];
            }
            try {
                CertifiedByCMBX.Items.Clear();
                var dv = Client.GetCertifiers(_attendance.CID);

                for (var i = 0; i < dv.Rows.Count; i++)
                {
                    CertifiedByCMBX.Items.Add(
                        new ComboBoxItem(dv.Rows[i][4] + ", " + dv.Rows[i][2] + " " + dv.Rows[i][3], dv.Rows[i][0].ToString()));
                }

                if (CertifiedByCMBX.Items.Count == 0)
                {
                    RylMessageBox.ShowDialog(
                        "There are no certifiers added for this client. Please add a certifier before adding an attendance.",
                        "No Certifiers Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    Close();
                }
            }
            catch (Exception ex) {
                Console.Write(ex.Message);
            }

            CertifiedByCMBX.Text = _attendance.GetCertifiedBy();
        }
Exemple #27
0
 private static void ShowErrorBox(string name, string error)
 {
     RylMessageBox.ShowDialog("Please try again.\nIf the problem still persist, please contact your administrator. \n\n\nError Message: \n=============================\n" + error + "\n=============================\n", "Error Configuring " + name,
                              MessageBoxButtons.OK, MessageBoxIcon.Error);
 }
Exemple #28
0
        private void AddBTN_Click(object sender, EventArgs e)
        {
            try {
                bool[] changes    = { false, false, false, false, false };
                var    changeText = "Are you sure you want to change these values?\n";
                if (!_data["thirteen"].ToString("N2").Equals(ThirteenBX.Value.ToString("N2")))
                {
                    changes[0]  = true;
                    changeText += "Thirteenth Month Pay: " + _data["thirteen"].ToString("N2") + " to " +
                                  ThirteenBX.Value.ToString("N2") + "\n";
                }

                if (!_data["Cola"].ToString("N2").Equals(ColaBX.Value.ToString("N2")))
                {
                    changes[1]  = true;
                    changeText += "Cola: " + _data["Cola"].ToString("N2") + " to " + ColaBX.Value.ToString("N2") + "\n";
                }

                if (!_data["Emergency"].ToString("N2").Equals(EmergencyBX.Value.ToString("N2")))
                {
                    changes[2]  = true;
                    changeText += "Emergency: " + _data["Emergency"].ToString("N2") + " to " +
                                  EmergencyBX.Value.ToString("N2") + "\n";
                }

                if (!_data["CashBonds"].ToString("N2").Equals(BondsBX.Value.ToString("N2")))
                {
                    changes[3]  = true;
                    changeText += "Cash Bonds: " + _data["CashBonds"].ToString("N2") + " to " +
                                  BondsBX.Value.ToString("N2") + "\n";
                }

                if (!_data["CashAdv"].ToString("N2").Equals(AdvBX.Value.ToString("N2")))
                {
                    changes[4]  = true;
                    changeText += "Cash Advance: " + _data["CashAdv"].ToString("N2") + " to " +
                                  AdvBX.Value.ToString("N2");
                }
                if (!changeText.Equals("Are you sure you want to change these values?"))
                {
                    if (RylMessageBox.ShowDialog(changeText, "Confirm Chnages", MessageBoxButtons.YesNo,
                                                 MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        if (changes[0])
                        {
                            Pay.ThirteenthMonthPay = double.Parse(ThirteenBX.Value.ToString("N2"));
                        }
                        if (changes[1])
                        {
                            Pay.Cola = double.Parse(ColaBX.Value.ToString("N2"));
                        }
                        if (changes[2])
                        {
                            Pay.EmergencyAllowance = double.Parse(EmergencyBX.Value.ToString("N2"));
                        }
                        if (changes[3])
                        {
                            Pay.CashBond = double.Parse(BondsBX.Value.ToString("N2"));
                        }
                        if (changes[4])
                        {
                            Pay.CashAdvance = double.Parse(AdvBX.Value.ToString("N2"));
                        }
                        Refer.LoadAjustments();
                        CloseBTN.Tag = "1";
                        Close();
                    }
                }
                else
                {
                    RylMessageBox.ShowDialog("No Changes", "There are no changes to commit", MessageBoxButtons.OK,
                                             MessageBoxIcon.Information);
                }
            }
            catch (Exception ex) {
                ShowErrorBox("Adjustments", ex.Message);
            }
        }
Exemple #29
0
 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();
             }
         }
     }
 }