Пример #1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (dataGridViewX1.SelectedRows.Count != 1)
            {
                return;
            }

            Item   it         = new Item(DataRowList[dataGridViewX1.SelectedRows[0].Index], filterOrganizers.Items);
            string log_before = "原 學年度:" + it._cir.SchoolYear + ",學期:" + it._cir.Semester + ",日期:" + it._cir.OccurDate + ",事由:" + it._cir.Reason + ",時數:" + it._cir.ExpectedHours + ",主辦單位:" + it._cir.Organizers + ",備註:" + it._cir.Remark;

            if (it.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                it._cir.Save();
                if (it._cir.SchoolYear != int.Parse(filterSchoolYear.Text) || it._cir.Semester != int.Parse(filterSemester.Text))
                {
                    dataGridViewX1.Rows.RemoveAt(dataGridViewX1.SelectedRows[0].Index);
                    DataRowList.Remove(it._cir);
                }
                ApplicationLog.Log("服務學習線上開設", "修改項目", "修改一筆\n" + log_before
                                   + "\n後 學年度:" + it._cir.SchoolYear + ",學期:" + it._cir.Semester + ",日期:" + it._cir.OccurDate + ",事由:" + it._cir.Reason + ",時數:" + it._cir.ExpectedHours + ",主辦單位:" + it._cir.Organizers + ",備註:" + it._cir.Remark);
                //RunSelect();
            }
        }
            /// <summary>
            /// Looks for and recursively adds ColumnProxy objects, based on detail
            /// grids from the supplied data row collection, to the
            /// supplied proxy collection.
            /// </summary>
            /// <remarks><para>
            /// This method is provided as an example, a starting point for you to modify
            /// to your specific needs.
            /// 
            /// As the name implies, the algorithm looks at data rows to find detail grids
            /// and their cplumns. It does not scan detail grid templates. There are, however, limitations
            /// to this algorithm, especially when GridControl.SynchronizeDetailGrids is false.
            /// Please look at the block comments in the code below for details.
            /// 
            /// The algorithm does not compute a 'fancy' column title for the detail grid
            /// columns, it uses the column object's title.
            /// 
            /// Understand that Xceed does not guarantee that detail columns will show up
            /// correctly in the "Column Settings" list of this Form nor will we provide
            /// support for the code in this particular method. It is provided
            /// as a sample, an example you can expand to suit to the complexity of your grids
            /// and to the desired visual presentation of the column titles.
            /// 
            /// </para></remarks>
            /// <param name="grid">Grid control on which we are operating</param>
            /// <param name="proxies">Collection to which the ColumnProxy objects will be added</param>
            /// <param name="dataRows">List of data rows that will be scanned for detail grids. Can be null</param>
            /// <param name="nestingLevel">Current number of recurse levels. Could be used to help build column titles</param>
            /// <returns>true is columns have been added by the method, false otherwise</returns>
            private static bool AddDetailGridColumnsFromDataRows(GridControl grid, ArrayList proxies, DataRowList dataRows, int nestingLevel)
            {
                bool columnsAdded;
                ReadOnlyDetailGridList detailGrids;
                ColumnProxy columnProxy;
                string title;

                // Assume no columns will be added
                columnsAdded = false;

                // If we have data rows
                if (dataRows != null && dataRows.Count > 0)
                {
                    /* If GridControl.SynchronizeDetailGrids is true, we can safely assume that
                     * all the detail grids in the supplied DataRows collection are the same so we only
                     * need to look at the first one.
                     *
                     * If GridControl.SynchronizeDetailGrids is false, the detail grids
                     * in the supplied collection can all be different. Reliably detecting
                     * the changes between different detail grids, in every situation, is a
                     * huge undertaking we can't support right now, so we'll stick with looking
                     * at the first data row in this case also. */

                    /*
                    // If we cannot assume that all detail grids in the supplied collection are the same
                    if( !grid.SynchronizeDetailGrids )
                    {
                      // TODO: If you really need to have better detail grid support when
                      // GridControl.SynchronizeDetailGrids is false you can implement that support
                      // here.
                    }
                    */

                    // Get the first data row's detail grid collection
                    detailGrids = dataRows[0].DetailGrids;

                    // Go through each detail grid in the current detail grid collection
                    foreach (DetailGrid detailGrid in detailGrids)
                    {
                        // Recurse into the current detail grid's data rows while keeping note
                        // if columns were added
                        columnsAdded = ColumnProxy.AddDetailGridColumnsFromDataRows(grid, proxies, detailGrid.DataRows, nestingLevel + 1) || columnsAdded;

                        // Go through each column in the current detail grid
                        foreach (Column column in detailGrid.Columns)
                        {
                            // If we should add the column to the proxy collection
                            if (ColumnProxy.ShouldAddColumnToProxy(column))
                            {
                                /* TODO: Compute a more fancy title. Perhaps using the current detail grid
                                 * title, the nesting level or some other information */

                                title = column.Title;

                                // Create a column proxy based on the current column
                                columnProxy = new ColumnProxy(column, title);

                                // Add the column to the supplied proxy collection
                                proxies.Add(columnProxy);

                                // Columns have beed added
                                columnsAdded = true;
                            }
                        }
                    }
                }

                return columnsAdded;
            }