//private void calcularPrecio(Int32 indexRow) //{ // //obtengo la cantidad // Int32 cantidad = Convert.ToInt32(dgDetalle.Rows[indexRow].Cells[colCantidad.Index].Value); // //obtengo el precio // decimal precio = Convert.ToDecimal(dgDetalle.Rows[indexRow].Cells[colPrecio.Index].Value); // //calculo el total // decimal total = cantidad * precio; // //cambio el toal de la celda // dgDetalle.Rows[indexRow].Cells[4].Value = total; // txtNeto.Text = calcularPrecioNeto().ToString(); //} //private decimal calcularPrecioNeto() //{ // decimal precioTotal = 0; // if (dgDetalle.Rows.Count != 0) // { // foreach (DataGridViewRow fila in dgDetalle.Rows) // { // precioTotal += Convert.ToDecimal(fila.Cells[colTotal.Index].Value); //celda precio final // } // } // return precioTotal; //} //private decimal calcularDescuento() //{ // decimal totalDescuento = 0; // if (!string.IsNullOrEmpty(txtDescuento.Text) && !string.IsNullOrEmpty(txtNeto.Text)) // { // decimal descuento = Convert.ToDecimal(txtDescuento.Text); // decimal precioNeto = Convert.ToDecimal(txtNeto.Text); // if (cboTipDescuento.SelectedIndex == 0)//% // { // totalDescuento = descuento * precioNeto / 100; // } // else//$ // { // totalDescuento = descuento; // } // } // return totalDescuento; //} //private decimal calcularTotalCompra() //{ // decimal descuento = calcularDescuento(); // decimal neto = calcularPrecioNeto(); // decimal totalVenta = neto - descuento; // txtNeto.Text = neto.ToString(); // txtDescVenta.Text = descuento.ToString(); // txtTotalVenta.Text = totalVenta.ToString(); // //calcular el total de articulos // Int16 cantArticulo = 0; // foreach (DataGridViewRow filaDetalle in dgDetalle.Rows) // { // cantArticulo += Convert.ToInt16(filaDetalle.Cells[colCantidad.Index].Value); // } // txtCantArticulo.Text = cantArticulo.ToString(); // return totalVenta; //} private Boolean generarPedido() { Boolean xConf = false; if (dgDetalle.Rows.Count == 0) { return(xConf); } E_Pedido pedido = new E_Pedido(); //Cargar cabecera pedido.proveedor.idProveedor = _idProveedor; pedido.proveedor.raSocial = txtDescripcion.Text; pedido.condPago.idCondPago = ((ComboItem)cboCondPago.SelectedItem).Id; pedido.cuit = txtCuitDni.Text; pedido.fecha = dtFecVenta.Value;; pedido.observacion = txtObservacion.Text; pedido.vendedor.idVendedor = ((ComboItem)cboVendedor.SelectedItem).Id; pedido.direccion = txtDireccion.Text; pedido.anular = false; pedido.estadoPedido.idEstado = E_EstadoPedido.PENDIENTE; //compra.precioTotal = calcularTotalCompra(); //Cargar detalle foreach (DataGridViewRow filaDetalle in dgDetalle.Rows) { E_DetallePedido detalle = new E_DetallePedido(); detalle.codArticulo = filaDetalle.Cells[colCodArticulo.Index].Value.ToString(); detalle.descripcionArt = filaDetalle.Cells[colDescripcion.Index].Value.ToString(); detalle.observacionArt = filaDetalle.Cells[colObservacion.Index].Value.ToString(); detalle.cantidad = Convert.ToInt16(filaDetalle.Cells[colCantidad.Index].Value); pedido.detalles.Add(detalle); } N_Pedido nPedido = new N_Pedido(); string xRet = nPedido.addPedido(pedido); if (xRet != "0") { xConf = false; } else { xConf = true; } return(xConf); }
//Metodos private void valPrederteminado() { N_Pedido nCompra = new N_Pedido(); Int64 ultCodCompra = nCompra.ultCodCompra(); txtUltVenta.Text = ultCodCompra.ToString(); txtCodPedido.Text = (ultCodCompra + 1).ToString(); cboVendedor.SelectedIndex = 0; //primer vendedor cboCondPago.SelectedIndex = 0; // efectivo //cboTipDescuento.SelectedIndex = 0;//% btnAgrArticulo.Focus(); dgDetalle.Rows.Clear(); //txtNeto.Text = "0"; //txtDescuento.Text = "0"; //txtTotalVenta.Text = "0"; txtCantArticulo.Text = "0"; }
private void btnAnular_Click(object sender, EventArgs e) { N_Pedido nPedido = new N_Pedido(); Int64 codPedido = Convert.ToInt64(txtCodPedido.Text); Boolean xConf = nPedido.anularPedido(codPedido); if (!xConf) { MessageBox.Show("¡No se pudo anular la venta!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else // se confirmao la anulacion { lblInfoAnular.Visible = false; btnAnular.Visible = false; } }
private void btnConfirmar_Click(object sender, EventArgs e) { if (dgDetalle.Rows.Count > 0) { E_Pedido pedido = new E_Pedido(); pedido.codPedido = Convert.ToInt64(txtCodPedido.Text); pedido.observacion = txtObservacion.Text; foreach (DataGridViewRow filaDetalle in dgDetalle.Rows) { E_DetallePedido detalle = new E_DetallePedido(); detalle.codArticulo = filaDetalle.Cells[colCodArticulo.Index].Value.ToString(); detalle.descripcionArt = filaDetalle.Cells[colDescripcion.Index].Value.ToString(); detalle.observacionArt = filaDetalle.Cells[colObservacion.Index].Value.ToString(); detalle.cantidad = Convert.ToInt16(filaDetalle.Cells[colCantidad.Index].Value); pedido.detalles.Add(detalle); } frmConfPedido frmConf = new frmConfPedido(); frmConf.ShowDialog(); if (_fecEntrega != null) // si se confirmo { N_Pedido nPedido = new N_Pedido(); pedido.fecEntrega = _fecEntrega; Boolean xConf = nPedido.confirmarPedido(pedido); if (xConf) { lblInfoAnular.Text = "Pedido Confirmado. Fecha de Entrega: " + _fecEntrega; lblInfoAnular.Visible = true; lblInfoAnular.ForeColor = Color.Blue; dgDetalle.Enabled = false; btnConfirmar.Visible = false; } _fecEntrega = null; // vuelvo la fecha a null porque es static } } else { MessageBox.Show("¡No se ha cargado ningun artículo al detalle!", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void refrescarGrilla() { DateTime fecDesde = dtDesde.Value.Date; DateTime fecHasta = dtHasta.Value.Date; if (fecDesde <= fecHasta) { List <E_Pedido> pedidos; N_Pedido nPedido = new N_Pedido(); dgPedidos.AutoGenerateColumns = false; //selecciono el estado de busqueda del radio button string estado; if (rbTodos.Checked) { estado = "todos"; } else if (rbPendiente.Checked) { estado = "pendiente"; } else if (rbConfirmados.Checked) { estado = "confirmado"; } else { estado = "anulado"; } pedidos = nPedido.getAllPedido(dtDesde.Value, dtHasta.Value, txtBscProveedor.Text, estado); if (pedidos != null) { dgPedidos.AutoGenerateColumns = false; dgPedidos.DataSource = pedidos; txtCantPedidos.Text = pedidos.Count().ToString(); foreach (DataGridViewRow row in dgPedidos.Rows) { Int32 idEstado = Convert.ToInt32(row.Cells[colEstado.Index].Value); if (idEstado == E_EstadoPedido.CONFIRMADO) // { //Cambio el color de la fila a naranja o a cualquier otro color dgPedidos.Rows[row.Index].DefaultCellStyle.BackColor = Color.LightGreen; } else if (idEstado == E_EstadoPedido.ANULADO) // { dgPedidos.Rows[row.Index].DefaultCellStyle.BackColor = Color.OrangeRed; } } } else { MessageBox.Show("¡No se cargó la gilla!"); } } else // su la fecha desde es mayo al hasta { MessageBox.Show("¡La fecha DESDE tiene que ser menor a la fecha HASTA!", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void consultarPedido(Int64 codPedido) { N_Pedido nPedido = new N_Pedido(); E_Pedido pedido = nPedido.getOnePedido(codPedido); //por si anula la venta //_VentaAnular = pedido; posicionarCbo(pedido.vendedor.idVendedor, pedido.condPago.idCondPago); //si esta anulada la venta if (pedido.anular) // si esta anulada la venta { //lblInfoAnular.Visible = true; } else // si no esta anulada { //mostrar el boton anular //btnAnularVenta.Visible = true; } //cabecera cboVendedor.Enabled = false; dtFecVenta.Enabled = false; txtIdProveedor.Enabled = false; txtDescripcion.ReadOnly = true; txtDireccion.ReadOnly = true; txtCuitDni.ReadOnly = true; cboCondPago.Enabled = false; txtObservacion.ReadOnly = true; btnBuscar.Enabled = false; if (pedido.estadoPedido.idEstado == E_EstadoPedido.PENDIENTE) { btnConfirmar.Visible = true; btnAnular.Visible = true; } else if (pedido.estadoPedido.idEstado == E_EstadoPedido.CONFIRMADO) { btnAnular.Visible = false; dgDetalle.Enabled = false; lblInfoAnular.Text = "Pedido Confirmado. Fecha de Entrega: " + pedido.fecEntrega.Value.Date.ToString("dd/MM/yyyy"); lblInfoAnular.Visible = true; lblInfoAnular.ForeColor = Color.Blue; } else if (pedido.estadoPedido.idEstado == E_EstadoPedido.ANULADO) { lblInfoAnular.Visible = true; dgDetalle.Enabled = false; } txtIdProveedor.Text = pedido.proveedor.idProveedor.ToString(); txtCodPedido.Text = pedido.codPedido.ToString(); txtObservacion.Text = pedido.observacion; //piso la direccion y el cuit buscarProveedor(); txtDireccion.Text = pedido.direccion; txtCuitDni.Text = pedido.cuit; //botones btnAgrArticulo.Visible = false; btnCancelar.Visible = false; btnGenerarPedido.Visible = false; //datagrid cargarGrillaPedido(pedido); //btnPrimir btnImprimir.Visible = true; }