Пример #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_Eventos_READ_ALL";
         // Set Parameters
         // Set sql instruction
         command.CommandText = sql;
         // Execute
         ds = db.ExecuteReader(command, "Eventos");
         // Extract table 0
         DataTable dt = ds.Tables[0];
         if (dt.Rows.Count > 0)
         {
             foreach (DataRow dr in dt.Rows)
             {
                 CObject oCObject = new CEvento();
                 oCObject = this.PopulateObject(dr);
                 objCollection.Add(oCObject);
             }
         }
         return objCollection;
     }
 }
Пример #3
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)
        {
            CEvento oCObject = new CEvento();
            oCObject.Id = Convert.ToInt32(dr["IdEvento"]);
            oCObject.Descripcion = Convert.ToString(dr["Descripcion"]);
            oCObject.FechaEvento = Convert.ToDateTime(dr["FechaEvento"]);
            oCObject.Estado = EnumUtil.ParseEnum<EstadoEvento>(Convert.ToString(dr["Estado"]));

            // Checking for NULL
            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;
        }
Пример #4
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>        
        internal CObject PopulateObject(DataRow dr)
        {
            CCierreMesa oCObject = new CCierreMesa();
            //Datos para evento
            CEvento cEvento = new CEvento();
            DALEvento dalEvento = new DALEvento();
            cEvento.Id = (Convert.ToInt32(dr["IdEvento"]));

            //Datos para Usuario
            CUsuario cUsuario = new CUsuario();
            DALUsuario dalUsuario = new DALUsuario();
            cUsuario.Id = (Convert.ToInt32(dr["IdUsuario"]));

            oCObject.Id = (Convert.ToInt32(dr["IdCierreMesa"]));
            oCObject.IdEvento = (dalEvento.ReadById(cEvento) as CEvento);
            oCObject.IdUsuario= (dalUsuario.ReadById(cUsuario.Id) as CUsuario);
            oCObject.Estado = EnumUtil.ParseEnum<UserState>(Convert.ToString(dr["Estado"]));

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

            // Return
            return oCObject;
        }
Пример #5
0
        protected void ASPxGridView1_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            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 usuarioModificacion = id.Ticket.Name;
                    try
                    {
                        e.Cancel = true;
                        CEvento CObject = new CEvento();
                        CObject.Id = Convert.ToInt32(e.Values["Id"].ToString());
                        CObject.UsuarioModificacion = usuarioModificacion;

                        BLLEvento.Delete(CObject, ParameterToSearch.Id);

                        this.ASPxGridView1.CancelEdit();
                        this.RefreshData();

                        // Mostrar valor ingresado
                        string registro = e.Values["Descripcion"].ToString();
                        this.UpdateLastPosting(registro, "Descripcion");
                    }
                    catch (Exception error)
                    {
                        e.Cancel = true;
                        this.ASPxGridView1.CancelEdit();

                        this.ASPxGridView1.Settings.ShowTitlePanel = true;
                        if (error.Message.Contains("constrain"))
                        {
                            this.ASPxGridView1.SettingsText.Title = "No se puede eliminar el registro porque esta siendo utilizado por otro proceso";
                        }
                        else
                        {
                            this.ASPxGridView1.SettingsText.Title = error.Message;
                        }
                    }

                }
            }
        }
Пример #6
0
        protected void ASPxGridView1_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e)
        {
            foreach (GridViewColumn column in this.ASPxGridView1.Columns)
            {
                GridViewDataColumn dataColumn = column as GridViewDataColumn;
                // If null continue
                if (dataColumn == null) continue;
                // Required fields
                if (e.NewValues[dataColumn.FieldName] == null && dataColumn.FieldName != "UsuarioCreacion" && dataColumn.FieldName != "FechaCreacion"
                    && dataColumn.FieldName != "UsuarioModificacion" && dataColumn.FieldName != "FechaModificacion" && dataColumn.FieldName != "Id"
                    && dataColumn.FieldName != "Estado" && dataColumn.FieldName != "Detalle")
                {
                    e.Errors[dataColumn] = "Campo requerido!!!";
                }
                // If errors count > 0 then show error message
                if (e.Errors.Count > 0) e.RowError = "Por favor complete todos los campos";
                //
                if (string.IsNullOrEmpty(e.RowError) && e.Errors.Count > 0)
                    e.RowError = "Por favor corrija todos los errores";

                // Validate if exist
                if (e.IsNewRow)
                {
                    if (e.NewValues[dataColumn.FieldName] != null && dataColumn.FieldName == "Descripcion")
                    {
                        CEvento evento = new CEvento();
                        evento.Descripcion = Convert.ToString(e.NewValues["Descripcion"]);
                        if (BLLEvento.Exists(evento,ParameterToSearch.Descripcion))
                            e.Errors[dataColumn] = "Ya existe un registro con este Nombre de Evento. Seleccione otro!!!";
                    }
                }
            }
        }
