protected void BRegistrarAlerta_Click(object sender, EventArgs e) { int placa; DateTime fecha; String recordatorio; try { placa = Convert.ToInt32(this.TBPlacaReg.Text); } catch { placa = -1; } try { fecha = this.CAlertaReg.SelectedDate; } catch { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Debe escojer una fecha');", true); return; } recordatorio = TBAlertaReg.Text; if (fecha < DateTime.Now) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Debe escojer una fecha mayor a la de hoy');", true); return; } Alerta Alert = new Alerta(placa,fecha,recordatorio); registroBLL.RegistrarAlerta(Alert); }
// Funcion para registrar un repuesto en una reparacion public void RegistrarAlerta(Alerta DatosAlert) { Database db = DatabaseFactory.CreateDatabase("Desarrollo"); string sqlCommand = "dbo.[insertar_alertas]"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); try { db.AddInParameter(dbCommand, "@INTplaca", DbType.Int32, Utilerías.ObtenerValor(DatosAlert.Placa)); db.AddInParameter(dbCommand, "@DTfecha", DbType.DateTime, Utilerías.ObtenerValor(DatosAlert.Fecha)); db.AddInParameter(dbCommand, "@STRrecordatorio", DbType.String, Utilerías.ObtenerValor(DatosAlert.Recordatorio)); db.AddOutParameter(dbCommand, "@nStatus", DbType.Int16, 2); db.AddOutParameter(dbCommand, "@strMessage", DbType.String, 250); db.ExecuteNonQuery(dbCommand); if (int.Parse(db.GetParameterValue(dbCommand, "@nStatus").ToString()) > 0) throw new Exception(db.GetParameterValue(dbCommand, "@strMessage").ToString()); } catch (Exception ex) { throw new Exception(ex.Message); } }
public void RegistrarAlerta(Alerta DatosAlert) { try { this.Registros.RegistrarAlerta(DatosAlert); } catch (Exception ex) { throw new Exception(ex.Message); } }