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); + } + } } }