private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //save to the database
                db.SaveChanges();
                MessageBox.Show("Save Successfull!", "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information);

                CalculateTotalNonCashBenefitAmount();

                if (OnEmployeeBenefitAmountChanged != null)
                {
                    OnEmployeeBenefitAmountChanged(this, new BenefitAmountHandlerEventArgs(TotalNonCashBenefitsAmount));
                }

                if (this.Owner is EditEmployee)
                {
                    EditEmployee f = (EditEmployee)this.Owner;
                    f.GridRefresh();
                    this.Close();
                }
                else if (this.Owner is AddEmpTxn)
                {
                    AddEmpTxn aet = (AddEmpTxn)this.Owner;
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                Utils.ShowError(ex);
            }
        }
Esempio n. 2
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (IsEmployeeTransactionValid())
            {
                try
                {
                    if (cbItemId.SelectedIndex != -1)
                    {
                        _empTxn.ItemId = cbItemId.SelectedValue.ToString();
                    }
                    decimal _amount;
                    if (!string.IsNullOrEmpty(txtAmount.Text) && decimal.TryParse(txtAmount.Text, out _amount))
                    {
                        _empTxn.Amount = _amount;
                    }
                    decimal _YTDAmount;
                    if (!string.IsNullOrEmpty(txtYTDAmount.Text) && decimal.TryParse(txtYTDAmount.Text, out _YTDAmount))
                    {
                        _empTxn.Balance = _YTDAmount;
                    }
                    _empTxn.PostDate         = DateTime.Today;
                    _empTxn.EmpNo            = _empTxn.EmpNo;
                    _empTxn.Recurrent        = chkRecurrent.Checked;
                    _empTxn.Enabled          = chkEnabled.Checked;
                    _empTxn.TrackYTD         = chkTrackYTD.Checked;
                    _empTxn.CreatedBy        = _empTxn.CreatedBy;
                    _empTxn.LastChangeDate   = DateTime.Today;
                    _empTxn.LastChangedBy    = _User;
                    _empTxn.AuthorizedBy     = _empTxn.AuthorizedBy;
                    _empTxn.AuthorizeDate    = _empTxn.AuthorizeDate.GetValueOrDefault();
                    _empTxn.ShowYTDInPayslip = chkShowYTDinPayslip.Checked;


                    rep.UpdateEmpTxn(_empTxn);

                    EditEmployee f = (EditEmployee)this.Owner;
                    f.GridRefresh();
                    this.Close();
                }
                catch (Exception ex)
                {
                    Utils.ShowError(ex);
                }
            }
        }
Esempio n. 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (IsEmployeeTransactionValid())
            {
                try
                {
                    var _employerquery = (from ep in db.Employers
                                          select ep).FirstOrDefault();
                    DAL.Employer _Employer = _employerquery;

                    EmployeeTransaction et = new EmployeeTransaction();
                    decimal             _amount;
                    if (!string.IsNullOrEmpty(txtAmount.Text) && decimal.TryParse(txtAmount.Text, out _amount))
                    {
                        et.Amount = decimal.Parse(txtAmount.Text.Trim());
                    }
                    et.PostDate   = DateTime.Today;
                    et.EmployeeId = employee.Id;
                    if (employee.EmpNo != null)
                    {
                        et.EmpNo = employee.EmpNo;
                    }
                    if (cbItemId.SelectedIndex != -1)
                    {
                        et.ItemId = cbItemId.SelectedValue.ToString();
                    }
                    et.Recurrent           = chkRecurrent.Checked;
                    et.Processed           = false;
                    et.InitialAmount       = 0M;
                    et.AccumulativePayment = 0M;
                    et.Enabled             = true;
                    et.TrackYTD            = chkTrackYTD.Checked;
                    et.CreatedBy           = _User;
                    et.LastChangeDate      = DateTime.Today;
                    et.LastChangedBy       = _User;
                    if (_Employer.AuthorizedSignatory != null)
                    {
                        et.AuthorizedBy = _Employer.AuthorizedSignatory;
                    }
                    et.AuthorizeDate = DateTime.Today;
                    decimal _YTDAmount;
                    if (!string.IsNullOrEmpty(txtYTDAmount.Text) && decimal.TryParse(txtYTDAmount.Text, out _YTDAmount))
                    {
                        et.Balance = _YTDAmount;
                    }
                    et.ShowYTDInPayslip = chkShowYTDinPayslip.Checked;

                    if (db.EmployeeTransactions.Any(i => i.EmpNo == et.EmpNo && i.ItemId == et.ItemId))
                    {
                        MessageBox.Show("Employee Transaction for item \n" + et.ItemId + "Exists!", "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    if (!db.EmployeeTransactions.Any(i => i.EmpNo == et.EmpNo && i.ItemId == et.ItemId))
                    {
                        db.EmployeeTransactions.AddObject(et);
                        db.SaveChanges();
                    }

                    EditEmployee f = (EditEmployee)this.Owner;
                    f.GridRefresh();
                    this.Close();
                }
                catch (Exception ex)
                {
                    Utils.ShowError(ex);
                }
            }
        }