Ejemplo n.º 1
0
    /// <summary>
    /// Saves the given form.
    /// </summary>
    /// <param name="form">Form to save</param>
    private static bool SaveForm(BasicForm form)
    {
        if (form.Visible)
        {
            return(form.SaveData(""));
        }

        return(true);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Saves the given DataRow data to the web part properties.
    /// </summary>
    /// <param name="basicForm">Form to save</param>
    private void SaveFormToWebPart(BasicForm basicForm)
    {
        if (basicForm.Visible && (webPartInstance != null))
        {
            // Keep the old ID to check the change of the ID
            string oldId = webPartInstance.ControlID.ToLowerInvariant();

            DataRow dr = basicForm.DataRow;
            foreach (DataColumn column in dr.Table.Columns)
            {
                var safeColumnName = column.ColumnName.ToLowerInvariant();

                webPartInstance.MacroTable[safeColumnName] = basicForm.MacroTable[safeColumnName];
                webPartInstance.SetValue(column.ColumnName, dr[column]);

                // If name changed, move the content
                if (safeColumnName == "webpartcontrolid")
                {
                    try
                    {
                        string newId = null;
                        if (!IsNewVariant)
                        {
                            newId = ValidationHelper.GetString(dr[column], "").ToLowerInvariant();
                        }

                        // Name changed
                        if ((!string.IsNullOrEmpty(newId)) && (newId != oldId))
                        {
                            if (!IsNewWebPart && !IsNewVariant)
                            {
                                WebPartIDChanged = true;
                            }
                            WebPartID = newId;

                            // Move the document content if present
                            ChangeEditableContentIDs(oldId, newId);

                            // Change the underlying zone names if layout web part
                            if ((wpi != null) && ((WebPartTypeEnum)wpi.WebPartType == WebPartTypeEnum.Layout))
                            {
                                ChangeLayoutZoneIDs(oldId, newId);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        EventLogProvider.LogException("Content", "CHANGEWEBPART", ex);
                    }
                }
            }

            SaveCategoryCollapsingState(basicForm);
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Initializes the form.
    /// </summary>
    /// <param name="form">Form</param>
    /// <param name="dr">Datarow with the data</param>
    /// <param name="fi">Form info</param>
    private void InitForm(BasicForm form, DataRow dr, FormInfo fi)
    {
        form.DataRow    = dr;
        form.MacroTable = widgetInstance != null ? widgetInstance.MacroTable : new Hashtable();

        form.SubmitButton.Visible = false;
        form.SiteName             = CMSContext.CurrentSiteName;
        form.FormInformation      = fi;
        form.ShowPrivateFields    = true;
        form.OnItemValidation    += formElem_OnItemValidation;
    }
Ejemplo n.º 4
0
        public override void InitToolBar()
        {
            this.gToolBar1.ClearButton();
            foreach (string s in listTool)
            {
                this.gToolBar1.AddButton(s);
            }
            this.gToolBar1.ButtonClick = new Controls.GToolBar.GToolBar.FunButtonClick(name =>
            {
                switch (name)
                {
                case "新增":
                    this.New();
                    break;

                case "保存":
                    this.Save();
                    break;

                case "增行":
                    AddRow();
                    break;

                case "删行":
                    DeleteRow();
                    break;

                case "打印":
                    PrintSale(true);
                    break;

                case "预览":
                    PrintSale(false);
                    break;

                case "退出":
                    BasicForm f = this.ParentForm as BasicForm;
                    if (f != null)
                    {
                        this.Close();
                        f.DisplayOut((int)this.MenuId);
                    }
                    else
                    {
                        this.Close();
                    }
                    break;

                default:
                    break;
                }
            });
        }
    /// <summary>
    /// Initializes the form.
    /// </summary>
    /// <param name="form">Form</param>
    /// <param name="dr">Datarow with the data</param>
    /// <param name="fi">Form info</param>
    private void InitForm(BasicForm form, DataRow dr, FormInfo fi)
    {
        form.DataRow    = dr;
        form.MacroTable = (mWidgetInstance != null) ? mWidgetInstance.MacroTable : new Hashtable(StringComparer.InvariantCultureIgnoreCase);

        form.SubmitButton.Visible = false;
        form.SiteName             = SiteContext.CurrentSiteName;
        form.FormInformation      = fi;
        form.OnItemValidation    += formElem_OnItemValidation;
        form.Mode = IsNewWidget ? FormModeEnum.Insert : FormModeEnum.Update;

        form.ReloadData();
    }
Ejemplo n.º 6
0
        private void Exit()
        {
            BasicForm f = this.ParentForm as BasicForm;

            if (f != null)
            {
                this.Close();
                f.DisplayOut((int)this.MenuId);
            }
            else
            {
                this.Close();
            }
        }
Ejemplo n.º 7
0
    /// <summary>
    /// Loads basicform with filter controls.
    /// </summary>
    /// <param name="bf">BasicForm control</param>
    /// <param name="fi">Form definition</param>
    /// <param name="activityType">Activity type in case the rule type is activity</param>
    private void LoadForm(BasicForm bf, FormInfo fi, string activityType = null)
    {
        bf.FormInformation      = fi;
        bf.Data                 = RuleHelper.GetDataFromCondition(Rule, fi.GetDataRow().Table, ref activityType);
        bf.SubmitButton.Visible = false;
        bf.SiteName             = SiteContext.CurrentSiteName;

        if (Rule != null)
        {
            bf.Mode = FormModeEnum.Update;
        }

        bf.ReloadData();
    }
Ejemplo n.º 8
0
        private void InitToolBar()
        {
            this.gToolBar1.AddButton("新增");
            this.gToolBar1.AddButton("修改");
            this.gToolBar1.AddButton("删除");
            this.gToolBar1.AddButton("刷新");
            this.gToolBar1.AddButton("-");
            this.gToolBar1.AddButton("过滤");
            this.gToolBar1.AddButton("|");
            this.gToolBar1.AddButton("退出");
            this.gToolBar1.ButtonClick = new Controls.GToolBar.GToolBar.FunButtonClick(name =>
            {
                switch (name)
                {
                case "新增":
                    AddNew();
                    break;

                case "修改":
                    Modify();
                    break;

                case "刷新":
                    RefreshData();
                    break;

                case "删除":
                    this.Delete();
                    break;

                case "过滤":
                    Filter();
                    break;

                case "退出":
                    BasicForm f = this.ParentForm as BasicForm;
                    if (f != null)
                    {
                        this.Close();
                        f.DisplayOut((int)this.MenuId);
                    }
                    else
                    {
                        this.Close();
                    }
                    break;
                }
            });
        }
Ejemplo n.º 9
0
    /// <summary>
    /// Loads basicform with filter controls.
    /// </summary>
    /// <param name="bf">BasicForm control</param>
    /// <param name="fi">Form definition</param>
    /// <param name="activityType">Activity type in case the rule type is activity</param>
    private void LoadForm(BasicForm bf, FormInfo fi, string activityType)
    {
        bf.FormInformation        = fi;
        bf.Data                   = RuleHelper.GetDataFromCondition((RuleInfo)rule, fi.GetDataRow().Table, ref activityType);
        bf.SubmitButton.Visible   = false;
        bf.SiteName               = CMSContext.CurrentSiteName;
        bf.FieldLabelCellCssClass = "RuleSettingsLabel";
        bf.FieldLabelCssClass     = null;

        if (rule != null)
        {
            bf.Mode = FormModeEnum.Update;
        }

        bf.ReloadData();
    }
Ejemplo n.º 10
0
 private void tools_Btn_MouseClick(object sender, MouseEventArgs e)
 {
     if (ToolsMouseClick != null)
     {
         ToolsMouseClick(sender, e);
     }
     else
     {
         BasicForm bf = new BasicForm();
         bf.BackgroundImage = this.BackgroundImage;
         bf.Text            = "设置";
         bf.Size            = new Size(600, 400);
         bf.Show();
         //Process.Start("http://www.seezt.com");
     }
 }
Ejemplo n.º 11
0
        public virtual void ToolButtonClick(string name)
        {
            switch (name)
            {
            case "导出":
                Export();
                break;

            case "打印":
                Print();
                break;

            case "过滤":
                Filter();
                break;

            case "新增":
                AddNew();
                break;

            case "修改":
                Modify();
                break;

            case "刷新":
                RefreshData();
                break;

            case "删除":
                this.Delete();
                break;

            case "退出":
                BasicForm f = this.ParentForm as BasicForm;
                if (f != null)
                {
                    this.Close();
                    f.DisplayOut((int)this.MenuId);
                }
                else
                {
                    this.Close();
                }
                break;
            }
        }
Ejemplo n.º 12
0
 private void find_Btn_MouseClick(object sender, MouseEventArgs e)
 {
     if (FindMouseClick != null)
     {
         FindMouseClick(sender, e);
     }
     else
     {
         BasicForm bf = new BasicForm();
         bf.BackgroundImage = this.BackgroundImage;
         bf.Text            = "查找好友";
         bf.AllowMove       = false;
         bf.AllowResize     = false;
         bf.Size            = new Size(400, 500);
         bf.Show();
         //Process.Start("http://www.seezt.com");
     }
 }
    /// <summary>
    /// Initializes the form.
    /// </summary>
    /// <param name="basicForm">Form</param>
    /// <param name="dr">Data row with the data</param>
    /// <param name="fi">Form info</param>
    private void InitForm(BasicForm basicForm, DataRow dr, FormInfo fi)
    {
        if (basicForm != null)
        {
            basicForm.DataRow = dr;

            basicForm.MacroTable = webPartInstance != null ? webPartInstance.MacroTable : new Hashtable(StringComparer.InvariantCultureIgnoreCase);

            basicForm.SubmitButton.Visible = false;
            basicForm.SiteName             = SiteContext.CurrentSiteName;
            basicForm.FormInformation      = fi.Clone();
            basicForm.OnItemValidation    += formElem_OnItemValidation;

            ApplySavedCategoryCollapsingState(basicForm);

            basicForm.ReloadData();
        }
    }
Ejemplo n.º 14
0
 private void message_Btn_MouseClick(object sender, MouseEventArgs e)
 {
     if (MessageMouseClick != null)
     {
         MessageMouseClick(sender, e);
     }
     else
     {
         BasicForm bf = new BasicForm();
         bf.BackgroundImage = this.BackgroundImage;
         bf.Text            = "消息管理器";
         bf.ShowIcon        = false;
         bf.AllowMove       = false;
         bf.Size            = new Size(500, 300);
         bf.Show();
         //Process.Start("http://www.seezt.com");
     }
 }
Ejemplo n.º 15
0
        private void InitializeActions()
        {
            var preview = new PreviewForm(Matrix is GuiPanel)
            {
                MdiParent = this
            };

            preview.Show();
            preview.Location = new Point(0, 0);

            var basic = new BasicForm {
                MdiParent = this
            };

            basic.Show();
            basic.Location = new Point(preview.Right, 0);

            actionsToolStripMenuItem.Visible = true;
        }
Ejemplo n.º 16
0
        private void InitToolBar()
        {
            this.gToolBar1.AddButton("保存");
            this.gToolBar1.AddButton("退出");
            this.gToolBar1.ButtonClick = new Controls.GToolBar.GToolBar.FunButtonClick(name =>
            {
                switch (name)
                {
                case "保存":
                    this.Save();
                    break;

                case "退出":
                    BasicForm f = this.ParentForm as BasicForm;
                    this.Close();
                    break;

                default:
                    break;
                }
            });
        }
Ejemplo n.º 17
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (picture.IsDisposed)
     {
         picture = new BasicForm();
         picture.parent_window = this;
         picture.Visible       = false;
     }
     picture.Left = this.Left + this.Size.Width;
     picture.Top  = this.Top;
     ;
     if (picture.Visible == false)
     {
         picture.Visible = true;
         set_hide_picture();
     }
     else
     {
         picture.Visible = false;
         set_show_picture();
     }
 }
Ejemplo n.º 18
0
    /// <summary>
    /// Initializes the form.
    /// </summary>
    /// <param name="basicForm">Form</param>
    /// <param name="dr">Data row with the data</param>
    /// <param name="fi">Form info</param>
    private void InitForm(BasicForm basicForm, DataRow dr, FormInfo fi)
    {
        if (basicForm != null)
        {
            basicForm.DataRow = dr;
            if (webPartInstance != null)
            {
                basicForm.MacroTable = webPartInstance.MacroTable;
            }
            else
            {
                basicForm.MacroTable = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            }

            if (!RequestHelper.IsPostBack() && (webPartInstance != null))
            {
                fi = new FormInfo(fi.GetXmlDefinition());

                // Load the collapsed/un-collapsed state of categories
                var categories = fi.GetCategoryNames();
                foreach (string category in categories)
                {
                    FormCategoryInfo fci = fi.GetFormCategory(category);
                    if (ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.Collapsible, basicForm.ContextResolver), false) && ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, basicForm.ContextResolver), false) && ValidationHelper.GetBoolean(webPartInstance.GetValue("cat_open_" + category), false))
                    {
                        fci.SetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, "false");
                    }
                }
            }

            basicForm.SubmitButton.Visible = false;
            basicForm.SiteName             = SiteContext.CurrentSiteName;
            basicForm.FormInformation      = fi;
            basicForm.ShowPrivateFields    = true;
            basicForm.OnItemValidation    += formElem_OnItemValidation;
            basicForm.ReloadData();
        }
    }
