private void LoadAlbums()
        {
            if (!string.IsNullOrEmpty(Request.Form["LanguageId"]))
            {
                LandId = Request.Form["LanguageId"].ToString();
            }

            if (!string.IsNullOrEmpty(Request.Form["ProductId"]))
            {
                ProId = Request.Form["ProductId"].ToString();
            }

            ProductAlbumRepository _rpoObj = new ProductAlbumRepository();
            dlAlbums.DataSource = _rpoObj.LoadByProductIdAndLanguageId(LandId, ProId);
            dlAlbums.DataBind();
        }
        protected void grdData_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            _rpoObj = new ProductAlbumRepository();
            switch (e.CommandName)
            {

                case "restoreitem":
                    if (_rpoObj.Restore(e.CommandArgument.ToString(), Request.Cookies["CooLoginUserId"].Value))
                    { grdData.DataBind(); }
                    break;
                case "deleteitem":
                    if (_rpoObj.Delete(e.CommandArgument.ToString(), Request.Cookies["CooLoginUserId"].Value))
                    { grdData.DataBind(); }
                    break;
            }
        }
Пример #3
0
        protected void rptrProductsSections_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                ProductRepository _prorpoObj = new ProductRepository();
                ProductAlbumRepository _rpoProAlbumObj = new ProductAlbumRepository();

                DataRowView row = (DataRowView)e.Item.DataItem;
                //tring varAlbumId = ((Label)e.Item.FindControl("lblAlbumId")).Text;
                Literal lbltitle = (Literal)e.Item.FindControl("lblProductTitle");
                Literal lblFullDesc = (Literal)e.Item.FindControl("lblProductFullDescrition");
                lbltitle.Text = row["ProductTitle"].ToString();
                lblFullDesc.Text = row["FullDescription"].ToString();

                Repeater albums = (Repeater)e.Item.FindControl("dlAlbums");
                albums.DataSource = _rpoProAlbumObj.LoadByProductIdAndLanguageId((row["LanguageId"].ToString()), (row["Id"].ToString()));
                albums.DataBind();

            }
        }
        void GetInfo()
        {
            if (!string.IsNullOrEmpty(ProductAlbumId))
            {
                _rpoObj = new ProductAlbumRepository();
                ProductAlbum ProductAlbumEnt = _rpoObj.LoadById(ProductAlbumId);
                if (ProductAlbumEnt != null)
                {
                    txtAlbumTitile.Text = ProductAlbumEnt.Title;
                    txtAlbumDescription.Text = ProductAlbumEnt.AlbumDescription;

                    //ifrmProductImages.Attributes["src"] = "../MainPages/ProductImagesGallery.aspx?ProductId=" + ProductEnt.Id.ToString() + "&LanguageId=" + ProductEnt.LanguageId.ToString();
                    //TabContainer1.ActiveTabIndex = 1;

                    //TabGallery.Enabled = true;

                    if (!string.IsNullOrEmpty(ProductAlbumEnt.ImageFile))
                    {
                        imgProductImage.ImageUrl = ConfigurationManager.AppSettings["Products"].ToString() + ProductAlbumEnt.ImageFile;
                        imgProductImage.Visible = true;
                    }
                    else
                        imgProductImage.Visible = false;
                    try
                    {
                        ddlLanguage.SelectedValue = ProductAlbumEnt.LanguageId.ToString();
                        ddlProducts.SelectedValue = ProductAlbumEnt.ProductId.ToString();
                    }
                    catch
                    {
                        ddlLanguage.SelectedIndex = -1;
                        ddlProducts.SelectedIndex = -1;
                    }
                }
            }
        }
        void Save()
        {
            string ImageFile = string.Empty;
            _rpoObj = new ProductAlbumRepository();
            #region Manage Item
            //string FileName = string.Empty;
            string FileName = string.Empty;
            _rpoObj._Obj.LanguageId = new Guid(ddlLanguage.SelectedValue.ToString());
            _rpoObj._Obj.ProductId = new Guid(ddlProducts.SelectedValue.ToString());
            _rpoObj._Obj.Title = txtAlbumTitile.Text;
            _rpoObj._Obj.AlbumDescription = txtAlbumDescription.Text;

            //isdefault here

            if (string.IsNullOrEmpty(ProductAlbumId))
            {
                _rpoObj._Obj.CreatedBy = new Guid(Request.Cookies["CooLoginUserId"].Value);
                if (fpld.PostedFile.FileName != "")
                {
                    FileName = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(fpld.PostedFile.FileName);
                    string PathUrl = Server.MapPath(ConfigurationManager.AppSettings["Products"].ToString()) + FileName;
                    fpld.SaveAs(PathUrl);
                    // DAL.ImagesFact.ResizeWithCropResizeImage("", FileName, "Section");
                    _rpoObj._Obj.ImageFile = FileName;
                }
                ProductAlbumId = _rpoObj.Add().ToString();
                //if (!string.IsNullOrEmpty(PageSectionId))
                //{
                //    BackendMessages(101);
                //}
                //else
                //{
                //    BackendMessages(201);
                //}
            }
            else
            {
                _rpoObj._Obj = _rpoObj.LoadById(ProductAlbumId);
                _rpoObj._Obj.LanguageId = new Guid(ddlLanguage.SelectedValue.ToString());
                _rpoObj._Obj.ProductId = new Guid(ddlProducts.SelectedValue.ToString());
                _rpoObj._Obj.Title = txtAlbumTitile.Text;
                _rpoObj._Obj.AlbumDescription = txtAlbumDescription.Text;

                if (fpld.PostedFile.FileName != "")
                {
                    if (_rpoObj._Obj.ImageFile != null)
                    {
                        DirectoryInfo di = new DirectoryInfo(Server.MapPath(ConfigurationManager.AppSettings["Products"]));
                        foreach (FileInfo fi in di.GetFiles())
                        {
                            if (_rpoObj._Obj.ImageFile == fi.Name)
                            {
                                File.Delete(fi.Name);
                            }
                        }
                    }
                    FileName = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(fpld.PostedFile.FileName);
                    string PathUrl = Server.MapPath(ConfigurationManager.AppSettings["Products"].ToString()) + FileName;
                    fpld.SaveAs(PathUrl);
                    // DAL.ImagesFact.ResizeWithCropResizeImage("", FileName, "Section");
                    _rpoObj._Obj.ImageFile = FileName;
                }

                _rpoObj._Obj.ModifiedBy = new Guid(Request.Cookies["CooLoginUserId"].Value);
                if (_rpoObj.Edit())
                {
                    //lblMessge.Text = "Done, changes has been saved successfully!";
                    //msg.Attributes["class"] = "msg-success";
                }
                else
                {
                    //lblMessge.Text = "Error, Please try again later!";
                    //msg.Attributes["class"] = "msg-error";
                }
            }
            #endregion
        }
 private void LoadProductAlbumsByLanguageIDAndProductId()
 {
     _rpoObj = new ProductAlbumRepository();
     grdData.DataSource = _rpoObj.LoadByProductIdAndLanguageId(ddlLanguage.SelectedValue.ToString(),ddlProducts.SelectedValue.ToString());
     grdData.DataBind();
 }