Exemple #1
0
        public static User_Groups ToModel(this USER_GROUPS Table)
        {
            if (Table == null)
            {
                return(null);
            }

            return(new User_Groups()
            {
                UserId = Table.UserId,
                GroupId = Table.GroupId
            });
        }
        protected void OnAddGroup(object sender, EventArgs e)
        {
            Guid guid = Guid.NewGuid();

            DBUtils.ExecuteNonQuery(@"
                INSERT INTO dbo.UserGroups(
                    Name
                )
                VALUES
                (@Descr)",
                                    new SqlParameter("Descr", DESCR.Text));

            USER_GROUPS.DataBind();
        }
        /// <summary>
        /// Converts this instance of <see cref="USER_GROUPS"/> to an instance of <see cref="User_Groups"/>.
        /// </summary>
        /// <param name="entity"><see cref="USER_GROUPS"/> to convert.</param>
        public static User_Groups ToModel(this USER_GROUPS entity)
        {
            if (entity == null)
            {
                return(new User_Groups());
            }

            var dto = new User_Groups();

            dto.UserId  = entity.UserId;
            dto.GroupId = entity.GroupId;

            entity.OnDTO(dto);

            return(dto);
        }
        /// <summary>
        /// Converts this instance of <see cref="User_Groups"/> to an instance of <see cref="USER_GROUPS"/>.
        /// </summary>
        /// <param name="dto"><see cref="User_Groups"/> to convert.</param>
        public static USER_GROUPS ToTable(this User_Groups dto)
        {
            if (dto == null)
            {
                return(null);
            }

            var entity = new USER_GROUPS();

            entity.UserId  = dto.UserId;
            entity.GroupId = dto.GroupId;

            dto.OnEntity(entity);

            return(entity);
        }
Exemple #5
0
        // dung file get data
        // dung file get list( data source)
        public List <USER_GROUPS> getDataSource()
        {
            List <USER_GROUPS> list = new List <USER_GROUPS>();
            USER_GROUPS        obj  = null;
            SqlConnection      conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "Use [rbi]" +
                         "SELECT [UserGroupID]" +
                         ",[UserGroup]" +
                         ",[SysGroup]" +
                         ",[Disabled]" +
                         "  FROM [rbi].[dbo].[USER_GROUPS]";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.HasRows)
                        {
                            obj             = new USER_GROUPS();
                            obj.UserGroupID = reader.GetInt32(0);
                            obj.UserGroup   = reader.GetString(1);
                            obj.SysGroup    = reader.GetInt32(2);
                            obj.Disabled    = reader.GetInt32(3);
                            list.Add(obj);
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("GET DATA SOURCE FAIL!");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
            return(list);
        }
 /// <summary>
 /// Invoked when <see cref="ToTable"/> operation is about to return.
 /// </summary>
 /// <param name="entity"><see cref="USER_GROUPS"/> converted from <see cref="User_Groups"/>.</param>
 static partial void OnEntity(this User_Groups dto, USER_GROUPS entity);
 /// <summary>
 /// Invoked when <see cref="ToModel"/> operation is about to return.
 /// </summary>
 /// <param name="dto"><see cref="User_Groups"/> converted from <see cref="USER_GROUPS"/>.</param>
 static partial void OnDTO(this USER_GROUPS entity, User_Groups dto);
 public void delete(USER_GROUPS obj)
 {
     DAL.delete(obj.UserGroupID);
 }
 public void edit(USER_GROUPS obj)
 {
     DAL.add(obj.UserGroup, obj.SysGroup, obj.Disabled);
 }