コード例 #1
0
ファイル: Cine.cs プロジェクト: alpermazlum/try_git
 /// <summary>
 /// Retrieves one record from DB.
 /// </summary>
 /// <param name="id">Filter to use</param>
 /// <returns>NULL if no record found.</returns>
 public CineDto getCine(int id) {
     if (log.IsDebugEnabled) {
         log.Debug("getCine Starts");
         log.Debug("id=[" + id + "]");
     }
     SqlDataReader rdr = null;
     SqlTransaction transaction = null;
     HandleDatabase hdb = null;
     CineDto r = null;
     try {                
         hdb = new HandleDatabase(Settings.Connection);
         hdb.Open();
         SqlParameter param = new SqlParameter() { ParameterName = "@id", Value = id, SqlDbType = SqlDbType.Int};
         string sql = "sp_obtenerCine @id";                
         if (log.IsDebugEnabled) {
             log.Debug("SQL=[" + sql + "]");                    
             var paramValues = "ParameterName=[" + param.ParameterName + "], Value=[" + param.Value + "], SqlDbType=[" + param.SqlDbType + "]";
             log.Debug("Parameter val=[" + paramValues + "]");
         }
         transaction = hdb.BeginTransaction("getCine");
         rdr = hdb.ExecSelectSQLStmtAsReader(transaction, sql, param);
         if (rdr.HasRows) {
             rdr.Read();
             r = new CineDto() {
                 idCine = Convert.ToInt32(rdr["idCine"]),
                 nit = rdr["nit"].ToString(),
                 fechaCreacionCine = Convert.ToDateTime(rdr["fechaCreacionCine"]),
                 nombreCine = rdr["nombreCine"].ToString()
             };
             if (log.IsDebugEnabled) {
                 log.Debug("Record retrieved =[" + r.ToString() + "]");
             }
         }
     } catch (Exception ex) {
         if (log.IsFatalEnabled) {
             log.Fatal("Exception occurred " + ex.Message);
             log.Fatal("Exception trace=[" + ex.StackTrace + "]");
         }
         r = null;                
     } finally {
         try {
             if (rdr != null) { rdr.Close(); }
             if (transaction != null) { transaction.Commit(); }
             if (hdb != null) { hdb.Close(); }
         } catch (Exception e) {
             if (log.IsFatalEnabled) {
                 log.Fatal("Exception occurred " + e.Message);
                 log.Fatal("Exception trace=[" + e.StackTrace + "]");
             }
             r = null;
         }                
     }
     if (log.IsDebugEnabled) {
         if (r == null) {
             log.Debug("Result is NULL");
         }
         else {
             log.Debug("Result sets to [" + r.ToString() + "]");
         }
         log.Debug("getCine Ends");
     }
     return r;
 }
コード例 #2
0
ファイル: cine.aspx.cs プロジェクト: alpermazlum/try_git
 /// <summary>
 /// Event fired to create a new record
 /// </summary>
 /// <param name="sender">object which fires the event</param>
 /// <param name="e">Event arguments</param>
 protected void OnButtonNuevo(object sender, EventArgs e) {
     if (log.IsDebugEnabled) {
         log.Debug("OnButtonNuevo Starts");
     }
     if (!ValidarCampos()) {
         registerToastrMsg(MessageType.Error, "No ha ingresado datos para crear.");
         if (log.IsDebugEnabled) {
             log.Debug("No data input");
         }
     }
     else {
         Cine daoMovie = new Cine();
         CineDto movieInfo = new CineDto() { nombreCine = txtNombre.Text, nit = txtNit.Text, fechaCreacionCine = DateTime.Now };
         if (log.IsDebugEnabled) {
             log.Debug("New Record data [" + movieInfo.ToString() + "]");
         }
         daoMovie.createCine(movieInfo, 1);
         txtNombre.Text = txtNit.Text = "";
         btnEliminar.Visible = btnActualizar.Visible = false;
         registerToastrMsg(MessageType.Success, "Nuevo registro realizado con éxito.");
         CargarGridInfoData();
         if (log.IsDebugEnabled) {
             log.Debug("Record created with data=[" + movieInfo.ToString() + "]");
         }
     }
     if (log.IsDebugEnabled) {
         log.Debug("OnButtonNuevo End");
     }
 }