private void btnAgregarFac_Click(object sender, EventArgs e) { Entities.Producto p = (Entities.Producto) this.cbxFacProd.SelectedItem; if (p.Cantidad > 0) { Entities.Cliente c = (Entities.Cliente) this.cbxCliFac.SelectedItem; Entities.Vendedor ve = (Entities.Vendedor) this.cbxFacVen.SelectedItem; int cant = Convert.ToInt32(this.numCan.Value); if (ve.User == "Seleccione el vendedor") { MessageBox.Show("Seleccione el vendedor"); } else { if (this.numCan.Value != 0) { if (controller.registrarFactura(p, c, ve, cant)) { MessageBox.Show("Produto Registrado"); double valT = Convert.ToDouble(this.txtValProd.Text); this.gridFactura.DataSource = controller.gridFacturando(); sum = sum + (Convert.ToDouble(this.txtValProd.Text)); this.txtValTotal.Text = sum.ToString(); } else { MessageBox.Show("Error al registrar producto"); } } } } }
public List <Entities.Vendedor> cbxVendedores() { List <Entities.Vendedor> vendedores = new List <Entities.Vendedor>(); SqlConnection c = con.getConexion(); vendedores.Add(new Entities.Vendedor("Seleccione el vendedor", "")); String sql = "SELECT venUsuario, venContraseña FROM vendedores;"; try { SqlCommand comando = new SqlCommand(sql, c); SqlDataReader lector = comando.ExecuteReader(); while (lector.Read()) { String us = lector.GetValue(0).ToString(); Entities.Vendedor ven = new Entities.Vendedor(); ven.User = us; vendedores.Add(ven); } return(vendedores); } catch (Exception ex) { return(null); } finally { } }
public bool registrarFactura(Entities.Producto pro, Entities.Cliente cli, Entities.Vendedor ven, int cantidad) { int estado = 0; //rel = obtenerRel(); SqlConnection c = con.getConexion(); String sql = "INSERT INTO detalleFactura (facEstado, codigoProd, cantidadProd, usuarioVen, cliDocumento, facRel) VALUES (@estado, @codigo, @cantidad, @vendedor, @cliente, @rel)"; try { SqlCommand comando = new SqlCommand(sql, c); comando.Parameters.AddWithValue("@estado", estado); comando.Parameters.AddWithValue("@codigo", pro.Codigo); comando.Parameters.AddWithValue("@cantidad", cantidad); comando.Parameters.AddWithValue("@vendedor", ven.User); comando.Parameters.AddWithValue("@cliente", cli.Documento); comando.Parameters.AddWithValue("@rel", rel); comando.ExecuteNonQuery(); registrarVentas(pro.Codigo, cantidad); return(true); }catch (Exception ex) { return(false); } finally { c.Close(); } }
private void BtnCargar_Click(object sender, EventArgs e) { Entities.Vendedor vendedor = new Entities.Vendedor(); vendedor.DNI = txtDNI.Text; vendedor.NOMBRE = txtNOMBRE.Text; vendedor.APELLIDO = txtAPELLIDO.Text; vendedor.DIRRECIOn = txtDIRECCION.Text; vendedor.TELEFONO = txtTELEFONO.Text; vendedor.EMAIL = txtEMAIL.Text; vendedor_action.Create(vendedor); }
private void BtnBuscar_Click(object sender, EventArgs e) { try { Entities.Vendedor vendedor = vendedor_action.Read(txtDNI.Text); txtDNI.Text = vendedor.DNI; if (txtDNI.Text != null) { txtNOMBRE.Text = vendedor.NOMBRE; txtAPELLIDO.Text = vendedor.APELLIDO; txtDIRECCION.Text = vendedor.DIRRECIOn; txtTELEFONO.Text = vendedor.TELEFONO; txtEMAIL.Text = vendedor.EMAIL; } } catch { MessageBox.Show("El vendedor no existe.", "Mostrar vendedor.", MessageBoxButtons.OK, MessageBoxIcon.Information); } }