From bbc47c50db8f13c611576cedf7766df8abfe4778 Mon Sep 17 00:00:00 2001 From: LGram16 Date: Sat, 11 Oct 2025 00:40:55 +0900 Subject: [PATCH] =?UTF-8?q?Marc=5FPlan:=20=EB=B2=94=EC=9C=84=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=EB=B0=9B=EC=95=84=20=EC=97=AC=EB=9F=AC=20=ED=96=89=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - toolStripButton1_Click 메서드에 범위 삭제 기능 구현 - InputBox로 "1~100" 형식의 범위 입력 받음 - 입력 형식 검증 및 범위 유효성 확인 - 뒤에서부터 삭제하여 인덱스 오류 방지 - 디버그 모드에서만 toolStrip 표시하도록 설정 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- unimarc/unimarc/마크/Marc_Plan.cs | 79 +++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/unimarc/unimarc/마크/Marc_Plan.cs b/unimarc/unimarc/마크/Marc_Plan.cs index e65b88e..2870dc4 100644 --- a/unimarc/unimarc/마크/Marc_Plan.cs +++ b/unimarc/unimarc/마크/Marc_Plan.cs @@ -28,6 +28,7 @@ namespace WindowsFormsApp1.Mac { InitializeComponent(); main = _main; + this.toolStrip1.Visible = System.Diagnostics.Debugger.IsAttached; } private void Marc_Plan_Load(object sender, EventArgs e) @@ -538,6 +539,7 @@ namespace WindowsFormsApp1.Mac if (dataGridView1.Rows[a].Cells["colCheck"].Value.ToString() != "T") continue; + if (a==825) Console.WriteLine( "test" ); string marc = dataGridView1.Rows[a].Cells["Marc"].Value.ToString().Replace("₩", "\\"); marc = st.ConvertMarcType(marc); marc = st.made_Ori_marc(marc, FileEncodingType); @@ -1370,5 +1372,82 @@ namespace WindowsFormsApp1.Mac { mk_Grid(btn_Select_List.Text, this.date); } + + private void toolStripButton1_Click(object sender, EventArgs e) + { + // 범위 입력받기 + string input = Microsoft.VisualBasic.Interaction.InputBox( + "삭제할 행 범위를 입력하세요.\n예) 1~100 (1번부터 100번까지 삭제)", + "행 범위 삭제", + "", + -1, -1); + + // 취소 또는 빈 입력 + if (string.IsNullOrWhiteSpace(input)) + return; + + try + { + // "1~100" 형식 파싱 + string[] parts = input.Split('~', '-'); + if (parts.Length != 2) + { + MessageBox.Show("올바른 형식으로 입력해주세요.\n예) 1~100", "입력 오류", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + + int startRow = int.Parse(parts[0].Trim()); + int endRow = int.Parse(parts[1].Trim()); + + // 범위 검증 + if (startRow < 1 || endRow < 1) + { + MessageBox.Show("행 번호는 1 이상이어야 합니다.", "입력 오류", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + + if (startRow > endRow) + { + MessageBox.Show("시작 행 번호가 끝 행 번호보다 클 수 없습니다.", "입력 오류", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + + // 사용자 입력은 1부터 시작하지만, 인덱스는 0부터 시작하므로 -1 + int startIndex = startRow - 1; + int endIndex = endRow - 1; + + // 범위가 그리드 범위를 벗어나는지 확인 + if (endIndex >= dataGridView1.Rows.Count) + { + MessageBox.Show($"입력한 범위가 전체 행 수({dataGridView1.Rows.Count})를 초과합니다.", "입력 오류", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + + // 삭제 확인 + string confirmMsg = string.Format("{0}번부터 {1}번까지 총 {2}개의 행을 삭제하시겠습니까?", + startRow, endRow, endRow - startRow + 1); + if (MessageBox.Show(confirmMsg, "행 삭제 확인", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + return; + + // 뒤에서부터 삭제 (인덱스가 꼬이지 않도록) + for (int i = endIndex; i >= startIndex; i--) + { + if (i < dataGridView1.Rows.Count && !dataGridView1.Rows[i].IsNewRow) + { + dataGridView1.Rows.RemoveAt(i); + } + } + + MessageBox.Show("삭제가 완료되었습니다.", "완료", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (FormatException) + { + MessageBox.Show("숫자 형식으로 입력해주세요.\n예) 1~100", "입력 오류", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + catch (Exception ex) + { + MessageBox.Show($"삭제 중 오류가 발생했습니다.\n{ex.Message}", "오류", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } } }