/// <summary>
        /// Actualiza registros en la tabla Tipo_documento
        /// </summary>
        /// <param name="entity">Entidad Tipo_documento</param>
        public void Update(Tipo_documento entity)
        {
            string SqlString = "UPDATE [dbo].[Tipo_documento] " +
                               "SET [tipo_documento] = @tipo_documento " +
                               ",[letra] = @letra " +
                               ",[sucursal] = @sucursal " +
                               ",[numero] = @numero " +
                               "WHERE id = @id ";

            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    using (SqlCommand cmd = new SqlCommand(SqlString, conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@id", entity.id);
                        cmd.Parameters.AddWithValue("@tipo_documento", entity.tipo_documento);
                        cmd.Parameters.AddWithValue("@letra", entity.letra);
                        cmd.Parameters.AddWithValue("@sucursal", entity.sucursal);
                        cmd.Parameters.AddWithValue("@numero", entity.numero);

                        conn.Open();

                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        //----------------------------------------------------------------------------------------------
        //Llenar Combobox con
        public DataTable LlenarMedidorDAL()
        {
            ConnectionBD     stringconn  = new ConnectionBD();
            NpgsqlConnection conn        = new NpgsqlConnection(stringconn.Postgreconnection());
            NpgsqlCommand    postCommand = new NpgsqlCommand("LlenarCombo_Medidor", conn);

            postCommand.CommandType = CommandType.StoredProcedure;

            try
            {
                conn.Open();
                postCommand.ExecuteNonQuery();
                NpgsqlDataAdapter dta = new NpgsqlDataAdapter(postCommand);
                dta.Fill(ds);
            }

            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            if (ds.Tables.Count > 0)
            {
                return(ds.Tables[0]);
            }

            else
            {
                return(null);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Selecciona un registro de la tabla Proveedor
        /// </summary>
        /// <param name="id">int del registro a seleccionar</param>
        /// <returns>Proveedor</returns>
        public Proveedor GetById(int id)
        {
            Proveedor entity = null;

            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand("sp_get_supplier_by_id @id", conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@id", id);
                        using (IDataReader dr = cmd.ExecuteReader())
                        {
                            if (dr.Read())
                            {
                                entity = LoadEntity(dr);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }


            return(entity);
        }
Esempio n. 4
0
        //----------------------------------------------------------------------------------------------
        //Eliminar Fuente
        public String EliminarFuenteDAL(UTIL_Fuente utilFu)
        {
            ConnectionBD     stringconn  = new ConnectionBD();
            NpgsqlConnection conn        = new NpgsqlConnection(stringconn.Postgreconnection());
            NpgsqlCommand    postCommand = new NpgsqlCommand("update_fuentes", conn);

            postCommand.CommandType = CommandType.StoredProcedure;

            try
            {
                postCommand.Parameters.Add("_nombre", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilFu.sNombre);
                NpgsqlParameter message = postCommand.Parameters.Add("message", NpgsqlTypes.NpgsqlDbType.Text, 250);
                message.Direction = ParameterDirection.Output;


                conn.Open();
                postCommand.ExecuteNonQuery();
                messageOutput = postCommand.Parameters["message"].Value.ToString();
            }

            catch (Exception ex)
            {
                return(ex.Message);

                throw new Exception(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(messageOutput);
        }
        /// <summary>
        /// Inserta registros en la tabla TipoDoc_identidad
        /// </summary>
        /// <param name="entity">Entidad TipoDoc_identidad</param>
        /// <returns>Entidad TipoDoc_identidad</returns>
        public TipoDoc_identidad Insert(TipoDoc_identidad entity)
        {
            string SqlString = "INSERT INTO [dbo].[TipoDoc_identidad] " +
                               "([doc_identidad]) " +
                               "VALUES " +
                               "(@doc_identidad) ;SELECT SCOPE_IDENTITY() ";

            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    using (SqlCommand cmd = new SqlCommand(SqlString, conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@doc_identidad", entity.doc_identidad);
                        conn.Open();

                        //cmd.ExecuteNonQuery();
                        entity.id = Convert.ToInt32(cmd.ExecuteScalar());
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(entity);
        }
Esempio n. 6
0
        public List <Producto> ListByCategoria(int idCat)
        {
            List <Producto> result = new List <Producto>();

            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand("sp_get_productos_by_categoria @id", conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@id", idCat);
                        using (IDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                Producto entity = LoadEntity(dr);
                                result.Add(entity);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }


            return(result);
        }
Esempio n. 7
0
        //----------------------------------------------------------------------------------------------
        //Buscar Abonado por cedula
        public DataTable GetTarifaDALL()
        {
            ConnectionBD     stringconn  = new ConnectionBD();
            NpgsqlConnection conn        = new NpgsqlConnection(stringconn.Postgreconnection());
            NpgsqlCommand    postCommand = new NpgsqlCommand("Buscar_Tarifa", conn);

            postCommand.CommandType = CommandType.StoredProcedure;
            try
            {
                conn.Open();
                postCommand.ExecuteNonQuery();
                NpgsqlDataAdapter dta = new NpgsqlDataAdapter(postCommand);
                dta.Fill(ds);
                messageOutput = postCommand.Parameters["message"].Value.ToString();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            if (ds.Tables.Count > 0)
            {
                return(ds.Tables[0]);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Anula registros de la tabla Doc_cabecera_egreso
        /// </summary>
        /// <param name="id">int del id a eliminar</param>
        public void Delete(int id)
        {
            string SqlString = "UPDATE [dbo].[Doc_cabecera_egreso] " +
                               "SET [cancelada] = 1 " +
                               "WHERE id = @id ";

            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    using (SqlCommand cmd = new SqlCommand(SqlString, conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@id", id);
                        conn.Open();

                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 9
0
        //----------------------------------------------------------------------------------------------
        //Modificar Arreglo
        public String ModificarArregloDAL(UTIL_Arreglo utilAr)
        {
            ConnectionBD     stringconn  = new ConnectionBD();
            NpgsqlConnection conn        = new NpgsqlConnection(stringconn.Postgreconnection());
            NpgsqlCommand    postCommand = new NpgsqlCommand("update_arreglo", conn);

            postCommand.CommandType = CommandType.StoredProcedure;

            try
            {
                postCommand.Parameters.Add("_abonado", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilAr.iCedula);
                postCommand.Parameters.Add("_monto", NpgsqlTypes.NpgsqlDbType.Integer).Value   = UTIL.UTIL.ObtenerValor(utilAr.iMonto);
                postCommand.Parameters.Add("_abono", NpgsqlTypes.NpgsqlDbType.Integer).Value   = UTIL.UTIL.ObtenerValor(utilAr.iAbono);
                NpgsqlParameter message = postCommand.Parameters.Add("message", NpgsqlTypes.NpgsqlDbType.Text, 250);
                message.Direction = ParameterDirection.Output;


                conn.Open();
                postCommand.ExecuteNonQuery();
                messageOutput = postCommand.Parameters["message"].Value.ToString();
            }

            catch (Exception ex)
            {
                return(ex.Message);

                throw new Exception(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(messageOutput);
        }
Esempio n. 10
0
        /// <summary>
        /// Actualiza registros en la tabla Doc_detalle_egreso
        /// </summary>
        /// <param name="entity">Entidad Doc_detalle_egreso</param>
        public void Update(Doc_detalle_egreso entity)
        {
            string SqlString = "UPDATE [dbo].[Doc_detalle_egreso] " +
                               "SET [fk_id_producto] = @fk_id_producto " +
                               ",[cantidad] = @cantidad " +
                               ",[precio] = @precio " +
                               "WHERE id = @id ";

            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    using (SqlCommand cmd = new SqlCommand(SqlString, conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@id", entity.id);
                        cmd.Parameters.AddWithValue("@fk_id_producto", entity.fk_id_producto);
                        cmd.Parameters.AddWithValue("@cantidad", entity.cantidad);
                        cmd.Parameters.AddWithValue("@precio", entity.precio);

                        conn.Open();

                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Elimina registros de la tabla Categoría
        /// </summary>
        /// <param name="id">int para eliminar Categoria por id</param>
        public void Delete(int id)
        {
            try
            {
                string SqlString = "DELETE FROM [dbo].[Categoria] " +
                                   "WHERE id = @id";


                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    using (SqlCommand cmd = new SqlCommand(SqlString, conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@id", id);
                        conn.Open();

                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Selecciona los detalles de ventas de una cabecera en específico
        /// </summary>
        /// <param name="id_cab">int</param>
        /// <returns>List Doc_detalle_egreso</returns>
        public List <Doc_detalle_egreso> ListDetallesByCabecera(int id_cab)
        {
            List <Doc_detalle_egreso> result = new List <Doc_detalle_egreso>();

            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand("sp_get_detalles_ventas_by_id_cabecera @id_cab", conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@id_cab", id_cab);
                        using (IDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                Doc_detalle_egreso entity = LoadEntity(dr);
                                result.Add(entity);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(result);
        }
Esempio n. 13
0
        /// <summary>
        /// Inserta registros en la tabla Categoría
        /// </summary>
        /// <param name="entity">Entidad Categoría</param>
        /// <returns>Entidad Categoría a ser insertada</returns>
        public Categoria Insert(Categoria entity)
        {
            try
            {
                string SqlString = "INSERT INTO [dbo].[Categoria] " +
                                   "([categoria]) " +
                                   "VALUES " +
                                   "(@categoria) ;SELECT SCOPE_IDENTITY()";


                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    using (SqlCommand cmd = new SqlCommand(SqlString, conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@categoria", entity.categoria);
                        conn.Open();

                        //cmd.ExecuteNonQuery();
                        entity.id = Convert.ToInt32(cmd.ExecuteScalar());
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(entity);
        }
Esempio n. 14
0
        /// <summary>
        /// Actualiza registro de la tabla Categoría
        /// </summary>
        /// <param name="entity">Entidad Categoría a ser actualizada</param>
        public void Update(Categoria entity)
        {
            try
            {
                string SqlString = "UPDATE [dbo].[Categoria] " +
                                   "SET [categoria] = @categoria " +
                                   "WHERE id = @id ";


                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    using (SqlCommand cmd = new SqlCommand(SqlString, conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@id", entity.id);
                        cmd.Parameters.AddWithValue("@categoria", entity.categoria);
                        conn.Open();

                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 15
0
        //----------------------------------------------------------------------------------------------
        //Insertar Material
        public String AgregarMaterialDAL(UTIL_Material utilMa)
        {
            ConnectionBD     stringconn  = new ConnectionBD();
            NpgsqlConnection conn        = new NpgsqlConnection(stringconn.Postgreconnection());
            NpgsqlCommand    postCommand = new NpgsqlCommand("insert_materiales", conn);

            postCommand.CommandType = CommandType.StoredProcedure;

            try
            {
                postCommand.Parameters.Add("_asadafk", NpgsqlTypes.NpgsqlDbType.Text).Value  = UTIL.UTIL.ObtenerValor(utilMa.sAsada);
                postCommand.Parameters.Add("_material", NpgsqlTypes.NpgsqlDbType.Text).Value = UTIL.UTIL.ObtenerValor(utilMa.sNombre);
                postCommand.Parameters.Add("_stock", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilMa.iStock);
                NpgsqlParameter message = postCommand.Parameters.Add("message", NpgsqlTypes.NpgsqlDbType.Text, 250);
                message.Direction = ParameterDirection.Output;


                conn.Open();
                postCommand.ExecuteNonQuery();
                messageOutput = postCommand.Parameters["message"].Value.ToString();
            }

            catch (Exception ex)
            {
                return(ex.Message);

                throw new Exception(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(messageOutput);
        }
Esempio n. 16
0
        /// <summary>
        /// Selecciona registros de la tabla Tipo_log
        /// </summary>
        /// <returns>Lista Tipo_log</returns>
        public List <Tipo_log> List()
        {
            string SqlString = "SELECT [id] " +
                               ",[tipo_log] " +
                               "FROM [dbo].[Tipo_log] ";

            List <Tipo_log> result = new List <Tipo_log>();

            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand(SqlString, conn))
                    {
                        using (IDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                Tipo_log entity = LoadEntity(dr);
                                result.Add(entity);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(result);
        }
Esempio n. 17
0
        //----------------------------------------------------------------------------------------------
        //Modificar Usuario
        public String ModificarUsuarioDAL(UTIL_Usuario utilUs)
        {
            ConnectionBD     stringconn  = new ConnectionBD();
            NpgsqlConnection conn        = new NpgsqlConnection(stringconn.Postgreconnection());
            NpgsqlCommand    postCommand = new NpgsqlCommand("update_users", conn);

            postCommand.CommandType = CommandType.StoredProcedure;

            try
            {
                postCommand.Parameters.Add("_nick", NpgsqlTypes.NpgsqlDbType.Text).Value    = UTIL.UTIL.ObtenerValor(utilUs.sUser);
                postCommand.Parameters.Add("_tipo", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilUs.iTipo);
                NpgsqlParameter message = postCommand.Parameters.Add("message", NpgsqlTypes.NpgsqlDbType.Text, 250);
                message.Direction = ParameterDirection.Output;


                conn.Open();
                postCommand.ExecuteNonQuery();
                messageOutput = postCommand.Parameters["message"].Value.ToString();
            }

            catch (Exception ex)
            {
                return(ex.Message);

                throw new Exception(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(messageOutput);
        }
Esempio n. 18
0
        public String TipoMedidorDALL(int medidor)
        {
            ConnectionBD     stringconn  = new ConnectionBD();
            NpgsqlConnection conn        = new NpgsqlConnection(stringconn.Postgreconnection());
            NpgsqlCommand    postCommand = new NpgsqlCommand("Buscar_Tipo", conn);

            postCommand.CommandType = CommandType.StoredProcedure;
            try
            {
                postCommand.Parameters.Add("_medidor", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(medidor);
                NpgsqlParameter message = postCommand.Parameters.Add("message", NpgsqlTypes.NpgsqlDbType.Text, 250);
                message.Direction = ParameterDirection.Output;
                conn.Open();
                postCommand.ExecuteNonQuery();
                messageOutput = postCommand.Parameters["message"].Value.ToString();
            }
            catch (Exception ex)
            {
                return(ex.Message);

                throw new Exception(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(messageOutput);
        }
Esempio n. 19
0
        /// <summary>
        /// Selecciona registros de la tabla Proveedor
        /// </summary>
        /// <returns>Lista Proveedor</returns>
        public List <Proveedor> List()
        {
            List <Proveedor> result = new List <Proveedor>();


            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand("sp_list_suppliers", conn))
                    {
                        using (IDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                Proveedor entity = LoadEntity(dr);
                                result.Add(entity);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }


            return(result);
        }
Esempio n. 20
0
        /// <summary>
        /// Actualiza registros en la tabla Stock
        /// </summary>
        /// <param name="entity">Entidad Stock</param>
        public void Update(Stock entity)
        {
            string SqlString = "UPDATE [dbo].[Stock] " +
                               "SET [cantidad] = @cantidad " +
                               "WHERE [fk_id_producto] = @fk_id_producto ";

            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    using (SqlCommand cmd = new SqlCommand(SqlString, conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@fk_id_producto", entity.fk_id_producto);
                        cmd.Parameters.AddWithValue("@cantidad", entity.cantidad);

                        conn.Open();

                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Actualiza registros en la tabla Tipo_log
        /// </summary>
        /// <param name="entity">Entidad Tipo_log</param>
        public void Update(Tipo_log entity)
        {
            string SqlString = "UPDATE [dbo].[Tipo_log] " +
                               "SET [tipo_log] = @tipo_log " +
                               "WHERE id = @id ";

            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    using (SqlCommand cmd = new SqlCommand(SqlString, conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@id", entity.id);
                        cmd.Parameters.AddWithValue("@tipo_log", entity.tipo_log);

                        conn.Open();

                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Inserta registros en la tabla Tipo_log
        /// </summary>
        /// <param name="entity">Entidad Tipo_log</param>
        /// <returns>Entidad Tipo_log</returns>
        public Tipo_log Insert(Tipo_log entity)
        {
            string SqlString = "INSERT INTO [dbo].[Tipo_log] " +
                               "([tipo_log]) " +
                               "VALUES " +
                               "(@tipo_log) ";

            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    using (SqlCommand cmd = new SqlCommand(SqlString, conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@tipo_log", entity.tipo_log);
                        conn.Open();

                        //cmd.ExecuteNonQuery();
                        entity.id = Convert.ToInt32(cmd.ExecuteScalar());
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(entity);
        }
Esempio n. 23
0
        /// <summary>
        /// Selecciona un registro de la tabla Tipo_log
        /// </summary>
        /// <param name="id">int del registro a seleccionar</param>
        /// <returns>Tipo_log</returns>
        public Tipo_log GetById(int id)
        {
            string SqlString = "SELECT [id] " +
                               ",[tipo_log] " +
                               "FROM [dbo].[Tipo_log] " +
                               "WHERE id = @id";

            Tipo_log entity = null;

            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand(SqlString, conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@id", id);
                        using (IDataReader dr = cmd.ExecuteReader())
                        {
                            if (dr.Read())
                            {
                                entity = LoadEntity(dr);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(entity);
        }
Esempio n. 24
0
        /// <summary>
        /// Actualiza registros en la tabla Precio
        /// </summary>
        /// <param name="entity">Entidad Precio</param>
        public void Update(Precio entity)
        {
            string SqlString = "UPDATE [dbo].[Precio] " +
                               "SET [fk_id_producto] = @fk_id_producto " +
                               ",[desde] = @desde " +
                               ",[hasta] = @hasta " +
                               ",[costo] = @costo " +
                               ",[precio] = @precio " +
                               "WHERE id = @id ";

            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    using (SqlCommand cmd = new SqlCommand(SqlString, conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@id", entity.id);
                        cmd.Parameters.AddWithValue("@fk_id_producto", entity.fk_id_producto);
                        cmd.Parameters.AddWithValue("@desde", entity.desde);
                        cmd.Parameters.AddWithValue("@hasta", entity.hasta);
                        cmd.Parameters.AddWithValue("@costo", entity.costo);
                        cmd.Parameters.AddWithValue("@precio", entity.precio);
                        conn.Open();

                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Selecciona registros de la tabla Doc_cabecera_egreso
        /// </summary>
        /// <returns>Lista Doc_cabecera_egreso</returns>
        public List <Doc_cabecera_egreso> List()
        {
            List <Doc_cabecera_egreso> result = new List <Doc_cabecera_egreso>();

            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand("sp_list_facturas_ventas", conn))
                    {
                        using (IDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                Doc_cabecera_egreso entity = LoadEntity(dr);
                                result.Add(entity);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(result);
        }
Esempio n. 26
0
        //----------------------------------------------------------------------------------------------
        //Eliminar Lectura
        public String ModificarLecturaDAL(UTIL_Lectura utilLe)
        {
            ConnectionBD     stringconn  = new ConnectionBD();
            NpgsqlConnection conn        = new NpgsqlConnection(stringconn.Postgreconnection());
            NpgsqlCommand    postCommand = new NpgsqlCommand("update_lectura", conn);

            postCommand.CommandType = CommandType.StoredProcedure;

            try
            {
                postCommand.Parameters.Add("_medidor", NpgsqlTypes.NpgsqlDbType.Integer).Value  = UTIL.UTIL.ObtenerValor(utilLe.iMedidor);
                postCommand.Parameters.Add("_cantidad", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilLe.iLectura);
                NpgsqlParameter message = postCommand.Parameters.Add("message", NpgsqlTypes.NpgsqlDbType.Text, 250);
                message.Direction = ParameterDirection.Output;


                conn.Open();
                postCommand.ExecuteNonQuery();
                messageOutput = postCommand.Parameters["message"].Value.ToString();
            }

            catch (Exception ex)
            {
                return(ex.Message);

                throw new Exception(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(messageOutput);
        }
Esempio n. 27
0
        /// <summary>
        /// Selecciona un registro de la tabla Doc_cabecera_egreso
        /// </summary>
        /// <param name="id">int del registro a seleccionar</param>
        /// <returns>Doc_cabecera_egreso</returns>
        public Doc_cabecera_egreso GetById(int id)
        {
            Doc_cabecera_egreso entity = null;

            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand("sp_factura_venta_by_id @id", conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@id", id);
                        using (IDataReader dr = cmd.ExecuteReader())
                        {
                            if (dr.Read())
                            {
                                entity = LoadEntity(dr);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(entity);
        }
Esempio n. 28
0
        /// <summary>
        /// Inserta registros en la tabla Log
        /// </summary>
        /// <param name="entity">Entidad Log</param>
        /// <returns>Entidad Log a ser insertada</returns>
        public Log Insert(Log entity)
        {
            string SqlString = "INSERT INTO [dbo].[Log] " +
                               "([tipo_log] " +
                               ",[usuario] " +
                               ",[fecha] " +
                               ",[clase] " +
                               ",[metodo] " +
                               ",[stack_trace]  " +
                               ",[mensaje] " +
                               ",[info_operacion]) " +
                               "VALUES " +
                               "(@tipo_log " +
                               ",@usuario " +
                               ",@fecha " +
                               ",@clase " +
                               ",@metodo " +
                               ",@stack_trace " +
                               ",@mensaje " +
                               ",@info_operacion) ";

            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    using (SqlCommand cmd = new SqlCommand(SqlString, conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@id", entity.id);
                        cmd.Parameters.AddWithValue("@tipo_log", entity.tipo_log);
                        cmd.Parameters.AddWithValue("@usuario", entity.usuario);
                        cmd.Parameters.AddWithValue("@fecha", entity.fecha);
                        cmd.Parameters.AddWithValue("@clase", entity.clase);
                        cmd.Parameters.AddWithValue("@metodo", entity.metodo);
                        cmd.Parameters.AddWithValue("@stack_trace", entity.stack_trace);
                        cmd.Parameters.AddWithValue("@mensaje", entity.mensaje);
                        cmd.Parameters.AddWithValue("@info_operacion", entity.info_operacion);

                        conn.Open();

                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }


            return(entity);
        }
Esempio n. 29
0
        /// <summary>
        /// Inserta registros en la tabla Producto
        /// </summary>
        /// <param name="entity">Entidad Producto</param>
        /// <returns>Entidad Producto</returns>
        public Producto Insert(Producto entity)
        {
            string SqlString = "INSERT INTO [dbo].[Producto] " +
                               "([nombre] " +
                               ",[descripcion] " +
                               ",[fk_id_categoria] " +
                               ",[peso] " +
                               ",[alto] " +
                               ",[ancho] " +
                               ",[profundidad]) " +
                               "VALUES " +
                               "(@nombre " +
                               ",@descripcion " +
                               ",@fk_id_categoria " +
                               ",@peso " +
                               ",@alto " +
                               ",@ancho " +
                               ",@profundidad) ;SELECT SCOPE_IDENTITY()";


            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    using (SqlCommand cmd = new SqlCommand(SqlString, conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@nombre", entity.nombre);
                        cmd.Parameters.AddWithValue("@descripcion", entity.descripcion);
                        cmd.Parameters.AddWithValue("@fk_id_categoria", entity.fk_id_categoria);
                        cmd.Parameters.AddWithValue("@peso", entity.peso);
                        cmd.Parameters.AddWithValue("@alto", entity.alto);
                        cmd.Parameters.AddWithValue("@ancho", entity.ancho);
                        cmd.Parameters.AddWithValue("@profundidad", entity.profundidad);

                        conn.Open();

                        //cmd.ExecuteNonQuery();
                        entity.id = Convert.ToInt32(cmd.ExecuteScalar());
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(entity);
        }
Esempio n. 30
0
        /// <summary>
        /// Inserta registros en la tabla Proveedor
        /// </summary>
        /// <param name="entity">Entidad Proveedor</param>
        /// <returns>Entidad Proveedor</returns>
        public Proveedor Insert(Proveedor entity)
        {
            string SqlString = "INSERT INTO [dbo].[Proveedor] " +
                               "([nombre] " +
                               ",[fk_id_tipo_doc_identidad] " +
                               ",[num_documento] " +
                               ",[direccion] " +
                               ",[telefono] " +
                               ",[mail] " +
                               ",[url]) " +
                               "VALUES " +
                               "(@nombre " +
                               ",@fk_id_tipo_doc_identidad " +
                               ",@num_documento " +
                               ",@direccion " +
                               ",@telefono " +
                               ",@mail " +
                               ",@url) ;SELECT SCOPE_IDENTITY()";


            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    using (SqlCommand cmd = new SqlCommand(SqlString, conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@nombre", entity.nombre);
                        cmd.Parameters.AddWithValue("@fk_id_tipo_doc_identidad", entity.fk_id_tipo_doc_identidad);
                        cmd.Parameters.AddWithValue("@num_documento", entity.num_documento);
                        cmd.Parameters.AddWithValue("@direccion", entity.direccion);
                        cmd.Parameters.AddWithValue("@telefono", entity.telefono);
                        cmd.Parameters.AddWithValue("@mail", entity.mail);
                        cmd.Parameters.AddWithValue("@url", entity.url);
                        conn.Open();

                        //cmd.ExecuteNonQuery();
                        entity.id = Convert.ToInt32(cmd.ExecuteScalar());
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }


            return(entity);
        }