public static List<NotaVentaEN> BuscarNotaVenta(string NroNota) { var ListaNota = new List<NotaVentaEN>(); using (var Cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["Mercader"].ToString())) { Cnn.Open(); string ConsultaActivo = "SELECT COUNT(*) FROM Nota_Venta WHERE Nro_Nota=@Param1 AND Activo=0"; var CmdActivo = new SqlCommand(ConsultaActivo, Cnn); CmdActivo.Parameters.AddWithValue("@Param1", NroNota); int Activo = Conversions.ToInteger(CmdActivo.ExecuteScalar()); if (Activo > 0) { throw new WarningException(My.Resources.ArchivoIdioma.NotaVentaDadaBaja); //throw new WarningException(Datos.My.Resources.ArchivoIdioma.NotaVentaDadaBaja); } else { string Consulta = "SELECT Nro_Nota,CONVERT(VARCHAR(10),Fecha,103) FROM Nota_Venta WHERE Nro_Nota LIKE '%' + @Param1 + '%'"; var CmdBuscar = new SqlCommand(Consulta, Cnn); CmdBuscar.Parameters.AddWithValue("@Param1", NroNota); var Lector = CmdBuscar.ExecuteReader(); while (Lector.Read()) { var UnaNota = new NotaVentaEN(); UnaNota.NroNota = Conversions.ToString(Lector[0]); UnaNota.Fecha = Conversions.ToString(Lector[1]); ListaNota.Add(UnaNota); } return ListaNota; } } }
public static void BajaNotaVenta(NotaVentaEN NotaVenta) { using (var Cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["Mercader"].ToString())) { Cnn.Open(); string ConsultaValidar = "SELECT COUNT(*) FROM Nota_Venta WHERE Nro_Nota=@Param1"; var Cmd = new SqlCommand(ConsultaValidar, Cnn); Cmd.Parameters.AddWithValue("@Param1", NotaVenta.NroNota); int Resultado = Conversions.ToInteger(Cmd.ExecuteScalar()); if (Resultado > 0) { string ConsultaActivo = "SELECT COUNT(*) FROM Nota_Venta WHERE Nro_Nota=@Param1 AND Activo=0"; var CmdActivo = new SqlCommand(ConsultaActivo, Cnn); CmdActivo.Parameters.AddWithValue("@Param1", NotaVenta.NroNota); int Activo = Conversions.ToInteger(CmdActivo.ExecuteScalar()); if (Activo > 0) { throw new WarningException(Datos.My.Resources.ArchivoIdioma.NotaVentaDadaBaja); } else { // BajaNota string ConsultaUpdate = "UPDATE Nota_Venta SET Activo=0 WHERE Nro_Nota=@Param1"; var CmdUpdate = new SqlCommand(ConsultaUpdate, Cnn); CmdUpdate.Parameters.AddWithValue("@Param1", NotaVenta.NroNota); CmdUpdate.ExecuteNonQuery(); } } else { throw new WarningException(Datos.My.Resources.ArchivoIdioma.NotaVentaNoExiste); } } }
/// <param name="NotaVenta"></param> public static void CrearNotaVenta(NotaVentaEN NotaVenta) { using (var Cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["Mercader"].ToString())) { Cnn.Open(); string ConsultaAlta = "INSERT INTO Nota_Venta(Nro_Nota,Cliente_CodCli,Fecha,Activo)" + "VALUES('1',@CodCli,GETDATE(),1) " + "SELECT SCOPE_IDENTITY()"; var Cmd = new SqlCommand(ConsultaAlta, Cnn); Cmd.Parameters.AddWithValue("@CodCli", NotaVenta.CodCli); NotaVenta.CodNot = Conversions.ToInteger(Cmd.ExecuteScalar()); foreach (DetalleEN item in NotaVenta.Detalle) DatosC.NegocioAD.AltaLineaDetalle(NotaVenta.CodNot, item, "Detalle_NotaVenta"); } }
/// <param name="NotaVenta"></param> public static void CrearNotaVenta(NotaVentaEN NotaVenta) { var ListaDetalle = new List<DetalleEN>(); foreach (DetalleEN item in NotaVenta.Detalle) { var Linea = new DetalleEN(); Linea.CodProd = item.CodProd; Linea.NombreProducto = item.NombreProducto; Linea.Precio = Seguridad.Encriptar(item.Precio); Linea.Cantidad = item.Cantidad; ListaDetalle.Add(Linea); } NotaVenta.Detalle = ListaDetalle; NotaVentaAD.CrearNotaVenta(NotaVenta); foreach (DetalleEN item in NotaVenta.Detalle) { var DVHDatos = new DVHEN(); DVHDatos.Tabla = "Producto"; DVHDatos.CodReg = item.CodProd; int DVH = Integridad.CalcularDVH(DVHDatos); int ValorDVHAntiguo = Integridad.GrabarDVH(DVHDatos, DVH); var DVVDatos = new DVVEN(); DVVDatos.Tabla = "Producto"; DVVDatos.ValorDVH = DVH; DVVDatos.TipoAccion = "Baja Modificar"; DVVDatos.ValorDVHAntiguo = ValorDVHAntiguo; Integridad.GrabarDVV(DVVDatos); } var Bitacora = new BitacoraEN(); var UsuAut = Autenticar.Instancia(); Bitacora.Descripcion = Seguridad.Encriptar("Alta de Nota de Venta | Cod: " + NotaVenta.CodNot); Bitacora.Criticidad = 3.ToString(); Bitacora.Usuario = UsuAut.UsuarioLogueado; BitacoraAD.GrabarBitacora(Bitacora); var DVHDatosBitacora = new DVHEN(); DVHDatosBitacora.Tabla = "Bitacora"; DVHDatosBitacora.CodReg = Bitacora.CodBit; int DVHBitacora = Integridad.CalcularDVH(DVHDatosBitacora); int ValorDVHAntiguoBit = Integridad.GrabarDVH(DVHDatosBitacora, DVHBitacora); var DVVDatosBitacora = new DVVEN(); DVVDatosBitacora.Tabla = "Bitacora"; DVVDatosBitacora.ValorDVH = DVHBitacora; DVVDatosBitacora.TipoAccion = "Alta"; Integridad.GrabarDVV(DVVDatosBitacora); throw new InformationException(My.Resources.ArchivoIdioma.AltaNotaVenta); //throw new InformationException(Negocios.My.Resources.ArchivoIdioma.AltaNotaVenta); }
/// <param name="NotaVenta"></param> public static void BajaNotaVenta(NotaVentaEN NotaVenta) { NotaVentaAD.BajaNotaVenta(NotaVenta); int CodNot = NotaVentaAD.ObtenerIDNotaVenta(NotaVenta.NroNota); var ListaDetalle = new List<DetalleEN>(); ListaDetalle = NotaVentaAD.ObtenerDetalleNV(CodNot); foreach (DetalleEN item in ListaDetalle) { var Detalle = new DetalleEN(); Detalle.CodProd = item.CodProd; Detalle.Cantidad = item.Cantidad; NotaVentaAD.ActualizarCantidadProducto(Detalle); var DVHDatos = new DVHEN(); DVHDatos.Tabla = "Producto"; DVHDatos.CodReg = item.CodProd; int DVH = Integridad.CalcularDVH(DVHDatos); int ValorDVHAntiguo = Integridad.GrabarDVH(DVHDatos, DVH); var DVVDatos = new DVVEN(); DVVDatos.Tabla = "Producto"; DVVDatos.ValorDVH = DVH; DVVDatos.TipoAccion = "Baja Modificar"; DVVDatos.ValorDVHAntiguo = ValorDVHAntiguo; Integridad.GrabarDVV(DVVDatos); } var Bitacora = new BitacoraEN(); var UsuAut = Autenticar.Instancia(); Bitacora.Descripcion = Seguridad.Encriptar("Baja de la Nota de Venta con Nro: " + NotaVenta.NroNota); Bitacora.Criticidad = 2.ToString(); Bitacora.Usuario = UsuAut.UsuarioLogueado; BitacoraAD.GrabarBitacora(Bitacora); var DVHDatosBitacora = new DVHEN(); DVHDatosBitacora.Tabla = "Bitacora"; DVHDatosBitacora.CodReg = Bitacora.CodBit; int DVHBitacora = Integridad.CalcularDVH(DVHDatosBitacora); int ValorDVHAntiguoBit = Integridad.GrabarDVH(DVHDatosBitacora, DVHBitacora); var DVVDatosBitacora = new DVVEN(); DVVDatosBitacora.Tabla = "Bitacora"; DVVDatosBitacora.ValorDVH = DVHBitacora; DVVDatosBitacora.TipoAccion = "Alta"; Integridad.GrabarDVV(DVVDatosBitacora); throw new InformationException(My.Resources.ArchivoIdioma.BajaNotaVenta); //throw new InformationException(Negocios.My.Resources.ArchivoIdioma.BajaNotaVenta); }
public static List<NotaVentaEN> CargarNotaVenta() { var ListaNV = new List<NotaVentaEN>(); using (var Cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["Mercader"].ToString())) { Cnn.Open(); string Consulta = "SELECT Nro_Nota,CONVERT(VARCHAR(10),Fecha,103) FROM Nota_Venta WHERE Activo=1"; var Cmd = new SqlCommand(Consulta, Cnn); var Lector = Cmd.ExecuteReader(); while (Lector.Read()) { var UnaNota = new NotaVentaEN(); UnaNota.NroNota = Conversions.ToString(Lector[0]); UnaNota.Fecha = Conversions.ToString(Lector[1]); ListaNV.Add(UnaNota); } return ListaNV; } }