Пример #1
0
        private void empleadosToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmEmployees frmEmployees = new frmEmployees();

            frmEmployees.Show();
            Hide();
        }
Пример #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (IsValid())
            {
                DateTime dateTime = new DateTime();
                dateTime.AddDays(dtpDateOfAdmission.Value.Day);
                dateTime.AddMonths(dtpDateOfAdmission.Value.Month);
                dateTime.AddYears(dtpDateOfAdmission.Value.Year);

                rentACarEntities.Employees.Add(new Employee()
                {
                    Name            = txtName.Text,
                    DocumentNumber  = txtDocumentNumber.Text,
                    BatchId         = (int)cbBatch.SelectedValue,
                    Comission       = txtComision.Value,
                    DateOfAdmission = dtpDateOfAdmission.Value,
                    Status          = true
                });

                rentACarEntities.SaveChanges();

                MessageBox.Show("El empleado fue agreagdo correctamente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                frmEmployees frmEmployees = new frmEmployees();
                frmEmployees.Show();
                Close();
            }
        }
Пример #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (IsValid())
            {
                Employee employee = rentACarEntities.Employees.Where(em => em.Id == Employee.Id).FirstOrDefault();
                employee.Name            = txtName.Text;
                employee.DocumentNumber  = txtDocumentNumber.Text;
                employee.BatchId         = (int)cbBatch.SelectedValue;
                employee.Comission       = txtComision.Value;
                employee.DateOfAdmission = dtpDateOfAdmission.Value;

                rentACarEntities.Entry(employee).State = System.Data.Entity.EntityState.Modified;
                rentACarEntities.SaveChanges();
                MessageBox.Show("El empleado fue editado correctamente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                frmEmployees frmEmployees = new frmEmployees();
                frmEmployees.Show();
                Hide();
            }
        }