Exemplo n.º 1
0
        protected void btnAddToAlbum_Click(object sender, EventArgs e)
        {
            if (ddlAlbumList.SelectedValue != "0")
            {
                List<string> addlist = new List<string>();
                GetCheckedList(addlist);

                //update list in db
                if (addlist.Count > 0)
                {
                    var tc = new ItemController();
                    foreach (string id in addlist)
                    {
                        var t = new Item();
                        t = tc.GetItem(Convert.ToInt32(id), ModuleId);
                        //make the AlbumID = what is in the ddList
                        t.AlbumID = Convert.ToInt32(ddlAlbumList.SelectedValue);
                        tc.UpdateItem(t);
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var t = new Item();
            var tc = new ItemController();

            if (ItemId > 0)
            {
                t = tc.GetItem(ItemId, ModuleId);
                t.ItemTitle = txtTitle.Text.Trim();
                t.ItemFileName = txtFileName.Text.Trim();
                t.ItemDescription = txtDescription.Text.Trim();
                t.ItemKind = rblItemKind.SelectedValue;

                if (ddlAlbumID.SelectedValue != "0") t.AlbumID = Convert.ToInt32(ddlAlbumID.SelectedValue);
                else t.AlbumID = 0;

                t.LastModifiedByUserId = UserId;
                t.LastModifiedOnDate = DateTime.Now;
            }
            else
            {
                //make sure there are no ' in title or description
                string newTitle = txtTitle.Text.Trim();
                string newDescription = txtDescription.Text.Trim();
                newTitle = newTitle.Replace("'", "");
                newDescription = newDescription.Replace("'", "");

                t = new Item()
                {
                    CreatedByUserId = UserId,
                    CreatedOnDate = DateTime.Now,

                    ItemTitle = newTitle,
                    ItemFileName = txtFileName.Text.Trim(),
                    ItemDescription = newDescription,
                    ItemKind = "",
                    AlbumID = 0
                };
            }
            t.LastModifiedOnDate = DateTime.Now;
            t.LastModifiedByUserId = UserId;
            t.ModuleId = ModuleId;
            if (t.ItemId > 0)
            {
                tc.UpdateItem(t);
            }
            else
            {
                tc.CreateItem(t);
            }
            //reload
            LoadGalleryList();
            LoadAlbumList();
            SetPanels(true);
        }