예제 #1
0
        public string PutDetalleNotaCredito(DetalleNotaCredito d)
        {
            try
            {
                DataTable table = new DataTable();

                string query = @"
                                update DetalleNotaCredito set IdNotaCredito =" + d.IdNotaCredito + ", ClaveProducto='" + d.ClaveProducto + "', Producto='" + d.Producto + "', Unidad='" + d.Unidad + "', ClaveSAT='" + d.ClaveSat + "', PrecioUnitario='" + d.PrecioUnitario + "', Cantidad='" + d.Cantidad + "', Importe='" + d.Importe + "', Observaciones='" + d.Observaciones + "',TextoExtra='" + d.TextoExtra +
                               "', PrecioUnitarioDlls='" + d.PrecioUnitarioDlls + "', ImporteDlls='" + d.ImporteDlls + "', ImporteIVA='" + d.ImporteIVA + "', ImporteIVADlls='" + d.ImporteIVADlls + "' where IdDetalleNotaCredito =" + d.IdDetalleNotaCredito + ";";

                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["Prolapp"].ConnectionString))
                    using (var cmd = new SqlCommand(query, con))
                        using (var da = new SqlDataAdapter(cmd))
                        {
                            cmd.CommandType = CommandType.Text;
                            da.Fill(table);
                        }

                return("Se Actualizo Correctamente");
            }
            catch (Exception exe)
            {
                return("Se produjo un error" + exe);
            }
        }
예제 #2
0
        public string PostDetalleNotaCredito(DetalleNotaCredito d)
        {
            try
            {
                DataTable table = new DataTable();
                string    query = @"
                              insert into DetalleNotaCredito (IdNotaCredito, ClaveProducto, Producto, Unidad, ClaveSAT, PrecioUnitario, Cantidad, Importe, Observaciones, TextoExtra, PrecioUnitarioDlls, ImporteDlls, ImporteIVA, ImporteIVADlls)
values (" + d.IdNotaCredito + ", '" + d.ClaveProducto + "', '" + d.Producto + "', '" + d.Unidad + "', '" + d.ClaveSat + "', '" + d.PrecioUnitario + "', '" + d.Cantidad + "', '" + d.Importe + "', '" + d.Observaciones + "', '" + d.TextoExtra + "', '" + d.PrecioUnitarioDlls + "', '" + d.ImporteDlls + "','" + d.ImporteIVA + "', '" + d.ImporteIVADlls + "');";

                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["Prolapp"].ConnectionString))
                    using (var cmd = new SqlCommand(query, con))
                        using (var da = new SqlDataAdapter(cmd))
                        {
                            cmd.CommandType = CommandType.Text;
                            da.Fill(table);
                        }



                return("Detalle Nota Credito Agregado");
            }
            catch (Exception exe)
            {
                return("Se produjo un error" + exe);
            }
        }
        public DetalleNotaCredito CargarDetalleDevolucion(DetalleVenta unDetalleVenta)
        {
            DetalleNotaCredito unDetalleNotaCredito = new DetalleNotaCredito();

            unDetalleNotaCredito.Producto = new Producto();
            unDetalleNotaCredito.Linea    = unDetalleVenta.Linea;
            unDetalleNotaCredito.Producto.CodigoProducto = unDetalleVenta.Producto.CodigoProducto;
            unDetalleNotaCredito.Cantidad        = unDetalleVenta.Cantidad;
            unDetalleNotaCredito.Bultos          = unDetalleVenta.Bultos;
            unDetalleNotaCredito.Unidades        = unDetalleVenta.Unidades;
            unDetalleNotaCredito.CantidadxBulto  = unDetalleVenta.CantidadxBulto;
            unDetalleNotaCredito.PrecioCosto     = unDetalleVenta.PrecioCosto;
            unDetalleNotaCredito.PrecioMinorista = unDetalleVenta.PrecioMinorista;
            unDetalleNotaCredito.PrecioMayorista = unDetalleVenta.PrecioMayorista;
            unDetalleNotaCredito.Subtotal        = unDetalleVenta.Subtotal;
            return(unDetalleNotaCredito);
        }
        public void AgregarDetalleNotaDevolucion(DetalleNotaCredito unDetalleDevolucion, int NumeroFactura)
        {
            AdministradorAccesoDatos AccederDatos = new AdministradorAccesoDatos();

            AccederDatos.AbrirConexion();
            AccederDatos.DefinirProcedimientoAlmacenado("SP_CargarDetalleNotaDevolucion");
            AccederDatos.Comando.Parameters.Clear();
            AccederDatos.Comando.Parameters.AddWithValue("@NumeroFactura", NumeroFactura);
            AccederDatos.Comando.Parameters.AddWithValue("@NumeroLinea", unDetalleDevolucion.Linea);
            AccederDatos.Comando.Parameters.AddWithValue("@CodigoProducto", unDetalleDevolucion.Producto.CodigoProducto);
            AccederDatos.Comando.Parameters.AddWithValue("@Unidad", unDetalleDevolucion.Unidades);
            AccederDatos.Comando.Parameters.AddWithValue("@PrecioCosto", unDetalleDevolucion.PrecioCosto);
            AccederDatos.Comando.Parameters.AddWithValue("@PrecioVentaMinorista", unDetalleDevolucion.PrecioMinorista);
            AccederDatos.Comando.Parameters.AddWithValue("@PrecioVentaMayorista", unDetalleDevolucion.PrecioMayorista);
            AccederDatos.Comando.Parameters.AddWithValue("@CantidadxBulto", unDetalleDevolucion.CantidadxBulto);
            AccederDatos.Comando.Parameters.AddWithValue("@Bulto", unDetalleDevolucion.Bultos);
            AccederDatos.EjecutarAccion();
            AccederDatos.CerrarConexion();
        }
