Exemple #1
0
        /// <summary>
        /// Tries the execute the save command
        /// </summary>
        private void SaveExecute()
        {
            try
            {
                service.AddReport(Report);
                IsUpdateReport = true;

                addReport.Close();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception" + ex.Message.ToString());
            }
        }
 /// <summary>
 /// Method for adding new products
 /// </summary>
 private void SaveExecute()
 {
     try
     {
         Service s          = new Service();
         int     employeeid = LoggedEmployee.ID;
         report.Employee = employeeid;
         report.Position = LoggedEmployee.position;
         s.AddReport(Report);
         isUpdateReport = true;
         addReport.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
        private void SaveExecute()
        {
            try
            {

                if (Report.NumberOfHours==null || Report.NumberOfHours<=0)
                {
                    MessageBox.Show("Number of hours must be greater than 0");
                    return;
                }
               
                List<vwReport> todaysReport =
                    reportService.GetAllReportsOfEmployeeByDate(DateTime.Today, employeeLogedIn);
                double sumOfHours = 0;
                foreach (var rep in todaysReport)
                {
                    if (rep.NumberOfHours!=null)
                    {
                        sumOfHours += (double)rep.NumberOfHours;
                    }
                   
                }

                if (Report.NumberOfHours>12 ||todaysReport.Count > 2 || sumOfHours>12)
                {
                    MessageBox.Show("You are not allowed to add report.\nYou can add two reports in one day and " +
                        "\ntheir sum of hours must be less than 12");
                }
                reportService.AddReport(Report);
                view.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }