예제 #1
0
        public static List <DetallesFacturaEntity> GetAllQuery(string pConnection, string pQuery)
        {
            List <DetallesFacturaEntity> lReturnList = new List <DetallesFacturaEntity>();

            using (SqlConnection lConnection = new SqlConnection(pConnection))
            {
                using (SqlDataAdapter lDataAdapter = new SqlDataAdapter(pQuery, lConnection))
                {
                    lDataAdapter.SelectCommand.CommandType = CommandType.Text;
                    DataTable lDataTable = new DataTable();
                    lDataAdapter.Fill(lDataTable);
                    if (lDataTable != null && lDataTable.Rows.Count > 0)
                    {
                        foreach (DataRow lRow in lDataTable.Rows)
                        {
                            DetallesFacturaEntity lDetalles = new DetallesFacturaEntity();
                            lDetalles.id = Convert.ToInt32(lRow["id"]);
                            lDetalles.cantidad_productos = Convert.ToInt32(lRow["cantidad_productos"]);
                            lDetalles.total        = Convert.ToDecimal(lRow["total"]);
                            lDetalles.id_factura   = Guid.Parse((string)lRow["id_factura"]);
                            lDetalles.id_productos = Convert.ToInt32(lRow["id_productos"]);
                            lReturnList.Add(lDetalles);
                        }
                    }
                }
            }
            return(lReturnList);
        }
예제 #2
0
 public static DetallesFacturaEntity GetSingle(string pConnection, DetallesFacturaEntity pDetalles)
 {
     using (SqlConnection lConnection = new SqlConnection(pConnection))
     {
         using (SqlDataAdapter lDataAdapter = new SqlDataAdapter("SELECT TOP 1 * FROM tb_detalles_factura WHERE id=@id", lConnection))
         {
             lDataAdapter.SelectCommand.CommandType = CommandType.Text;
             lDataAdapter.SelectCommand.Parameters.AddWithValue("@id", pDetalles.id);
             DataTable lDataTable = new DataTable();
             lDataAdapter.Fill(lDataTable);
             if (lDataTable != null && lDataTable.Rows.Count > 0)
             {
                 DataRow lRow = lDataTable.Rows[0];
                 DetallesFacturaEntity lDetalles = new DetallesFacturaEntity();
                 lDetalles.id = Convert.ToInt32(lRow["id"]);
                 lDetalles.cantidad_productos = Convert.ToInt32(lRow["cantidad_productos"]);
                 lDetalles.total        = Convert.ToDecimal(lRow["total"]);
                 lDetalles.id_factura   = Guid.Parse((string)lRow["id_factura"]);
                 lDetalles.id_productos = Convert.ToInt32(lRow["id_productos"]);
                 return(lDetalles);
             }
         }
     }
     return(null);
 }
예제 #3
0
        public void Delete(string pConnection)
        {
            DetallesFacturaEntity pDetalles = new DetallesFacturaEntity();

            pDetalles.id = id;
            DetallesFacturaDAL.Delete(pConnection, pDetalles);
        }
예제 #4
0
        public static bool Exists(string pConnection, int pId)
        {
            DetallesFacturaEntity pDetalles = new DetallesFacturaEntity();

            pDetalles.id = pId;

            return(DetallesFacturaDAL.Exists(pConnection, pDetalles));
        }
예제 #5
0
        public void DeleteTransaction(SqlConnection pConnection, SqlTransaction pTransaction)
        {
            DetallesFacturaEntity pDetalles = new DetallesFacturaEntity();

            pDetalles.id = id;

            DetallesFacturaDAL.DeleteTransaction(pConnection, pTransaction, pDetalles);
        }
예제 #6
0
 public DetallesFacturaBO(DetallesFacturaEntity pDetalles)
 {
     try
     {
         this.FillEntity(pDetalles);
     }
     catch
     {
         this.FillEntity();
     }
 }
예제 #7
0
 public static void Delete(string pConnection, DetallesFacturaEntity pDetalles)
 {
     using (SqlConnection lConnection = new SqlConnection(pConnection))
     {
         using (SqlCommand lCommand = new SqlCommand("DELETE FROM tb_detalles_factura WHERE id=@id", lConnection))
         {
             lCommand.CommandType = CommandType.Text;
             lCommand.Parameters.AddWithValue("@id", pDetalles.id);
             lConnection.Open();
             lCommand.ExecuteNonQuery();
             lConnection.Close();
         }
     }
 }
예제 #8
0
        public DetallesFacturaBO(string pConnection, int pId)
        {
            DetallesFacturaEntity pDetalles = new DetallesFacturaEntity();

            pDetalles.id = pId;

            try
            {
                this.FillEntity(DetallesFacturaDAL.GetSingle(pConnection, pDetalles));
            }
            catch
            {
                this.FillEntity();
            }
        }
예제 #9
0
 private void FillEntity(DetallesFacturaEntity pDetalle)
 {
     try
     {
         id = pDetalle.id;
         cantidad_productos = pDetalle.cantidad_productos;
         total        = pDetalle.total;
         id_factura   = pDetalle.id_factura;
         id_productos = pDetalle.id_productos;
         IsNew        = false;
     }
     catch
     {
         this.FillEntity();
     }
 }
