コード例 #1
0
ファイル: AdminAddEditPage.cs プロジェクト: elshiekh5/CMS.V6
        //---------------------------------------------------------
        protected void ClearControl(Control c)
        {
            Type   controlType = c.GetType();
            string s           = controlType.FullName;

            if (c is TextBox)
            {
                TextBox txt = (TextBox)c;
                txt.Text = "";
            }
            else if (c is DropDownList)
            {
                DropDownList ddl = (DropDownList)c;
                ddl.SelectedIndex = -1;
            }
            else if (c is CheckBox)
            {
                CheckBox cb = (CheckBox)c;
                cb.Checked = false;
            }
            else if (c is FCKeditor)
            {
                FCKeditor editor = (FCKeditor)c;
                editor.Value = "";
            }

            if (c.HasControls())
            {
                foreach (Control child2 in c.Controls)
                {
                    ClearControl(child2);
                }
            }
        }
    protected void marcNTextRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        try
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView drv = e.Item.DataItem as DataRowView;

                FCKeditor NTEXT_Value = (FCKeditor)e.Item.FindControl("NTEXT_Value");
                if (Convert.ToBoolean(ConfigurationManager.AppSettings["FCKEditorEnableCKFinder"].ToString()))
                {
                    CKFinder.FileBrowser _FileBrowser = new CKFinder.FileBrowser();
                    _FileBrowser.BasePath = "AdminTools/ckfinder/";
                    _FileBrowser.SetupFCKeditor(NTEXT_Value);
                }
                NTEXT_Value.ToolbarCanCollapse   = true;
                NTEXT_Value.ToolbarStartExpanded = false;
                NTEXT_Value.DefaultLanguage      = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.ToLower();
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
        protected void dvwProduct_ItemCreated(object sender, EventArgs e)
        {
            Control ctl = dvwProduct.FindControl("txtDescription");

            if (ctl != null)
            {
                FCKeditor txtDescription = ctl as FCKeditor;
                txtDescription.BasePath = this.BaseUrl + "FCKeditor/";
            }
        }
コード例 #4
0
        protected void dvwArticle_ItemCreated(object sender, EventArgs e)
        {
            Control ctl = dvwArticle.FindControl("txtBody");

            if (ctl != null)
            {
                FCKeditor txtBody = ctl as FCKeditor;
                txtBody.BasePath = this.BaseUrl + "FCKeditor/";
            }
        }
コード例 #5
0
 private void clearForm(ControlCollection controls)
 {
     foreach (Control c in controls)
     {
         if (c is TextBox)
         {
             TextBox textBox = (TextBox)c;
             textBox.Text = "";
         }
         else if (c.HasControls())
         {
             clearForm(c.Controls);
         }
         else if (c is FCKeditor)
         {
             FCKeditor fck = (FCKeditor)c;
             fck.Value = "";
         }
     }
 }
コード例 #6
0
        private void GetSuAnnouncementLangInfo(SuAnnouncementLang announcementLang)
        {
            TextBox   ctlTxtHeader  = ctlAnnouncementLangForm.FindControl("ctlTxtHeader") as TextBox;
            TextBox   ctlTxtBody    = ctlAnnouncementLangForm.FindControl("ctlTxtBody") as TextBox;
            TextBox   ctlTxtFooter  = ctlAnnouncementLangForm.FindControl("ctlTxtFooter") as TextBox;
            TextBox   ctlTxtComment = ctlAnnouncementLangForm.FindControl("ctlTxtComment") as TextBox;
            CheckBox  ctlActive     = ctlAnnouncementLangForm.FindControl("ctlActive") as CheckBox;
            FCKeditor ctlFCK        = ctlAnnouncementLangForm.FindControl("ctlFCK") as FCKeditor;

            announcementLang.AnnouncementHeader = ctlTxtHeader.Text;
            //announcementLang.AnnouncementBody = ctlTxtBody.Text;
            announcementLang.AnnouncementBody   = ctlFCK.Value;
            announcementLang.AnnouncementFooter = ctlTxtFooter.Text;
            announcementLang.Comment            = ctlTxtComment.Text;
            announcementLang.Active             = ctlActive.Checked;
            announcementLang.UpdPgm             = ProgramCode;
            announcementLang.CreBy   = UserAccount.UserID;
            announcementLang.CreDate = DateTime.Now;
            announcementLang.UpdBy   = UserAccount.UserID;
            announcementLang.UpdDate = DateTime.Now;
        }
    protected void save_MetaContentData()
    {
        try
        {
            _MetaContent = new ContentEditorDataHelper();
            _MetaContent.load_Xml(Session["METADATA"].ToString());

            _MetaContent.Alias = txtMetaContentAlias.Text;
            if (!String.IsNullOrEmpty(this.dropCategories.SelectedValue))
            {
                _MetaContent.CategoryID = Convert.ToInt16(this.dropCategories.SelectedValue.ToString());
            }
            _MetaContent.LocalCode = txtLocalCode.Text;
            //check duplicate in local code go here
            if (!String.IsNullOrEmpty(txtLocalCode.Text))
            {
                if (LegoWebAdmin.BusLogic.MetaContents.is_LocalCode_Exist(txtLocalCode.Text, _MetaContent.CategoryID, _MetaContent.MetaContentID))
                {
                    throw new Exception("Local Code is already existed!");
                }
            }
            _MetaContent.RecordStatus   = int.Parse(this.radioRecordStatus.SelectedValue);
            _MetaContent.LangCode       = this.dropLanguages.SelectedValue.ToString();
            _MetaContent.AccessLevel    = int.Parse(this.dropAccessLevels.SelectedValue);
            _MetaContent.ImportantLevel = int.Parse(this.dropImportantLevels.SelectedValue);

            DataTable marcTable = _MetaContent.create_MarcDataTable();

            for (int i = 0; i < marcTextRepeater.Items.Count; i++)
            {
                DataRow nRow     = marcTable.NewRow();
                Label   labelTag = (Label)marcTextRepeater.Items[i].FindControl("labelTag");
                if (labelTag != null)
                {
                    nRow["TAG"] = labelTag.Text;
                }
                else
                {
                    throw new Exception("Error: save_MetaContentData labelTag==null");
                }

                Label labelTagIndex = (Label)marcTextRepeater.Items[i].FindControl("labelTagIndex");
                if (labelTagIndex != null)
                {
                    nRow["TAG_INDEX"] = int.Parse(labelTagIndex.Text);
                }
                else
                {
                    throw new Exception("Error: save_MetaContentData labelTagIndex==null");
                }

                Label labelSubfieldID = (Label)marcTextRepeater.Items[i].FindControl("labelSubfieldID");
                if (labelSubfieldID != null && !String.IsNullOrEmpty(labelSubfieldID.Text))
                {
                    nRow["SUBFIELD_ID"] = Int32.Parse(labelSubfieldID.Text);
                }

                Label labelSubfieldCode = (Label)marcTextRepeater.Items[i].FindControl("labelSubfieldCode");
                if (labelSubfieldCode != null)
                {
                    nRow["SUBFIELD_CODE"] = labelSubfieldCode.Text;
                }
                else
                {
                    throw new Exception("Error: save_MetaContentData labelSubfieldCode==null");
                }

                Label labelSubfieldLabel = (Label)marcTextRepeater.Items[i].FindControl("labelSubfieldLabel");

                if (labelSubfieldLabel != null)
                {
                    nRow["SUBFIELD_LABEL"] = labelSubfieldLabel.Text;
                }
                else
                {
                    throw new Exception("Error: save_MetaContentData labelSubfieldLabel==null");
                }

                Label labelSubfieldType = (Label)marcTextRepeater.Items[i].FindControl("labelSubfieldType");
                if (labelSubfieldType != null)
                {
                    nRow["SUBFIELD_TYPE"] = labelSubfieldType.Text;
                    TextBox Subfield_Value = (TextBox)marcTextRepeater.Items[i].FindControl("Subfield_Value");
                    if (Subfield_Value != null)
                    {
                        nRow["SUBFIELD_VALUE"] = Subfield_Value.Text;
                    }
                }
                else
                {
                    throw new Exception("Error: save_MetaContentData labelSubfieldType==null");
                }

                marcTable.Rows.Add(nRow);
            }

            /*marcNTextRepeater*/
            #region marcNTextRepeater
            for (int i = 0; i < marcNTextRepeater.Items.Count; i++)
            {
                DataRow nRow     = marcTable.NewRow();
                Label   labelTag = (Label)marcNTextRepeater.Items[i].FindControl("labelTag");
                if (labelTag != null)
                {
                    nRow["TAG"] = labelTag.Text;
                }
                else
                {
                    throw new Exception("Error: save_MetaContentData labelTag==null");
                }

                Label labelTagIndex = (Label)marcNTextRepeater.Items[i].FindControl("labelTagIndex");
                if (labelTagIndex != null)
                {
                    nRow["TAG_INDEX"] = int.Parse(labelTagIndex.Text);
                }
                else
                {
                    throw new Exception("Error: save_MetaContentData labelTagIndex==null");
                }

                Label labelSubfieldID = (Label)marcNTextRepeater.Items[i].FindControl("labelSubfieldID");
                if (labelSubfieldID != null && !String.IsNullOrEmpty(labelSubfieldID.Text))
                {
                    nRow["SUBFIELD_ID"] = labelSubfieldID.Text;
                }

                Label labelSubfieldCode = (Label)marcNTextRepeater.Items[i].FindControl("labelSubfieldCode");
                if (labelSubfieldCode != null)
                {
                    nRow["SUBFIELD_CODE"] = labelSubfieldCode.Text;
                }
                else
                {
                    throw new Exception("Error: save_MetaContentData labelSubfieldCode==null");
                }

                Label labelSubfieldLabel = (Label)marcNTextRepeater.Items[i].FindControl("labelSubfieldLabel");

                if (labelSubfieldLabel != null)
                {
                    nRow["SUBFIELD_LABEL"] = labelSubfieldLabel.Text;
                }
                else
                {
                    throw new Exception("Error: save_MetaContentData labelSubfieldLabel==null");
                }

                Label labelSubfieldType = (Label)marcNTextRepeater.Items[i].FindControl("labelSubfieldType");
                if (labelSubfieldType != null)
                {
                    nRow["SUBFIELD_TYPE"] = labelSubfieldType.Text;
                    FCKeditor fckValue = (FCKeditor)marcNTextRepeater.Items[i].FindControl("NTEXT_Value");
                    if (fckValue != null)
                    {
                        nRow["SUBFIELD_VALUE"] = HttpUtility.HtmlDecode(fckValue.Value);
                    }
                }
                else
                {
                    throw new Exception("Error: save_MetaContentData labelSubfieldType==null");
                }

                marcTable.Rows.Add(nRow);
            }
            #endregion marcNTextRepeater
            _MetaContent.bind_TableDataToMarc(ref marcTable);
            Session["METADATA"] = _MetaContent.OuterXml;
        }
        catch (Exception ex)
        {
            throw new Exception("Data error:" + ex.Message + "\n" + ex.InnerException);
        }
    }
