Ejemplo n.º 1
0
 /// <summary>
 /// saveOrder
 /// </summary>
 private void SaveOrder()
 {
     foreach (RepeaterItem item in rptResult.Items)
     {
         if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
         {
             HtmlInputButton   btId       = (HtmlInputButton)item.FindControl("btId");
             PNK_ContentStatic productCat = new PNK_ContentStatic();
             productCat.Id = DBConvert.ParseInt(btId.Value);
             productCat    = genericBLL.Load(productCat, new string[] { "Id" });
             HtmlInputText txtOrder = (HtmlInputText)item.FindControl("txtOrder");
             if (txtOrder != null)
             {
                 try
                 {
                     productCat.Ordering = DBConvert.ParseInt(txtOrder.Value);
                     if (productCat.Ordering > 0)
                     {
                         genericBLL.Update(productCat, productCat, new string[] { "Id" });
                     }
                 }
                 catch { }
             }
         }
     }
 }
        /// <summary>
        /// Show location
        /// </summary>
        private void ShowProductcategory()
        {
            if (this.productcategoryId != int.MinValue)
            {
                PNK_ContentStatic productcatObj = new PNK_ContentStatic();
                string[]          fields        = { "Id" };
                productcatObj.Id          = this.productcategoryId;
                productcatObj             = generic2CBLL.Load(productcatObj, fields, Constant.DB.LangId);
                this.chkPublished.Checked = productcatObj.Published == "1" ? true : false;
                txtPhone.Value            = productcatObj.Phone;
                block_baseimage.ImageName = productcatObj.Image;

                IList <PNK_ContentStaticDesc> lst = genericDescBLL.GetAllBy(new PNK_ContentStaticDesc(), string.Format(" where mainid = {0}", this.productcategoryId), null);
                foreach (PNK_ContentStaticDesc item in lst)
                {
                    switch (item.LangId)
                    {
                    case 1:
                        this.txtName.Value    = item.Title;
                        this.txtIntro.Text    = item.Brief;
                        this.editBriefVi.Text = item.Detail;
                        //this.editDetailVi.Text = item.Detail;
                        break;

                    case 2:
                        this.txtNameEng.Value = item.Title;
                        this.txtIntroEn.Text  = item.Brief;
                        this.editBriefEn.Text = item.Detail;
                        //this.editDetailEn.Text = item.Detail;
                        //editDetailEn.Text = item.Intro;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Save location
        /// </summary>
        private void SaveContentStaticCategory()
        {
            //Xoá cache trước khi lưu
            CacheHelper.ClearContains("ContentStatic");

            PNK_ContentStatic     productcatObj   = new PNK_ContentStatic();
            PNK_ContentStaticDesc productcatObjVn = new PNK_ContentStaticDesc();
            PNK_ContentStaticDesc productcatObjEn = new PNK_ContentStaticDesc();

            if (this.productcategoryId == int.MinValue)
            {
                //get data insert
                productcatObj          = this.GetDataObjectParent(productcatObj);
                productcatObj.PostDate = DateTime.Now;
                productcatObj.Ordering = genericBLL.getOrdering();
                productcatObjVn        = this.GetDataObjectChild(productcatObjVn, Constant.DB.LangId);
                productcatObjEn        = this.GetDataObjectChild(productcatObjEn, Constant.DB.LangId_En);

                List <PNK_ContentStaticDesc> lst = new List <PNK_ContentStaticDesc>();
                lst.Add(productcatObjVn);
                lst.Add(productcatObjEn);
                //excute
                this.productcategoryId = generic2CBLL.Insert(productcatObj, lst);
            }
            else
            {
                string[] fields = { "Id" };
                productcatObj.Id = this.productcategoryId;

                productcatObj = genericBLL.Load(productcatObj, fields);
                //string publisheddOld = productcatObj.Published;
                //get data update
                productcatObj   = this.GetDataObjectParent(productcatObj);
                productcatObjVn = this.GetDataObjectChild(productcatObjVn, Constant.DB.LangId);
                productcatObjEn = this.GetDataObjectChild(productcatObjEn, Constant.DB.LangId_En);
                List <PNK_ContentStaticDesc> lst = new List <PNK_ContentStaticDesc>();
                lst.Add(productcatObjVn);
                lst.Add(productcatObjEn);
                //excute
                generic2CBLL.Update(productcatObj, lst, fields);
                //neu ve Published oo thay doi thi chay ham ChangeWithTransaction de doi Published cac con va cac product
                //if (publisheddOld != productcatObj.Published)
                //    PNK_ContentStatic.ChangeWithTransaction(DBConvert.ParseString(this.productcategoryId), productcatObj.Published);
            }
        }
        /// <summary>
        /// get data for insert update
        /// </summary>
        /// <param name="userObj"></param>
        /// <returns></returns>
        private PNK_ContentStatic GetDataObjectParent(PNK_ContentStatic productcatObj)
        {
            productcatObj.CategoryId = 1;
            productcatObj.Phone      = this.txtPhone.Value;
            productcatObj.Published  = chkPublished.Checked ? "1" : "0";
            productcatObj.UpdateDate = DateTime.Now;

            HtmlControl hddImageName = block_baseimage.FindControl("hddImageName") as HtmlControl;

            if (hddImageName != null && hddImageName.Attributes["value"] != null)
            {
                productcatObj.Image = hddImageName.Attributes["value"].ToString();
            }
            else
            {
                productcatObj.Image = "";
            }
            return(productcatObj);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// ItemDataBound
        /// </summary>
        protected void rptResult_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                string        img, alt, publishedTask;
                HtmlTableRow  tr  = (HtmlTableRow)e.Item.FindControl("trList");
                HtmlInputText txt = null;
                if (e.Item.ItemIndex % 2 == 0)
                {
                    tr.Attributes.Add("class", "even");
                }
                else
                {
                    tr.Attributes.Add("class", "old");
                }

                try
                {
                    PNK_ContentStatic data = (PNK_ContentStatic)e.Item.DataItem;

                    //Role
                    Literal ltr = null;
                    ltr      = (Literal)e.Item.FindControl("ltrchk");
                    ltr.Text = string.Format(@"<INPUT class='txt' TYPE='checkbox' ID='cb{0}' NAME='cid[]' value='{1}' onclick='isChecked(this.checked);' >",
                                             e.Item.ItemIndex, data.Id);

                    //ltrNewsCategory
                    ltr = (Literal)e.Item.FindControl("ltrNewsCategory");


                    //image
                    if (data.Published == "1")
                    {
                        img           = "tick.png";
                        alt           = LocalizationUtility.GetText(ltrAdminPublish.Text);
                        publishedTask = "unpublish";
                    }
                    else
                    {
                        img           = "publish_x.png";
                        alt           = LocalizationUtility.GetText(ltrAdminPublish.Text);
                        publishedTask = "publish";
                    }

                    //Order
                    txt       = (HtmlInputText)e.Item.FindControl("txtOrder");
                    txt.Value = DBConvert.ParseString(data.Ordering);

                    //Id
                    HtmlInputButton btId = (HtmlInputButton)e.Item.FindControl("btId");
                    btId.Value = DBConvert.ParseString(data.Id);

                    //Base img
                    HtmlImage Image = (HtmlImage)e.Item.FindControl("Image");
                    Image.Src = WebUtils.GetUrlImage(ConfigurationManager.AppSettings["ContentStaticUpload"], data.Image);
                    HtmlAnchor hypImage = (HtmlAnchor)e.Item.FindControl("hypImage");

                    //set link
                    HyperLink hdflink = new HyperLink();
                    hdflink       = (HyperLink)e.Item.FindControl("hdflink");
                    hypImage.HRef = hdflink.NavigateUrl = template_path + LinkHelper.GetAdminLink("edit_contentstatic", data.Id);
                    ImageButton imgctr = (ImageButton)e.Item.FindControl("btnPublish");
                    imgctr.ImageUrl = string.Format("/Admin/images/{0}", img);
                    imgctr.Attributes.Add("alt", alt);
                    HtmlTableCell btn = (HtmlTableCell)e.Item.FindControl("tdbtn");
                    btn.Attributes.Add("onclick", string.Format(" return listItemTask('cb{0}', '{1}')", e.Item.ItemIndex, publishedTask));

                    //Name
                    ltr            = (Literal)e.Item.FindControl("ltrName");
                    hypImage.Title = ltr.Text = data.ContentStaticDesc.Title;
                }
                catch { }
            }
        }