예제 #10
0
 public static void Add(string pConnection, DetallesFacturaEntity pDetalle)
 {
     using (SqlConnection lConnection = new SqlConnection(pConnection))
     {
         using (SqlCommand lCommand = new SqlCommand("INSERT INTO tb_detalles_factura (cantiad_productos,total,id_factura,id_productos) VALUES (@cantiad_productos,@total,@id_factura,@id_productos)", lConnection))
         {
             lCommand.CommandType = CommandType.Text;
             lCommand.Parameters.AddWithValue("@cantidad_productos", pDetalle.cantidad_productos);
             lCommand.Parameters.AddWithValue("@total", pDetalle.total);
             lCommand.Parameters.AddWithValue("@id_factura", pDetalle.id_factura);
             lCommand.Parameters.AddWithValue("@id_productos", pDetalle.id_productos);
             lConnection.Open();
             lCommand.ExecuteNonQuery();
             lConnection.Close();
         }
     }
 }
예제 #11
0
 public static void Update(string pConnection, DetallesFacturaEntity pDetalle)
 {
     using (SqlConnection lConnection = new SqlConnection(pConnection))
     {
         using (SqlCommand lCommand = new SqlCommand("UPDATE tb_detalles_factura SET cantidad_productos=@cantidad_productos, total=@total,id_factura=@id_factura,id_productos=@id_productos WHERE id=@id", lConnection))
         {
             lCommand.CommandType = CommandType.Text;
             lCommand.Parameters.AddWithValue("@id", pDetalle.id);
             lCommand.Parameters.AddWithValue("@cantidad_productos", pDetalle.cantidad_productos);
             lCommand.Parameters.AddWithValue("@total", pDetalle.total);
             lCommand.Parameters.AddWithValue("@id_factura", pDetalle.id_factura);
             lCommand.Parameters.AddWithValue("@id_productos", pDetalle.id_productos);
             lConnection.Open();
             lCommand.ExecuteNonQuery();
             lConnection.Close();
         }
     }
 }
예제 #12
0
        public void Save(string pConnection)
        {
            DetallesFacturaEntity pDetalles = new DetallesFacturaEntity();

            pDetalles.id = id;
            pDetalles.cantidad_productos = cantidad_productos;
            pDetalles.total        = total;
            pDetalles.id_factura   = id_factura;
            pDetalles.id_productos = id_productos;
            if (IsNew == false)
            {
                DetallesFacturaDAL.Update(pConnection, pDetalles);
            }
            else
            {
                DetallesFacturaDAL.Add(pConnection, pDetalles);
            }
        }
예제 #13
0
        public void SaveTransaction(SqlConnection pConnection, SqlTransaction pTransaction)
        {
            DetallesFacturaEntity pDettalles = new DetallesFacturaEntity();

            pDettalles.id = id;
            pDettalles.cantidad_productos = cantidad_productos;
            pDettalles.total        = total;
            pDettalles.id_factura   = id_factura;
            pDettalles.id_productos = id_productos;

            if (IsNew == false)
            {
                DetallesFacturaDAL.UpdateTransaction(pConnection, pTransaction, pDettalles);
            }
            else
            {
                DetallesFacturaDAL.AddTransaction(pConnection, pTransaction, pDettalles);
            }
        }
예제 #14
0
        public static bool Exists(string pConnection, DetallesFacturaEntity pDetalle)
        {
            bool lExists = false;

            using (SqlConnection lConnection = new SqlConnection(pConnection))
            {
                using (SqlCommand lCommand = new SqlCommand("SELECT COUNT(*) FROM tb_detalles_factura WHERE id=@id", lConnection))
                {
                    lCommand.CommandType = CommandType.Text;
                    lCommand.Parameters.AddWithValue("@id", pDetalle.id);
                    lConnection.Open();
                    object lReturnValue = lCommand.ExecuteScalar();
                    lConnection.Close();
                    if (!object.ReferenceEquals(lReturnValue, DBNull.Value) && lReturnValue != null)
                    {
                        lExists = Convert.ToInt32(lReturnValue) > 0;
                    }
                }
            }

            return(lExists);
        }
예제 #15
0
 public static void DeleteTransaction(SqlConnection pConnection, SqlTransaction pTransaction, DetallesFacturaEntity pDetalles)
 {
     using (SqlCommand lCommand = new SqlCommand("DELETE FROM tb_detalles_factura WHERE id=@id", pConnection))
     {
         lCommand.Transaction = pTransaction;
         lCommand.CommandType = CommandType.Text;
         lCommand.Parameters.AddWithValue("@id", pDetalles.id);
         lCommand.ExecuteNonQuery();
     }
 }
예제 #16
0
 public static DetallesFacturaBO GetSingle(string pConnection, DetallesFacturaEntity pDetalles)
 {
     pDetalles = DetallesFacturaDAL.GetSingle(pConnection, pDetalles);
     return(new DetallesFacturaBO(pDetalles));
 }