コード例 #1
0
    public static NotasDeCompraDetalle Get(System.Int32 ndCdetalleID)
    {
        DataSet              ds;
        Database             db;
        string               sqlCommand;
        DbCommand            dbCommand;
        NotasDeCompraDetalle instance;


        instance = new NotasDeCompraDetalle();

        db         = DatabaseFactory.CreateDatabase();
        sqlCommand = "[dbo].gspNotasDeCompraDetalle_SELECT";
        dbCommand  = db.GetStoredProcCommand(sqlCommand, ndCdetalleID);

        // Get results.
        ds = db.ExecuteDataSet(dbCommand);
        // Verification.
        if (ds == null || ds.Tables[0].Rows.Count == 0)
        {
            throw new ApplicationException("Could not get NotasDeCompraDetalle ID:" + ndCdetalleID.ToString() + " from Database.");
        }
        // Return results.
        ds.Tables[0].TableName = TABLE_NAME;

        instance.MapFrom(ds.Tables[0].Rows[0]);
        return(instance);
    }
コード例 #2
0
    public static NotasDeCompraDetalle[] Search(System.Int32?ndCdetalleID, System.Int32?notadecompraID, System.Int32?productoID, System.Int32?bodegaID, System.Double?cantidad, System.Decimal?preciodecompra, System.Double?sacos)
    {
        DataSet   ds;
        Database  db;
        string    sqlCommand;
        DbCommand dbCommand;


        db         = DatabaseFactory.CreateDatabase();
        sqlCommand = "[dbo].gspNotasDeCompraDetalle_SEARCH";
        dbCommand  = db.GetStoredProcCommand(sqlCommand, ndCdetalleID, notadecompraID, productoID, bodegaID, cantidad, preciodecompra, sacos);

        ds = db.ExecuteDataSet(dbCommand);
        ds.Tables[0].TableName = TABLE_NAME;
        return(NotasDeCompraDetalle.MapFrom(ds));
    }
コード例 #3
0
ファイル: NotasDeCompraDetalle.cs プロジェクト: windygu/CCSys
    public static NotasDeCompraDetalle[] Search(System.Int32?notadecompraID)
    {
        DataSet   ds;
        Database  db;
        string    sqlCommand;
        DbCommand dbCommand;


        db         = DatabaseFactory.CreateDatabase();
        sqlCommand = "[dbo].gspNotasDeCompraDetalle_SEARCH";
        dbCommand  = db.GetStoredProcCommand(sqlCommand, null,
                                             notadecompraID, null, null, null, null, null, null);

        ds = db.ExecuteDataSet(dbCommand);
        ds.Tables[0].TableName = TABLE_NAME;
        return(NotasDeCompraDetalle.MapFrom(ds));
    }
コード例 #4
0
    /*
     *  private void MapFrom(DataRow dr)
     *          {
     *                  NDCdetalleID = dr["NDCdetalleID"] != DBNull.Value ? Convert.ToInt32(dr["NDCdetalleID"]) : NDCdetalleID = null;
     *                  NotadecompraID = dr["notadecompraID"] != DBNull.Value ? Convert.ToInt32(dr["notadecompraID"]) : NotadecompraID = null;
     *                  ProductoID = dr["productoID"] != DBNull.Value ? Convert.ToInt32(dr["productoID"]) : ProductoID = null;
     *                  BodegaID = dr["bodegaID"] != DBNull.Value ? Convert.ToInt32(dr["bodegaID"]) : BodegaID = null;
     *                  Cantidad = dr["cantidad"] != DBNull.Value ? Convert.ToDouble(dr["cantidad"]) : Cantidad = null;
     *                  Preciodecompra = dr["preciodecompra"] != DBNull.Value ? Convert.ToDecimal(dr["preciodecompra"]) : Preciodecompra = null;
     *                  Sacos = dr["sacos"] != DBNull.Value ? Convert.ToDouble(dr["sacos"]) : Sacos = null;
     *          }*/


    public static NotasDeCompraDetalle[] MapFrom(DataSet ds)
    {
        List <NotasDeCompraDetalle> objects;


        // Initialise Collection.
        objects = new List <NotasDeCompraDetalle>();

        // Validation.
        if (ds == null)
        {
            throw new ApplicationException("Cannot map to dataset null.");
        }
        else if (ds.Tables[TABLE_NAME].Rows.Count == 0)
        {
            return(objects.ToArray());
        }

        if (ds.Tables[TABLE_NAME] == null)
        {
            throw new ApplicationException("Cannot find table [dbo].[NotasDeCompra_Detalle] in DataSet.");
        }

        if (ds.Tables[TABLE_NAME].Rows.Count < 1)
        {
            throw new ApplicationException("Table [dbo].[NotasDeCompra_Detalle] is empty.");
        }

        // Map DataSet to Instance.
        foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows)
        {
            NotasDeCompraDetalle instance = new NotasDeCompraDetalle();
            instance.MapFrom(dr);
            objects.Add(instance);
        }

        // Return collection.
        return(objects.ToArray());
    }