Exemplo n.º 1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     workingDaysHoursService = new WorkingDaysHoursService();
     if (workingDaysHoursService.deleteWorkingDaysHours())
     {
         SuccessMessage sm = new SuccessMessage("All Data Related to Working Days / Hours Deleted!");
         sm.Show();
         btnUpdate.Visible = false;
         btnDelete.Visible = false;
         btnSave.Visible   = true;
         btnClear.Visible  = true;
         clear();
     }
     else
     {
         ErrorMessage em = new ErrorMessage("Ooops...Something went wrong");
         em.Show();
     }
 }
Exemplo n.º 2
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     workingDaysHoursService = new WorkingDaysHoursService();
     if (workingDaysHoursService.deleteWorkingDaysHours())
     {
         SuccessMessage sm = new SuccessMessage("Working-Days And Hours deleted successfully");
         sm.Show();
         btnUpdate.Visible = false;
         btnDelete.Visible = false;
         btnSave.Visible   = true;
         btnClear.Visible  = true;
         clear();
     }
     else
     {
         ErrorMessage em = new ErrorMessage("there is somethin wrong when Working-Days And Hours deleting");
         em.Show();
     }
 }
Exemplo n.º 3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            #region adding validation
            if (numericNoOfDays.Value < 1 ^ numericNoOfDays.Value >= 7)
            {
                numericNoOfDays.Focus();
                errorAddWorkingDays.SetError(numericNoOfDays, "Please Enter Valid No Of Working Days");
            }
            else if (checkBoxMonday.Checked == false & checkBoxTuesday.Checked == false & checkBoxWednesday.Checked == false & checkBoxThursday.Checked == false & checkBoxFriday.Checked == false & checkBoxSaturday.Checked == false & checkBoxSunday.Checked == false)
            {
                ErrorMessage em = new ErrorMessage("Please Select One or More Working Days");
                em.Show();
            }
            else if (numericTPerDayHours.Value < 0 ^ numericTPerDayHours.Value > 24)
            {
                numericTPerDayHours.Focus();
                errorAddWorkingDays.SetError(numericTPerDayHours, "Please Enter Valid No Of Working Hours");
            }
            else if (numericTPerDayMinutes.Value < 0 ^ numericTPerDayMinutes.Value >= 60)
            {
                numericTPerDayMinutes.Focus();
                errorAddWorkingDays.SetError(numericTPerDayMinutes, "Please Enter Valid No Of Working Minutes");
            }
            #endregion
            else
            {
                workingDaysHoursService = new WorkingDaysHoursService();
                WorkingDaysHours workingDaysHoursUpdate = new WorkingDaysHours();

                #region Set Data to Object
                // Set Data to model
                workingDaysHoursUpdate.NoOfWorkingDays = int.Parse(numericNoOfDays.Value.ToString());
                workingDaysHoursUpdate.NoOfHours       = int.Parse(numericTPerDayHours.Value.ToString());
                workingDaysHoursUpdate.NoOfMinutes     = int.Parse(numericTPerDayMinutes.Value.ToString());

                // Check Days Monday
                if (checkBoxMonday.Checked == true)
                {
                    workingDaysHoursUpdate.Monday = 1;
                }
                else
                {
                    workingDaysHoursUpdate.Monday = 0;
                }

                // Check Days Tuesday
                if (checkBoxTuesday.Checked == true)
                {
                    workingDaysHoursUpdate.Tuesday = 1;
                }
                else
                {
                    workingDaysHoursUpdate.Tuesday = 0;
                }

                // Check Days Wednesday
                if (checkBoxWednesday.Checked == true)
                {
                    workingDaysHoursUpdate.Wednesday = 1;
                }
                else
                {
                    workingDaysHoursUpdate.Wednesday = 0;
                }

                // Check Days Thursday
                if (checkBoxThursday.Checked == true)
                {
                    workingDaysHoursUpdate.Thursday = 1;
                }
                else
                {
                    workingDaysHoursUpdate.Thursday = 0;
                }

                // Check Days Friday
                if (checkBoxFriday.Checked == true)
                {
                    workingDaysHoursUpdate.Friday = 1;
                }
                else
                {
                    workingDaysHoursUpdate.Friday = 0;
                }

                // Check Days Saturday
                if (checkBoxSaturday.Checked == true)
                {
                    workingDaysHoursUpdate.Saturday = 1;
                }
                else
                {
                    workingDaysHoursUpdate.Saturday = 0;
                }

                // Check Days Sunday
                if (checkBoxSunday.Checked == true)
                {
                    workingDaysHoursUpdate.Sunday = 1;
                }
                else
                {
                    workingDaysHoursUpdate.Sunday = 0;
                }
                #endregion

                if (workingDaysHoursService.deleteWorkingDaysHours())
                {
                    if (workingDaysHoursService.addWorkingDaysHours(workingDaysHoursUpdate))
                    {
                        SuccessMessage sm = new SuccessMessage("Working Days / Hours Updated Succesfully!");
                        sm.Show();
                    }
                }
                else
                {
                    ErrorMessage em = new ErrorMessage("Ooops...Something went wrong");
                    em.Show();
                }
            }
        }