Ejemplo n.º 1
0
 public AddEditPayRateForm(EmployeeAddEditForm parentForm, PayRate currPayRate, bool isEdit)
 {
     this.parentForm = parentForm;
     this.currPayRate = currPayRate;
     this.isEdit = isEdit;
     InitializeComponent();
 }
Ejemplo n.º 2
0
 public AddEditPayRateForm(EmployeeAddEditForm parentForm, List<Job> alreadyAssignedJobList, PayRate currPayRate, bool isEdit)
 {
     this.alreadyAssignedJobList = alreadyAssignedJobList;
     this.parentForm = parentForm;
     this.currPayRate = currPayRate;
     this.isEdit = isEdit;
     InitializeComponent();
 }
Ejemplo n.º 3
0
        public bool editPayRate(PayRate p)
        {
            for (int i = 0; i < this.empJobDataGridView.Rows.Count; i++)
            {
                if (p.Job.JobName.Equals(this.empJobDataGridView.Rows[i].Cells[2].Value.ToString()) &&
                    p.Job.RefCode.Equals(this.empJobDataGridView.Rows[i].Cells[3].Value.ToString()))
                {
                    this.empJobDataGridView.Rows[i].Cells[4].Value = p.Active;
                    this.empJobDataGridView.Rows[i].Cells[5].Value = String.Format("{0:0.00}",p.HourlyPayRate);
                }
            }

            for (int i = 0; i < this.currEmp.PayRateList.Count; i++)
            {
                if (p.Job.JobName == this.currEmp.PayRateList[i].Job.JobName && p.Job.RefCode == this.currEmp.PayRateList[i].Job.RefCode)
                {
                    this.currEmp.PayRateList[i].Active = p.Active;
                    this.currEmp.PayRateList[i].HourlyPayRate = p.HourlyPayRate;
                }

            }

            return true;
        }
Ejemplo n.º 4
0
        private void updatePayRate(Employee emp, PayRate p)
        {
            using (SqlConnection conn = DBUtils.getConnection("MCLabor"))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand("UPDATE PAY_RATE " +
                                                       "SET employeeId = @employeeId, jobId = @jobId, hourlyPayRate = @hourlyPayRate, active = @active " +
                                                       "WHERE payRateId = @payRateId", conn))
                {
                    cmd.Parameters.AddWithValue("@employeeId", emp.EmployeeId);
                    cmd.Parameters.AddWithValue("@jobId", p.Job.JobId);
                    cmd.Parameters.AddWithValue("@hourlyPayRate", p.HourlyPayRate);
                    cmd.Parameters.AddWithValue("@active", p.Active);
                    cmd.Parameters.AddWithValue("@payRateId", p.PayRateId);

                    cmd.ExecuteNonQuery();
                }
            }
        }
Ejemplo n.º 5
0
 public void addPayRate(PayRate p)
 {
     this.currEmp.PayRateList.Add(p);
     this.empJobDataGridView.Rows.Add(new Object[] { -1, p.Job.JobId, p.Job.JobName, p.Job.RefCode, p.Active, String.Format("{0:0.00}",p.HourlyPayRate) });
 }
Ejemplo n.º 6
0
        private int insertNewPayRate(Employee emp, PayRate p)
        {
            using (SqlConnection conn = DBUtils.getConnection("MCLabor"))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand("INSERT INTO PAY_RATE (employeeId, jobId, hourlyPayRate, active) " +
                                                       "VALUES (@employeeId, @jobId, @hourlyPayRate, @active); " +
                                                       "SELECT cast(Scope_Identity() as int)", conn))
                {
                    cmd.Parameters.AddWithValue("@employeeId", emp.EmployeeId);
                    cmd.Parameters.AddWithValue("@jobId", p.Job.JobId);
                    cmd.Parameters.AddWithValue("@hourlyPayRate", p.HourlyPayRate);
                    cmd.Parameters.AddWithValue("@active", p.Active);

                    return (int)cmd.ExecuteScalar();
                }
            }
        }
Ejemplo n.º 7
0
        private void editPayRateBtn_Click(object sender, EventArgs e)
        {
            PayRate currSelectedPayRate = new PayRate();

            if(this.empJobDataGridView.SelectedRows.Count > 1)
            {
                MessageBox.Show("Please select just one job record to edit.", "Invalid Input");
            }
            else if (this.empJobDataGridView.SelectedRows.Count < 1)
            {
                MessageBox.Show("Please select a job record to edit.", "Invalid Input");
            }
            else
            {

                if (this.empJobDataGridView.SelectedRows[0].Cells[0].Value != null)
                {
                    currSelectedPayRate.PayRateId = (int)this.empJobDataGridView.SelectedRows[0].Cells[0].Value;
                }

                if (this.empJobDataGridView.SelectedRows[0].Cells[1].Value != null)
                {
                    currSelectedPayRate.Job.JobId = (int)this.empJobDataGridView.SelectedRows[0].Cells[1].Value;
                }

                currSelectedPayRate.Job.JobName = this.empJobDataGridView.SelectedRows[0].Cells[2].Value.ToString();
                currSelectedPayRate.Job.RefCode = this.empJobDataGridView.SelectedRows[0].Cells[3].Value.ToString();
                currSelectedPayRate.Active = (bool)this.empJobDataGridView.SelectedRows[0].Cells[4].Value;
                currSelectedPayRate.HourlyPayRate = Decimal.Parse(this.empJobDataGridView.SelectedRows[0].Cells[5].Value.ToString());

                AddEditPayRateForm addEditPayRateForm = new AddEditPayRateForm(this, currSelectedPayRate, true);
                this.Enabled = false;
                addEditPayRateForm.Show();
            }
        }