コード例 #8
0
 public FCKeditorAdapter()
 {
     _Control          = new FCKeditor();
     _Control.BasePath = "~/FCKeditor/";
 }
コード例 #9
0
    private static void ParsingFillVO(Control ctrl, object obj)
    {
        log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        if (string.IsNullOrEmpty(ctrl.ID))
        {
            return;
        }

        ObjectWrapper ow = new ObjectWrapper(obj);

        if (ctrl is TextBox)
        {
            if (!ctrl.ID.StartsWith("txt"))
            {
                return;
            }

            TextBox txtCtrl = (TextBox)ctrl;

            string fieldName = ctrl.ID.Replace("txt", "");

            if (HasProperty(ow, fieldName))
            {
                Type propertyType = ow.GetPropertyType(fieldName);

                object setValue = txtCtrl.Text;

                if (!string.IsNullOrEmpty(setValue.ToString()))
                {
                    if (propertyType == typeof(DateTime) || propertyType == typeof(DateTime?))
                    {
                        string date = txtCtrl.Text;
                        if (!string.IsNullOrEmpty(date))
                        {
                            date = date.Replace("-", "/");
                        }
                        setValue = ConvertUtil.ToDateTime(date);
                    }

                    log.Debug(string.Format("set {0}, {1} = {2}", ow.WrappedInstance.GetType().Name, fieldName, setValue));

                    ow.SetPropertyValue(fieldName, setValue);
                }
                else
                {
                    if (propertyType == typeof(Double))
                    {
                        ow.SetPropertyValue(fieldName, default(Double));
                    }
                    else if (propertyType == typeof(int))
                    {
                        ow.SetPropertyValue(fieldName, default(int));
                    }
                    else
                    {
                        ow.SetPropertyValue(fieldName, null);
                    }
                }
            }
        }
        else if (ctrl is ListControl)
        {
            ListControl lstCtrl = (ListControl)ctrl;

            string fieldName = GetFieldName(ctrl);

            if (HasProperty(ow, fieldName))
            {
                object value = lstCtrl.SelectedValue;
                if (value != null && !string.IsNullOrEmpty(value.ToString()))
                {
                    log.Debug(string.Format("set {0}, {1} = {2}", ow.WrappedInstance.GetType().Name, fieldName, value));
                    ow.SetPropertyValue(fieldName, value);
                }
            }
        }
        else if (ctrl is FCKeditor)
        {
            FCKeditor fckCtrl = (FCKeditor)ctrl;

            string fieldName = fckCtrl.ID.Replace("fck", "");

            if (HasProperty(ow, fieldName))
            {
                Type propertyType = ow.GetPropertyType(fieldName);

                object setValue = fckCtrl.Value;

                log.Debug(string.Format("set {0}, {1} = {2}", ow.WrappedInstance.GetType().Name, fieldName, setValue));

                ow.SetPropertyValue(fieldName, setValue);
            }
        }
    }
