private void dataGridViewX1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.Button != MouseButtons.Left) { return; } if (e.ColumnIndex < 0) { return; } if (e.RowIndex < 0) { return; } DataGridViewCell cell = dataGridViewX1.Rows[e.RowIndex].Cells[e.ColumnIndex]; // 找到選取到的 梯次 _selectedBatch = _BatchList.Find(x => x.UID == "" + cell.OwningRow.Tag); // 修改模式 InsertUpdateMakeUpBatchForm iumbf = new InsertUpdateMakeUpBatchForm("修改", cboSchoolYear.Text, cbosemester.Text, _selectedBatch); if (iumbf.ShowDialog() == DialogResult.OK) { _selectedBatch = iumbf.GetCurrentBatch(); // 回寫畫面資料 foreach (DataGridViewRow drv in dataGridViewX1.Rows) { if (drv.IsNewRow) { continue; } string uid = drv.Tag.ToString(); if (uid == _selectedBatch.UID) { drv.Cells[colIsArchive.Index].Value = _selectedBatch.is_archive; drv.Cells[ColMakeUpBatch.Index].Value = _selectedBatch.MakeUp_Batch; drv.Cells[ColStartTime.Index].Value = _selectedBatch.Start_Time.ToString("yyyy/MM/dd HH:mm:ss"); drv.Cells[ColEndTime.Index].Value = _selectedBatch.End_Time.ToString("yyyy/MM/dd HH:mm:ss"); drv.Cells[ColIncludedClassID.Index].Value = _selectedBatch.totalclassName; drv.Cells[ColDescription.Index].Value = _selectedBatch.Description; break; } } } // RefreshListView(); //重整畫面 }
private void btnInsertBatch_Click(object sender, EventArgs e) { btnInsertBatch.Enabled = false; // 新增模式 InsertUpdateMakeUpBatchForm iumbf = new InsertUpdateMakeUpBatchForm("新增", cboSchoolYear.Text, cbosemester.Text, _BatchList); if (iumbf.ShowDialog() == DialogResult.Yes) { RefreshListView(); } btnInsertBatch.Enabled = true; }