コード例 #1
0
ファイル: BasePage.cs プロジェクト: dolani/CodeTorch
        public void PopulateFormByDataRowView(Control container, List <Widget> controls, DataRowView data, bool RefreshControls)
        {
            foreach (Widget control in controls)
            {
                if (!String.IsNullOrEmpty(control.DataField))
                {
                    if (data.Row.Table.Columns.Contains(control.DataField))
                    {
                        if (!String.IsNullOrEmpty(control.Name))
                        {
                            CodeTorch.Web.FieldTemplates.BaseFieldTemplate c = this.FindFieldRecursive(container, control.Name);

                            if (c != null)
                            {
                                try
                                {
                                    if (RefreshControls)
                                    {
                                        c.Refresh();
                                    }
                                    c.ValueObject  = data[control.DataField];
                                    c.Value        = data[control.DataField].ToString();
                                    c.RecordObject = data.Row;
                                }
                                catch { }
                            }
                        }
                        else
                        {
                            throw new ApplicationException("Control is missing ControlName - " + control.DataField);
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: BasePage.cs プロジェクト: dolani/CodeTorch
        public void RefeshForm(Control container, List <Widget> controls)
        {
            foreach (Widget control in controls)
            {
                if (!String.IsNullOrEmpty(control.DataField))
                {
                    if (!String.IsNullOrEmpty(control.Name))
                    {
                        CodeTorch.Web.FieldTemplates.BaseFieldTemplate c = this.FindFieldRecursive(container, control.Name);

                        if (c != null)
                        {
                            try
                            {
                                c.Refresh();
                            }
                            catch { }
                        }
                    }
                    else
                    {
                        throw new ApplicationException("Control is missing ControlName - " + control.DataField);
                    }
                }
            }
        }
コード例 #3
0
ファイル: BasePage.cs プロジェクト: dolani/CodeTorch
        public void PopulateFormByDataTable(Control container, List <Widget> controls, DataTable data, bool RefreshControls)
        {
            if (data.Rows.Count >= 1)
            {
                DataRow row = data.Rows[0];

                foreach (Widget control in controls)
                {
                    string DataField = null;
                    //determine if we are in edit mode - check label ends with _ReadOnly_Label
                    DataField = control.DataField;


                    if (!String.IsNullOrEmpty(DataField))
                    {
                        if (data.Columns.Contains(DataField))
                        {
                            if (!String.IsNullOrEmpty(control.Name))
                            {
                                CodeTorch.Web.FieldTemplates.BaseFieldTemplate c = this.FindFieldRecursive(container, control.Name);

                                if (c != null)
                                {
                                    try
                                    {
                                        if (RefreshControls)
                                        {
                                            c.Refresh();
                                        }
                                        c.ValueObject  = row[control.DataField];
                                        c.Value        = row[control.DataField].ToString();
                                        c.RecordObject = row;
                                    }
                                    catch { }
                                }
                                else
                                {
                                    //likely a read only control - lets try seach again
                                    c = this.FindFieldRecursive(container, (control.Name + "_ReadOnly_Label"));

                                    if (c != null)
                                    {
                                        try
                                        {
                                            if (RefreshControls)
                                            {
                                                c.Refresh();
                                            }
                                            c.ValueObject  = row[control.ReadOnlyDataField];
                                            c.Value        = row[control.ReadOnlyDataField].ToString();
                                            c.RecordObject = row;
                                        }
                                        catch { }
                                    }
                                }
                            }
                            else
                            {
                                throw new ApplicationException("Control is missing ControlName - " + control.DataField);
                            }
                        }
                    }
                }
            }
        }