Пример #1
0
        public static ItemTypes AddItemType(int evid, string type, bool isImpt, DAL dalDataContext)
        {
            Table<ItemTypes> typeTable = dalDataContext.itemTypes;
            ItemTypes newItemType = new ItemTypes(evid, type, isImpt);

            typeTable.InsertOnSubmit(newItemType);
            typeTable.Context.SubmitChanges();
            return newItemType;
        }
Пример #2
0
 public Items(ItemTypes t, string itemName, int sat, decimal est)
 {
     this.eventID = t.EventID;
     this.typeName = t.typeString;
     this.itemName = itemName;
     this.satisfaction = sat;
     this.estimatedPrice = est;
     this.actualPrice = 0;
 }
Пример #3
0
        public static ItemTypes AddItemType(User user, int evid, string type, bool isImpt)
        {
            if (!user.isAuthorized( EventController.GetEvent(evid), EnumFunctions.Manage_ItemTypes))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Add Items!"));

                ItemTypes iType = GetItemType(evid, type);
                if (iType == null)
                {
                    DAL dalDataContext = new DAL();
                    Table<ItemTypes> typeTable = dalDataContext.itemTypes;
                    ItemTypes newItemType = new ItemTypes(evid, type, isImpt);

                    typeTable.InsertOnSubmit(newItemType);
                    typeTable.Context.SubmitChanges();
                    return newItemType;
                }
                else
                {
                    throw new FaultException<SException>(new SException(),
                   new FaultReason("Item type already exist!"));
                }
        }
Пример #4
0
        public static Items AddItem(User user, ItemTypes type, string name, int sat, decimal est)
        {
            if (!user.isAuthorized( EventController.GetEvent(type.EventID), EnumFunctions.Manage_Items))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Add Items!"));

            if (GetItem(type, name) == null)
            {
                DAL dalDataContext = new DAL();
                Table<Items> itemTable = dalDataContext.items;
                Items newItem = new Items(type, name, sat, est);

                itemTable.InsertOnSubmit(newItem);
                itemTable.Context.SubmitChanges();

                return newItem;
            }
            else
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Item already exist!"));
            }
        }
Пример #5
0
        public static void deleteItemType(User user, ItemTypes type)
        {
            if (!user.isAuthorized( EventController.GetEvent(type.EventID), EnumFunctions.Manage_ItemTypes))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Delete Guest!"));

            DAL dalDataContext = new DAL();

            try
            {
                ItemTypes itemType = (from iType in dalDataContext.itemTypes
                                      where iType.EventID == type.EventID
                                      && iType.typeString == type.typeString
                                      select iType).FirstOrDefault<ItemTypes>();

                dalDataContext.itemTypes.DeleteOnSubmit(itemType);
                dalDataContext.SubmitChanges();
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Deleting Item Type, Please Try Again!"));
            }
        }
Пример #6
0
        public static void setItemTypeImportance(User user, ItemTypes type, bool isImpt)
        {
            if (!user.isAuthorized( EventController.GetEvent(type.EventID), EnumFunctions.Manage_ItemTypes))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Edit this Guest!"));
            try
            {
                DAL dalDataContext = new DAL();

                ItemTypes matchedItem = (from iten in dalDataContext.itemTypes
                                         where iten.EventID == type.EventID
                                         && iten.typeString == type.typeString
                                         select iten).FirstOrDefault<ItemTypes>();

                if (matchedItem == null)
                {
                    throw new FaultException<SException>(new SException(),
                       new FaultReason("Invalid Item Type"));
                }
                else
                {
                    matchedItem.IsImportantType = isImpt;
                    dalDataContext.SubmitChanges();

                }
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Updating Item Type, Please Try Again!"));
            }
        }
Пример #7
0
        private void btnAddItemType_Click(object sender, RoutedEventArgs e)
        {
            String itemType2Add = "";
            if (radItemType.IsChecked == true)
            {
                if (cboItemType.SelectedIndex == -1)
                {
                    MessageBox.Show("Please Select an Item Type!");
                }
                itemType2Add = cboItemType.SelectedItem.ToString();
            }
            else
            {
                //Save to item type repository here
                itemType2Add = txtOthers.Text.ToString().Trim();

                refreshItemTypes();
            }

            //check if got already
            for (int i = 0; i < lvItemType.Items.Count; i++)
            {
                ItemTypes itemtype = (ItemTypes)lvItemType.Items[i];
                if (itemtype.typeString == itemType2Add)
                {
                    MessageBox.Show("Item type already added");
                    return;

                }
            }

            //lvItemType.AddNewItemType(user, event_, itemType2Add, chkNecessary.IsChecked.Value);
            //lvItemType.Items.Add("Column1Text").SubItems.AddRange(row1);

            ItemTypes it = new ItemTypes();
            it.typeString = itemType2Add;
            it.IsImportantType = chkNecessary.IsChecked.Value;
            lvItemType.Items.Add(it);

            rebindcboItemType4Item();
            clearItemTypeInput();
        }
Пример #8
0
        public static List<Items> GetItemsList(ItemTypes type)
        {
            DAL dalDataContext = new DAL();

            List<Items> itemList = (from iten in dalDataContext.items
                                    where iten.EventID == type.EventID
                                    && iten.typeString == type.typeString
                                    select iten).ToList<Items>();
            return itemList;
        }
Пример #9
0
        private static Items GetItem(ItemTypes type, string name)
        {
            DAL dalDataContext = new DAL();

            Items matchedItem = (from item in dalDataContext.items
                                 where item.typeString == type.typeString
                                 && item.EventID == type.EventID
                                 && item.ItemName == name
                                 select item).FirstOrDefault<Items>();
            return matchedItem;
        }
Пример #10
0
 public void SetItemTypeImportance(User user, ItemTypes type, Boolean isImpt)
 {
     ItemTypesController.setItemTypeImportance(user, type, isImpt);
 }
Пример #11
0
 //Event Specific Item
 public Items AddEventItem(User user, ItemTypes type, string name, int sat, decimal est)
 {
     return ItemsController.AddItem(user, type, name, sat, est);
 }
Пример #12
0
 public void DeleteEventItemType(User user, ItemTypes type)
 {
     ItemTypesController.deleteItemType(user, type);
 }