public void InicializarFormulario(FormMode op, BugTracker.Entities.Clientes clienteSelected) { formMode = op; oClienteSelected = clienteSelected; }
public void InicializarFormulario(BugTracker.Entities.Clientes clienteSelected) { oClienteSelected = clienteSelected; }
private void btnAceptar_Click(object sender, EventArgs e) { switch (formMode) { case FormMode.insert: { if (ExisteCliente() == false) { if (ValidarCampos()) { var oClientes = new BugTracker.Entities.Clientes(); oClientes.RazonSocial = txtRazonSocial.Text; oClientes.Cuit = (int)Convert.ToUInt32(txtCuit.Text); oClientes.Calle = txtCalle.Text; oClientes.Barrio = new Barrio(); oClientes.Barrio.IDBarrio = (int)cboBarrio.SelectedValue; oClientes.FechaAlta = Convert.ToDateTime(txtFechaAlta.Text); oClientes.NumeroCalle = Convert.ToInt32(txtNumeroCalle.Text); oClientes.Borrado = 0; if (oClienteService.CrearCliente(oClientes)) { MessageBox.Show("Cliente Insertado", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } } else { MessageBox.Show("Cliente encontrado! Ingrese un cliente distinto", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; } case FormMode.update: { if (ValidarCampos()) { oClienteSelected.RazonSocial = txtRazonSocial.Text; oClienteSelected.Cuit = Convert.ToInt32(txtCuit.Text); oClienteSelected.FechaAlta = Convert.ToDateTime(txtFechaAlta.Text); oClienteSelected.Calle = txtCalle.Text; oClienteSelected.NumeroCalle = Convert.ToInt32(txtNumeroCalle.Text); oClienteSelected.Barrio = new Barrio(); oClienteSelected.Barrio.IDBarrio = (int)cboBarrio.SelectedValue; if (oClienteService.ActualizarCliente(oClienteSelected)) { MessageBox.Show("Cliente actualizado!", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Dispose(); } else { MessageBox.Show("Error al actualizar el usuario!", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); } } break; } case FormMode.delete: { if (MessageBox.Show("¿Seguro que desea eliminar el cliente seleccionado?", "Aviso", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { if (oClienteService.EliminarCliente(oClienteSelected)) { MessageBox.Show("Cliente eliminado", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Error al eliminar el cliente!", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Error); } } break; } } }