Example #1
0
        public int Workload_Insert(WorkloadModel wm)
        {
            try
            {
                using (var con = GetDbConnection())
                {
                    var retValue = con.ExecuteScalar <int>("dbo.Usp_Workload_Insert",
                                                           new
                    {
                        @iIntEmployeeId    = wm.EmployeeId,
                        @iIntSemesterId    = wm.SemesterId,
                        @iStrDayOfWork     = wm.DayOfWork,
                        @iTmTimeInAM       = wm.TimeInAM == TimeSpan.Zero ? null : wm.TimeInAM,
                        @iTmTimeOutAM      = wm.TimeOutAM == TimeSpan.Zero ? null : wm.TimeOutAM,
                        @iTmTimeInPM       = wm.TimeInPM == TimeSpan.Zero ? null: wm.TimeInPM,
                        @iTmTimeOutPM      = wm.TimeOutPM == TimeSpan.Zero ? null : wm.TimeOutPM,
                        @iTmTimeInEvening  = wm.TimeInEvening == TimeSpan.Zero ? null : wm.TimeInEvening,
                        @iTmTimeOutEvening = wm.TimeOutEvening == TimeSpan.Zero ? null : wm.TimeOutEvening
                    }, commandType: CommandType.StoredProcedure);

                    return(retValue);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #2
0
 public void Workload_Update(WorkloadModel wm)
 {
     try
     {
         using (var con = GetDbConnection())
         {
             con.Execute("dbo.Usp_Workload_Update",
                         new
             {
                 @iIntWorkloadId    = wm.WorkloadId,
                 @iIntEmployeeId    = wm.EmployeeId,
                 @iIntSemesterId    = wm.SemesterId,
                 @iStrDayOfWork     = wm.DayOfWork,
                 @iTmTimeInAM       = wm.TimeInAM == TimeSpan.Zero ? null : wm.TimeInAM,
                 @iTmTimeOutAM      = wm.TimeOutAM == TimeSpan.Zero ? null : wm.TimeOutAM,
                 @iTmTimeInPM       = wm.TimeInPM == TimeSpan.Zero ? null : wm.TimeInPM,
                 @iTmTimeOutPM      = wm.TimeOutPM == TimeSpan.Zero ? null : wm.TimeOutPM,
                 @iTmTimeInEvening  = wm.TimeInEvening == TimeSpan.Zero ? null : wm.TimeInEvening,
                 @iTmTimeOutEvening = wm.TimeOutEvening == TimeSpan.Zero ? null : wm.TimeOutEvening
             }, commandType: CommandType.StoredProcedure);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Example #3
0
 public int Workload_Insert(WorkloadModel wm)
 {
     return(_repo.Workload_Insert(wm));
 }
Example #4
0
 public void Workload_Update(WorkloadModel wm)
 {
     _repo.Workload_Update(wm);
 }
        private void bttnSave_Click(object sender, EventArgs e)
        {
            int result;

            if (employeeId < 1)
            {
                ShowMessage.CustomErrorMessage("Employee not selected. Select employee first.");
                this.Close();
            }
            else if (semesterId < 1)
            {
                ShowMessage.CustomErrorMessage("Semester not selected. Select semester first.");
                this.Close();
            }
            else if (Validation.IsComboEmpty(cmbDay))
            {
                Validation.FocusComboBox(cmbDay, "Day of Week");
                return;
            }
            else if (!chkAM.Checked && (dtTimeInAM.Value > dtTimeOutAM.Value))
            {
                ShowMessage.CustomErrorMessage("Time-In AM must be greater than Time-Out AM");
                dtTimeOutAM.Focus();
            }
            else if (!chkPM.Checked && (dtTimeInPM.Value > dtTimeOutPM.Value))
            {
                ShowMessage.CustomErrorMessage("Time-In PM must be greater than Time-Out PM");
                dtTimeInPM.Focus();
            }
            else
            {
                WorkloadModel md = new WorkloadModel {
                    DayOfWork      = cmbDay.Text,
                    EmployeeId     = employeeId,
                    SemesterId     = semesterId,
                    TimeInAM       = chkAM.Checked ? TimeSpan.Zero : dtTimeInAM.Value.TimeOfDay,
                    TimeOutAM      = chkAM.Checked ? TimeSpan.Zero : dtTimeOutAM.Value.TimeOfDay,
                    TimeInPM       = chkPM.Checked ? TimeSpan.Zero : dtTimeInPM.Value.TimeOfDay,
                    TimeOutPM      = chkPM.Checked ? TimeSpan.Zero : dtTimeOutPM.Value.TimeOfDay,
                    TimeInEvening  = chkEvening.Checked ? TimeSpan.Zero : dtTimeInEvening.Value.TimeOfDay,
                    TimeOutEvening = chkEvening.Checked ? TimeSpan.Zero : dtTimeOutEvening.Value.TimeOfDay
                };

                if (ADD_STATE)
                {
                    result = svc.Workload_Insert(md);
                    if (result > 0)
                    {
                        ShowMessage.ShowMessageBox(1);
                        this.Close();
                    }
                    else if (result == -1)
                    {
                        ShowMessage.ShowMessageBox(4);
                    }
                    else
                    {
                        ShowMessage.ShowMessageBox(3);
                    }
                }
                else
                {
                    md.WorkloadId = workloadId;
                    svc.Workload_Update(md);
                    ShowMessage.ShowMessageBox(2);
                    this.Close();
                }
            }
        }