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); }
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)); }
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)); }
/* * 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()); }
protected void btnAddproduct_Click(object sender, EventArgs e) { try { NotasDeCompraDetalle detalle = new NotasDeCompraDetalle(); detalle.ProductoID = int.Parse(this.drpdlProducto.SelectedValue); detalle.Preciodecompra = decimal.Parse(this.txtPrecio.Text); detalle.NotadecompraID = int.Parse(this.txtNotaIDToMod.Text); NotasDeCompraDetalle [] detalles = NotasDeCompraDetalle.Search(detalle); if (detalles.Length == 1) { detalles[0].Cantidad += double.Parse(this.txtCantidad.Text); detalles[0].Sacos = 1; detalles[0].Update(); } else { detalle.NotadecompraID = int.Parse(this.txtNotaIDToMod.Text); detalle.ProductoID = int.Parse(this.drpdlProducto.SelectedValue); detalle.BodegaID = int.Parse(this.drpdlBodega.SelectedValue); detalle.Cantidad = double.Parse(this.txtCantidad.Text); detalle.Preciodecompra = decimal.Parse(this.txtPrecio.Text); detalle.Sacos = 1; detalle.Insert(); } this.txtCantidad.Text = this.txtPrecio.Text = this.txtImporte.Text = ""; } catch (System.Exception ex) { Logger.Instance.LogException(Logger.typeUserActions.INSERT, "error agregando producto a nota", this.Request.Url.ToString(), ref ex); } this.grdvProNotas.DataBind(); this.btnGuardaNotaCompra_Click(null, null); }
public static NotasDeCompraDetalle[] Search(NotasDeCompraDetalle searchObject) { return(Search(searchObject.NDCdetalleID, searchObject.NotadecompraID, searchObject.ProductoID, searchObject.BodegaID, searchObject.Cantidad, searchObject.Preciodecompra, searchObject.Sacos)); }
public static void Update(NotasDeCompraDetalle notasDeCompraDetalle, DbTransaction transaction) { notasDeCompraDetalle.Update(transaction); }
public static void Update(NotasDeCompraDetalle notasDeCompraDetalle) { notasDeCompraDetalle.Update(); }