private void AddJob()
        {
            if (listBoxAllJobs.SelectedItem == null)
            {
                return;
            }
            double?payRate = PosDialogWindow.PromptCurrency(Strings.EmployeeJobEditorPayRate, 0.0);

            if (payRate == null)
            {
                return;
            }
            FormattedListBoxItem item = listBoxAllJobs.SelectedItem as FormattedListBoxItem;

            if (item != null)
            {
                EmployeeJob job = item.ReferenceObject as EmployeeJob;
                if (job != null)
                {
                    EmployeePayRate rate =
                        EmployeePayRate.Add(SelectedEmployee.Id, job.Id, payRate.Value, 0);
                    listBoxAllJobs.Items.Remove(listBoxAllJobs.SelectedItem);
                    item = GetJobListBoxItem(job, rate);
                    listBoxSelectedJobs.Items.Add(item);
                    listBoxSelectedJobs.SelectedItem = item;
                    listBoxSelectedJobs.ScrollToEnd();
                }
            }
            buttonAdd.IsEnabled    = false;
            buttonRemove.IsEnabled = true;
        }
Beispiel #2
0
        public int AddPayEmployeePayRate(EmployeePayRate employeePayRate)
        {
            int returnValue = 0;

            try
            {
                var           connectionString = ConfigurationManager.AppSettings["PayMe-Connectionstring"];
                SqlConnection connection       = new SqlConnection(connectionString);
                SqlCommand    cmd = new SqlCommand("AddEmployeePayRate", connection);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@EmployeeID", employeePayRate.ID);
                cmd.Parameters.AddWithValue("@StartDate", employeePayRate.StartDate);
                cmd.Parameters.AddWithValue("@EndDate", employeePayRate.EndDate);
                cmd.Parameters.AddWithValue("@PayRateID", employeePayRate.PayRateTypeID);
                cmd.Parameters.AddWithValue("@RegularRate", employeePayRate.RegularRate);
                cmd.Parameters.AddWithValue("@OTRate", employeePayRate.OTRate);
                connection.Open();
                cmd.ExecuteNonQuery();
                connection.Close();
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message.ToString());
            }
            return(returnValue);
        }
Beispiel #3
0
        public ActionResult AddPayRate(EmployeePayRate collection)
        {
            UserManager userManager = new UserManager();

            userManager.AddPayEmployeePayRate(collection);
            //TempData["Message"] = "Pay Rate Added Successfully";
            return(RedirectToAction("edit", "Employee", new { id = collection.ID }));
            //return RedirectToAction("/Employee/"+ collection.ID);
        }
        private void EditEmployeePayRate()
        {
            double?payRate = PosDialogWindow.PromptCurrency(Strings.EmployeeJobEditorPayRate, 0.0);

            if (payRate != null)
            {
                FormattedListBoxItem item = listBoxSelectedJobs.SelectedItem as FormattedListBoxItem;
                if (item != null)
                {
                    EmployeeJob     job  = item.ReferenceObject as EmployeeJob;
                    EmployeePayRate rate =
                        EmployeePayRate.GetEmployeePayRateForJob(SelectedEmployee.Id, job.Id);
                    rate.SetWage(payRate.Value);
                    rate.Update();
                    item.Set(job, job.Description + Environment.NewLine +
                             rate.Wage.ToString("C2"));
                }
            }
        }
        private void InitializeJobsList()
        {
            List <EmployeeJob> employeeJobs = new List <EmployeeJob>(SelectedEmployee.GetJobs());
            List <EmployeeJob> filterList   = (
                from job in EmployeeJob.GetAll()
                let found = employeeJobs.Any(employeeJob => employeeJob.Id == job.Id)
                            where !found select job).ToList();

            foreach (FormattedListBoxItem item in filterList
                     .Select(job => new FormattedListBoxItem(job, job.Description, true)))
            {
                listBoxAllJobs.Items.Add(item);
            }
            foreach (FormattedListBoxItem item in
                     from employeeJob in employeeJobs
                     let pay = EmployeePayRate.GetEmployeePayRateForJob(SelectedEmployee.Id, employeeJob.Id)
                               select GetJobListBoxItem(employeeJob, pay))
            {
                listBoxSelectedJobs.Items.Add(item);
            }
        }
Beispiel #6
0
 public IEnumerable <EmployeePayRate> GetPayrateByEmployeeID(int id)
 {
     try
     {
         var           connectionString = ConfigurationManager.AppSettings["PayMe-Connectionstring"];
         SqlConnection connection       = new SqlConnection(connectionString);
         SqlCommand    cmd = new SqlCommand("GetPayRateByEmployeeID", connection);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@EmployeeID", id);
         connection.Open();
         SqlDataReader          reader = cmd.ExecuteReader();
         List <EmployeePayRate> EmployeePayRateList = new List <EmployeePayRate>();
         if (reader.HasRows)
         {
             while (reader.Read())
             {
                 EmployeePayRate employeePayRate = new EmployeePayRate();
                 employeePayRate.ID            = Convert.ToInt32(reader["ID"].ToString());
                 employeePayRate.EmployeeID    = Convert.ToInt32(reader["EmployeeID"].ToString());
                 employeePayRate.StartDate     = Convert.ToDateTime(reader["StartDate"].ToString());
                 employeePayRate.EndDate       = Convert.ToDateTime(reader["EndDate"].ToString());
                 employeePayRate.PayRateTypeID = Convert.ToInt32(reader["PayRateTypeID"].ToString());
                 employeePayRate.RegularRate   = Convert.ToDecimal(reader["RegularRate"] == DBNull.Value ? 0 : reader["RegularRate"]);
                 employeePayRate.OTRate        = Convert.ToDecimal(reader["OTRate"] == DBNull.Value ? 0 : reader["OTRate"]);
                 employeePayRate.Name          = reader["Name"].ToString();
                 EmployeePayRateList.Add(employeePayRate);
             }
         }
         reader.Close();
         connection.Close();
         return(EmployeePayRateList);
     }
     catch (Exception ex)
     {
         throw new ApplicationException(ex.Message.ToString());
     }
 }
        private void RemoveJob()
        {
            if (listBoxSelectedJobs.SelectedItem == null)
            {
                return;
            }
            FormattedListBoxItem item = listBoxSelectedJobs.SelectedItem as FormattedListBoxItem;

            if (item != null)
            {
                EmployeeJob job = item.ReferenceObject as EmployeeJob;
                if (job != null)
                {
                    EmployeePayRate.Delete(SelectedEmployee.Id, job.Id);
                    listBoxSelectedJobs.Items.Remove(listBoxSelectedJobs.SelectedItem);
                    item = new FormattedListBoxItem(job, job.Description, true);
                    listBoxAllJobs.Items.Add(item);
                    listBoxAllJobs.SelectedItem = item;
                    listBoxAllJobs.ScrollToEnd();
                }
            }
            buttonRemove.IsEnabled = false;
            buttonAdd.IsEnabled    = true;
        }
 private FormattedListBoxItem GetJobListBoxItem(EmployeeJob employeeJob, EmployeePayRate pay)
 {
     return(new FormattedListBoxItem(employeeJob,
                                     employeeJob.Description + Environment.NewLine +
                                     pay.Wage.ToString("C2"), true));
 }