private void btnBuscar_Click(object sender, EventArgs e) { Factura objFactura = FacturacionFacade.SelectByIdFactura(txtNumeroFactura.Text); txtCliente.Text = objFactura.Cliente; txtDireccion.Text = objFactura.Direccion; txtNit.Text = objFactura.Nit; txtTelefono.Text = objFactura.Telefono; var list = objFactura.DetalleFacturas.ToList(); var binding = new BindingList <DetalleFactura>(list); dgvProductos.DataSource = binding; dgvProductos.Refresh(); for (int i = 0; i < list.Count; i++) { dgvProductos.Rows[i].Cells[0].Value = list[i].Cantidad; dgvProductos.Rows[i].Cells[1].Value = list[i].Producto; dgvProductos.Rows[i].Cells[2].Value = list[i].ValorUnitario; } dgvProductos.Enabled = false; btnGuardar.Visible = false; btnImprimir.Visible = true; lblNombreVendedor.Text = objFactura.Usuario; //Se deshabilitan los campos DeshabilitarCampos(); }
private void cboTipo_SelectedIndexChanged(object sender, EventArgs e) { if (cboTipo.SelectedIndex == 0 || cboTipo.SelectedIndex == 1) { cboPeriodos.Visible = false; dtpPeriodo.Visible = true; } else if (cboTipo.SelectedIndex == 2 || cboTipo.SelectedIndex == 3 || cboTipo.SelectedIndex == 4 || cboTipo.SelectedIndex == 5) { cboPeriodos.Visible = true; dtpPeriodo.Visible = false; var query = FacturacionFacade.GetPeriodos(cboTipo.SelectedIndex - 1); cboPeriodos.DataSource = query; cboPeriodos.ValueMember = "Periodo"; cboPeriodos.DisplayMember = "Descripcion"; } }
private void lblIngresar_Click(object sender, EventArgs e) { Usuario objUsuario = FacturacionFacade.SelectByIdUsuario(txtUsuario.Text, int.Parse(cboRoles.SelectedValue.ToString())); if (objUsuario != null) { if (cboRoles.SelectedValue.ToString() == "2" || objUsuario.Contrasena == txtContrasena.Text) { this.Hide(); new frmFacturacion(txtUsuario.Text, int.Parse(cboRoles.SelectedValue.ToString())).Show(); } else { MessageBox.Show("La contraseña es incorrecta."); } } else { MessageBox.Show("El usuario es incorrecto."); } }
private void button1_Click(object sender, EventArgs e) { if (cboTipo.SelectedIndex == 0) { //Diario this.SPGetFacturasConsolidadoByFechaTableAdapter.Fill(this.MaxiconfortDataSetConsolidado.SPGetFacturasConsolidadoByFecha, dtpPeriodo.Value.AddDays(-1), dtpPeriodo.Value); } else if (cboTipo.SelectedIndex == 1) { //Semanal this.SPGetFacturasConsolidadoByFechaTableAdapter.Fill(this.MaxiconfortDataSetConsolidado.SPGetFacturasConsolidadoByFecha, dtpPeriodo.Value.AddDays(-1), dtpPeriodo.Value.AddDays(6)); } else { //Por periodos var query = FacturacionFacade.GetPeriodos(cboTipo.SelectedIndex - 1); int periodo = int.Parse(cboPeriodos.SelectedValue.ToString()); var periodoSelected = query.Where(p => p.Periodo == periodo).FirstOrDefault(); this.SPGetFacturasConsolidadoByFechaTableAdapter.Fill(this.MaxiconfortDataSetConsolidado.SPGetFacturasConsolidadoByFecha, periodoSelected.FechaInicio, periodoSelected.FechaFin); } rpvFacturasConsolidadas.RefreshReport(); }
private void btnGuardar_Click(object sender, EventArgs e) { try { //Guardar List <DetalleFactura> lstDetalleFactura = new List <DetalleFactura>(); foreach (DataGridViewRow item in dgvProductos.Rows) { if (item.Index + 1 < dgvProductos.Rows.Count) { if (item.Cells[0].Value == null) { throw new Exception("Ingrese la cantidad"); } if (item.Cells[1].Value == null) { throw new Exception("Ingrese la referencia"); } if (item.Cells[2].Value == null) { throw new Exception("Ingrese el valor del producto"); } int cantidad = int.Parse(item.Cells[0].Value.ToString()); string producto = item.Cells[1].Value.ToString(); float valorUnitario = float.Parse(item.Cells[2].Value.ToString()); lstDetalleFactura.Add(new DetalleFactura() { Cantidad = cantidad, Producto = producto, ValorUnitario = valorUnitario, ValorTotal = valorUnitario * cantidad }); } } Factura objFactura = new Factura() { CodigoFactura = "", Fecha = DateTime.Now, Usuario = lblNombreVendedor.Text, DetalleFacturas = lstDetalleFactura, Cliente = txtCliente.Text, Direccion = txtDireccion.Text, Nit = txtNit.Text, Telefono = txtTelefono.Text }; FacturacionFacade.SaveFactura(objFactura); DialogResult result = MessageBox.Show("Registro guardado con éxito. ¿Desea imprimir la Factura?. ", "Exitoso", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.Yes) { new frmImprimirFactura(objFactura.FacturaId).Show(); } this.LimpiarCampos(); } catch (Exception ex) { MessageBox.Show(ex.GetBaseException().Message); } }
private void frmLogin_Load(object sender, EventArgs e) { cboRoles.DataSource = FacturacionFacade.SelectAllRole(); cboRoles.ValueMember = "RolId"; cboRoles.DisplayMember = "Nombre"; }