173 lines
		
	
	
		
			7.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			173 lines
		
	
	
		
			7.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.ComponentModel;
 | |
| using System.Data;
 | |
| using System.Drawing;
 | |
| using System.Linq;
 | |
| using System.Net;
 | |
| using System.Text;
 | |
| using System.Threading;
 | |
| using System.Threading.Tasks;
 | |
| using System.Windows.Forms;
 | |
| using WindowsFormsApp1.Delivery;
 | |
| 
 | |
| namespace WindowsFormsApp1.Mac
 | |
| {
 | |
|     public partial class Check_ISBN : Form
 | |
|     {
 | |
|         /// <summary>
 | |
|         /// 전체 보류.
 | |
|         /// 납품측 ISBN조회부터 작성할것.
 | |
|         /// </summary>
 | |
| 
 | |
|         Main main;
 | |
|         List_aggregation list_agg;
 | |
|         Helper_DB db = new Helper_DB();
 | |
|         public string compidx;
 | |
|         public string list_name = string.Empty;
 | |
|         public Check_ISBN(Main _main)
 | |
|         {
 | |
|             InitializeComponent();
 | |
|             main = _main;
 | |
|             compidx = main.com_idx;
 | |
|         }
 | |
|         public Check_ISBN(List_aggregation _list_agg)
 | |
|         {
 | |
|             InitializeComponent();
 | |
|             list_agg = _list_agg;
 | |
|             compidx = list_agg.compidx;
 | |
|         }
 | |
| 
 | |
|         private void Check_ISBN_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             tb_list_name.Text = compidx + " " + list_name;
 | |
| 
 | |
|             string[] list_combo = { "도서명 + 저자", "도서명", "저자", "출판사" };
 | |
|             cb_filter.Items.AddRange(list_combo);
 | |
|             cb_filter.SelectedIndex = 0;
 | |
| 
 | |
|             db.DBcon();
 | |
|             string[] search_tbl = { "compidx", "list_name" };
 | |
|             string[] search_col = { compidx, list_name };
 | |
|             string search_data = "`header`, `num`, `isbn`, `book_name`, `author`, `book_comp`, " +
 | |
|                                  "`count`, `pay`, `total`, `import`, `price`, " +
 | |
|                                  "`etc`, `pubDate`, `persent`, `category`";
 | |
| 
 | |
|             string tmp_data = db.More_DB_Search("Obj_List_Book", search_tbl, search_col,search_data);
 | |
|             string[] data = tmp_data.Split('|');
 | |
|             made_Grid(data);
 | |
| 
 | |
|         }
 | |
|         private void btn_lookup_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             string temp = string.Empty;
 | |
|             string type = string.Empty;
 | |
|             string query = string.Empty;
 | |
|             // 도서명 / 저자 / 출판사 / isbn / 정가 / 발행일 / 도서분류
 | |
|             string[] param = { "title", "author", "publisher", "isbn13", "priceStandard", "pubDate", "categoryName" };
 | |
|             API_Aladdin api = new API_Aladdin();
 | |
|             for (int a = 0; a < dataGridView1.Rows.Count - 1; a++) 
 | |
|             {
 | |
|                 // int a = 1;
 | |
|                 query = dataGridView1.Rows[a].Cells["book_name"].Value.ToString();
 | |
|                 insert_API(api.Find(query, type, param), a);
 | |
|                 Thread.Sleep(300);
 | |
|             }
 | |
|         }
 | |
|         void insert_API(string data, int row)
 | |
|         {
 | |
|             if (row > 0) { dataGridView1.Rows[row - 1].Selected = false; }
 | |
|             dataGridView1.Rows[row].Selected = true;
 | |
| 
 | |
|             bool[] chk = { false, false, false };   // 도서명 저자 출판사 체크.
 | |
|             string book_name = dataGridView1.Rows[row].Cells["book_name"].Value.ToString();
 | |
|             string author = dataGridView1.Rows[row].Cells["author"].Value.ToString();
 | |
|             string book_comp = dataGridView1.Rows[row].Cells["book_comp"].Value.ToString();
 | |
|             string[] insert = data.Split('|');
 | |
| 
 | |
|             string newstring = string.Empty;
 | |
| 
 | |
|             if (data == "") { return; }
 | |
| 
 | |
|             // pubDate형 보기편하게 DateTime형으로 재정리
 | |
|             newstring = String.Format("{0:yyyy/MM/dd HH:mm}", 
 | |
|                 DateTime.Parse(insert[5].Remove(insert[5].IndexOf(" G"))));
 | |
| 
 | |
|             // 도서 분류 필요한 데이터로 재정리
 | |
|             int top = insert[6].IndexOf('>');
 | |
|             int mid = insert[6].IndexOf('>', top + 1);
 | |
|             int bot = insert[6].IndexOf('>', mid + 1);
 | |
|             if (bot < 0) { insert[6] = insert[6].Substring(top + 1); }
 | |
|             else { insert[6] = insert[6].Substring(top + 1, bot - top - 1); }
 | |
| 
 | |
|             if (insert.Length > 10) {
 | |
|                 // 값이 2개 이상일 경우 따로 저장할수 있는 폼이 구축되어야함.
 | |
|                 return;
 | |
|             }
 | |
|             if (insert[0] == book_name) { chk[0] = true; }
 | |
|             if (insert[1].Contains(author) == true) { chk[1] = true; }
 | |
|             if (insert[2] == book_comp) { chk[2] = true; }
 | |
| 
 | |
|             if (chk[0] == true && chk[1] == true && chk[2] == true) {
 | |
|                 dataGridView1.Rows[row].Cells["isbn"].Value = insert[3];
 | |
|                 dataGridView1.Rows[row].Cells["price"].Value = insert[4];
 | |
|                 dataGridView1.Rows[row].Cells["pubDate"].Value = newstring;
 | |
|                 dataGridView1.Rows[row].Cells["category"].Value = insert[6];
 | |
|             }
 | |
|         }
 | |
|         void made_Grid(string[] data)
 | |
|         {
 | |
|                           /* 번호 isbn 도서명 저자 출판사
 | |
|                            * 수량 단가 합계 상태 정가
 | |
|                            * 비고 발행일 % 도서분류 */
 | |
|             string[] grid = { "", "", "", "", "", 
 | |
|                               "", "", "", "", "", 
 | |
|                               "", "", "", "" };
 | |
| 
 | |
|             int sdc = 15; // search_data_count
 | |
|             for (int a = 0; a < data.Length; a++)
 | |
|             {
 | |
|                 if (a % sdc == 1) { grid[0] = data[a-1] + " " + data[a]; }  // 번호
 | |
|                 if (a % sdc == 2) { grid[1] = data[a]; }                    // isbn
 | |
|                 if (a % sdc == 3) { grid[2] = data[a]; }                    // 도서명
 | |
|                 if (a % sdc == 4) { grid[3] = data[a]; }                    // 저자
 | |
|                 if (a % sdc == 5) { grid[4] = data[a]; }                    // 출판사
 | |
|                 if (a % sdc == 6) { grid[5] = data[a]; }                    // 수량
 | |
|                 if (a % sdc == 7) { grid[6] = data[a]; }                    // 단가
 | |
|                 if (a % sdc == 8) { grid[7] = data[a]; }                    // 합계
 | |
|                 if (a % sdc == 9) { grid[8] = data[a]; }                    // 상태
 | |
|                 if (a % sdc == 10) { grid[9] = data[a]; }                   // 정가
 | |
|                 if (a % sdc == 11) { grid[10] = data[a]; }                  // 비고
 | |
|                 if (a % sdc == 12) { grid[11] = data[a]; }                  // 발행일
 | |
|                 if (a % sdc == 13) { grid[12] = data[a]; }                  // %
 | |
|                 if (a % sdc == 14) { grid[13] = data[a];                    // 도서분류
 | |
|                     dataGridView1.Rows.Add(grid); }
 | |
|             }
 | |
|         }
 | |
|         private void btn_Save_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             for (int a = 0; a < dataGridView1.Rows.Count; a++)
 | |
|             {
 | |
|                 if (dataGridView1.Rows[a].Cells["isbn"].Value.ToString() == "" ||
 | |
|                     dataGridView1.Rows[a].Cells["price"].Value.ToString() == "" ||
 | |
|                     dataGridView1.Rows[a].Cells["pubDate"].Value.ToString() == "" ||
 | |
|                     dataGridView1.Rows[a].Cells["category"].Value.ToString() == "") { continue; }
 | |
|                 string[] Edit_tbl = { "isbn", "price", "pubDate", "category" };
 | |
|                 string[] Edit_Col = { dataGridView1.Rows[a].Cells["isbn"].Value.ToString(),
 | |
|                                       dataGridView1.Rows[a].Cells["price"].Value.ToString(),
 | |
|                                       dataGridView1.Rows[a].Cells["pubDate"].Value.ToString(),
 | |
|                                       dataGridView1.Rows[a].Cells["category"].Value.ToString() };
 | |
|                 string[] Search_tbl = { "book_name", "author", "book_comp", "list_name" };
 | |
|                 string[] Search_col = {dataGridView1.Rows[a].Cells["book_name"].Value.ToString(),
 | |
|                                        dataGridView1.Rows[a].Cells["author"].Value.ToString(),
 | |
|                                        dataGridView1.Rows[a].Cells["book_comp"].Value.ToString(),
 | |
|                                        list_name };
 | |
|                 db.More_Update("Obj_List_Book", Edit_tbl, Edit_Col, Search_tbl, Search_col);
 | |
|             }
 | |
|         }
 | |
|         private void btn_Close_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             this.Close();
 | |
|         }
 | |
|     }
 | |
| } | 
