protected void ctrl_btnGuardar_Click(object sender, EventArgs e) { try { if (String.IsNullOrEmpty(ctrl_txtCodigoFactura.Text)) { MensajeExito("Código factura obligatorio."); return; } Entidades.Usuario usuario = (Entidades.Usuario)HttpContext.Current.Session["InfoUsuario"]; Entidades.Empleado empleado = blEmpleado.ObtenerPorIdUsuario(usuario.IdUsuario); Entidades.Factura factura = new Entidades.Factura(); factura.Codigo = ctrl_txtCodigoFactura.Text; factura.IdCliente = Convert.ToInt32(ctrl_ddlCliente.SelectedValue); factura.IdEmpleado = empleado.IdEmpleado; factura.FechaVenta = DateTime.Now; factura.IdPuntoDeVenta = 1; List <Entidades.DetalleFactura> guardados = (List <Entidades.DetalleFactura>)ViewState["lstDetalle"]; if (guardados == null || guardados.Count <= 0) { throw new Exception("No existe detalle en la factura"); } factura.DetalleFacturas = guardados; double total = 0; foreach (Entidades.DetalleFactura detalle in guardados) { total += detalle.Total; } Entidades.MedioPagoFactura medioPago = new Entidades.MedioPagoFactura(); medioPago.IdMedioPago = 1; medioPago.Total = total; List <Entidades.MedioPagoFactura> medioPagos = new List <Entidades.MedioPagoFactura>(); medioPagos.Add(medioPago); factura.MedioPagoFacturas = medioPagos; factura = bl.Guardar(factura); MensajeExito("Factura guardada con éxito"); Buscar(); Limpiar(); } catch (Exception ex) { MensajeError(ex.Message); } }
private void Buscar() { Entidades.Empleado empleado = new Entidades.Empleado(); empleado.Identificacion = ctrl_txtIdentificacionFiltro.Text; empleado.PrimerNombre = ctrl_txtNombreFiltro.Text; ICollection <Entidades.Empleado> empleados = bl.ObtenerPorFiltro(empleado); ctrl_gvEmpleados.DataSource = empleados; ctrl_gvEmpleados.DataBind(); }
private void Seleccionar(int id) { Entidades.Empleado empleado = bl.ObtenerPorId(id); ctrl_hdIdEmpleado.Value = empleado.IdEmpleado.ToString(); ctrl_hdIdPersona.Value = empleado.IdPersona.ToString(); ctrl_hdIdUsuario.Value = empleado.IdUsuario.ToString(); ctrl_txtEmail.Text = empleado.Email; ctrl_txtIdentificacion.Text = empleado.Identificacion; ctrl_ddlSexo.SelectedValue = empleado.IdSexo.ToString(); crtl_ddlTipoIdentificacion.SelectedValue = empleado.IdTipoDocumento.ToString(); ctrl_txtPrimerApellido.Text = empleado.PrimerApellido; ctrl_txtPrimerNombre.Text = empleado.PrimerNombre; ctrl_txtSegundoApellido.Text = empleado.SegundoApellido; ctrl_txtSegundoNombre.Text = empleado.SegundoNombre; ctrl_txtTelefono.Text = empleado.Telefono; }
protected void ctrl_btnGuardar_Click(object sender, EventArgs e) { try { if (String.IsNullOrEmpty(ctrl_txtPrimerNombre.Text)) { MensajeExito("Primer nombre obligatorio."); return; } if (String.IsNullOrEmpty(ctrl_txtPrimerApellido.Text)) { MensajeExito("Primer apellido obligatorio."); return; } if (String.IsNullOrEmpty(ctrl_txtIdentificacion.Text)) { MensajeExito("Identificación obligatorio."); return; } int id = Convert.ToInt32(ctrl_hdIdEmpleado.Value); int idPersona = Convert.ToInt32(ctrl_hdIdPersona.Value); int idUsuario = Convert.ToInt32(ctrl_hdIdUsuario.Value); Entidades.Empleado empleado = new Entidades.Empleado(); empleado.Email = ctrl_txtEmail.Text; empleado.FechaActualizacion = DateTime.Now; empleado.FechaCreacion = DateTime.Now; empleado.FechaNacimiento = DateTime.Now; empleado.Habilitado = true; empleado.Identificacion = ctrl_txtIdentificacion.Text; empleado.IdSexo = Convert.ToInt32(ctrl_ddlSexo.SelectedValue); empleado.IdTipoDocumento = Convert.ToInt32(crtl_ddlTipoIdentificacion.SelectedValue); empleado.PrimerApellido = ctrl_txtPrimerApellido.Text; empleado.PrimerNombre = ctrl_txtPrimerNombre.Text; empleado.SegundoApellido = ctrl_txtSegundoApellido.Text; empleado.SegundoNombre = ctrl_txtSegundoNombre.Text; empleado.Telefono = ctrl_txtTelefono.Text; if (id <= 0) { empleado = bl.Guardar(empleado); } else { empleado.IdEmpleado = id; empleado.IdPersona = idPersona; empleado.IdUsuario = idUsuario; bl.Actualizar(empleado); } Buscar(); Limpiar(); MensajeExito("Empleado creado con éxito"); } catch (Exception ex) { MensajeError(ex.Message); } }