public static NotasDeCompra Get(System.Int32 notadecompraID) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; NotasDeCompra instance; instance = new NotasDeCompra(); db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspNotasDeCompra_SELECT"; dbCommand = db.GetStoredProcCommand(sqlCommand, notadecompraID); // Get results. ds = db.ExecuteDataSet(dbCommand); // Verification. if (ds == null || ds.Tables[0].Rows.Count == 0) { throw new ApplicationException("Could not get NotasDeCompra ID:" + notadecompraID.ToString() + " from Database."); } // Return results. ds.Tables[0].TableName = TABLE_NAME; instance.MapFrom(ds.Tables[0].Rows[0]); return(instance); }
public static NotasDeCompra[] Search(System.Int32?notadecompraID, System.Int32?proveedorID, System.Int32?cicloID, System.DateTime?fecha, System.String folio, System.Boolean?llevaIVA, System.String observaciones, System.Int32?userID, System.DateTime?storeTS, System.DateTime?updateTS, System.DateTime?fechapago, System.Boolean?pagada, System.Int32?tipomonedaID) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspNotasDeCompra_SEARCH"; dbCommand = db.GetStoredProcCommand(sqlCommand, notadecompraID, proveedorID, cicloID, fecha, folio, llevaIVA, observaciones, userID, storeTS, updateTS, fechapago, pagada, tipomonedaID); ds = db.ExecuteDataSet(dbCommand); ds.Tables[0].TableName = TABLE_NAME; return(NotasDeCompra.MapFrom(ds)); }
private void LoadNota(string NotaID) { try { NotasDeCompra nota = NotasDeCompra.Get(int.Parse(NotaID)); this.drpdlProveedor.SelectedValue = nota.ProveedorID.ToString(); this.drpdlProveedor_SelectedIndexChanged(null, null); this.drpdlCiclo.SelectedValue = nota.CicloID.ToString(); this.PopCalendar3.SelectedDate = Utils.converttoshortFormatfromdbFormat(nota.Fecha.ToString()); this.txtNumNota.Text = nota.Folio.ToString(); this.ddlTipoDeMoneda.DataBind(); this.ddlTipoDeMoneda.SelectedValue = nota.TipomonedaID.ToString(); this.ActualizaTotales(); } catch (System.Exception ex) { Logger.Instance.LogException(Logger.typeUserActions.SELECT, "LoadNota", this.Request.Url.ToString(), ref ex); } }
public static NotasDeCompra[] MapFrom(DataSet ds) { List <NotasDeCompra> objects; // Initialise Collection. objects = new List <NotasDeCompra>(); // 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] in DataSet."); } if (ds.Tables[TABLE_NAME].Rows.Count < 1) { throw new ApplicationException("Table [dbo].[NotasDeCompra] is empty."); } // Map DataSet to Instance. foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows) { NotasDeCompra instance = new NotasDeCompra(); instance.MapFrom(dr); objects.Add(instance); } // Return collection. return(objects.ToArray()); }
protected void btnAgregarNewNotaCompra_Click(object sender, EventArgs e) { this.pnlCentral.Visible = true; this.btnAgregarNewNotaCompra.Visible = false; try { NotasDeCompra nota = new NotasDeCompra(); nota.ProveedorID = int.Parse(this.drpdlProveedor.SelectedValue); nota.CicloID = int.Parse(this.drpdlCiclo.SelectedValue); nota.Fecha = DateTime.Parse(this.txtFecha.Text); nota.Folio = this.txtNumNota.Text; nota.Observaciones = this.txtObservaciones.Text; nota.UserID = this.UserID; nota.StoreTS = nota.UpdateTS = Utils.Now; nota.TipomonedaID = int.Parse(this.ddlTipoDeMoneda.SelectedItem.Value); nota.LlevaIVA = false; nota.Pagada = false; nota.Insert(); if (nota.NotadecompraID > 0) { Logger.Instance.LogUserSessionRecord(Logger.typeModulo.NOTACOMPRA, Logger.typeUserActions.INSERT, int.Parse(Session["USERID"].ToString()), "AGREGÓ LA NOTA DE COMPRA:" + nota.NotadecompraID); String sQuery = "NotaComID=" + nota.NotadecompraID.ToString(); sQuery = Utils.GetEncriptedQueryString(sQuery); String strRedirect = "~/frmAddNotasCompras.aspx" + sQuery; Response.Redirect(strRedirect); } else { throw new Exception("error insertando nota de compra"); } } catch (System.Exception ex) { Logger.Instance.LogException(Logger.typeUserActions.INSERT, "btnAgregarNewNotaCompra_Click", this.Request.Url.ToString(), ref ex); } }
protected void btnGuardaNotaCompra_Click(object sender, EventArgs e) { try { NotasDeCompra nota = NotasDeCompra.Get(int.Parse(this.txtNotaIDToMod.Text)); nota.ProveedorID = int.Parse(this.drpdlProveedor.SelectedValue); nota.CicloID = int.Parse(this.drpdlCiclo.SelectedValue); nota.Fecha = DateTime.Parse(Utils.converttoLongDBFormat(this.txtFecha.Text)); nota.Folio = this.txtNumNota.Text; nota.Observaciones = this.txtObservaciones.Text; nota.Fechapago = DateTime.Parse(Utils.converttoLongDBFormat(this.txtFechapago.Text)); nota.TipomonedaID = int.Parse(this.ddlTipoDeMoneda.SelectedItem.Value); nota.Update(); } catch (System.Exception ex) { Logger.Instance.LogException(Logger.typeUserActions.UPDATE, "err updating NOTA", ref ex); this.imgBien.Visible = false; this.imgMal.Visible = this.pnlNotaCompraResult.Visible = true; this.lblNotaCompraResult.Visible = true; this.lblNotaCompraResult.Text = "ESTO ES VERGONZOSO, HA OCURRIDO UNA EXCEPCION Y NO SE PUDO GUARDAR LA NOTA.<BR>POR FAVOR ESPERE UN MOMENTO E INTENTELO DE NUEVO<BR>Descripción del error<BR>" + ex.Message; } }
public static NotasDeCompra[] Search(NotasDeCompra searchObject) { return(Search(searchObject.NotadecompraID, searchObject.ProveedorID, searchObject.CicloID, searchObject.Fecha, searchObject.Folio, searchObject.LlevaIVA, searchObject.Observaciones, searchObject.UserID, searchObject.StoreTS, searchObject.UpdateTS, searchObject.Fechapago, searchObject.Pagada, searchObject.TipomonedaID)); }
public static void Update(NotasDeCompra notasDeCompra, DbTransaction transaction) { notasDeCompra.Update(transaction); }
public static void Update(NotasDeCompra notasDeCompra) { notasDeCompra.Update(); }