203 lines
		
	
	
		
			7.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			203 lines
		
	
	
		
			7.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.ComponentModel;
 | |
| using System.Data;
 | |
| using System.Drawing;
 | |
| using System.IO;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| using System.Threading.Tasks;
 | |
| using System.Windows.Forms;
 | |
| 
 | |
| namespace WindowsFormsApp1.Mac
 | |
| {
 | |
|     public partial class Mac_Output : Form
 | |
|     {
 | |
|         Helper_DB db = new Helper_DB();
 | |
|         Main main;
 | |
|         string compidx = string.Empty;
 | |
|         List<string> save_date = new List<string>();
 | |
|         public Mac_Output(Main _main)
 | |
|         {
 | |
|             InitializeComponent();
 | |
|             main = _main;
 | |
|             compidx = main.com_idx;
 | |
|         }
 | |
| 
 | |
|         private void Mac_Output_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             db.DBcon();
 | |
| 
 | |
|             string[] state = { "진행", "완료" };
 | |
|             cb_state.Items.AddRange(state);
 | |
|             cb_state.SelectedIndex = 0;
 | |
|         }
 | |
| 
 | |
|         private void cb_state_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             if (cb_state.SelectedIndex == 0)
 | |
|             {
 | |
|                 cb_years.Enabled = false;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 cb_years.Enabled = true;
 | |
| 
 | |
|                 int start_years = 2009;
 | |
|                 int now_years = Convert.ToInt32(DateTime.Now.ToString("yyyy"));
 | |
|                 int years_count = now_years - start_years;
 | |
|                 List<string> l_years = new List<string>();
 | |
|                 for (int a = 0; a <= years_count; a++)
 | |
|                 {
 | |
|                     l_years.Add(start_years.ToString());
 | |
|                     start_years += 1;
 | |
|                 }
 | |
|                 string[] years = l_years.ToArray();
 | |
|                 cb_years.Items.AddRange(years);
 | |
|                 cb_years.SelectedIndex = cb_years.Items.Count - 1;
 | |
|             }
 | |
|             Input_list_combo();
 | |
|         }
 | |
| 
 | |
|         #region cb_state 선택 시 Sub함수
 | |
|         private void Input_list_combo()
 | |
