//LOAD private void PrincipalPedidosRegistrar_Load(object sender, EventArgs e) { ClasePedidos cl = new ClasePedidos(); String auxCodPe = cl.ObtenerCodigoPedido(); if (auxCodPe == null) { cajaNumeroPedido.Text = "1"; } else { cajaNumeroPedido.Text = (Convert.ToInt32(auxCodPe) + 1).ToString(); } DateTime dt = DateTime.Now; cajaFecha.Text = dt.ToShortDateString(); cajaNeto.Text = "0"; cajaIva.Text = "0"; cajaSubtotal.Text = "0"; cajaTotal.Text = "0"; cajaDescuento.Text = "0"; botonAgregar.Enabled = false; botonGuardar.Enabled = false; cajaFormaPago.Enabled = false; cajaDirecciones.Enabled = false; //FORMA PAGO cajaFormaPago.Items.Add("EFECTIVO"); cajaFormaPago.Items.Add("DÉBITO"); cajaFormaPago.Items.Add("CRÉDITO"); cajaFormaPago.Items.Add("CHEQUE"); }
//LOAD private void PrincipalPedidosVerPedidos_Load(object sender, EventArgs e) { ClasePedidos pc = new ClasePedidos(); ArrayList are = new ArrayList(); are = pc.ObtenerDatosPedidos(codiPedi); cajaNumeroPedido.Text = are[0].ToString(); cajaFecha.Text = are[1].ToString(); cajaNombre.Text = are[2].ToString() + " " + are[3].ToString();; cajaRun.Text = are[4].ToString(); cajaCelular.Text = are[5].ToString(); descuentoCliente = Convert.ToInt32(are[6]); cajaCiudad.Text = are[7].ToString(); cajaDireccion.Text = are[8].ToString(); cajaFormaPago.Text = are[9].ToString(); pc.MostrarDetallesPedido(datosPedido, codiPedi); cajaNeto.Text = sumaNeto().ToString(); cajaIva.Text = sumaIVA().ToString(); cajaSubtotal.Text = sumaSubtotal().ToString(); cajaDescuento.Text = sumaDescuento().ToString(); cajaTotal.Text = sumaTotal().ToString(); }
//BOTÓN CREAR PEDIDO private void botonGuardar_Click(object sender, EventArgs e) { if (cajaCelular.Text == "" || cajaCiudad.Text == "" || cajaDireccion.Text == "" || cajaDirecciones.Text == "" || cajaFecha.Text == "" || cajaIva.Text == "" || cajaNeto.Text == "" || cajaNombre.Text == "" || cajaNumeroPedido.Text == "" || cajaRun.Text == "" || cajaTotal.Text == "" || cajaFormaPago.Text == "") { MessageBox.Show("No hubo respuesta o no se respetaron las instrucciones."); } else { //FORMA DE PAGO ClasePedidos cl = new ClasePedidos(); String auxFormaPago = ""; switch (cajaFormaPago.Text) { case "EFECTIVO": auxFormaPago = "01EFE"; break; case "DÉBITO": auxFormaPago = "02DEB"; break; case "CRÉDITO": auxFormaPago = "03CRE"; //SI ES CREDITO, SE DESCUENTA EL CREDITO CON EL TOTAL DEL PEDIDO cl.ModificarCreditoCliente(codiCliente, (creditoCliente - Convert.ToInt32(cajaTotal.Text))); break; case "CHEQUE": auxFormaPago = "04CHE"; break; } cl = new ClasePedidos(); int codiPedidoRecibido = 0; //CREAR EL PEDIDO codiPedidoRecibido = Convert.ToInt32(cl.RegistrarPedido(cajaFecha.Text, codiCliente, auxFormaPago, auxCodDireccionModificar)); if (codiPedidoRecibido == 0) { //NO SE RECIBIO EL CODIGO DEL PEDIDO MessageBox.Show("Error no controlado."); } else { //RECORRER EL DATAGRIEDVIEW REALIZANDO TODOS LOS DETALLES PEDIDOS foreach (DataGridViewRow row in datosPedido.Rows) { cl.RegistrarDetallePedido(Convert.ToInt32(row.Cells["CANTIDAD"].Value), Convert.ToInt32(row.Cells["PRECIOTOTAL"].Value), codiPedidoRecibido, Convert.ToInt32(row.Cells["CÓDIGO"].Value), Convert.ToInt32(row.Cells["PRECIO"].Value)); //QUITAR STOCK DEL PRODUCTO SELECCIONADO ClaseProductos pro = new ClaseProductos(); ArrayList proStock = new ArrayList(); proStock = pro.ObtenerDatosProducto(Convert.ToInt32(row.Cells["CÓDIGO"].Value)); //OBTENGO EL STOCK ACTUAL int auxStock = Convert.ToInt32(proStock[3]); //RESTO EL STOCK CON LA CANTIDAD QUE SE VENDERÁ int stockNuevo = auxStock - (Convert.ToInt32(row.Cells["CANTIDAD"].Value)); pro.AgregarStock(Convert.ToInt32(row.Cells["CÓDIGO"].Value), stockNuevo); } MessageBox.Show("PEDIDO CREADO SATISFACTORIAMENTE."); this.Close(); } } }
/* ******************************** FUNCIONES ************************************** ******************************************************************************* */ /* ******************************** EVENTOS ************************************** ******************************************************************************* */ //BUSCAR UN PEDIDO MEDIANTE TECLADO private void cajaBuscar_KeyUp(object sender, KeyEventArgs e) { ClasePedidos conad = new ClasePedidos(); conad.MostrarPedidosBusqueda(MostrarPedidos, cajaBuscar.Text); }
//LOAD private void PrincipalPedidosVer_Load(object sender, EventArgs e) { ClasePedidos pedi = new ClasePedidos(); pedi.MostrarPedidos(MostrarPedidos); }