미소장 화면이 폼에 직접 연결되지 않도록 수정 중
This commit is contained in:
@@ -1569,7 +1569,7 @@ namespace ExcelTest
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UniMarc.Marc_FillBlank fb = new UniMarc.Marc_FillBlank(this);
|
UniMarc.Marc_FillBlank fb = new UniMarc.Marc_FillBlank();
|
||||||
for (int a = 0; a < List_Book.Rows.Count; a++)
|
for (int a = 0; a < List_Book.Rows.Count; a++)
|
||||||
{
|
{
|
||||||
if (List_Book.Rows[a].DefaultCellStyle.ForeColor == Color.Red)
|
if (List_Book.Rows[a].DefaultCellStyle.ForeColor == Color.Red)
|
||||||
@@ -1588,7 +1588,40 @@ namespace ExcelTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fb.ISBN = ISBN;
|
fb.ISBN = ISBN;
|
||||||
fb.Show();
|
if (fb.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
String_Text st = new String_Text();
|
||||||
|
if (fb.BulkMarcResults.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var kvp in fb.BulkMarcResults)
|
||||||
|
{
|
||||||
|
int targetListIdx = kvp.Key;
|
||||||
|
foreach (DataGridViewRow r in List_Book.Rows)
|
||||||
|
{
|
||||||
|
// In legacy Marc.cs, finding row by index logic might be similar?
|
||||||
|
// Marc_FillBlank used 'idx' from 'List_idx' column in legacy logic too?
|
||||||
|
// Legacy code: int idx = Convert.ToInt32(dataGridView1.Rows[a].Cells["List_idx"].Value.ToString());
|
||||||
|
// And then: this.marc.List_Book.Rows[idx].Cells["db_marc"].Value = ...
|
||||||
|
// Wait, legacy used `Rows[idx]`. This implies `idx` IS the row index in List_Book?
|
||||||
|
// Let's assume it matches if we use the same index logic.
|
||||||
|
// In my refactor, I passed 'a' as first element of GridData if 'List_idx' col missing?
|
||||||
|
// In Marc.cs line 1579: `a.ToString()` is passed as first element.
|
||||||
|
// So `idx` in `BulkMarcResults` IS `a` (the row index).
|
||||||
|
// So we can directly access `List_Book.Rows[targetListIdx]`.
|
||||||
|
|
||||||
|
if (targetListIdx >= 0 && targetListIdx < List_Book.Rows.Count)
|
||||||
|
{
|
||||||
|
List_Book.Rows[targetListIdx].Cells["db_marc"].Value = kvp.Value;
|
||||||
|
List_Book.Rows[targetListIdx].DefaultCellStyle.ForeColor = Color.Blue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrEmpty(fb.SingleMarcResult))
|
||||||
|
{
|
||||||
|
richTextBox1.Text = fb.SingleMarcResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
|
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ namespace ExcelTest
|
|||||||
if (row_idx == -1 || col_idx == -1) { return; }
|
if (row_idx == -1 || col_idx == -1) { return; }
|
||||||
SaveRowIdx = row_idx;
|
SaveRowIdx = row_idx;
|
||||||
|
|
||||||
mOldMarc = List_Book.Rows[row_idx].Cells["db_marc"].Value.ToString();
|
mOldMarc = List_Book.Rows[row_idx].Cells["db_marc"].Value?.ToString() ?? string.Empty;
|
||||||
string isbn = List_Book.Rows[row_idx].Cells["ISBN13"].Value.ToString();
|
string isbn = List_Book.Rows[row_idx].Cells["ISBN13"].Value.ToString();
|
||||||
if (isbn != "")
|
if (isbn != "")
|
||||||
{
|
{
|
||||||
@@ -692,7 +692,7 @@ namespace ExcelTest
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var fb = new UniMarc.Marc_FillBlank(this);
|
var fb = new UniMarc.Marc_FillBlank();
|
||||||
for (int a = 0; a < List_Book.Rows.Count; a++)
|
for (int a = 0; a < List_Book.Rows.Count; a++)
|
||||||
{
|
{
|
||||||
if (List_Book.Rows[a].DefaultCellStyle.ForeColor == Color.Red)
|
if (List_Book.Rows[a].DefaultCellStyle.ForeColor == Color.Red)
|
||||||
@@ -711,7 +711,41 @@ namespace ExcelTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fb.ISBN = ISBN;
|
fb.ISBN = ISBN;
|
||||||
fb.Show();
|
if (fb.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
String_Text st = new String_Text();
|
||||||
|
if (fb.BulkMarcResults.Count > 0)
|
||||||
|
{
|
||||||
|
foreach(var kvp in fb.BulkMarcResults)
|
||||||
|
{
|
||||||
|
// Use list_idx to find row? Or assume key matches?
|
||||||
|
// Marc_FillBlank used 'idx' from 'List_idx' column.
|
||||||
|
// We need to iterate List_Book to find matching List_idx or if key is row index?
|
||||||
|
// In Marc_FillBlank, I stored 'idx' which was from 'List_idx'.
|
||||||
|
// Key = List_idx.
|
||||||
|
int targetListIdx = kvp.Key;
|
||||||
|
// Find row with this list_idx
|
||||||
|
foreach(DataGridViewRow r in List_Book.Rows)
|
||||||
|
{
|
||||||
|
if(r.Cells["List_idx"].Value != null && Convert.ToInt32(r.Cells["List_idx"].Value) == targetListIdx)
|
||||||
|
{
|
||||||
|
r.Cells["db_marc"].Value = kvp.Value;
|
||||||
|
// Update color etc?
|
||||||
|
r.DefaultCellStyle.ForeColor = Color.Blue;
|
||||||
|
// Need to update 'item' too if bound
|
||||||
|
var item = r.DataBoundItem as MarcBookItem;
|
||||||
|
if(item != null) item.ForeColor = Color.Blue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrEmpty(fb.SingleMarcResult))
|
||||||
|
{
|
||||||
|
// Update current Editor
|
||||||
|
marcEditorControl1.SetMarcString(fb.SingleMarcResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,20 +16,14 @@ namespace UniMarc
|
|||||||
public partial class Marc_FillBlank : Form
|
public partial class Marc_FillBlank : Form
|
||||||
{
|
{
|
||||||
public string ISBN;
|
public string ISBN;
|
||||||
|
public string SingleMarcResult { get; private set; }
|
||||||
|
public Dictionary<int, string> BulkMarcResults { get; private set; } = new Dictionary<int, string>();
|
||||||
bool isAll;
|
bool isAll;
|
||||||
bool isBreak;
|
bool isBreak;
|
||||||
ExcelTest.Marc marc;
|
|
||||||
Marc2 mae;
|
|
||||||
public Marc_FillBlank(Marc2 _mae)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
mae = _mae;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Marc_FillBlank(ExcelTest.Marc _marc)
|
public Marc_FillBlank()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
marc = _marc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Marc_FillBlank_Load(object sender, EventArgs e)
|
private void Marc_FillBlank_Load(object sender, EventArgs e)
|
||||||
@@ -252,14 +246,10 @@ namespace UniMarc
|
|||||||
}
|
}
|
||||||
SearchResultMarc();
|
SearchResultMarc();
|
||||||
string Text = richTextBox1.Text;
|
string Text = richTextBox1.Text;
|
||||||
if (marc != null)
|
|
||||||
{
|
this.SingleMarcResult = MakeMarc(Text);
|
||||||
marc.richTextBox1.Text = MakeMarc(Text);
|
this.DialogResult = DialogResult.OK;
|
||||||
}
|
this.Close();
|
||||||
else if (mae != null)
|
|
||||||
{
|
|
||||||
mae.marcEditorControl1.SetMarcString(MakeMarc(Text));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btn_AllMove_Click(object sender, EventArgs e)
|
private void btn_AllMove_Click(object sender, EventArgs e)
|
||||||
@@ -268,6 +258,8 @@ namespace UniMarc
|
|||||||
|
|
||||||
progressBar1.Maximum = dataGridView1.Rows.Count;
|
progressBar1.Maximum = dataGridView1.Rows.Count;
|
||||||
isAll = true;
|
isAll = true;
|
||||||
|
BulkMarcResults.Clear();
|
||||||
|
|
||||||
for (int a = 0; a < dataGridView1.Rows.Count; a++)
|
for (int a = 0; a < dataGridView1.Rows.Count; a++)
|
||||||
{
|
{
|
||||||
for (int b = 0; b < dataGridView1.RowCount; b++)
|
for (int b = 0; b < dataGridView1.RowCount; b++)
|
||||||
@@ -276,7 +268,14 @@ namespace UniMarc
|
|||||||
}
|
}
|
||||||
isBreak = false;
|
isBreak = false;
|
||||||
dataGridView1.Rows[a].DefaultCellStyle.BackColor = Color.Yellow;
|
dataGridView1.Rows[a].DefaultCellStyle.BackColor = Color.Yellow;
|
||||||
int idx = Convert.ToInt32(dataGridView1.Rows[a].Cells["List_idx"].Value.ToString());
|
// Assuming List_idx is stored as a cell value? Or should we trust the 'a' index?
|
||||||
|
// The original code used "List_idx" cell.
|
||||||
|
int idx = -1;
|
||||||
|
if (dataGridView1.Rows[a].Cells["List_idx"].Value != null)
|
||||||
|
idx = Convert.ToInt32(dataGridView1.Rows[a].Cells["List_idx"].Value.ToString());
|
||||||
|
else
|
||||||
|
idx = Convert.ToInt32(dataGridView1.Rows[a].Cells[0].Value.ToString()); // Fallback to column 0 if List_idx not guaranteed
|
||||||
|
|
||||||
string isbn = dataGridView1.Rows[a].Cells["ISBN13"].Value.ToString();
|
string isbn = dataGridView1.Rows[a].Cells["ISBN13"].Value.ToString();
|
||||||
|
|
||||||
if (isbn == "")
|
if (isbn == "")
|
||||||
@@ -301,17 +300,17 @@ namespace UniMarc
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
dataGridView1.Rows[a].DefaultCellStyle.ForeColor = Color.Blue;
|
dataGridView1.Rows[a].DefaultCellStyle.ForeColor = Color.Blue;
|
||||||
|
string processedMarc = st.made_Ori_marc(MakeMarc(marc));
|
||||||
if (this.marc != null)
|
if (!BulkMarcResults.ContainsKey(idx))
|
||||||
this.marc.List_Book.Rows[idx].Cells["db_marc"].Value = st.made_Ori_marc(MakeMarc(marc));
|
BulkMarcResults.Add(idx, processedMarc);
|
||||||
else if (this.mae != null)
|
|
||||||
this.mae.List_Book.Rows[idx].Cells["db_marc"].Value = st.made_Ori_marc(MakeMarc(marc));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
progressBar1.Value += 1;
|
progressBar1.Value += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageBox.Show("완료되었습니다!");
|
MessageBox.Show("완료되었습니다!");
|
||||||
|
this.DialogResult = DialogResult.OK;
|
||||||
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
string MakeMarc(string text)
|
string MakeMarc(string text)
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ namespace WindowsFormsApp1.Mac
|
|||||||
|
|
||||||
if (dataGridView1.Rows[row].Cells[col].ReadOnly)
|
if (dataGridView1.Rows[row].Cells[col].ReadOnly)
|
||||||
{
|
{
|
||||||
if (chkEditorTest.Checked)
|
if (chkEditorTest.Checked == false)
|
||||||
{
|
{
|
||||||
string[] Marc = {
|
string[] Marc = {
|
||||||
dataGridView1.Rows[row].Cells["marc"].Value.ToString(),
|
dataGridView1.Rows[row].Cells["marc"].Value.ToString(),
|
||||||
@@ -365,6 +365,23 @@ namespace WindowsFormsApp1.Mac
|
|||||||
f.OpenFillBlank(dataList, currentIsbn);
|
f.OpenFillBlank(dataList, currentIsbn);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
f.BulkBooksUpdated += (s, args) =>
|
||||||
|
{
|
||||||
|
foreach (var kvp in args.Updates)
|
||||||
|
{
|
||||||
|
int rowIdx = kvp.Key;
|
||||||
|
string newMarc = kvp.Value;
|
||||||
|
|
||||||
|
// Ensure rowIdx is valid (it should be, as it came from 'a' loop index)
|
||||||
|
if (rowIdx >= 0 && rowIdx < dataGridView1.Rows.Count)
|
||||||
|
{
|
||||||
|
dataGridView1.Rows[rowIdx].Cells["marc"].Value = newMarc;
|
||||||
|
// Optional: Update color or status to indicate filled?
|
||||||
|
// Legacy code updated color. Marc_Plan might not enforce color rules yet, but setting value is key.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
f.Show();
|
f.Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,14 +60,35 @@ namespace UniMarc.마크
|
|||||||
|
|
||||||
public void OpenFillBlank(List<string[]> gridData, string currentIsbn)
|
public void OpenFillBlank(List<string[]> gridData, string currentIsbn)
|
||||||
{
|
{
|
||||||
var fb = new UniMarc.Marc_FillBlank(this);
|
var fb = new UniMarc.Marc_FillBlank();
|
||||||
foreach (var rowData in gridData)
|
foreach (var rowData in gridData)
|
||||||
{
|
{
|
||||||
fb.InitFillBlank(rowData);
|
fb.InitFillBlank(rowData);
|
||||||
}
|
}
|
||||||
fb.ISBN = currentIsbn;
|
fb.ISBN = currentIsbn;
|
||||||
fb.Show();
|
|
||||||
|
if (fb.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
// Handle results
|
||||||
|
// We don't have direct access to 'BulkMarcResults' here easily unless we iterate.
|
||||||
|
// But wait, BookUpdated event is for single update.
|
||||||
|
// Marc_Plan expects 'RequestFillBlankData' to handle the *opening*, but it doesn't handle the *return* logic for bulk updates within Marc_Plan.
|
||||||
|
// The current architecture: Marc_Plan_Sub_MarcEdit2 raises RequestFillBlankData -> Marc_Plan calls OpenFillBlank.
|
||||||
|
// So now OpenFillBlank is running. When it returns, we have data.
|
||||||
|
// We need to pass this data BACK to Marc_Plan.
|
||||||
|
// I will add a 'BulkBooksUpdated' event or reuse 'BookUpdated' (but BookUpdated is single).
|
||||||
|
// Let's create 'BulkBooksUpdated'.
|
||||||
|
|
||||||
|
BulkBooksUpdated?.Invoke(this, new BulkBookUpdatedEventArgs { Updates = fb.BulkMarcResults });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BulkBookUpdatedEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public Dictionary<int, string> Updates { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public event EventHandler<BulkBookUpdatedEventArgs> BulkBooksUpdated;
|
||||||
|
|
||||||
private void MarcEditorControl_FillBlankClicked(object sender, EventArgs e)
|
private void MarcEditorControl_FillBlankClicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user