|         {
 | |
|             cb_list.Items.Clear();
 | |
|             string area = "`date`, `list_name`, `connect_data`";
 | |
|             string[] table = { "compidx", "state" };
 | |
|             string[] data = { compidx, cb_state.Text };
 | |
|             string cmd = db.More_DB_Search("Obj_List_Marc", table, data, area);
 | |
|             string db_res = db.DB_Send_CMD_Search(cmd);
 | |
|             string[] marc_list = db_res.Split('|');
 | |
| 
 | |
|             string[] tmp = { "", "", "" };
 | |
|             bool years = true;
 | |
| 
 | |
|             for(int a = 0; a < marc_list.Length - 1; a++)
 | |
|             {
 | |
|                 if (a % 3 == 0) { tmp[0] = marc_list[a];
 | |
|                     years = years_UpAndDown(tmp[0]);
 | |
|                     if (cb_state.SelectedIndex == 0) years = true;
 | |
|                 }
 | |
|                 if (a % 3 == 1) { tmp[1] = marc_list[a]; }
 | |
|                 if (a % 3 == 2) { tmp[2] = marc_list[a];
 | |
|                     if (years) {
 | |
|                         save_date.Add(tmp[0]);
 | |
|                         cb_list.Items.Add(tmp[1]);
 | |
|                         connect_list.Items.Add(tmp[2]);
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         private bool years_UpAndDown(string years)
 | |
|         {
 | |
|             if(cb_years.Text == "") { return false; }
 | |
|             int select = Convert.ToInt32(cb_years.Text);
 | |
|             int year = Convert.ToInt32(years.Substring(0, 4));
 | |
| 
 | |
|             if (select != year) 
 | |
|                 return false;
 | |
|             else 
 | |
|                 return true;
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         private void cb_list_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             dataGridView1.Rows.Clear();
 | |
|             connect_list.SelectedIndex = cb_list.SelectedIndex;
 | |
|             string area = "`isbn`, `book_name`, `author`, `book_comp`, `price`";
 | |
|             string[] col = { "compidx", "list_name", "date" };
 | |
|             string[] data = { compidx, connect_list.Text, save_date[cb_list.SelectedIndex] };
 | |
|             string cmd = db.More_DB_Search("Obj_List_Book", col, data, area);
 | |
|             string db_res = db.DB_Send_CMD_Search(cmd);
 | |
|             string[] tmp_ary = db_res.Split('|');
 | |
|             Input_Grid(tmp_ary);
 | |
|             Search_Marc();
 | |
|         }
 | |
| 
 | |
|         #region cb_list 선택 시 Sub함수
 | |
|         private void Input_Grid(string[] db_data)
 | |
|         {
 | |
|             string[] grid = { "", "", "", "", "", "", "" }; // isbn, 도서명, 총서명, 저자, 출판사, 정가, 마크
 | |
|             for (int a = 0; a < db_data.Length; a++)
 | |
|             {
 | |
|                 if (a % 5 == 0) { grid[0] = db_data[a]; }
 | |
|                 if (a % 5 == 1) { grid[1] = db_data[a]; }
 | |
|                 if (a % 5 == 2) { grid[3] = db_data[a]; }
 | |
|                 if (a % 5 == 3) { grid[4] = db_data[a]; }
 | |
|                 if (a % 5 == 4) { grid[5] = db_data[a];
 | |
|                     dataGridView1.Rows.Add(grid);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         private void Search_Marc()
 | |
|         {
 | |
|             string area = "`총서명`, `marc`, `marc_chk`, `marc1`, `marc_chk1`, `marc2`, `marc_chk2`";
 | |
|             string[] col = { "ISBN" };
 | |
|             for(int a = 0; a < dataGridView1.Rows.Count; a++)
 | |
|             {
 | |
|                 string[] data = { dataGridView1.Rows[a].Cells["isbn"].Value.ToString() };
 | |
| 
 | |
|                 string cmd = db.More_DB_Search("Marc", col, data, area);
 | |
|                 string db_res = db.DB_Send_CMD_Search(cmd);
 | |
|                 if (db_res.Length < 7) { continue; }
 | |
|                 string[] tmp_ary = db_res.Split('|');
 | |
|                 Add_Marc(tmp_ary, a);
 | |
|             }
 | |
|         }
 | |
|         private void Add_Marc(string[] db_data, int idx)
 | |
|         {
 | |
|             if (db_data[2] == "1") {
 | |
|                 dataGridView1.Rows[idx].Cells["series"].Value = db_data[0];
 | |
|                 dataGridView1.Rows[idx].Cells["Marc"].Value = db_data[1];
 | |
|             }
 | |
|             else if (db_data[4] == "1") {
 | |
|                 dataGridView1.Rows[idx].Cells["series"].Value = db_data[0];
 | |
|                 dataGridView1.Rows[idx].Cells["Marc"].Value = db_data[3];
 | |
|             }
 | |
|             else if (db_data[6] == "1") {
 | |
|                 dataGridView1.Rows[idx].Cells["series"].Value = db_data[0];
 | |
|                 dataGridView1.Rows[idx].Cells["Marc"].Value = db_data[5];
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
 | |
|         {
 | |
|             Skill_Grid sg = new Skill_Grid();
 | |
|             sg.Print_Grid_Num(sender, e);
 | |
|         }
 | |
| 
 | |
|         private void btn_file_save_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             string Marc_data = string.Empty;
 | |
|             for (int a = 0; a < dataGridView1.Rows.Count; a++)
 | |
|             {
 | |
|                 if (dataGridView1.Rows[a].Cells["Marc"].Value.ToString() == "" &&
 | |
|                     dataGridView1.Rows[a].Cells["Marc"].Value == null)
 | |
|                     continue;
 | |
| 
 | |
|                 Marc_data += dataGridView1.Rows[a].Cells["Marc"].Value.ToString();
 | |
|             }
 | |
| 
 | |
|             string FileName;
 | |
|             SaveFileDialog saveFileDialog = new SaveFileDialog();
 | |
|             saveFileDialog.Title = "저장 경로를 지정하세요.";
 | |
|             saveFileDialog.OverwritePrompt = true;
 | |
|             saveFileDialog.Filter = "마크 파일 (*.mrc)|*.mrc|모든 파일 (*.*)|*.*";
 | |
| 
 | |
|             if (saveFileDialog.ShowDialog() == DialogResult.OK)
 | |
|             {
 | |
|                 FileName = saveFileDialog.FileName;
 | |
|                 File.WriteAllText(FileName, Marc_data);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void btn_close_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             Close();
 | |
|         }
 | |
|     }
 | |
| }
 | 
