public ActionResult Create([Bind(Include = "MemCatId,MemCatName,TotalLoans,PenaltyDays")] MemberCategory memberCategory)
        {
            if (ModelState.IsValid)
            {
                db.MemberCategories.Add(memberCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(memberCategory));
        }
        public async Task <ActionResult> Edit([Bind(Include = "MemberCategoriesID,CategoryName,Descrptn")] MemberCategory memberCategory)
        {
            if (ModelState.IsValid)
            {
                db.Entry(memberCategory).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(memberCategory));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Description,TotalLoan,ReturningDays")] MemberCategory memberCategory)
        {
            if (ModelState.IsValid)
            {
                db.MemberCategories.Add(memberCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(memberCategory));
        }
        public ActionResult Create([Bind(Include = "MemberCategoryID,MemberName,TotalLoans,Description,FineAmountPerDay,ReturningDays")] MemberCategory memberCategory)
        {
            if (ModelState.IsValid)
            {
                db.MemberCategories.Add(memberCategory);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(memberCategory);
        }
예제 #5
0
        private MemberCategory GetOrInstantiateAndAddMemberCategory(string categoryName)
        {
            MemberCategory memberCategory = Categories.FirstOrDefault(item => item.Name == categoryName);

            if (memberCategory == null)
            {
                memberCategory = new MemberCategory(categoryName);
                Categories.Add(memberCategory);
            }
            return(memberCategory);
        }
예제 #6
0
        public ActionResult Create(MemberCategory memberCategory)
        {
            if (ModelState.IsValid)
            {
                db.MemberCategories.Add(memberCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(memberCategory));
        }
        public ActionResult Create([Bind(Include = "Id,LoanDays,FinePerDays,NoOfDvdRent,Name")] MemberCategory memberCatagory)
        {
            if (ModelState.IsValid)
            {
                db.MemberCategories.Add(memberCatagory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(memberCatagory));
        }
예제 #8
0
        public ActionResult Create([Bind(Include = "MemberCategoryId,CategoryName,Description,LoanAvailable,FinePerExtraDays")] MemberCategory memberCategory)
        {
            if (ModelState.IsValid)
            {
                db.MemberCategories.Add(memberCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(memberCategory));
        }
        public static bool ShouldLineSeparateIndividualMember(MemberCategory category)
        {
            switch (category)
            {
            case MemberCategory.Field:
                return(false);

            default:
                return(true);
            }
        }
예제 #10
0
        public void Refresh()
        {
            foreach (var item in InternalControl.Items)
            {
                MemberCategory memberCategory = item as MemberCategory;

                foreach (var instanceMember in memberCategory.Members)
                {
                    instanceMember.SimulateValueChanged();
                }
            }
        }
예제 #11
0
        public void SaveData(Models.MemberCategoryModel memberCategoryModel)
        {
            var data = new MemberCategory()
            {
                StaffMemberID      = memberCategoryModel.StaffMemberID,
                MemberCategoryName = memberCategoryModel.MemberCategoryName,
                Remarks            = memberCategoryModel.Remarks
            };

            context.MemberCategories.Add(data);
            context.SaveChanges();
        }
예제 #12
0
        public async Task <ActionResult> Create([Bind(Include = "MemeberCategoryId,Name")] MemberCategory membercategory)
        {
            if (ModelState.IsValid)
            {
                db.MemberCategories.Add(membercategory);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(membercategory));
        }
예제 #13
0
        private static void CreateAlways3Member(Character character, MemberCategory category)
        {
            // This shows how to create a custom member. It doesn't do much since it has no
            // backing data - it is of type int, ignores any input, and will always display 3
            var member = new InstanceMember("I'm always 3", character);

            // this property always returns 3
            member.CustomGetEvent     += (characterInstance) => 3;
            member.CustomSetEvent     += (characterInstance, value) => { /*Could assign a value here*/ };
            member.CustomGetTypeEvent += (characterInstance) => typeof(int); // This determines the (default) control to create
            category.Members.Add(member);
        }
 // GET: MemberCategories/Delete/5
 public ActionResult Delete(int? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     MemberCategory memberCategory = db.MemberCategories.Find(id);
     if (memberCategory == null)
     {
         return HttpNotFound();
     }
     return View(memberCategory);
 }
예제 #15
0
        private static MemberCategory CreateNameInstanceMember(NamedObjectSave instance)
        {
            var instanceMember = new DataGridItem();

            instanceMember.DisplayName            = "Name";
            instanceMember.UnmodifiedVariableName = "Name";

            // this gets updated in the CustomSetEvent below
            string oldValue = instance.InstanceName;

            instanceMember.CustomSetEvent += (throwaway, value) =>
            {
                instanceMember.IsDefault = false;
                RefreshLogic.IgnoreNextRefresh();

                instance.InstanceName = value as string;

                EditorObjects.IoC.Container.Get <SetVariableLogic>().ReactToPropertyChanged(
                    "InstanceName", oldValue, "InstanceName", null);


                //GlueCommands.Self.GluxCommands.SetVariableOn(
                //    instance,
                //    "Name",
                //    typeof(string),
                //    value);


                GlueCommands.Self.GluxCommands.SaveGlux();

                GlueCommands.Self.RefreshCommands.RefreshPropertyGrid();

                GlueCommands.Self.GenerateCodeCommands.GenerateCurrentElementCode();

                oldValue = (string)value;
            };
            instanceMember.CustomGetEvent += (throwaway) =>
            {
                return(instance.InstanceName);
            };

            instanceMember.CustomGetTypeEvent += (throwaway) => typeof(string);

            MemberCategory category = new MemberCategory();

            category.Name       = "";
            category.HideHeader = true;
            category.Members.Add(instanceMember);

            return(category);
        }
예제 #16
0
        public ActionResult Create([Bind(Include = "LoanId,MemberId,AlbumCopyId,IssuedDate,DueDate,ReturnedDate,TotalCharge,LoanTypes")] Loan loan)
        {
            if (ModelState.IsValid)
            {
                AlbumCopy albumCopy = db.AlbumCopies.Find(loan.AlbumCopyId);
                DateTime  startTime = DateTime.Now;

                Member member = db.Members.Single(m => m.MemberID == loan.MemberId);
                var    age    = startTime.Year - member.Dob.Year;

                int copyLoancount = (from l in db.Loans.ToList()
                                     where l.AlbumCopyId == albumCopy.AlbumCopyId
                                     select albumCopy
                                     ).ToList().Count();

                int loanCount = (from l in db.Loans.ToList()
                                 where l.MemberId == member.MemberID
                                 where l.ReturnedDate == null
                                 select l).ToList().Count();
                //MemberCategory silver = db.MemberCategories.Single(m => m.CategoryName == "Silver");
                //MemberCategory gold = db.MemberCategories.Single(m => m.CategoryName == "Gold");
                //MemberCategory diamond = db.MemberCategories.Single(m => m.CategoryName == "Diamond");
                MemberCategory cata     = db.MemberCategories.Single(m => m.MemberCategoryId == member.MemberCategoryId);
                var            albumres = (
                    from l in db.Loans
                    join c in db.AlbumCopies
                    on l.AlbumCopyId equals c.AlbumCopyId
                    join a in db.Albums on c.AlbumId equals a.AlbumId
                    select a
                    );
                Album album = db.Albums.Find(albumCopy.AlbumId);
                if (member.MemberCategoryId == cata.MemberCategoryId && loanCount == cata.LoanAvailable && copyLoancount > 1)
                {
                    TempData["Error"] = "loan not available";
                }
                else if (album.AgeRestricted == true && age < 18)
                {
                    TempData["Error"] = "User is small";
                }
                else
                {
                    db.Loans.Add(loan);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            ViewBag.AlbumCopyId = new SelectList(db.AlbumCopies, "AlbumCopyId", "DvdCopyNumber", loan.AlbumCopyId);
            ViewBag.MemberId    = new SelectList(db.Members, "MemberID", "FirstName", loan.MemberId);
            return(View(loan));
        }
예제 #17
0
        public static void UpdateShownVariables(DataUiGrid grid, NamedObjectSave instance, IElement container)
        {
            grid.Categories.Clear();

            List <MemberCategory> categories = new List <MemberCategory>();
            var defaultCategory = new MemberCategory("Variables");

            defaultCategory.FontSize = 14;
            categories.Add(defaultCategory);

            AssetTypeInfo ati = instance.GetAssetTypeInfo();

            // not sure if this is needed:
            if (instance.TypedMembers.Count == 0)
            {
                instance.UpdateCustomProperties();
            }

            CreateCategoriesAndVariables(instance, container, categories, ati);

            if (ati != null)
            {
                SortCategoriesAndMembers(ref categories, ati);
            }


            if (defaultCategory.Members.Count == 0)
            {
                categories.Remove(defaultCategory);
            }
            else if (categories.Count != 1)
            {
                defaultCategory.Name = "Other Variables";
            }

            if (categories.Count != 0)
            {
                // "Name" should be the very first property:
                var nameCategory = CreateNameInstanceMember(instance);
                categories.Insert(0, nameCategory);
            }

            SetAlternatingColors(grid, categories);

            foreach (var category in categories)
            {
                grid.Categories.Add(category);
            }

            grid.Refresh();
        }
        // GET: MemberCategories/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MemberCategory memberCategory = db.MemberCategories.Find(id);

            if (memberCategory == null)
            {
                return(HttpNotFound());
            }
            return(View(memberCategory));
        }
예제 #19
0
        // GET: /MembersCategories/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MemberCategory membercategory = await db.MemberCategories.FindAsync(id);

            if (membercategory == null)
            {
                return(HttpNotFound());
            }
            return(View(membercategory));
        }
예제 #20
0
        private void RefreshCategories()
        {
            DataGrid.Categories.Clear();

            MemberCategory category = new MemberCategory();

            category.Members.Add(new InstanceMember(nameof(Camera.X), this.DataGrid.Instance));
            category.Members.Add(new InstanceMember(nameof(Camera.Y), this.DataGrid.Instance));
            category.Members.Add(new InstanceMember(nameof(Camera.Z), this.DataGrid.Instance));

            var filteringMember = new InstanceMember("Filtering", null);

            filteringMember.CustomGetEvent += (notUsed) =>
                                              FlatRedBallServices.GraphicsOptions.TextureFilter == Microsoft.Xna.Framework.Graphics.TextureFilter.Linear;
            filteringMember.CustomGetTypeEvent += (notUsed) => typeof(bool);
            filteringMember.CustomSetEvent     += (instance, value) =>
            {
                bool newValue = (bool)value;

                if (newValue)
                {
                    FlatRedBallServices.GraphicsOptions.TextureFilter = Microsoft.Xna.Framework.Graphics.TextureFilter.Linear;
                }
                else
                {
                    FlatRedBallServices.GraphicsOptions.TextureFilter = Microsoft.Xna.Framework.Graphics.TextureFilter.Point;
                }
            };

            category.Members.Add(filteringMember);

            // There's no built-in control for this, need to bring in XCeed and wrap it...or not, because
            // maybe the color value should really be part of Glue.
            //categories.Members.Add(new InstanceMember(nameof(Camera.BackgroundColor), this.DataGrid.Instance));
            category.Members.Add(new InstanceMember(nameof(Camera.FieldOfView), this.DataGrid.Instance));

            category.Members.Add(new InstanceMember(nameof(Camera.Orthogonal), this.DataGrid.Instance));
            category.Members.Add(new InstanceMember(nameof(Camera.OrthogonalWidth), this.DataGrid.Instance));
            category.Members.Add(new InstanceMember(nameof(Camera.OrthogonalHeight), this.DataGrid.Instance));

            category.Members.Add(new InstanceMember(nameof(Camera.FarClipPlane), this.DataGrid.Instance));

            foreach (var member in category.Members)
            {
                member.DisplayName = StringFunctions.InsertSpacesInCamelCaseString(member.Name);
            }

            DataGrid.Categories.Add(category);
        }
예제 #21
0
        private void TryCreateCategoryAndInstanceFor(MemberInfo memberInfo)
        {
            if (ShouldCreateUiFor(memberInfo.GetMemberType(), memberInfo.Name))
            {
                string categoryName = GetCategoryFor(memberInfo);

                MemberCategory memberCategory = GetOrInstantiateAndAddMemberCategory(categoryName);

                InstanceMember newMember = new InstanceMember(memberInfo.Name, Instance);
                newMember.AfterSetByUi  += HandleInstanceMemberSetByUi;
                newMember.BeforeSetByUi += HandleInstanceMemberBeforeSetByUi;
                newMember.Category       = memberCategory;
                memberCategory.Members.Add(newMember);
            }
        }
예제 #22
0
 public void DeleteData(int id)
 {
     try
     {
         MemberCategory data = new MemberCategory();
         data = context.MemberCategories.
                Where(a => a.StaffMemberID == id).FirstOrDefault();
         context.MemberCategories.Remove(data);
         context.SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #23
0
 public void UpdateData(Models.MemberCategoryModel model)
 {
     try
     {
         MemberCategory data = new MemberCategory();
         data = context.MemberCategories.
                Where(a => a.StaffMemberID == model.StaffMemberID).FirstOrDefault();
         data.MemberCategoryName = model.MemberCategoryName;
         data.Remarks            = model.Remarks;
         context.SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #24
0
 public SymbolMemberInfo(MemberCategory category, string name, string typeName, ulong size, ulong bitSize, ulong offset, uint bitPosition)
 {
     Category          = category;
     Name              = name;
     TypeName          = typeName;
     Size              = size;
     BitSize           = bitSize;
     Offset            = offset;
     BitPosition       = bitPosition;
     AlignWithPrevious = false;
     PaddingBefore     = 0;
     BitPaddingAfter   = 0;
     BitField          = false;
     Volatile          = false;
     Expanded          = false;
 }
예제 #25
0
        private void CreateTwiceXMember(Character character, MemberCategory category)
        {
            // This shows how to create a custom member. It doesn't do much since it has no
            // backing data - it is of type int, ignores any input, and will always display 3
            var member = new InstanceMember("X * 2", character);

            // this property always returns 3
            member.CustomGetEvent += (characterInstance) => character.X * 2;
            member.CustomSetEvent += (characterInstance, value) =>
            {
                character.X = (float)value / 2.0f;
                // The grid doesn't automatically refresh, so we have to tell it to, so X will get updated:
                this.DataGrid.Refresh();
            };
            member.CustomGetTypeEvent += (characterInstance) => typeof(float); // This determines the (default) control to create
            category.Members.Add(member);
        }
예제 #26
0
        private static void ReorganizeCategories(List <MemberCategory> categories)
        {
            MemberCategory categoryToMove = categories.FirstOrDefault(item => item.Name == "Position");

            if (categoryToMove != null)
            {
                categories.Remove(categoryToMove);
                categories.Insert(1, categoryToMove);
            }

            categoryToMove = categories.FirstOrDefault(item => item.Name == "Dimensions");
            if (categoryToMove != null)
            {
                categories.Remove(categoryToMove);
                categories.Insert(2, categoryToMove);
            }
        }
예제 #27
0
        private void GetMemberCategoriesForStateCategory(ElementSave element, InstanceSave instance, List <MemberCategory> categories, StateSaveCategory stateCategory)
        {
            categories.Clear();

            List <string> commonMembers = new List <string>();

            var firstState = stateCategory.States.FirstOrDefault();

            if (firstState != null)
            {
                foreach (var variable in firstState.Variables)
                {
                    bool canAdd = variable.ExcludeFromInstances == false || instance == null;

                    if (canAdd)
                    {
                        commonMembers.Add(variable.Name);
                    }
                }
            }

            if (commonMembers.Any())
            {
                var memberCategory = new MemberCategory();
                memberCategory.Name = $"{stateCategory.Name} Variables";
                categories.Add(memberCategory);

                foreach (var commonMember in commonMembers)
                {
                    var instanceMember = new InstanceMember();

                    instanceMember.Name = commonMember;
                    instanceMember.CustomGetTypeEvent += (member) => typeof(string);
                    instanceMember.CustomGetEvent     += (member) => commonMember;
                    instanceMember.CustomSetEvent     += (not, used) =>
                    {
                        VariableInCategoryPropagationLogic.Self
                        .AskRemoveVariableFromAllStatesInCategory(commonMember, stateCategory);
                    };

                    instanceMember.PreferredDisplayer = typeof(VariableRemoveButton);

                    memberCategory.Members.Add(instanceMember);
                }
            }
        }
예제 #28
0
        //public Boolean CheckAge(int memberID)
        //{
        //    Member member = db.Members.Find(memberID);
        //    DateTime dateOfBirth = member.DateOfBirth;
        //    DateTime currentDate = DateTime.Today;
        //    TimeSpan timeSpan = currentDate.Subtract(dateOfBirth);
        //    int years = timeSpan.Days / 365;
        //    if (years >= 18)
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}

        public Boolean CheckNumberOfLoan(int memberID)
        {
            Member         member         = db.Members.Find(memberID);
            string         memberName     = member.Name;
            int            memberCatId    = member.MemberCategoryId;
            MemberCategory memberCategory = db.MemberCategories.Find(memberCatId);
            int?           loan           = memberCategory.TotalLoan;
            var            list           = db.Loans.Include("Members").Where(x => x.Members.Name == memberName).Count();

            if (list > loan)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
예제 #29
0
        private static void AddSourceNameVariable(NamedObjectSave instance, List <MemberCategory> categories)
        {
            var categoryToAddTo = new MemberCategory("File");

            categoryToAddTo.FontSize = 14;

            if (categories.Count > 0)
            {
                categories.Insert(0, categoryToAddTo);
            }
            else
            {
                categories.Add(categoryToAddTo);
            }

            var instanceMember = CreateInstanceMemberForSourceName(instance);

            categoryToAddTo.Members.Add(instanceMember);
        }
예제 #30
0
        public static void UpdateShownVariables(DataUiGrid grid, IElement element)
        {
            grid.Categories.Clear();

            List <MemberCategory> categories = new List <MemberCategory>();
            var defaultCategory = new MemberCategory("Variables");

            defaultCategory.FontSize = 14;
            categories.Add(defaultCategory);

            CreateInstanceMembersForVariables(element, defaultCategory);

            foreach (var category in categories)
            {
                const byte brightness = 227;
                category.SetAlternatingColors(new SolidColorBrush(Color.FromRgb(brightness, brightness, brightness)), Brushes.Transparent);

                grid.Categories.Add(category);
            }

            grid.Refresh();
        }