private void dgv_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.Button == MouseButtons.Right) { if (e.RowIndex < Global.LessonPerMorning) { morning = true; night = false; section = e.RowIndex; } else if (e.RowIndex < Global.LessonPerDay + Global.LessonPerMorning) { morning = false; night = false; section = e.RowIndex - Global.LessonPerMorning; } else { night = true; holdMoring = false; section = e.RowIndex - Global.LessonPerDay - Global.LessonPerMorning; } if (operationState == OperationState.ExchangeMode) { if (hold) { //如果要交换的两节课为同一门课或者要交换的两节课一节是白天一节是晚自习,都返回失败 //if( (e.RowIndex == holdCellRowIndex && e.ColumnIndex == holdCellColumnIndex)|| (e.RowIndex -Global.LessonPerMorning == holdCellRowIndex && e.ColumnIndex == holdCellColumnIndex) || (e.RowIndex-Global.LessonPerDay-Global.LessonPerMorning == holdCellRowIndex && e.ColumnIndex == holdCellColumnIndex) ||(night!=holdNight)||(morning!=holdMoring)) if ((night != holdNight) || (morning != holdMoring) || (night && e.RowIndex - Global.LessonPerMorning - Global.LessonPerDay == holdCellRowIndex && e.ColumnIndex == holdCellColumnIndex) || (morning && e.RowIndex == holdCellRowIndex && e.ColumnIndex == holdCellColumnIndex) || (!morning && !night && e.RowIndex - Global.LessonPerMorning == holdCellRowIndex && e.ColumnIndex == holdCellColumnIndex) ) { setHoldState(false); tslExchange.Text = "不能更换"; } else { if (morning) { //交换缓存的课程表中的数据 morningSchedule[currentClassID].Exchange2Lesson(e.ColumnIndex, section, holdCellColumnIndex, holdCellRowIndex); //更新数据库中数据 StaticSQLiteHelper.Exchange2MorningLesson(currentClassID, e.ColumnIndex, section, holdCellColumnIndex, holdCellRowIndex); } if (night) { //交换缓存的课程表中的数据 nightSchedule[currentClassID].Exchange2Lesson(e.ColumnIndex, section, holdCellColumnIndex, holdCellRowIndex); //更新数据库中数据 StaticSQLiteHelper.Exchange2NightLesson(currentClassID, e.ColumnIndex, section, holdCellColumnIndex, holdCellRowIndex); } else { //交换缓存的课程表中的数据 schedule[currentClassID].Exchange2Lesson(e.ColumnIndex, section, holdCellColumnIndex, holdCellRowIndex); //更新数据库中数据 ///有问题..... StaticSQLiteHelper.Exchange2Lesson(currentClassID, e.ColumnIndex, section, holdCellColumnIndex, holdCellRowIndex); } //重新加载以刷新界面 loadClassSchedule(currentClassID); loadHistory(); setHoldState(false); TestConflict(); } } else { setHoldState(true); } } else if (operationState == OperationState.ReforceMode) { selectCell(e.RowIndex, e.ColumnIndex, true); cmsMenu.Show(dgv, e.X + dgv.CurrentCell.Size.Width * e.ColumnIndex + dgv.RowHeadersWidth, e.Y + dgv.CurrentCell.Size.Height * e.RowIndex + dgv.ColumnHeadersHeight); } } }