Ejemplo n.º 19
0
    /// <summary>
    /// Initializes the form.
    /// </summary>
    /// <param name="form">Form</param>
    /// <param name="dr">Data row with the data</param>
    /// <param name="fi">Form info</param>
    private void InitForm(BasicForm form, DataRow dr, FormInfo fi)
    {
        if (form != null)
        {
            form.DataRow = dr;
            if (webPartInstance != null)
            {
                form.MacroTable = webPartInstance.MacroTable;
            }
            else
            {
                form.MacroTable = new Hashtable();
            }

            if (!RequestHelper.IsPostBack() && (webPartInstance != null))
            {
                fi = new FormInfo(fi.GetXmlDefinition());

                // Load the collapsed/un-collapsed state of categories
                var categories = fi.GetCategoryNames();
                foreach (string category in categories)
                {
                    FormCategoryInfo fci = fi.GetFormCategory(category);
                    if (fci.CategoryCollapsible && fci.CategoryCollapsedByDefault && ValidationHelper.GetBoolean(webPartInstance.GetValue("cat_open_" + category), false))
                    {
                        fci.CategoryCollapsedByDefault = false;
                    }
                }
            }

            form.SubmitButton.Visible = false;
            form.SiteName             = CMSContext.CurrentSiteName;
            form.FormInformation      = fi;
            form.ShowPrivateFields    = true;
            form.OnItemValidation    += formElem_OnItemValidation;
            form.ReloadData();
        }
    }
