Esempio n. 1
0
        override protected void OnInit(EventArgs e)
        {
            InitializeComponent();
            base.OnInit(e);
            #region Request
            m_ProductId = DataProcessingProvider.GetProcessedInt(Request.QueryString["ProductId"]);
            m_preTabId  = DataProcessingProvider.GetProcessedInt(Request.QueryString["PreTabId"]);
            m_strTags   = ",";
            if (m_ProductId == -1)
            {
                m_strCategories = DataProcessingProvider.GetProcessedString(Request.QueryString["Categories"]);
                if (m_strCategories == "")
                {
                    m_strCategories = ",-1,";
                }
                else
                {
                    m_strCategories = DataProcessingProvider.GetProcessedBatchString(m_strCategories);
                }
            }
            else
            {
                DataTable dtTags = DotNetNuke.Data.DataProvider.Instance().ExecuteDataSet("THCore_CM_GetItemTags", m_ProductId, ProductProvider.TypeId).Tables[0];
                if (dtTags.Rows.Count > 0)
                {
                    for (int i = 0; i < dtTags.Rows.Count; i++)
                    {
                        m_strTags = m_strTags + dtTags.Rows[i][0].ToString() + ",";
                    }
                }
                m_strCategories = CategoryProvider.GetItemCategoryString(m_ProductId, ProductProvider.TypeId);
            }
            //Dynamic Form
            string[] arrCategories = m_strCategories.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            int      iCategory     = -1;
            int.TryParse(arrCategories[0].Trim(), out iCategory);

            m_strExtension = LoadStringSetting(ProductInsertSettings.EXTENSTION_KEY, ProductInsertSettings.EXTENSTION_VALUE_DEFAULT);
            //string strExtendedSettings = CategoryProvider.GetExtendedSettings(iCategory);
            string strExtendedSettings = m_strExtension;

            dtConfig = new DataTable();
            dtConfig = XMLProvider.XmlString2DataTable(strExtendedSettings);
            try
            {
                if (dtConfig != null && dtConfig.Rows.Count > 0)
                {
                    CreateDynamicForm(dtConfig);
                }
            }
            catch (Exception ex)
            {
                lblError.Text         = ex.Message;
                this.lblError.Visible = true;
            }
            #endregion
            #region Settings
            //Load Folder
            m_strFolderName = CategoryProvider.GetDefaultFolderPath(m_strCategories, this.PortalId);
            if (m_strFolderName == "")
            {
                m_strFolderName = (string)Settings[ProductInsertSettings.FOLDER_IMAGE_KEY];
                if (m_strFolderName == null || m_strFolderName.Length == 0)
                {
                    m_strFolderName = ProductInsertSettings.FOLDER_IMAGE_DEFAULT;
                }
            }
            string strFolderPath = string.Format("{0}{1}", PortalSettings.HomeDirectoryMapPath, m_strFolderName);
            if (!System.IO.Directory.Exists(strFolderPath))
            {
                m_strFolderName = ProductInsertSettings.FOLDER_IMAGE_DEFAULT;
            }


            #endregion
            #region Datetime
            lnkExpiredDate.NavigateUrl = DotNetNuke.Common.Utilities.Calendar.InvokePopupCal(txtExpiredDate).Replace("M/d/yyyy", "MM/dd/yyyy").Replace("d/MM/yyyy", "dd/MM/yyyy").Replace("MM/dd/yyyy", "dd/MM/yyyy");
            //Điền dữ liệu vào các control
            imgExpiredDate.ImageUrl = string.Format("{0}/images/calendar.png", this.ModulePath);

            lnkProducedDate.NavigateUrl = DotNetNuke.Common.Utilities.Calendar.InvokePopupCal(txtProducedDate).Replace("M/d/yyyy", "MM/dd/yyyy").Replace("d/MM/yyyy", "dd/MM/yyyy").Replace("MM/dd/yyyy", "dd/MM/yyyy");
            //Điền dữ liệu vào các control
            imgProducedDate.ImageUrl = string.Format("{0}/images/calendar.png", this.ModulePath);

            lnkDisplayDate.NavigateUrl = DotNetNuke.Common.Utilities.Calendar.InvokePopupCal(txtDisplayDate).Replace("M/d/yyyy", "MM/dd/yyyy").Replace("d/MM/yyyy", "dd/MM/yyyy").Replace("MM/dd/yyyy", "dd/MM/yyyy");
            //Điền dữ liệu vào các control
            imgDisplayDate.ImageUrl = string.Format("{0}/images/calendar.png", this.ModulePath);



            #endregion
            #region Register
            DotNetNuke.UI.Skins.Skin objParentSkin = DotNetNuke.UI.Skins.Skin.GetParentSkin(this);
            if (objParentSkin != null)
            {
                objParentSkin.RegisterModuleActionEvent(this.ModuleId, new ActionEventHandler(ModuleAction_Click));
            }
            if (m_ProductId == -1)
            {
                m_objRole = new Role(this.UserId, GetSuperMode(), this.PortalId, ProductProvider.TypeId);
            }
            else
            {
                m_objRole = new Role(this.UserId, m_ProductId, GetSuperMode(), this.PortalId, ProductProvider.TypeId);
            }
            #endregion
        }
