예제 #1
0
 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_CierreMesa_READ_ALL";
         // Set Parameters
         // Set sql instruction
         command.CommandText = sql;
         // Execute
         ds = db.ExecuteReader(command, "CierreMesa");
         // Extract table 0
         DataTable dt = ds.Tables[0];
         if (dt.Rows.Count > 0)
         {
             foreach (DataRow dr in dt.Rows)
             {
                 CObject oCObject = new CCierreMesa();
                 oCObject = this.PopulateObject(dr);
                 objCollection.Add(oCObject);
             }
         }
         return objCollection;
     }
 }
예제 #2
0
        protected void ASPxGridView1_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            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;

                        CCierreMesa CObject = new CCierreMesa();
                        //CObject.Id = Convert.ToInt32(e.NewValues["Id"]);
                        CObject.IdEvento.Id = Convert.ToInt32(e.NewValues["IdEvento.Descripcion"]);
                        //CObject.IdUsuario= Convert.ToInt32(e.NewValues["Descripcion"]);

                        CObject.UsuarioCreacion = usuario;
                        bllCierreMesa.Create(CObject, ParameterToSearch.Descripcion);
                        e.Cancel = true;
                        this.ASPxGridView1.CancelEdit();
                        this.RefreshData();
                    }
                }

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