Ejemplo n.º 20
0
        public async void CheckOut(Cart cart, BasicForm sender)
        {
            BookstoreService bookstoreService = new BookstoreService();
            Cart             updatedCart      = await bookstoreService.CheckOut(Global.Cart, User.Token);

            if (updatedCart == null)
            {
                Global.MainForm.ShowUnauthorizedErrorMessage();
                Global.CanCheckOut = false;
                return;
            }

            //assuming all items is available
            Global.CanCheckOut = true;
            foreach (CartItem item in updatedCart.CartItems)
            {
                if (!item.IsAvailable)
                {
                    //if one item is not available then can not check out (show message)
                    Global.CanCheckOut = false;
                }
            }
            ShowCheckOutForm();
        }
Ejemplo n.º 21
0
 public Detector()
 {
     InitializeComponent();
     picture = new BasicForm();
     picture.parent_window = this;
     picture.Visible       = false;
     dataGridView1.Rows.Add(23);
     for (int i = 0; i < 24; i++)
     {
         this.dataGridView1[0, i].Value = Convert.ToString(i + 1);
     }
     for (int i = 0; i < 24; i++)
     {
         this.dataGridView1[1, i].Value = "";
     }
     for (int i = 0; i < 24; i++)
     {
         this.dataGridView1[2, i].Value = "";
     }
     for (int i = 0; i < 24; i++)
     {
         this.dataGridView1[3, i].Value = "";
     }
     for (int i = 0; i < 24; i++)
     {
         this.dataGridView1[4, i].Value = "";
     }
     for (int i = 0; i < 24; i++)
     {
         this.dataGridView1[6, i].Value = "";
     }
     for (int i = 0; i < 24; i++)
     {
         this.dataGridView1.Rows[i].Cells[5].Value = "注射";
     }
 }
