예제 #1
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            String   strRaise   = txtPercent.Text;
            DateTime affectDate = dtpAffDate.Value;

            if (strRaise == "" && affectDate < DateTime.Today)
            {
                MessageBox.Show("You must enter a raise percent and a date earlier than today", "Invalid");
            }
            else
            {
                try
                {
                    double raise = Convert.ToDouble(strRaise);

                    PayRaise payRaise = PayFactory.Create();
                    payRaise.payIn      = raise;
                    payRaise.newAffDate = dtpAffDate.Value;


                    if (rdoPer.Checked)
                    {
                        payRaise.empId = Main.currEmp.Id;
                        payRaise.selfCheck(Settings.Default.EmployeeId);
                        payRaise           = HRUser.UpdateRaise(payRaise);
                        pnlPayInfo.Visible = true;
                        txtNewPay.Text     = payRaise.newPay.ToString("C");
                        txtOldPay.Text     = payRaise.oldPay.ToString("C");
                        txtOldDate.Text    = payRaise.oldAffDate.ToShortDateString();
                    }
                    else
                    {
                        HRUser.UpdateAllRaises(payRaise);
                    }
                    lblSaved.Visible = true;
                }
                catch (InvalidCastException exCast)
                {
                    MessageBox.Show("Raise must be a number", "Invalid");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }