public ActionResult Edit(Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(category);
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Category cats = new Category();
         cats.LoadAll();
         uiRepeaterCats.DataSource = cats.DefaultView;
         uiRepeaterCats.DataBind();
     }
 }
        public ActionResult Create(Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(category);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Category cats = new Category();
                cats.GetAllCats();
                uiRepeaterCats.DataSource = cats.DefaultView;
                uiRepeaterCats.DataBind();

                Room rooms = new Room();
                rooms.GetRoomsByCreatorID(Member.CurrentMemberID);
                catlink_minecount.Text = rooms.RowCount.ToString();
                rooms.GetFavoriteByMemberID(Member.CurrentMemberID);
                catlink_favcount.Text = rooms.RowCount.ToString();
            }
        }
 private void PopulateCatTree(String Type)
 {
     if (Type == "Drug")
     {
         Category cat = new Category();
         treeCategory.DataSource = cat.GetCategoryTree();
     }
     else
     {
         SupplyCategory subCat = new SupplyCategory();
         treeCategory.DataSource = subCat.GetAllSupplyCategories();
     }
 }
 /// <summary>
 /// Populates the CatTree
 /// </summary>
 private void PopulateCatTree()
 {
     Category cat = new Category();
     treeCategory.DataSource = cat.GetCategoryTree();
 }
 public void TestStart()
 {
     createDate = new DateTime(2013, 1, 1);
     auchanCategory = new Category { Id = 1, Name = "Auchan" };
     transactionManager = new TransactionManager();
 }
        /// <summary>
        /// Handles the treeCategory focused node changed and updates the form accordingly
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treeCategory_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            Category cat = new Category();
            SubCategory subCat = new SubCategory();
            if (treeCategory.Selection.Count == 0)
                return;

            string value = treeCategory.Selection[0].GetValue("ID").ToString();
            int categoryId = Convert.ToInt32(value.Substring(1));
            string type = "cat";
            if (value.Substring(0, 1) == "S")
            {
                type = "sub";
            }
            else if (value == "P999")
            {
                type = "All";
            }

            if (type == "cat")
            {
                cat.LoadByPrimaryKey(categoryId);
                cboCategory.SelectedValue = categoryId.ToString();
                cboCategory.Visible = false;
                txtCategory.Text = cat.CategoryName;
                txtCatCode.Text = cat.CategoryCode;
                txtDescription.Text = cat.Description;
                _catId = cat.ID;

            }
            else if (type == "sub")
            {
                subCat.LoadByPrimaryKey(categoryId);
                cboCategory.Visible = true;

                cboCategory.SelectedValue = subCat.CategoryId.ToString();
                txtCategory.Text = subCat.SubCategoryName;
                txtCatCode.Text = subCat.SubCategoryCode;
                txtDescription.Text = subCat.Description;
                _catId = subCat.ID;
            }
            btnSave.Text = "Update";
        }
        private void LoadDDLs()
        {
            Category cats = new Category();
            cats.LoadAll();
            uiDropDownListADD_Category.DataSource = cats.DefaultView;
            uiDropDownListADD_Category.DataTextField = "Name";
            uiDropDownListADD_Category.DataValueField = "CategoryID";
            uiDropDownListADD_Category.DataBind();

            uiDropDownListEdit_Category.DataSource = cats.DefaultView;
            uiDropDownListEdit_Category.DataTextField = "Name";
            uiDropDownListEdit_Category.DataValueField = "CategoryID";
            uiDropDownListEdit_Category.DataBind();

            var adminTypes = Helper.EnumUtil.GetValues<Helper.Enums.RoomMemberLevel>().Where(l => (int)l > (int)Helper.Enums.RoomMemberLevel.Visitor && (int)l != (int)Helper.Enums.RoomMemberLevel.Owner).Select(r => new
            {
                AdminTypeID = (int)r,
                Name = Helper.StringEnum.GetStringValue(r)
            }).ToList();
            uiDropDownListAdminType.DataSource = adminTypes;
            uiDropDownListAdminType.DataTextField = "Name";
            uiDropDownListAdminType.DataValueField = "AdminTypeID";
            uiDropDownListAdminType.DataBind();

            BindSubCats();

            Room myrooms = new Room();
            myrooms.GetRoomsByCreatorID(Member.CurrentMemberID);
            uiDropDownListMyRooms.DataSource = myrooms.DefaultView;
            uiDropDownListMyRooms.DataTextField = "Name";
            uiDropDownListMyRooms.DataValueField = "RoomID";
            uiDropDownListMyRooms.DataBind();
            uiDropDownListMyRooms.Items.Insert(0, new ListItem("إختر غرفة. . . ."));
            if (CurrentRoom != 0)
                uiDropDownListMyRooms.SelectedValue = CurrentRoom.ToString();
        }
Exemple #10
0
 public void Delete(Category item)
 {
     _repository.Delete(item);
 }
        public static Helper.ChatRoom GetRoomInfo(int id, bool isTemp, Room room)
        {
            Helper.ChatRoom roomObject = new Helper.ChatRoom();
            roomObject.ID = id;
            roomObject.Type = "Room";
            roomObject.IsTemp = isTemp;
            roomObject.Message = "";
            roomObject.AdminMessage = "";

            //Room info
            roomObject.Name = room.Name;
            roomObject.RoomTopic = room.RoomTopic;
            roomObject.fbURL = room.FbURL;
            roomObject.tURL = room.TURL;
            roomObject.utURL = room.UtURL;
            roomObject.OpenCams = room.OpenCams;
            if (!room.IsColumnNull("CreatedBy"))
                roomObject.CreatedBy = room.CreatedBy;

            RoomBot Allbots = new RoomBot();
            roomObject.RoomBots = Allbots.GetByRoomID(id);

            if (!room.IsColumnNull("CreatedDate"))
                roomObject.CreatedDate = room.CreatedDate;

            //Room settings
            roomObject.Settings.EnableCam = room.EnableCam;
            roomObject.Settings.EnableMic = room.EnableMic;
            roomObject.Settings.MarkOnLoginWithoutWrite = room.MarkOnLoginWithoutWrite;
            roomObject.Settings.MarkOnLoginWithWrite = room.MarkOnLoginWithWrite;
            roomObject.Settings.EnableMicForAdminsOnly = room.EnableMicForAdminsOnly;
            if (room.RoomType.RoomTypeSpecDuration.RoomTypeSpecID > 1) // not a free room
                roomObject.Settings.CamCount = 8;
            else
                roomObject.Settings.CamCount = 4;
            roomObject.Settings.MaxMic = room.RoomType.RoomTypeSpecDuration.RoomTypeSpec.MicCount;
            roomObject.Settings.TypeID = room.RoomType.RoomTypeSpecDuration.RoomTypeSpecID;
            roomObject.Settings.Color = room.RoomType.RoomTypeSpecDuration.RoomTypeSpec.Color;
            //Room Members
            RoomMember roomMember = new RoomMember();
            if (!roomMember.LoadByPrimaryKey(BLL.Member.CurrentMember.MemberID, id))
            {
                roomMember.AddNew();
                roomMember.MemberID = BLL.Member.CurrentMember.MemberID;
                roomMember.RoomID = id;
            }
            roomMember.InRoom = true;
            roomMember.LastJoinDate = DateTime.Now;
            if (BLL.Member.CurrentMember.Status == (int)Helper.Enums.MemberStatus.Offline && Helper.Admin.HasRole(Helper.Enums.MemberRoles.InvisibleInRoom.ToString()))
                roomMember.InRoom = false;
            if (!room.IsColumnNull("CreatedBy"))
            {
                if (roomMember.MemberID == room.CreatedBy)
                    roomMember.RoomMemberLevelID = (int)Helper.Enums.RoomMemberLevel.Owner;
            }
            roomMember.Save();
            roomObject.CurrentMemberID = BLL.Member.CurrentMemberID;

            List<int> connectedIDs = ChatRoomHub.ConnectedUsers.Select(m => m.MemberID).ToList();
            roomObject.Members = roomMember.LoadWithSettings(id, roomObject.CurrentMemberID, null, connectedIDs);
            var currentMemberSettings = roomObject.Members.First(m => m.MemberID == roomObject.CurrentMemberID);
            if (currentMemberSettings != null)
            {
                if (room.MarkOnLoginWithWrite)
                {
                    currentMemberSettings.IsMarked = true;
                    currentMemberSettings.CanWrite = true;
                }
                if (room.MarkOnLoginWithoutWrite)
                {
                    currentMemberSettings.IsMarked = true;
                    currentMemberSettings.CanWrite = false;
                }
            }
            // load owner / admins
            //roomObject.Admins = roomMember.GetAdminsMembersByRoomID(id);

            // load cat & subcat

            Category cat = new Category();
            if (!room.IsColumnNull("CategoryID"))
            {
                cat.LoadByPrimaryKey(room.CategoryID);
                roomObject.CategoryName = cat.Name;
            }

            SubCategory scat = new SubCategory();
            if (!room.IsColumnNull("SubCategoryID"))
            {
                scat.LoadByPrimaryKey(room.SubCategoryID);
                roomObject.SubCategoryName = scat.Name;
            }
            else
            {
                roomObject.SubCategoryName = "لا يوجد";
            }

            //member level change
            roomObject.MemberLevels = Helper.EnumUtil.GetValues<Helper.Enums.RoomMemberLevel>().Where(l => (int)l < currentMemberSettings.MemberLevelID).Select(l => new
            {
                ID = (int)l,
                Name = Helper.StringEnum.GetStringValue(l)
            }).ToList();

            //messages
            //roomObject.MessageHistory = new RoomMessages().GetLatestMessags(id, 0);
            roomObject.MessageHistory = new List<Helper.ChatMessage>() { };
            ///////////////////////////

            Gift allgifts = new Gift();
            allgifts.LoadAll();
            roomObject.Gifts = allgifts.DefaultView.Table.AsEnumerable().Select(m => new { giftid = m["GiftID"], name = m["Name"], price = m["Price_Point"], picPath = m["PicPath"], AudioPath = m["AudioPath"] }).ToList();

            //bots
            RoomBot bllRoomBot = new BLL.RoomBot();
            //welcome bot
            List<Info.RoomBot> bots = bllRoomBot.GetByRoomIDandBotID(id, Helper.Enums.Bot.Welcome);
            if (bots.Count > 0)
            {
                Info.WelcomeBot infoWelcomeBot = (Info.WelcomeBot)bots.First().Settings;
                roomObject.WelcomeBot = infoWelcomeBot;
            }

            return roomObject;
        }
        private void ManageItems_Load(object sender, EventArgs e)
        {
            Category cat = new Category();
            SubCategory subCat = new SubCategory();
            Product prod = new Product();
            cat.LoadAll();
            cat.Sort = "CategoryName";
            lblCategory.Text = "Products By Category";
            ProductTree.Nodes.Add("All0","All");
            foreach (DataRowView dv in cat.DefaultView)
            {
                TreeNode nodes = new TreeNode();
                nodes.Name =  "cat" + dv["ID"].ToString();
                nodes.Text = dv["CategoryName"].ToString() + " (" + dv["CategoryCode"].ToString() + ")";
                nodes.ToolTipText = "Double Click to List";
                subCat.GetSubCategory(Convert.ToInt32(dv["ID"]));
                subCat.Sort = "SubCategoryName";
                foreach (DataRowView subDv in subCat.DefaultView)
                {

                    TreeNode subNodes = new TreeNode();
                    subNodes.Name = "sub" + subDv["ID"].ToString();
                    subNodes.Text = subDv["SubCategoryName"].ToString() + " (" + subDv["SubCategoryCode"].ToString() + ")";
                    subNodes.ToolTipText = "Double Click to List";

                    nodes.Nodes.Add(subNodes);
                }
               ProductTree.Nodes[0].Nodes.Add(nodes);

            }
            ProductTree.Nodes[0].Expand();

            Stores stor = new Stores();
            stor.GetActiveStores();
            cboStores.DataSource = stor.DefaultView;
        }
        public ActionResult DeleteCategory(int id)
        {
            Session["ControllerName"] = "Delete Category";
            if (Session["loginDetails"] != null)
            {

                ProductAdminBLL bll = new ProductAdminBLL();
                Dictionary<string, string> dict = bll.GetCategory();
                List<Category> category = new List<Category>();
                foreach (var item in dict)
                {
                    Category cat = new Category();
                    cat.Cat_Id = Convert.ToInt32(item.Key);
                    cat.Cat_Name = item.Value;
                    category.Add(cat);

                }

                Category cate = category.Single(b => b.Cat_Id == id);
                return View(cate);
            }
            else
            {

                return RedirectToAction("Error");
            }

        }
        public ActionResult EditCategory(Category cat)
        {
            Session["ControllerName"] = "Edit Category";
            if (Session["loginDetails"] != null)
            {


                if (ModelState.IsValid)
                {
                    ProductAdminBLL bll = new ProductAdminBLL();
                    int res = bll.UpdateCategory(cat);
                    if (res > 0)
                    {
                        return RedirectToAction("Category");
                    }
                }
                return View();
            }
            else
            {

                return RedirectToAction("Error");
            }
        }
        private void PopulateCatTree()
        {
            ProductTree.Nodes.Clear();
            if (Convert.ToInt32(lkCommodityTypes.EditValue) == BLL.Type.Constants.Pharmacuticals)
            {
                Category cat = new Category();
                SubCategory subCat = new SubCategory();
                Product prod = new Product();
                cat.LoadAll();
                cat.Sort = "CategoryName";
                ProductTree.Nodes.Add("All0", "All");
                foreach (DataRowView dv in cat.DefaultView)
                {
                    TreeNode nodes = new TreeNode();
                    nodes.Name = "cat" + dv["ID"].ToString();
                    nodes.Text = dv["CategoryName"].ToString() + " (" + dv["CategoryCode"].ToString() + ")";
                    nodes.ToolTipText = "Double Click to List";
                    subCat.GetSubCategory(Convert.ToInt32(dv["ID"]));
                    subCat.Sort = "SubCategoryName";
                    foreach (DataRowView subDv in subCat.DefaultView)
                    {

                        TreeNode subNodes = new TreeNode();
                        subNodes.Name = "sub" + subDv["ID"].ToString();
                        subNodes.Text = subDv["SubCategoryName"].ToString() + " (" + subDv["SubCategoryCode"].ToString() + ")";
                        subNodes.ToolTipText = "Double Click to List";

                        nodes.Nodes.Add(subNodes);
                    }
                    ProductTree.Nodes[0].Nodes.Add(nodes);

                }
                ProductTree.Nodes[0].Expand();
            }
            else
            {
                SupplyCategory scat = new SupplyCategory();
                scat.LoadAll();
                scat.Sort = "Name";
                ProductTree.Nodes.Add("Als0", "All");
                foreach (DataRowView dv in scat.DefaultView)
                {
                    TreeNode nodes = new TreeNode();
                    nodes.Name = "sup" + dv["ID"].ToString();
                    nodes.Text = dv["Name"].ToString();
                    nodes.ToolTipText = "Double Click to List";
                    ProductTree.Nodes[0].Nodes.Add(nodes);

                }
                ProductTree.Nodes[0].Expand();
            }
        }
        /// <summary>
        /// Saves Category/Sub Category related information
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtCategory.Text != "" || txtCatCode.Text != "")
            {
                if (cboCategory.Visible)
                {
                    SubCategory subCat = new SubCategory();
                    if (_catId != 0)
                        subCat.LoadByPrimaryKey(_catId);
                    else
                        subCat.AddNew();

                    subCat.CategoryId = Convert.ToInt32(cboCategory.SelectedValue);
                    subCat.SubCategoryName = txtCategory.Text;
                    subCat.Description = txtDescription.Text;
                    subCat.SubCategoryCode = txtCatCode.Text;
                    subCat.Save();
                }
                else
                {
                    Category cat = new Category();
                    if (_catId != 0)
                        cat.LoadByPrimaryKey(_catId);
                    else
                        cat.AddNew();
                    cat.CategoryName = txtCategory.Text;
                    cat.Description = txtDescription.Text;
                    cat.CategoryCode = txtCatCode.Text;
                    cat.Save();
                }

                PopulateCategoryTree();
                ResetCategoryForm();
            }
            else
            {
                if (txtCatCode.Text == "")
                    txtCatCode.BackColor = Color.FromArgb(251, 214, 214);
                if (txtCategory.Text == "")
                    txtCategory.BackColor = Color.FromArgb(251, 214, 214);
            }
        }
Exemple #17
0
 public void Add(Category item)
 {
     _repository.Add(item);
 }
 /// <summary>
 /// Loads the category tree
 /// </summary>
 private void PopulateCategoryTree()
 {
     Category cat = new Category();
     DataTable dtbl = cat.GetCategoryTree();
     treeCategory.DataSource = dtbl;
 }
Exemple #19
0
 public void Edit(Category item)
 {
     _repository.Edit(item);
 }
        private void PopulateCategory()
        {
            ProductTree.Nodes.Clear();
            Category cat = new Category();
            SubCategory subCat = new SubCategory();
            cat.LoadAll();
            cat.Sort = "CategoryName";
            ProductTree.Nodes.Add("All0", "All");
            foreach (DataRowView dv in cat.DefaultView)
            {
                TreeNode nodes = new TreeNode
                                     {
                                         Name = "cat" + dv["ID"].ToString(),
                                         Text =
                                             dv["CategoryName"].ToString() + " (" + dv["CategoryCode"].ToString() + ")",
                                         ToolTipText = "Double click to add"
                                     };
                subCat.GetSubCategory(Convert.ToInt32(dv["ID"]));
                subCat.Sort = "SubCategoryName";
                foreach (DataRowView subDv in subCat.DefaultView)
                {
                    if (!ExistInList(Convert.ToInt32(subDv["ID"])))
                    {
                        TreeNode subNodes = new TreeNode
                                                {
                                                    Name = "sub" + subDv["ID"].ToString(),
                                                    Text =
                                                        subDv["SubCategoryName"].ToString() + " (" +
                                                        subDv["SubCategoryCode"].ToString() + ")",
                                                    ToolTipText = "Double click to add"
                                                };

                        nodes.Nodes.Add(subNodes);
                    }
                }
                ProductTree.Nodes[0].Nodes.Add(nodes);
            }
            ProductTree.Nodes[0].Expand();
        }