예제 #1
0
        private void AttributeDataForm_Shown(object sender, EventArgs e)
        {
            try
            {
                this.Text           = m_Table.TableName;
                updateLabel.Visible = (m_Data != null);

                if (m_Data == null)
                {
                    IDataServer ds = EditingController.Current.DataServer;
                    if (ds == null)
                    {
                        throw new InvalidOperationException("No database available");
                    }

                    DataRow data = ds.CreateNewRow(m_Table.TableName);

                    // Initialize items so they match the values of the last row we processed (if any).
                    // Otherwise assign default values that are indicative of the data type.
                    if (s_LastTable != null && s_LastTable.Id == m_Table.Id)
                    {
                        Debug.Assert(s_LastItems != null);
                        Debug.Assert(s_LastItems.Length == data.Table.Columns.Count);
                        data.ItemArray = s_LastItems;
                    }
                    else
                    {
                        AssignDefaultValues(data);
                    }

                    SetGrid(data);
                }
                else
                {
                    SetGrid(m_Data);
                }

                grid.Focus();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace, ex.Message);
            }
        }