Esempio n. 2
0
        public void ProductBinding()
        {
            DataTable objTableData = ProductProvider.GetProduct(m_ProductId);

            if (objTableData.Rows.Count > 0)
            {
                lblError.Text            = "Cập nhật sản phẩm";
                this.txtProductName.Text = txtProductNameOld.Text = objTableData.Rows[0]["ProductName"].ToString();
                this.txtCode.Text        = txtProductNameOld.Text = objTableData.Rows[0]["Code"].ToString();
                string strImageAdd1 = objTableData.Rows[0]["ImageAdd1"].ToString();
                string strImageAdd2 = objTableData.Rows[0]["ImageAdd2"].ToString();
                string strImageAdd3 = objTableData.Rows[0]["ImageAdd3"].ToString();
                urlSmallImageImgAdd1.Url = strImageAdd1;
                urlSmallImageImgAdd2.Url = strImageAdd2;
                urlSmallImageImgAdd3.Url = strImageAdd3;
                txtImageAdd1Old.Text     = strImageAdd1;
                txtImageAdd2Old.Text     = strImageAdd2;
                txtImageAdd3Old.Text     = strImageAdd3;
                string strSmallImage = objTableData.Rows[0]["Smallimage"].ToString();
                txtSmallimageOld.Text = strSmallImage;
                urlSmallImage.Url     = strSmallImage;
                string strLargeimage = objTableData.Rows[0]["Largeimage"].ToString();
                txtLargeimageOld.Text  = strLargeimage;
                urlLargeImage.Url      = strLargeimage;
                txtCreatedDateOld.Text = objTableData.Rows[0]["CreatedDate"].ToString();

                //this.imgImageFile.Src = string.Format("/Portals/{0}/{1}", this.PortalId, m_strOldImagePath);
                //spImageFile.InnerHtml = m_strOldImagePath;
                if (strImageAdd1.Contains("Portals"))
                {
                    this.imgAdd1.Src = strImageAdd1;
                }
                else
                {
                    this.imgAdd1.Src = string.Format("/Portals/{0}/{1}", this.PortalId, strImageAdd1);
                }
                if (strImageAdd2.Contains("Portals"))
                {
                    this.imgAdd2.Src = strImageAdd2;
                }
                else
                {
                    this.imgAdd2.Src = string.Format("/Portals/{0}/{1}", this.PortalId, strImageAdd2);
                }
                if (strImageAdd3.Contains("Portals"))
                {
                    this.imgAdd3.Src = strImageAdd3;
                }
                else
                {
                    this.imgAdd3.Src = string.Format("/Portals/{0}/{1}", this.PortalId, strImageAdd3);
                }
                this.spImgAdd1.InnerHtml = strImageAdd1;
                this.spImgAdd2.InnerHtml = strImageAdd2;
                this.spImgAdd3.InnerHtml = strImageAdd3;
                if (strSmallImage.Contains("Portals"))
                {
                    this.imgSmallImage.Src = strSmallImage;
                }
                else
                {
                    this.imgSmallImage.Src = string.Format("/Portals/{0}/{1}", this.PortalId, strSmallImage);
                }
                this.spSmallImage.InnerHtml = strSmallImage;
                if (strLargeimage.Contains("Portals"))
                {
                    this.imgLargeimage.Src = strLargeimage;
                }
                else
                {
                    this.imgLargeimage.Src = string.Format("/Portals/{0}/{1}", this.PortalId, strLargeimage);
                }
                spLargeimage.InnerHtml = strLargeimage;

                txtLead.Text = objTableData.Rows[0]["Lead"].ToString();

                txtSummary.Text       = objTableData.Rows[0]["Summary"].ToString();
                txtWeight.Text        = objTableData.Rows[0]["Weight"].ToString();
                txtPrice.Text         = objTableData.Rows[0]["Price"].ToString();
                txtPriceOld.Text      = objTableData.Rows[0]["PriceOld"].ToString();
                txtStatusProduct.Text = objTableData.Rows[0]["StatusProduct"].ToString();
                txtaddInfo1.Text      = objTableData.Rows[0]["AddInfo1"].ToString();
                txtaddInfo2.Text      = objTableData.Rows[0]["AddInfo2"].ToString();
                txtaddInfo3.Text      = objTableData.Rows[0]["AddInfo3"].ToString();

                txtaddInfo4.Text = objTableData.Rows[0]["AddInfo4"].ToString();
                txtaddInfo5.Text = objTableData.Rows[0]["AddInfo5"].ToString();
                txtaddInfo6.Text = objTableData.Rows[0]["AddInfo6"].ToString();

                txtaddRichInfo1.Text = objTableData.Rows[0]["AddRichInfo1"].ToString();
                txtaddRichInfo2.Text = objTableData.Rows[0]["AddRichInfo2"].ToString();
                txtaddRichInfo3.Text = objTableData.Rows[0]["AddRichInfo3"].ToString();

                txtOrder.Text             = objTableData.Rows[0]["Order"].ToString();
                this.txtProducedDate.Text = DateTime.Parse(objTableData.Rows[0]["ProducedDate"].ToString()).ToString("dd/MM/yyyy");
                this.txtDisplayDate.Text  = DateTime.Parse(objTableData.Rows[0]["DisplayDate"].ToString()).ToString("dd/MM/yyyy");
                txtExpiredDate.Text       = DateTime.Parse(objTableData.Rows[0]["ExpiredDate"].ToString()).ToString("dd/MM/yyyy");

                if (objTableData.Rows[0]["IsHot"].ToString() == "False")
                {
                    this.chkIsHot.Checked = false;
                }
                else
                {
                    this.chkIsHot.Checked = true;
                }
                this.txtHotPeriod.Text = objTableData.Rows[0]["HotPeriod"].ToString();
                //Bind Dynamic Form
                string strExtendedSettings = objTableData.Rows[0]["ExtendedSettings"].ToString();
                dtValue = new DataTable();
                dtValue = XMLProvider.XmlString2DataTable(strExtendedSettings);
                try
                {
                    if (dtValue != null && dtValue.Rows.Count > 0)
                    {
                        BindingDynamicForm(dtValue);
                    }
                }
                catch (Exception ex)
                {
                    lblError.Text         = ex.Message;
                    this.lblError.Visible = true;
                }
            }
        }