예제 #5
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            bool banderaCorrecto = false;

            if (txtTotalDevolucion.Text != "")
            {
                if (MessageBox.Show("¿Desea Gaurdar la Nota de Credito?", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (txtSerie1.Text != "" && txtSerie2.Text != "" && txtNumero.Text != "" && txtAutorizacionNC.Text != "" && txtSerie1NC.Text != "" && txtSerie2NC.Text != "" && txtNumeroNC.Text != "")
                    {
                        if (txtTotalDevolucion.Text != "0.00")
                        {
                            if (!modificar)
                            {
                                objENC = new EncabezadoNotaCredito(txtSerie1NC.Text, txtSerie2NC.Text, txtNumeroNC.Text, compraDetalle, Convert.ToSingle(Funcion.reemplazarcaracterViceversa(txtTotalDevolucion.Text)), sumasubcero, sumasubiva, ivatotal, sumaice, sumairbp, Convert.ToDateTime(dtpFechaEmision.Value.ToShortDateString()), txtAutorizacionNC.Text, subtotalPie);
                                string resultado = objENC.InsertarEncabezadoNC(objENC);
                                if (resultado == "Datos Guardados")
                                {
                                    string idEncabezadoNC = objConsultas.ObtenerValorCampo("IDENCABEZADONOTACREDITO", "TbEncabezadoNotaCredito", " where IDENCABEZADOCOMPRA = " + compraDetalle + " and SERIE1 = " + txtSerie1NC.Text + " and SERIE2 = " + txtSerie2NC.Text + " and NUMERO = " + txtNumeroNC.Text + " ");
                                    for (int i = 0; i < dgvProductosDevolucion.RowCount - 1; i++)
                                    {
                                        string[] porcentaje       = dgvProductosDevolucion.Rows[i].Cells[10].Value.ToString().Split('%');
                                        float    precioPorcentaje = Convert.ToSingle(porcentaje[0]);
                                        objDNC = new DetalleNotaCredito(Convert.ToInt32(idEncabezadoNC), Convert.ToSingle(Funcion.reemplazarcaracterViceversa(dgvProductosDevolucion.Rows[i].Cells[9].Value.ToString())), Convert.ToString(dgvProductosDevolucion.Rows[i].Cells[0].Value), Convert.ToSingle(Funcion.reemplazarcaracterViceversa(precioPorcentaje.ToString())));
                                        string resultadoDetalle = objDNC.InsertarDetalleNC(objDNC);
                                        if (resultadoDetalle == "Datos Guardados")
                                        {
                                            banderaCorrecto = true;
                                        }
                                        else if (resultadoDetalle == "Error al Registrar")
                                        {
                                            banderaCorrecto = false;
                                            break;
                                        }
                                        if (Convert.ToString(dgvProductosDevolucion.Rows[i + 1].Cells[0].Value) == "")
                                        {
                                            break;
                                        }
                                    }
                                    if (!banderaCorrecto)
                                    {
                                        MessageBox.Show("Error al guardar la Nota de Crédito", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        objConsultas.EjecutarSQL("DELETE FROM [dbo].[TbEncabezadoNotaCredito] WHERE IDENCABEZADOCOMPRA = " + compraDetalle + "");
                                        objConsultas.EjecutarSQL("DELETE FROM [dbo].[TbDetalleNotaCredito] WHERE IDENCABEZADONOTACREDITO = " + idEncabezadoNC + "");
                                        inicializar();
                                    }
                                    else
                                    {
                                        MessageBox.Show("Guardada correctamente la Nota de Crédito");
                                        inicializar();
                                    }
                                }
                                else if (resultado == "Error al Registrar")
                                {
                                    MessageBox.Show("Error al guardar la Nota de Crédito", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    objConsultas.EjecutarSQL("DELETE FROM [dbo].[TbEncabezadoNotaCredito] WHERE IDENCABEZADOCOMPRA = " + encabezadoNotaCredito + "");
                                }
                                else if (resultado == "Existe")
                                {
                                    MessageBox.Show("No hay mas crédito para esta compra", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }
                            }
                            else if (modificar)
                            {
                                objENC = new EncabezadoNotaCredito(txtSerie1NC.Text, txtSerie2NC.Text, txtNumeroNC.Text, compraDetalle, Convert.ToSingle(Funcion.reemplazarcaracterViceversa(txtTotalDevolucion.Text)), sumasubcero, sumasubiva, ivatotal, sumaice, sumairbp, Convert.ToDateTime(dtpFechaEmision.Value.ToShortDateString()), txtAutorizacionNC.Text, subtotalPie);
                                string resultado = objENC.ActualizarEncabezadoNC(encabezadoNotaCredito);
                                if (resultado == "Datos Guardados")
                                {
                                    string idEncabezadoNC = objConsultas.ObtenerValorCampo("IDENCABEZADONOTACREDITO", "TbEncabezadoNotaCredito", " where IDENCABEZADOCOMPRA = " + compraDetalle + " and SERIE1 = '" + txtSerie1NC.Text + "' and SERIE2 = '" + txtSerie2NC.Text + "' and NUMERO = '" + txtNumeroNC.Text + "' ");
                                    for (int i = 0; i < dgvProductosDevolucion.RowCount - 1; i++)
                                    {
                                        string[] porcentaje       = dgvProductosDevolucion.Rows[i].Cells[10].Value.ToString().Split('%');
                                        float    precioPorcentaje = Convert.ToSingle(porcentaje[0]);
                                        objDNC = new DetalleNotaCredito(Convert.ToInt32(idEncabezadoNC), Convert.ToSingle(Funcion.reemplazarcaracterViceversa(dgvProductosDevolucion.Rows[i].Cells[9].Value.ToString())), Convert.ToString(dgvProductosDevolucion.Rows[i].Cells[0].Value), Convert.ToSingle(Funcion.reemplazarcaracterViceversa(precioPorcentaje.ToString())));
                                        string resultadoDetalle = objDNC.ActualizarDetalleNC();
                                        if (resultadoDetalle == "Datos Guardados")
                                        {
                                            banderaCorrecto = true;
                                        }
                                        else if (resultadoDetalle == "Error al Registrar")
                                        {
                                            banderaCorrecto = false;
                                            break;
                                        }
                                        if (Convert.ToString(dgvProductosDevolucion.Rows[i + 1].Cells[0].Value) == "")
                                        {
                                            break;
                                        }
                                    }
                                    if (!banderaCorrecto)
                                    {
                                        MessageBox.Show("Error al guardar la Nota de Crédito", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        inicializar();
                                    }
                                    else
                                    {
                                        MessageBox.Show("Guardada correctamente la Nota de Crédito");
                                        inicializar();
                                    }
                                }
                                else if (resultado == "Error al Registrar")
                                {
                                    MessageBox.Show("Error al actualizar la Nota de Crédito", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }
                            }
                            else
                            {
                                MessageBox.Show("No se a realizado ninguna devolución", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Debe ingresar todos los datos", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        MessageBox.Show("No se a realizado ninguna devolución", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
        }
예제 #6
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            bool banderaCorrecto = false;

            if (txtTotalDevolucion.Text != "")
            {
                if (MessageBox.Show("¿Desea Gaurdar la Nota de Credito?", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (txtSerie1.Text != "" && txtSerie2.Text != "" && txtNumero.Text != "")
                    {
                        objENC = new EncabezadoNotaCredito(txtSerie1NC.Text, txtSerie2NC.Text, txtNumeroNC.Text, encabezadoCompra, Convert.ToSingle(Funcion.reemplazarcaracterViceversa(txtTotalDevolucion.Text)), sumasubcero, sumasubiva, ivatotal);
                        string resultado = objENC.InsertarEncabezadoNC(objENC);
                        if (resultado == "Datos Guardados")
                        {
                            string idEncabezadoNC = objConsultas.ObtenerValorCampo("IDENCABEZADONOTACREDITO", "TbEncabezadoNotaCredito", " where IDENCABEZADOCOMPRA = " + encabezadoCompra + "");
                            for (int i = 0; i < dgvProductosDevolucion.RowCount - 1; i++)
                            {
                                objDNC = new DetalleNotaCredito(Convert.ToInt32(idEncabezadoNC), Convert.ToInt32(dgvProductosDevolucion.Rows[i].Cells[10].Value), Convert.ToString(dgvProductosDevolucion.Rows[i].Cells[0].Value));
                                if (Convert.ToString(dgvProductosDevolucion.Rows[i].Cells[10].Value) != "")
                                {
                                    string resultadoDetalle = objDNC.InsertarDetalleNC(objDNC);
                                    if (resultado == "Datos Guardados")
                                    {
                                        banderaCorrecto = true;
                                    }
                                    else if (resultado == "Error al Registrar")
                                    {
                                        banderaCorrecto = false;
                                        break;
                                    }
                                    if (Convert.ToString(dgvProductosDevolucion.Rows[i + 1].Cells[0].Value) == "")
                                    {
                                        break;
                                    }
                                }
                            }
                            if (!banderaCorrecto)
                            {
                                MessageBox.Show("Error al guardar la Nota de Crédito", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                //string idEncabezadoNC = objConsultas.ObtenerValorCampo("IDENCABEZADONOTACREDITO", "TbEncabezadoNotaCredito", " where IDENCABEZADOCOMPRA = " + encabezadoCompra + "");
                                objConsultas.EjecutarSQL("DELETE FROM [dbo].[TbEncabezadoNotaCredito] WHERE IDENCABEZADOCOMPRA = " + encabezadoCompra + "");
                                objConsultas.EjecutarSQL("DELETE FROM [dbo].[TbDetalleNotaCredito] WHERE IDENCABEZADONOTACREDITO = " + idEncabezadoNC + "");
                                inicializar();
                            }
                            else
                            {
                                MessageBox.Show("Guardada correctamente la Nota de Crédito");
                                string numeroNC = (Convert.ToInt32(txtNumeroNC.Text) + 1).ToString("D9");
                                objConsultas.EjecutarSQL("UPDATE [dbo].[TbCajasTalonario] SET [DOCUMENTOACTUAL] = '" + numeroNC + "' WHERE SERIE1 = '" + txtSerie1NC.Text + "' and SERIE2 = '" + txtSerie2NC.Text + "' and IPESTACION = '" + bitacora.LocalIPAddress() + "' and TIPODOCUMENTO = 'NCRE'");
                                inicializar();
                            }
                        }
                        else if (resultado == "Error al Registrar")
                        {
                            MessageBox.Show("Error al guardar la Nota de Crédito", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            objConsultas.EjecutarSQL("DELETE FROM [dbo].[TbEncabezadoNotaCredito] WHERE IDENCABEZADOCOMPRA = " + encabezadoCompra + "");
                        }
                        else if (resultado == "Existe")
                        {
                            MessageBox.Show("Ya existe la Nota de Crédito", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("No se a realizado ninguna devolución", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }