Пример #1
0
        /// <summary>
        /// PopulateObject:
        /// Notese que en vez de utilizar un SqlDataReader para nuestra función de asignación, 
        /// se utiliza un IDataRecord, que es la interfaz que implementan todos los DataReaders. 
        /// El uso de IDataRecord hace que el proceso de asignación sea independiente del proveedor.         
        /// </summary>
        /// <param name="dr"></param>
        /// <returns></returns>        
        public CObject PopulateObject(DataRow dr)
        {
            DALEvento dalEvento = new DALEvento();
            DALAsociados dalAsociado = new DALAsociados();
            CEvento cEvento = new CEvento();
            CAsociado cAsociado = new CAsociado();

            cAsociado.Id = Convert.ToString(dr["IdAsociado"]);
            cEvento.Id = (Convert.ToInt32(dr["IdEvento"]));

            CBitacora oCObject = new CBitacora();
            oCObject.Id = Convert.ToInt32(dr["IdBitacora"]);
            oCObject.IdEvento = (dalEvento.ReadById(cEvento) as CEvento);
            oCObject.IdAsociado =   (dalAsociado.ReadById(cAsociado)as CAsociado);
            oCObject.Nombre = Convert.ToString(dr["Nombre"]);
            oCObject.NumeroCedula= Convert.ToString(dr["NumeroCedula"]);
            oCObject.Confirmado = EnumUtil.ParseEnum<AsocState>(Convert.ToString(dr["Confirmado"]));
            oCObject.Estado = EnumUtil.ParseEnum<UserState>(Convert.ToString(dr["Estado"]));
            oCObject.Correo = Convert.ToString(dr["Correo"]);
            oCObject.Telefono= Convert.ToString(dr["Telefono"]);
            oCObject.Presente= Convert.ToBoolean(dr["Presente"]);

            // Checking for NULL
            if(dr["FechaAsistencia"] != DBNull.Value)
                oCObject.FechaAsistencia= Convert.ToDateTime(dr["FechaAsistencia"]);
            if (dr["FechaCreacion"] != DBNull.Value)
                oCObject.FechaCreacion = Convert.ToDateTime(dr["FechaCreacion"]);
            if (dr["UsuarioCreacion"] != DBNull.Value)
                oCObject.UsuarioCreacion = Convert.ToString(dr["UsuarioCreacion"]);
            if (dr["FechaModificacion"] != DBNull.Value)
                oCObject.FechaModificacion = Convert.ToDateTime(dr["FechaModificacion"]);
            if (dr["UsuarioModificacion"] != DBNull.Value)
                oCObject.UsuarioModificacion = Convert.ToString(dr["UsuarioModificacion"]);

            // Return
            return oCObject;
        }
Пример #2
0
 /// <summary>
 /// Read By Id:
 /// </summary>
 /// <param name="pId"></param>
 /// <returns></returns>        
 public List<CObject> ReadALL()
 {
     List<CObject> objCollection = new List<CObject>();
     using (DataBase db = DataBaseFactory.OpenDatabase(base.ConnectionStringName))
     {
         // DataSet: Disconnected data.
         DataSet ds = null;
         // Create Command
         //OleDbCommand command = new OleDbCommand();
         SqlCommand command = new SqlCommand();
         // Define Type of command
         //command.CommandType = CommandType.StoredProcedure;
         command.CommandType = CommandType.Text;
         // SQL Instruction
         string sql = @"sp_Bitacora_READ_ALL";
         // Set Parameters
         // Set sql instruction
         command.CommandText = sql;
         // Execute
         ds = db.ExecuteReader(command, "Bitacora");
         // Extract table 0
         DataTable dt = ds.Tables[0];
         if (dt.Rows.Count > 0)
         {
             foreach (DataRow dr in dt.Rows)
             {
                 CObject oCObject = new CBitacora();
                 oCObject = this.PopulateObject(dr);
                 objCollection.Add(oCObject);
             }
         }
         return objCollection;
     }
 }
        protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            BLLEvento BLLEvento = new BLLEvento();
            CEvento evento = new CEvento();
            string msg = "Registro Correcto";
            bool correcto = true;

            evento.Descripcion = Convert.ToString(e.OldValues["IdEvento.Descripcion"]);
            evento = (BLLEvento.Read(evento, ParameterToSearch.Descripcion) as CEvento);

            if (EnumUtil.ParseEnum<AsocState>(e.OldValues["Confirmado"].ToString()).Equals(AsocState.No))
            {
                msg = "El asociado no confirmo su asistencia";
                correcto = false;
            }
            if (EnumUtil.ParseEnum<UserState>(e.OldValues["Estado"].ToString()).Equals(UserState.Inactivo))
            {
                msg = "El asociado esta inactivo";
                correcto = false;
            }
            if (evento.Estado == EstadoEvento.Cerrado)
            {
                msg = "No se puede modificar un evento Cerrado";
                correcto = false;
            }

            if (correcto)
            {
                try
                {
                    if (HttpContext.Current.User.Identity.IsAuthenticated)
                    {
                        if (HttpContext.Current.User.Identity is FormsIdentity)
                        {
                            FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity;
                            FormsAuthenticationTicket ticket = id.Ticket;
                            string usuario = id.Ticket.Name;

                            CAsociado asocidado = new CAsociado();

                            string IdAsociado = Convert.ToString(e.OldValues["IdAsociado.Id"]);
                            asocidado.Id = IdAsociado;

                            CBitacora CBitacora = new CBitacora();
                            CBitacora.IdEvento = evento;
                            CBitacora.IdAsociado = asocidado;
                            CBitacora.UsuarioModificacion = usuario;
                            CBitacora.Presente = Convert.ToBoolean(e.NewValues["Presente"]);

                            string asist = BLLBitacora.Update(CBitacora);

                            e.Cancel = true;
                            this.ASPxGridView1.CancelEdit();

                            this.RefreshData();

                            // Filter record updated
                            string registro = e.OldValues["IdAsociado.Id"].ToString();
                            this.UpdateLastPosting(registro, "IdAsociado.Id");
                        }
                    }
                }
                catch (Exception error)
                {
                    e.Cancel = true;
                    this.ASPxGridView1.CancelEdit();
                    this.ASPxGridView1.Settings.ShowTitlePanel = true;
                    this.ASPxGridView1.SettingsText.Title = error.Message;
                }
            }
            else
            {
                e.Cancel = true;
                this.ASPxGridView1.CancelEdit();
                this.ASPxGridView1.Settings.ShowTitlePanel = true;
                this.ASPxGridView1.SettingsText.Title = msg;
            }
        }