コード例 #10
0
    private static void ParsingFillField(Control ctrl, Object obj)
    {
        log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        if (string.IsNullOrEmpty(ctrl.ID))
        {
            return;
        }

        ObjectWrapper ow = new ObjectWrapper(obj);

        if (ctrl is TextBox)
        {
            if (!ctrl.ID.StartsWith("txt"))
            {
                return;
            }

            TextBox txtCtrl = (TextBox)ctrl;

            string fieldName = ctrl.ID.Replace("txt", "");

            if (HasProperty(ow, fieldName))
            {
                object value = ow.GetPropertyValue(fieldName);

                if (value != null)
                {
                    if (ow.GetPropertyType(fieldName) == typeof(DateTime) || ow.GetPropertyType(fieldName) == typeof(DateTime?))
                    {
                        string setValue = ConvertUtil.DateToShortDateStr((DateTime)value);
                        log.Debug(string.Format("set {0} = {1}", txtCtrl.ID, setValue));
                        txtCtrl.Text = setValue;
                    }
                    else
                    {
                        log.Debug(string.Format("set {0} = {1}", txtCtrl.ID, value.ToString()));
                        txtCtrl.Text = value.ToString();
                    }
                }
                else
                {
                    txtCtrl.Text = string.Empty;
                }
            }
        }
        else if (ctrl is Label)
        {
            Label  lblCtrl   = (Label)ctrl;
            string fieldName = ctrl.ID.Replace("lbl", "");
            if (HasProperty(ow, fieldName))
            {
                object value = ow.GetPropertyValue(fieldName);
                if (value != null)
                {
                    log.Debug(string.Format("set {0} = {1}", lblCtrl.ID, value.ToString()));
                    lblCtrl.Text = value.ToString();
                }
            }
        }
        else if (ctrl is ListControl)
        {
            string inStr = checkCtrlInIdStartWith(ctrl.ID, FILL_UIVO_LISTCONTROL_NOTE);

            if (string.IsNullOrEmpty(inStr))
            {
                return;
            }

            string fieldName = ctrl.ID.Replace(inStr, "");

            if (HasProperty(ow, fieldName))
            {
                ListControl ddlCtrl = (ListControl)ctrl;
                log.Debug(string.Format("set {0} = {1}", ddlCtrl.ID, ow.GetPropertyValue(fieldName)));
                UIHelper.SetDDLValue(ddlCtrl, obj, fieldName);
            }
        }

        else if (ctrl is FCKeditor)
        {
            FCKeditor fckCtrl   = (FCKeditor)ctrl;
            string    fieldName = fckCtrl.ID.Replace("fck", "");
            if (HasProperty(ow, fieldName))
            {
                object value = ow.GetPropertyValue(fieldName);
                if (value != null)
                {
                    log.Debug(string.Format("set {0} = {1}", fckCtrl.ID, value.ToString()));
                    fckCtrl.Value = value.ToString();
                }
            }
        }
    }