Пример #7
0
        protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            bool existe = true;
            CEvento evento = new CEvento();
            evento.Id = Convert.ToInt32(e.NewValues["Id"]);

            if (e.OldValues["Id"] != null)
            {
                if (!BLLEvento.Exists(evento,ParameterToSearch.Id))
                    existe = false;
            }
            // IF Exists then Update
            if (existe)
            {
                if (EnumUtil.ParseEnum<EstadoEvento>(Convert.ToString(e.OldValues["Estado"])) == EstadoEvento.Abierto)
                {
                    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;

                                CEvento CObject = new CEvento();
                                CObject.Id = Convert.ToInt32(e.NewValues["Id"]);
                                CObject.Descripcion = Convert.ToString(e.NewValues["Descripcion"]);
                                CObject.FechaEvento = Convert.ToDateTime(e.NewValues["FechaEvento"].ToString());
                                // Solo puede ser cambiado con el proceso de Cierre
                                CObject.Estado = EstadoEvento.Abierto;
                                CObject.UsuarioModificacion = usuario;

                                BLLEvento.Update(CObject, ParameterToSearch.Id);

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

                                this.RefreshData();

                                // Mostrar valor ingresado
                                string registro = e.NewValues["Descripcion"].ToString();
                                this.UpdateLastPosting(registro, "Descripcion");
                            }
                        }

                    }
                    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 = "No se puede modificar un evento Cerrado";
                }

            }
        }
Пример #8
0
        protected void ASPxGridView1_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            bool existe = true;
            if (e.NewValues["Descripcion"] != null)
            {
                CEvento evento = new CEvento();
                evento.Descripcion = Convert.ToString(e.NewValues["Descripcion"]);
                if (!BLLEvento.Exists(evento,ParameterToSearch.Descripcion))
                    existe = false;
            }
            // If Not Exist then Create
            if (!existe)
            {
                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;

                            CEvento CObject = new CEvento();
                            CObject.Id = Convert.ToInt32(e.NewValues["Id"]);
                            CObject.Descripcion = Convert.ToString(e.NewValues["Descripcion"]);
                            CObject.FechaEvento = Convert.ToDateTime(e.NewValues["FechaEvento"].ToString());
                            CObject.Estado = EstadoEvento.Abierto;
                            CObject.UsuarioCreacion = usuario;

                            string result = BLLEvento.Create(CObject, ParameterToSearch.Descripcion);

                            if (result.Equals(""))
                            {
                                e.Cancel = true;
                                this.ASPxGridView1.CancelEdit();

                                this.RefreshData();

                                // Mostrar valor ingresado
                                string registro = e.NewValues["Descripcion"].ToString();
                                this.UpdateLastPosting(registro, "Descripcion");
                            }
                            else
                            {
                                e.Cancel = true;
                                this.ASPxGridView1.CancelEdit();
                                this.ASPxGridView1.Settings.ShowTitlePanel = true;
                                this.ASPxGridView1.SettingsText.Title = result;
                                this.ASPxGridView1.Styles.TitlePanel.ForeColor = System.Drawing.Color.Red;
                            }
                        }
                    }

                }
                catch (Exception error)
                {
                    e.Cancel = true;
                    this.ASPxGridView1.CancelEdit();
                    this.ASPxGridView1.Settings.ShowTitlePanel = true;
                    this.ASPxGridView1.SettingsText.Title = error.Message;
                }
            }
        }
        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;
            }
        }