示例#1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridViewBenefits.SelectedRows.Count != 0)
                {
                    DAL.Benefit ben = (DAL.Benefit)bindingSourceBenefits.Current;

                    var _employeewithdepartmentquery = from br in rep.GetEmployeesWithBenefit(ben)
                                                       select br;
                    List <DAL.Employee> _employees = _employeewithdepartmentquery.ToList();

                    if (_employees.Count > 0)
                    {
                        MessageBox.Show("There is an Employee Associated with this Benefit\nDelete the Employee first!", "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    if (DialogResult.Yes == MessageBox.Show("Are you sure you want to delete Benefit\n" + ben.Description.ToString().Trim().ToUpper(), "Confirm Delete", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
                    {
                        rep.DeleteBenefit(ben);
                        RefreshGrid();
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowError(ex);
            }
        }
        public EditBenefit(DAL.Benefit benefit, string Conn)
        {
            InitializeComponent();

            if (string.IsNullOrEmpty(Conn))
            {
                throw new ArgumentNullException("connection");
            }
            connection = Conn;

            de  = new DataEntry(connection);
            db  = new SBPayrollDBEntities(connection);
            rep = new Repository(connection);

            _benefit = benefit;
        }
        private void dataGridNonCashBenefits_CellParsing(object sender, DataGridViewCellParsingEventArgs e)
        {
            if (dataGridNonCashBenefits.CurrentCell.OwningColumn is DataGridViewComboBoxColumn)
            {
                DataGridViewComboBoxEditingControl editingControl =
                    (DataGridViewComboBoxEditingControl)dataGridNonCashBenefits.EditingControl;
                e.Value = editingControl.SelectedItem;


                DAL.Benefit benefit = (DAL.Benefit)editingControl.SelectedItem;

                if (benefit != null)
                {
                    this.dataGridNonCashBenefits.Rows[dataGridNonCashBenefits.CurrentCell.RowIndex].Cells["cRate"].Value = benefit.Rate.ToString();
                }
            }
        }
示例#4
0
        private void dataGridViewBenefits_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (dataGridViewBenefits.SelectedRows.Count != 0)
                {
                    DAL.Benefit ben = (DAL.Benefit)bindingSourceBenefits.Current;

                    Forms.EditBenefit ab = new Forms.EditBenefit(ben, connection)
                    {
                        Owner = this
                    };
                    ab.Text = ben.Description.ToString();
                    ab.Show();
                }
            }
            catch (Exception ex)
            {
                Utils.ShowError(ex);
            }
        }
示例#5
0
 public void UpdateBenefit(DAL.Benefit benefit, string name, decimal rate)
 {
     rep.UpdateBenefit(benefit, name, rate);
 }