Ejemplo n.º 22
0
    /// <summary>
    /// Saves collapsed/un-collapsed states of the categories
    /// </summary>
    /// <param name="basicForm">Form</param>
    private void SaveCategoryState(BasicForm basicForm)
    {
        // Save the collapsed/un-collapsed state of categories
        FormInfo fi = GetWebPartFormInfo();

        var categories = fi.GetCategoryNames();

        foreach (string category in categories)
        {
            FormCategoryInfo fci = fi.GetFormCategory(category);
            if (ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.Collapsible, basicForm.ContextResolver), false) &&
                ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, basicForm.ContextResolver), false))
            {
                if (basicForm.IsCategoryCollapsed(category))
                {
                    webPartInstance.SetValue("cat_open_" + category, null);
                }
                else
                {
                    webPartInstance.SetValue("cat_open_" + category, true);
                }
            }
        }
    }
Ejemplo n.º 23
0
    /// <summary>
    /// Saves the given DataRow data to the web part properties.
    /// </summary>
    /// <param name="form">Form to save</param>
    /// <param name="pti">Page template instance</param>
    /// <param name="isLayoutWidget">Indicates whether the edited widget is a layout widget</param>
    private void SaveFormToWidget(BasicForm form, PageTemplateInstance pti, bool isLayoutWidget)
    {
        if (form.Visible && (mWidgetInstance != null))
        {
            // Keep the old ID to check the change of the ID
            string oldId = mWidgetInstance.ControlID.ToLowerCSafe();

            DataRow dr = form.DataRow;

            foreach (DataColumn column in dr.Table.Columns)
            {
                mWidgetInstance.MacroTable[column.ColumnName.ToLowerCSafe()] = form.MacroTable[column.ColumnName.ToLowerCSafe()];
                mWidgetInstance.SetValue(column.ColumnName, dr[column]);

                // If name changed, move the content
                // (This can happen when a user overrides the WidgetControlID property to be visible in the widget properties dialog)
                if (CMSString.Compare(column.ColumnName, "widgetcontrolid", true) == 0)
                {
                    try
                    {
                        string newId = ValidationHelper.GetString(dr[column], "").ToLowerCSafe();

                        // Name changed
                        if (!String.IsNullOrEmpty(newId) && (CMSString.Compare(newId, oldId, false) != 0))
                        {
                            WidgetIdChanged = true;
                            WidgetId        = newId;

                            // Move the document content if present
                            string currentContent = CurrentPageInfo.EditableWebParts[oldId];
                            if (currentContent != null)
                            {
                                TreeNode node = DocumentHelper.GetDocument(CurrentPageInfo.DocumentID, mTreeProvider);

                                // Move the content in the page info
                                CurrentPageInfo.EditableWebParts[oldId] = null;
                                CurrentPageInfo.EditableWebParts[newId] = currentContent;

                                // Update the document
                                node.SetValue("DocumentContent", CurrentPageInfo.GetContentXml());
                                DocumentHelper.UpdateDocument(node, mTreeProvider);
                            }

                            // Change the underlying zone names if layout widget
                            if (isLayoutWidget)
                            {
                                string prefix = oldId + "_";

                                foreach (WebPartZoneInstance zone in pti.WebPartZones)
                                {
                                    if (zone.ZoneID.StartsWithCSafe(prefix, true))
                                    {
                                        // Change the zone prefix to the new one
                                        zone.ZoneID = String.Format("{0}_{1}", newId, zone.ZoneID.Substring(prefix.Length));
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        EventLogProvider.LogException("Content", "CHANGEWIDGET", ex);
                    }
                }
            }
        }
    }
Ejemplo n.º 24
0
 public CartController(BasicForm _form)
 {
     form = _form;
 }
Ejemplo n.º 25
0
 private void BtnDirectory_Click(object sender, EventArgs e)
 {
     directory        = BasicForm.DirectoryUploadPrompt();
     TbDirectory.Text = directory;
 }
    /// <summary>
    /// Initializes the form.
    /// </summary>
    /// <param name="form">Form</param>
    /// <param name="dr">Data row with the data</param>
    /// <param name="fi">Form info</param>
    private void InitForm(BasicForm form, DataRow dr, FormInfo fi)
    {
        if (form != null)
        {
            form.DataRow = dr;
            if (webPartInstance != null)
            {
                form.MacroTable = webPartInstance.MacroTable;
            }
            else
            {
                form.MacroTable = new Hashtable();
            }

            if (!RequestHelper.IsPostBack() && (webPartInstance != null))
            {
                fi = new FormInfo(fi.GetXmlDefinition());

                // Load the collapsed/un-collapsed state of categories
                var categories = fi.GetCategoryNames();
                foreach (string category in categories)
                {
                    FormCategoryInfo fci = fi.GetFormCategory(category);
                    if (fci.CategoryCollapsible && fci.CategoryCollapsedByDefault && ValidationHelper.GetBoolean(webPartInstance.GetValue("cat_open_" + category), false))
                    {
                        fci.CategoryCollapsedByDefault = false;
                    }
                }
            }

            form.SubmitButton.Visible = false;
            form.SiteName = CMSContext.CurrentSiteName;
            form.FormInformation = fi;
            form.ShowPrivateFields = true;
            form.OnItemValidation += formElem_OnItemValidation;
            form.ReloadData();
        }
    }
Ejemplo n.º 27
0
    /// <summary>
    /// Saves the given DataRow data to the web part properties.
    /// </summary>
    /// <param name="form">Form to save</param>
    /// <param name="pti">Page template instance</param>
    private void SaveFormToWidget(BasicForm form, PageTemplateInstance pti)
    {
        if (form.Visible && (widgetInstance != null))
        {
            // Keep the old ID to check the change of the ID
            string oldId = widgetInstance.ControlID.ToLowerCSafe();

            DataRow dr = form.DataRow;

            // Load default values for new widget
            if (IsNewWidget)
            {
                form.FormInformation.LoadDefaultValues(dr, wi.WidgetDefaultValues);
            }

            foreach (DataColumn column in dr.Table.Columns)
            {
                widgetInstance.MacroTable[column.ColumnName.ToLowerCSafe()] = form.MacroTable[column.ColumnName.ToLowerCSafe()];
                widgetInstance.SetValue(column.ColumnName, dr[column]);

                // If name changed, move the content
                if (CMSString.Compare(column.ColumnName, "widgetcontrolid", true) == 0)
                {
                    try
                    {
                        string newId = ValidationHelper.GetString(dr[column], "").ToLowerCSafe();

                        // Name changed
                        if (!String.IsNullOrEmpty(newId) && (CMSString.Compare(newId, oldId, false) != 0))
                        {
                            mWidgetIdChanged = true;
                            WidgetId         = newId;

                            // Move the document content if present
                            string currentContent = pi.EditableWebParts[oldId];
                            if (currentContent != null)
                            {
                                TreeNode node = DocumentHelper.GetDocument(pi.DocumentID, tree);

                                // Move the content in the page info
                                pi.EditableWebParts[oldId] = null;
                                pi.EditableWebParts[newId] = currentContent;

                                // Update the document
                                node.SetValue("DocumentContent", pi.GetContentXml());
                                DocumentHelper.UpdateDocument(node, tree);
                            }

                            // Change the underlying zone names if layout web part
                            if ((wpi != null) && ((WebPartTypeEnum)wpi.WebPartType == WebPartTypeEnum.Layout))
                            {
                                string prefix = oldId + "_";

                                foreach (WebPartZoneInstance zone in pti.WebPartZones)
                                {
                                    if (zone.ZoneID.StartsWithCSafe(prefix, true))
                                    {
                                        // Change the zone prefix to the new one
                                        zone.ZoneID = String.Format("{0}_{1}", newId, zone.ZoneID.Substring(prefix.Length));
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        EventLogProvider ev = new EventLogProvider();
                        ev.LogEvent("Content", "CHANGEWIDGET", ex);
                    }
                }
            }
        }
    }
Ejemplo n.º 28
0
    /// <summary>
    /// Saves the given DataRow data to the web part properties.
    /// </summary>
    /// <param name="form">Form to save</param>
    private void SaveFormToWebPart(BasicForm form)
    {
        if (form.Visible && (webPartInstance != null))
        {
            // Keep the old ID to check the change of the ID
            string oldId = webPartInstance.ControlID.ToLowerCSafe();

            DataRow dr = form.DataRow;
            foreach (DataColumn column in dr.Table.Columns)
            {
                webPartInstance.MacroTable[column.ColumnName.ToLowerCSafe()] = form.MacroTable[column.ColumnName.ToLowerCSafe()];
                webPartInstance.SetValue(column.ColumnName, dr[column]);

                // If name changed, move the content
                if (column.ColumnName.ToLowerCSafe() == "webpartcontrolid")
                {
                    try
                    {
                        string newId = null;
                        if (!IsNewVariant)
                        {
                            newId = ValidationHelper.GetString(dr[column], "").ToLowerCSafe();
                        }

                        // Name changed
                        if ((!string.IsNullOrEmpty(newId)) && (newId != oldId))
                        {
                            if (!IsNewWebPart && !IsNewVariant)
                            {
                                mWebPartIdChanged = true;
                            }
                            WebpartId = newId;

                            // Move the document content if present
                            string currentContent = (string)(pi.EditableWebParts[oldId]);
                            if (currentContent != null)
                            {
                                TreeNode node = DocumentHelper.GetDocument(pi.DocumentID, tree);

                                // Move the content in the page info
                                pi.EditableWebParts[oldId] = null;
                                pi.EditableWebParts[newId] = currentContent;

                                // Update the document
                                node.SetValue("DocumentContent", pi.GetContentXml());
                                DocumentHelper.UpdateDocument(node, tree);
                            }

                            // Change the underlying zone names if layout web part
                            if ((wpi != null) && ((WebPartTypeEnum)wpi.WebPartType == WebPartTypeEnum.Layout))
                            {
                                string prefix = oldId + "_";

                                foreach (WebPartZoneInstance zone in pti.WebPartZones)
                                {
                                    if (zone.ZoneID.StartsWithCSafe(prefix, true))
                                    {
                                        // Change the zone prefix to the new one
                                        zone.ZoneID = newId + "_" + zone.ZoneID.Substring(prefix.Length);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        EventLogProvider ev = new EventLogProvider();
                        ev.LogEvent("Content", "CHANGEWEBPART", ex);
                    }
                }
            }

            // Save the collapsed/un-collapsed state of categories
            FormInfo fi = GetWebPartFormInfo();

            var categories = fi.GetCategoryNames();
            foreach (string category in categories)
            {
                FormCategoryInfo fci = fi.GetFormCategory(category);
                if (fci.CategoryCollapsible && fci.CategoryCollapsedByDefault)
                {
                    if (form.IsCategoryCollapsed(category))
                    {
                        webPartInstance.SetValue("cat_open_" + category, null);
                    }
                    else
                    {
                        webPartInstance.SetValue("cat_open_" + category, true);
                    }
                }
            }
        }
    }
    /// <summary>
    /// Saves the given DataRow data to the web part properties.
    /// </summary>
    /// <param name="form">Form to save</param>
    private void SaveFormToWebPart(BasicForm form)
    {
        if (form.Visible && (webPartInstance != null))
        {
            // Keep the old ID to check the change of the ID
            string oldId = webPartInstance.ControlID.ToLowerCSafe();

            DataRow dr = form.DataRow;
            foreach (DataColumn column in dr.Table.Columns)
            {
                webPartInstance.MacroTable[column.ColumnName.ToLowerCSafe()] = form.MacroTable[column.ColumnName.ToLowerCSafe()];
                webPartInstance.SetValue(column.ColumnName, dr[column]);

                // If name changed, move the content
                if (column.ColumnName.ToLowerCSafe() == "webpartcontrolid")
                {
                    try
                    {
                        string newId = null;
                        if (!IsNewVariant)
                        {
                            newId = ValidationHelper.GetString(dr[column], "").ToLowerCSafe();
                        }

                        // Name changed
                        if ((!string.IsNullOrEmpty(newId)) && (newId != oldId))
                        {
                            if (!IsNewWebPart && !IsNewVariant)
                            {
                                mWebPartIdChanged = true;
                            }
                            WebpartId = newId;

                            // Move the document content if present
                            string currentContent = (string)(pi.EditableWebParts[oldId]);
                            if (currentContent != null)
                            {
                                TreeNode node = DocumentHelper.GetDocument(pi.DocumentID, tree);

                                // Move the content in the page info
                                pi.EditableWebParts[oldId] = null;
                                pi.EditableWebParts[newId] = currentContent;

                                // Update the document
                                node.SetValue("DocumentContent", pi.GetContentXml());
                                DocumentHelper.UpdateDocument(node, tree);
                            }

                            // Change the underlying zone names if layout web part
                            if ((wpi != null) && ((WebPartTypeEnum)wpi.WebPartType == WebPartTypeEnum.Layout))
                            {
                                string prefix = oldId + "_";

                                foreach (WebPartZoneInstance zone in pti.WebPartZones)
                                {
                                    if (zone.ZoneID.StartsWithCSafe(prefix, true))
                                    {
                                        // Change the zone prefix to the new one
                                        zone.ZoneID = newId + "_" + zone.ZoneID.Substring(prefix.Length);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        EventLogProvider ev = new EventLogProvider();
                        ev.LogEvent("Content", "CHANGEWEBPART", ex);
                    }
                }
            }

            // Save the collapsed/un-collapsed state of categories
            FormInfo fi = GetWebPartFormInfo();

            var categories = fi.GetCategoryNames();
            foreach (string category in categories)
            {
                FormCategoryInfo fci = fi.GetFormCategory(category);
                if (fci.CategoryCollapsible && fci.CategoryCollapsedByDefault)
                {
                    if (form.IsCategoryCollapsed(category))
                    {
                        webPartInstance.SetValue("cat_open_" + category, null);
                    }
                    else
                    {
                        webPartInstance.SetValue("cat_open_" + category, true);
                    }
                }
            }
        }
    }
    /// <summary>
    /// Saves the given DataRow data to the web part properties.
    /// </summary>
    /// <param name="basicForm">Form to save</param>
    private void SaveFormToWebPart(BasicForm basicForm)
    {
        if (basicForm.Visible && (webPartInstance != null))
        {
            // Keep the old ID to check the change of the ID
            string oldId = webPartInstance.ControlID.ToLowerCSafe();

            DataRow dr = basicForm.DataRow;
            foreach (DataColumn column in dr.Table.Columns)
            {
                webPartInstance.MacroTable[column.ColumnName.ToLowerCSafe()] = basicForm.MacroTable[column.ColumnName.ToLowerCSafe()];
                webPartInstance.SetValue(column.ColumnName, dr[column]);

                // If name changed, move the content
                if (column.ColumnName.ToLowerCSafe() == "webpartcontrolid")
                {
                    try
                    {
                        string newId = null;
                        if (!IsNewVariant)
                        {
                            newId = ValidationHelper.GetString(dr[column], "").ToLowerCSafe();
                        }

                        // Name changed
                        if ((!string.IsNullOrEmpty(newId)) && (newId != oldId))
                        {
                            if (!IsNewWebPart && !IsNewVariant)
                            {
                                WebPartIDChanged = true;
                            }
                            WebPartID = newId;

                            // Move the document content if present
                            ChangeEditableContentIDs(oldId, newId);

                            // Change the underlying zone names if layout web part
                            if ((wpi != null) && ((WebPartTypeEnum)wpi.WebPartType == WebPartTypeEnum.Layout))
                            {
                                ChangeLayoutZoneIDs(oldId, newId);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        EventLogProvider.LogException("Content", "CHANGEWEBPART", ex);
                    }
                }
            }

            SaveCategoryState(basicForm);
        }
    }
    /// <summary>
    /// Initializes the form.
    /// </summary>
    /// <param name="basicForm">Form</param>
    /// <param name="dr">Data row with the data</param>
    /// <param name="fi">Form info</param>
    private void InitForm(BasicForm basicForm, DataRow dr, FormInfo fi)
    {
        if (basicForm != null)
        {
            basicForm.DataRow = dr;
            if (webPartInstance != null)
            {
                basicForm.MacroTable = webPartInstance.MacroTable;
            }
            else
            {
                basicForm.MacroTable = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            }

            if (!RequestHelper.IsPostBack() && (webPartInstance != null))
            {
                fi = new FormInfo(fi.GetXmlDefinition());

                // Load the collapsed/un-collapsed state of categories
                var categories = fi.GetCategoryNames();
                foreach (string category in categories)
                {
                    FormCategoryInfo fci = fi.GetFormCategory(category);
                    if (ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.Collapsible, basicForm.ContextResolver), false) && ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, basicForm.ContextResolver), false) && ValidationHelper.GetBoolean(webPartInstance.GetValue("cat_open_" + category), false))
                    {
                        fci.SetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, "false");
                    }
                }
            }

            basicForm.SubmitButton.Visible = false;
            basicForm.SiteName = SiteContext.CurrentSiteName;
            basicForm.FormInformation = fi;
            basicForm.ShowPrivateFields = true;
            basicForm.OnItemValidation += formElem_OnItemValidation;
            basicForm.ReloadData();
        }
    }
    /// <summary>
    /// Initializes the form.
    /// </summary>
    /// <param name="form">Form</param>
    /// <param name="dr">Datarow with the data</param>
    /// <param name="fi">Form info</param>
    private void InitForm(BasicForm form, DataRow dr, FormInfo fi)
    {
        form.DataRow = dr;
        form.MacroTable = widgetInstance != null ? widgetInstance.MacroTable : new Hashtable(StringComparer.InvariantCultureIgnoreCase);

        form.SubmitButton.Visible = false;
        form.SiteName = SiteContext.CurrentSiteName;
        form.FormInformation = fi;
        form.ShowPrivateFields = true;
        form.OnItemValidation += formElem_OnItemValidation;
        form.Mode = IsNewWidget ? FormModeEnum.Insert : FormModeEnum.Update;

        form.ReloadData();
    }
Ejemplo n.º 33
0
    /// <summary>
    /// Loads basicform with filter controls.
    /// </summary>
    /// <param name="bf">BasicForm control</param>
    /// <param name="fi">Form definition</param>
    /// <param name="activityType">Activity type in case the rule type is activity</param>
    private void LoadForm(BasicForm bf, FormInfo fi, string activityType)
    {
        bf.FormInformation = fi;
        bf.Data = RuleHelper.GetDataFromCondition((RuleInfo)rule, fi.GetDataRow().Table, ref activityType);
        bf.SubmitButton.Visible = false;
        bf.SiteName = CMSContext.CurrentSiteName;
        bf.FieldLabelCellCssClass = "ContactLabel";
        bf.FieldLabelCssClass = null;

        if (rule != null)
        {
            bf.Mode = FormModeEnum.Update;
        }

        bf.ReloadData();
    }
    /// <summary>
    /// Saves the given DataRow data to the web part properties.
    /// </summary>
    /// <param name="form">Form to save</param>
    /// <param name="pti">Page template instance</param>
    /// <param name="isLayoutWidget">Indicates whether the edited widget is a layout widget</param>
    private void SaveFormToWidget(BasicForm form, PageTemplateInstance pti, bool isLayoutWidget)
    {
        if (form.Visible && (widgetInstance != null))
        {
            // Keep the old ID to check the change of the ID
            string oldId = widgetInstance.ControlID.ToLowerCSafe();

            DataRow dr = form.DataRow;

            foreach (DataColumn column in dr.Table.Columns)
            {
                widgetInstance.MacroTable[column.ColumnName.ToLowerCSafe()] = form.MacroTable[column.ColumnName.ToLowerCSafe()];
                widgetInstance.SetValue(column.ColumnName, dr[column]);

                // If name changed, move the content
                // (This can happen when a user overrides the WidgetControlID property to be visible in the widget properties dialog)
                if (CMSString.Compare(column.ColumnName, "widgetcontrolid", true) == 0)
                {
                    try
                    {
                        string newId = ValidationHelper.GetString(dr[column], "").ToLowerCSafe();

                        // Name changed
                        if (!String.IsNullOrEmpty(newId) && (CMSString.Compare(newId, oldId, false) != 0))
                        {
                            WidgetIdChanged = true;
                            WidgetId = newId;

                            // Move the document content if present
                            string currentContent = CurrentPageInfo.EditableWebParts[oldId];
                            if (currentContent != null)
                            {
                                TreeNode node = DocumentHelper.GetDocument(CurrentPageInfo.DocumentID, tree);

                                // Move the content in the page info
                                CurrentPageInfo.EditableWebParts[oldId] = null;
                                CurrentPageInfo.EditableWebParts[newId] = currentContent;

                                // Update the document
                                node.SetValue("DocumentContent", CurrentPageInfo.GetContentXml());
                                DocumentHelper.UpdateDocument(node, tree);
                            }

                            // Change the underlying zone names if layout widget
                            if (isLayoutWidget)
                            {
                                string prefix = oldId + "_";

                                foreach (WebPartZoneInstance zone in pti.WebPartZones)
                                {
                                    if (zone.ZoneID.StartsWithCSafe(prefix, true))
                                    {
                                        // Change the zone prefix to the new one
                                        zone.ZoneID = String.Format("{0}_{1}", newId, zone.ZoneID.Substring(prefix.Length));
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        EventLogProvider.LogException("Content", "CHANGEWIDGET", ex);
                    }
                }
            }
        }
    }
Ejemplo n.º 35
0
        private void button1_Click(object sender, EventArgs e)
        {
            BasicForm basic = new BasicForm();

            basic.ShowDialog();
        }
    /// <summary>
    /// Saves the given form.
    /// </summary>
    /// <param name="form">Form to save</param>
    private static bool SaveForm(BasicForm form)
    {
        if ((form != null) && form.Visible)
        {
            return form.SaveData("");
        }

        return true;
    }
 public CheckoutController(BasicForm _form)
 {
     form = _form;
 }
    /// <summary>
    /// Saves collapsed/un-collapsed states of the categories
    /// </summary>
    /// <param name="basicForm">Form</param>
    private void SaveCategoryState(BasicForm basicForm)
    {
        // Save the collapsed/un-collapsed state of categories
        FormInfo fi = GetWebPartFormInfo();

        var categories = fi.GetCategoryNames();
        foreach (string category in categories)
        {
            FormCategoryInfo fci = fi.GetFormCategory(category);
            if (ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.Collapsible, basicForm.ContextResolver), false) &&
                ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, basicForm.ContextResolver), false))
            {
                if (basicForm.IsCategoryCollapsed(category))
                {
                    webPartInstance.SetValue("cat_open_" + category, null);
                }
                else
                {
                    webPartInstance.SetValue("cat_open_" + category, true);
                }
            }
        }
    }
    /// <summary>
    /// Initializes the form.
    /// </summary>
    /// <param name="form">Form</param>
    /// <param name="dr">Datarow with the data</param>
    /// <param name="fi">Form info</param>
    private void InitForm(BasicForm form, DataRow dr, FormInfo fi)
    {
        form.DataRow = dr;
        form.MacroTable = widgetInstance != null ? widgetInstance.MacroTable : new Hashtable();

        form.SubmitButton.Visible = false;
        form.SiteName = CMSContext.CurrentSiteName;
        form.FormInformation = fi;
        form.ShowPrivateFields = true;
        form.OnItemValidation += formElem_OnItemValidation;
    }
    /// <summary>
    /// Saves the given DataRow data to the web part properties.
    /// </summary>
    /// <param name="form">Form to save</param>
    private void SaveFormToWidget(BasicForm form)
    {
        if (form.Visible && (widgetInstance != null))
        {
            // Keep the old ID to check the change of the ID
            string oldId = widgetInstance.ControlID.ToLower();

            DataRow dr = form.DataRow;

            // Load default values for new widget
            if (IsNewWidget)
            {
                form.FormInformation.LoadDefaultValues(dr, wi.WidgetDefaultValues);
            }

            foreach (DataColumn column in dr.Table.Columns)
            {
                widgetInstance.MacroTable[column.ColumnName.ToLower()] = form.MacroTable[column.ColumnName.ToLower()];
                widgetInstance.SetValue(column.ColumnName, dr[column]);

                // If name changed, move the content
                if (String.Compare(column.ColumnName, "widgetcontrolid", true) == 0)
                {
                    try
                    {
                        string newId = ValidationHelper.GetString(dr[column], "").ToLower();

                        // Name changed
                        if (!String.IsNullOrEmpty(newId) && (String.Compare(newId, oldId, false) != 0))
                        {
                            mWidgetIdChanged = true;
                            WidgetId = newId;

                            // Move the document content if present
                            string currentContent = (string)(pi.EditableWebParts[oldId]);
                            if (currentContent != null)
                            {
                                TreeNode node = DocumentHelper.GetDocument(pi.DocumentId, tree);

                                // Move the content in the page info
                                pi.EditableWebParts[oldId] = null;
                                pi.EditableWebParts[newId] = currentContent;

                                // Update the document
                                node.SetValue("DocumentContent", pi.GetContentXml());
                                DocumentHelper.UpdateDocument(node, tree);
                            }

                            // Change the underlying zone names if layout web part
                            if ((wpi != null) && ((WebPartTypeEnum)wpi.WebPartType == WebPartTypeEnum.Layout))
                            {
                                string prefix = oldId + "_";

                                foreach (WebPartZoneInstance zone in pti.WebPartZones)
                                {
                                    if (zone.ZoneID.StartsWith(prefix, StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        // Change the zone prefix to the new one
                                        zone.ZoneID = String.Format("{0}_{1}", newId, zone.ZoneID.Substring(prefix.Length));
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        EventLogProvider ev = new EventLogProvider();
                        ev.LogEvent("Content", "CHANGEWIDGET", ex);
                    }
                }
            }
        }
    }
    /// <summary>
    /// Loads basicform with filter controls.
    /// </summary>
    /// <param name="bf">BasicForm control</param>
    /// <param name="fi">Form definition</param>
    /// <param name="activityType">Activity type in case the rule type is activity</param>
    private void LoadForm(BasicForm bf, FormInfo fi, string activityType = null)
    {
        bf.FormInformation = fi;
        bf.Data = RuleHelper.GetDataFromCondition(Rule, fi.GetDataRow().Table, ref activityType);
        bf.SubmitButton.Visible = false;
        bf.SiteName = SiteContext.CurrentSiteName;

        if (Rule != null)
        {
            bf.Mode = FormModeEnum.Update;
        }

        bf.ReloadData();
    }