HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/TDijk1/erp-apps.eu/wwwroot/CMSWebParts/ERP/TestForm.ascx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMS.PortalControls;
using CMS.SettingsProvider;
using CMS.DataEngine;
using CMS.FormEngine;
using System.Data;
using CMS.GlobalHelper;

public partial class CMSWebParts_ERP_TestForm : CMSAbstractWebPart
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        SetupControl();
    }

    /// <summary>
    /// Content loaded event handler
    /// </summary>
    public override void OnContentLoaded()
    {
        base.OnContentLoaded();
        SetupControl();
    }


    /// <summary>
    /// Initializes the control properties
    /// </summary>
    protected void SetupControl()
    {
        if ( this.StopProcessing )
        {
            // Do not process
        }
        else
        {
                string className = "ERP.Application";

                DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(className);
                if ( dci != null )
                {
                    IDataClass formItem = DataClassFactory.NewDataClass(className);

                    string formLayout = dci.ClassFormLayout;
                    string formDefinition = dci.ClassFormDefinition;

                    this.form.Data = formItem;
                    this.form.FormInformation = new FormInfo(formDefinition);
                    this.form.FormLayout = formLayout;

                    //form.AlternativeFormFullName = className + ".TestAlternative";
                    //form.FormName = className + ".default";
                    //form.FormMode = FormModeEnum.Insert;
                    //form.ValidationErrorMessage = "This is error msg";
                    //form.Visible = true;

                    //lblInfo.Text = form.FormName + " @ " + form.AlternativeFormFullName;
                }
                else
                {
                    lblInfo.Text = "ClassName does not exist!";
                    this.form.StopProcessing = true;
                    this.form.Visible = false;
                }
            }
            
        lblPepa.Text = "ahoj" + (form.Visible ? "T" : "F");


        }

    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        lblPepa.Text += "zdar" + (form.Visible ? "T" : "F");

    }

    void form_OnAfterSave(object sender, EventArgs e)
    {
        this.lblInfo.Text = "DataRow was saved :)";
        //this.repClass.Visible = true;

        // Display DataRow
        //this.pnlDataRow.Visible = true;
        //this.repDataRow.DataSource = this.form.DataRow.Table;
        //this.repDataRow.DataSource = this.form.get
        //this.lblPepa.Text = ValidationHelper.GetString(this.form.Data["AppName"], "nee");
        //this.repDataRow.DataBind();
    }


    /// <summary>
    /// Reloads the control data
    /// </summary>
    public override void ReloadData()
    {
        base.ReloadData();
        SetupControl();
    }

    /// <summary>
    /// Save button click event handler.
    /// </summary>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        lblInfo.Text = "Save click";
        SetupControl();
    }
}