Пример #1
0
        public DataRow InsertSelected()
        {
            CurrentObjectDataView  codv = null;
            CurrentObjectTableView cotv = ControlList.schedule.Tables[_target_list] as CurrentObjectTableView;

            if (_target_list != null)
            {
                if (cotv == null)
                {
                    codv = DataSource as CurrentObjectDataView;
                    if (codv == null)
                    {
                        ListBox target_list = this.Parent.Controls[_target_list] as ListBox;
                        if (target_list != null)
                        {
                            cotv = target_list.DataSource as CurrentObjectTableView;
                            if (cotv == null)
                            {
                                codv = target_list.DataSource as CurrentObjectDataView;
                            }
                        }
                    }
                }
                if (cotv != null || codv != null)
                {
                    if (this.SelectedItem != null)
                    {
                        DataRowView drv = this.SelectedItem as DataRowView;
                        if (cotv != null)
                        {
                            return(cotv.InsertChildMember(drv.Row, cotv.Current));
                        }
                        else
                        {
                            return(codv.InsertChildMember(drv.Row, codv.Current));
                        }
                    }
                }
            }
            else if (AddCurrent != null)
            {
                if (this.SelectedItem != null)
                {
                    if (allow_edit)
                    {
                        DataRowView drv = this.SelectedItem as DataRowView;
                        if (cotv != null)
                        {
                            cotv.AddChildMember(drv.Row);
                        }
                        else
                        {
                            codv.AddChildMember(drv.Row);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Editing is not enabled.");
                    }
                }
            }
            return(null);
        }