=====* UniMarc [0.0147] 버전 업데이트 내용 *=====
** ERP 작업 전면 중단 (마크우선) ** 1. ISBN 조회 ㄴ> Yes24방식 반출에서 Yes24 로그인하는 작업 추가 구현 완료
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,6 +1,4 @@
|
||||
## 파일무시
|
||||
Helper_DB.cs
|
||||
Skill.cs
|
||||
|
||||
## 다음과 같은 확장자는 전체 무시
|
||||
*.pub
|
||||
|
||||
76
ExcelTest/ExcelTest/Helper_DB.cs
Normal file
76
ExcelTest/ExcelTest/Helper_DB.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MySql.Data.MySqlClient;
|
||||
|
||||
namespace ServerText
|
||||
{
|
||||
/// <summary>
|
||||
/// DB접속을 도와주는 클래스
|
||||
/// </summary>
|
||||
class Helper_DB
|
||||
{
|
||||
// 접속
|
||||
MySqlConnection conn = new MySqlConnection();
|
||||
|
||||
// 쿼리
|
||||
MySqlCommand sqlcmd = new MySqlCommand();
|
||||
MySqlDataReader sd;
|
||||
|
||||
/// <summary>
|
||||
/// DB를 사용하고 싶을 때 미리 저장된 DB의 기본 접속정보를 이용하여 DB에 접근한다.
|
||||
/// </summary>
|
||||
public void DBcon() // DB접속 함수
|
||||
{
|
||||
try
|
||||
{
|
||||
// DB 접속 정보
|
||||
string connectionString = "Server = 192.168.123.191;"
|
||||
+ "database=unimarc;"
|
||||
+ "uid=root;"
|
||||
+ "pwd=Admin21234;";
|
||||
|
||||
// 접속정보 적용
|
||||
conn.ConnectionString = connectionString;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
sqlcmd.Connection.Close();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DBcon이 선진행되어야함.
|
||||
/// </summary>
|
||||
/// <param name="DB_Table_Name"></param>
|
||||
/// <returns>검색된 결과값이 반환됨.</returns>
|
||||
public string DB_Search(string DB_Table_Name) // DB
|
||||
{
|
||||
string cmd = "SELECT * FROM ";
|
||||
cmd += DB_Table_Name;
|
||||
string result = "";
|
||||
|
||||
// DB연결
|
||||
conn.Open();
|
||||
// 쿼리 맵핑
|
||||
sqlcmd.CommandText = cmd;
|
||||
// 쿼리 날릴 곳은 conn, 즉 아까 연결한 DB
|
||||
sqlcmd.Connection = conn;
|
||||
// 쿼리 날리기, sqlDataReader에 결과값 저장
|
||||
sd = sqlcmd.ExecuteReader();
|
||||
|
||||
// 한줄씩 불러오기
|
||||
while (sd.Read())
|
||||
{
|
||||
// user_id, user_pw 순의 컬럼이 있다고 가정
|
||||
// 첫 컬럼 sd[0]으로 불러오기
|
||||
result = sd[0].ToString();
|
||||
// 다음 컬럼은 컬럼명으로 불러오기
|
||||
result += "|" + sd["RATING"].ToString();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
576
ISBN_Check_test/Helper_DB.cs
Normal file
576
ISBN_Check_test/Helper_DB.cs
Normal file
@@ -0,0 +1,576 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using MySql.Data.MySqlClient;
|
||||
using Renci.SshNet;
|
||||
|
||||
namespace WindowsFormsApp1
|
||||
{
|
||||
/// <summary>
|
||||
/// DB접속을 도와주는 클래스
|
||||
/// </summary>
|
||||
class Helper_DB
|
||||
{
|
||||
// 접속
|
||||
MySqlConnection conn;
|
||||
|
||||
// 쿼리
|
||||
MySqlCommand sqlcmd = new MySqlCommand();
|
||||
MySqlDataReader sd;
|
||||
|
||||
public string comp_idx { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// DB를 사용하고 싶을 때 미리 저장된 DB의 기본 접속정보를 이용하여 DB에 접근한다.
|
||||
/// </summary>
|
||||
public void DBcon() // DB접속 함수
|
||||
{
|
||||
PasswordConnectionInfo connectionInfo = new PasswordConnectionInfo("1.215.250.130", 815, "gloriabook", "admin@!@#$");
|
||||
connectionInfo.Timeout = TimeSpan.FromSeconds(30);
|
||||
using (var client = new SshClient(connectionInfo))
|
||||
{
|
||||
client.Connect();
|
||||
if (client.IsConnected)
|
||||
{
|
||||
string strConnection = "Server=1.215.250.130;"
|
||||
+ "Port=3306;"
|
||||
+ "Database=unimarc;"
|
||||
+ "uid=root;"
|
||||
+ "pwd=Admin21234;";
|
||||
conn = new MySqlConnection(strConnection);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 국중DB를 사용하고 싶을 때 미리 저장된 DB의 기본 접속정보를 이용하여 DB에 접근한다.
|
||||
/// </summary>
|
||||
public void DBcon_cl() // DB접속 함수
|
||||
{
|
||||
PasswordConnectionInfo connectionInfo = new PasswordConnectionInfo("1.215.250.130", 815, "gloriabook", "admin@!@#$");
|
||||
connectionInfo.Timeout = TimeSpan.FromSeconds(30);
|
||||
using (var client = new SshClient(connectionInfo))
|
||||
{
|
||||
client.Connect();
|
||||
if (client.IsConnected)
|
||||
{
|
||||
string strConnection = "Server=1.215.250.130;"
|
||||
+ "Port=3306;"
|
||||
+ "Database=cl_marc;"
|
||||
+ "uid=root;"
|
||||
+ "pwd=Admin21234;";
|
||||
conn = new MySqlConnection(strConnection);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// DBcon이 선진행되어야함.
|
||||
/// SELECT * FROM [DB_Table_Name] WHERE [DB_Where_Table] LIKE \"%DB_Search_Data%\"
|
||||
/// <summary>
|
||||
/// <param name="compidx"/>이용자 회사의 idx번호 단.none일 경우 다른 DB를 가져옴</param>
|
||||
/// <param name="DB_Table_Name">테이블명</param>
|
||||
/// <param name="DB_Where_Table">검색할 테이블</param>
|
||||
/// <param name="DB_Search_Data">검색할 텍스트</param>
|
||||
/// <returns>검색된 결과값이 반환됨.</returns>
|
||||
public string DB_Contains(string DB_Table_Name, string compidx,
|
||||
string DB_Where_Table = "", string DB_Search_Data = "",
|
||||
string Search_col = "",
|
||||
string DB_Where_Table1 = "", string DB_Search_Data1 = "" )
|
||||
{
|
||||
string cmd = "SELECT ";
|
||||
if (Search_col == "") { cmd += "*"; }
|
||||
else { cmd += Search_col; }
|
||||
cmd += " FROM ";
|
||||
cmd += DB_Table_Name;
|
||||
if (DB_Table_Name == "Obj_List") { cmd += " WHERE `comp_num` = \"" + compidx + "\""; }
|
||||
else if (DB_Table_Name == "Client") { cmd += " WHERE `campanyidx` = \"" + compidx + "\""; }
|
||||
else if (DB_Table_Name == "Purchase") { cmd += " WHERE `comparyidx` = \"" + compidx + "\""; }
|
||||
else if(compidx == "none") { cmd += " WHERE `grade` = \"2\""; }
|
||||
else { cmd += " WHERE `compidx` = \"" + compidx + "\""; }
|
||||
|
||||
if(DB_Search_Data != "")
|
||||
{
|
||||
cmd += " AND "+ DB_Where_Table + " LIKE\"%" + DB_Search_Data + "%\"";
|
||||
}
|
||||
if(DB_Search_Data1 != "")
|
||||
{
|
||||
cmd += " AND "+ DB_Where_Table1 + " LIKE\"%" + DB_Search_Data1 + "%\"";
|
||||
}
|
||||
cmd += ";";
|
||||
string result = "";
|
||||
// DB연결
|
||||
conn.Open();
|
||||
// 쿼리 맵핑
|
||||
sqlcmd.CommandText = cmd;
|
||||
// 쿼리 날릴 곳은 conn, 즉 아까 연결한 DB
|
||||
sqlcmd.Connection = conn;
|
||||
// 쿼리 날리기, sqlDataReader에 결과값 저장
|
||||
sd = sqlcmd.ExecuteReader();
|
||||
string change = "";
|
||||
// 한줄씩 불러오기
|
||||
while (sd.Read())
|
||||
{
|
||||
for(int cout = 0;cout < sd.FieldCount; cout++)
|
||||
{
|
||||
change = sd[cout].ToString().Replace("|","");
|
||||
result += change + "|";
|
||||
}
|
||||
}
|
||||
conn.Close();
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// DBcon이 선진행되어야함. / SELECT * FROM DB_Table_Name WHERE DB_Where_Table = \"DB_Search_Data\";
|
||||
/// <summary>
|
||||
/// <param name="Search_Area">가져올 데이터의 위치</param>
|
||||
/// <param name="DB_Table_Name">테이블명</param>
|
||||
/// <param name="DB_Where_Table">검색할 테이블</param>
|
||||
/// <param name="DB_Search_Data">검색할 텍스트</param>
|
||||
/// <returns>검색된 결과값이 반환됨.</returns>
|
||||
public string DB_Select_Search(string Search_Area, string DB_Table_Name,
|
||||
string DB_Where_Table = "", string DB_Search_Data = "",
|
||||
string DB_Where_Table1 = "", string DB_Search_Data1 = "")
|
||||
{
|
||||
string cmd = "SELECT "+Search_Area+" FROM ";
|
||||
cmd += DB_Table_Name;
|
||||
if(DB_Where_Table != "" && DB_Search_Data != "")
|
||||
{
|
||||
cmd += " WHERE `" + DB_Where_Table + "` = \"" + DB_Search_Data + "\"";
|
||||
}
|
||||
if(DB_Where_Table1 != "" && DB_Search_Data1 != "")
|
||||
{
|
||||
cmd += " AND `" + DB_Where_Table1 + "` = \"" + DB_Search_Data1 + "\"";
|
||||
}
|
||||
cmd += ";";
|
||||
string result = "";
|
||||
|
||||
// DB연결
|
||||
conn.Open();
|
||||
// 쿼리 맵핑
|
||||
sqlcmd.CommandText = cmd;
|
||||
// 쿼리 날릴 곳은 conn, 즉 아까 연결한 DB
|
||||
sqlcmd.Connection = conn;
|
||||
// 쿼리 날리기, sqlDataReader에 결과값 저장
|
||||
sd = sqlcmd.ExecuteReader();
|
||||
// 한줄씩 불러오기
|
||||
while (sd.Read())
|
||||
{
|
||||
for(int cout = 0;cout< sd.FieldCount; cout++)
|
||||
{
|
||||
result += sd[cout].ToString() + "|";
|
||||
}
|
||||
}
|
||||
conn.Close();
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// DBcon이 선진행되어야함. / SELECT * FROM DB_Table_Name WHERE DB_Where_Table = \"DB_Search_Data\";
|
||||
/// <summary>
|
||||
/// <param name="DB_Table_Name">테이블명</param>
|
||||
/// <param name="DB_Where_Table">검색할 테이블</param>
|
||||
/// <param name="DB_Search_Data">검색할 텍스트</param>
|
||||
/// <returns>검색된 결과값이 반환됨.</returns>
|
||||
public string DB_Search(string DB_Table_Name,
|
||||
string DB_Where_Table = "", string DB_Search_Data = "",
|
||||
string DB_Where_Table1 = "", string DB_Search_Data1 = "")
|
||||
{
|
||||
string cmd = "SELECT * FROM ";
|
||||
cmd += DB_Table_Name;// + " where id=\"id\"";
|
||||
if(DB_Search_Data != "")
|
||||
{
|
||||
cmd += " WHERE "+ DB_Where_Table + "=\"" + DB_Search_Data +"\"";
|
||||
}
|
||||
if (DB_Where_Table1 != "" && DB_Search_Data1 != "")
|
||||
{
|
||||
cmd += " AND `" + DB_Where_Table1 + "` =\"" + DB_Search_Data1 + "\"";
|
||||
}
|
||||
cmd += ";";
|
||||
string result = "";
|
||||
|
||||
// DB연결
|
||||
conn.Open();
|
||||
// 쿼리 맵핑
|
||||
sqlcmd.CommandText = cmd;
|
||||
// 쿼리 날릴 곳은 conn, 즉 아까 연결한 DB
|
||||
sqlcmd.Connection = conn;
|
||||
// 쿼리 날리기, sqlDataReader에 결과값 저장
|
||||
sd = sqlcmd.ExecuteReader();
|
||||
// 한줄씩 불러오기
|
||||
while (sd.Read())
|
||||
{
|
||||
for(int cout = 0;cout< sd.FieldCount; cout++)
|
||||
{
|
||||
result += sd[cout].ToString() + "|";
|
||||
}
|
||||
}
|
||||
conn.Close();
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 여러 조건이 있을때 사용 (단, Where_Table과 Search_Date의 배열길이는 같아야함)
|
||||
/// </summary>
|
||||
/// <param name="DB_Table_Name"></param>
|
||||
/// <param name="DB_Where_Table"></param>
|
||||
/// <param name="DB_Search_Data"></param>
|
||||
/// <param name="Search_Table">추출할 열의 이름."`num1`, `num2`" 이런식으로</param>
|
||||
/// <returns></returns>
|
||||
public string More_DB_Search(String DB_Table_Name, String[] DB_Where_Table,
|
||||
String[] DB_Search_Data, String Search_Table = "")
|
||||
{
|
||||
if(DB_Where_Table.Length != DB_Search_Data.Length) { return "오류발생"; }
|
||||
string result = "";
|
||||
string cmd = "SELECT ";
|
||||
if(Search_Table == "") { cmd += "*"; }
|
||||
else { cmd += Search_Table; }
|
||||
cmd += " FROM " + DB_Table_Name + " WHERE ";
|
||||
for(int a = 0; a < DB_Where_Table.Length; a++)
|
||||
{
|
||||
cmd += "`" + DB_Where_Table[a] + "` = \"" + DB_Search_Data[a] + "\" ";
|
||||
if(a == DB_Where_Table.Length - 1) { cmd += " LIMIT 1000;"; }
|
||||
else { cmd += " AND "; }
|
||||
}
|
||||
|
||||
// DB연결
|
||||
conn.Open();
|
||||
// 쿼리 맵핑
|
||||
sqlcmd.CommandText = cmd;
|
||||
// 쿼리 날릴 곳은 conn, 즉 아까 연결한 DB
|
||||
sqlcmd.Connection = conn;
|
||||
// 쿼리 날리기, sqlDataReader에 결과값 저장
|
||||
sd = sqlcmd.ExecuteReader();
|
||||
// 한줄씩 불러오기
|
||||
while (sd.Read())
|
||||
{
|
||||
for(int cout = 0; cout < sd.FieldCount; cout++)
|
||||
{
|
||||
result += sd[cout].ToString() + "|";
|
||||
}
|
||||
}
|
||||
conn.Close();
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// DB상의 날짜의 사이값을 가져오기 위한 함수
|
||||
/// </summary>
|
||||
/// <param name="Table_name">가져올 테이블의 이름</param>
|
||||
/// <param name="Search_Table">프로그램상으로 가져올 DB데이터</param>
|
||||
/// <param name="Search_date">DB상의 날짜가 저장된 컬럼명</param>
|
||||
/// <param name="start_date">시작할 날짜 0000-00-00</param>
|
||||
/// <param name="end_date">끝낼 날짜 0000-00-00</param>
|
||||
/// <param name="compidx">회사 인덱스 main.com_idx</param>
|
||||
/// <returns></returns>
|
||||
public string Search_Date(string Table_name, string Search_Table, string Search_date,
|
||||
string start_date, string end_date, string compidx)
|
||||
{
|
||||
string result = "";
|
||||
if (Search_Table == "") { Search_Table = "*"; }
|
||||
// select * from `table_name` where `날짜 컬럼` between date('start_date') and date('end_date')+1;
|
||||
string cmd = "SELECT " + Search_Table + " FROM `" + Table_name + "` " +
|
||||
"WHERE `comp_num` = '" + compidx + "' AND `" +
|
||||
Search_date + "` >= '" + start_date + "'";
|
||||
if(Table_name != "Obj_List") { cmd = cmd.Replace("`comp_num`", "`compidx`"); }
|
||||
if (end_date != "") { cmd += " AND `" + Search_date + "` <= '" + end_date + "';"; }
|
||||
else { cmd += ";"; }
|
||||
conn.Open();
|
||||
sqlcmd.CommandText = cmd;
|
||||
sqlcmd.Connection = conn;
|
||||
sd = sqlcmd.ExecuteReader();
|
||||
while (sd.Read()){
|
||||
for(int cout = 0; cout < sd.FieldCount; cout++)
|
||||
{
|
||||
result += sd[cout].ToString() + "|";
|
||||
}
|
||||
}
|
||||
conn.Close();
|
||||
return result;
|
||||
}
|
||||
public void DB_INSERT(String DB_Table_name, String[] DB_col_name, String[] setData)
|
||||
{
|
||||
string cmd = "INSERT INTO " + DB_Table_name + "(";
|
||||
for(int a = 0; a < DB_col_name.Length; a++)
|
||||
{
|
||||
if (a == DB_col_name.Length - 1) { cmd += "`" + DB_col_name[a] + "`) "; }
|
||||
else { cmd += "`" + DB_col_name[a] + "`, "; }
|
||||
}
|
||||
cmd += "values(";
|
||||
for(int a = 0; a < setData.Length; a++)
|
||||
{
|
||||
if (a == setData.Length - 1) { cmd += "\"" + setData[a] + "\")"; }
|
||||
else { cmd += "\"" + setData[a] + "\", "; }
|
||||
}
|
||||
cmd += ";";
|
||||
cmd = cmd.Replace("|", "");
|
||||
using (conn)
|
||||
{
|
||||
conn.Open();
|
||||
MySqlTransaction tran = conn.BeginTransaction();
|
||||
sqlcmd.Connection = conn;
|
||||
sqlcmd.Transaction = tran;
|
||||
try
|
||||
{
|
||||
sqlcmd.CommandText = cmd;
|
||||
sqlcmd.ExecuteNonQuery();
|
||||
tran.Commit();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
tran.Rollback();
|
||||
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 대상 컬럼 삭제 / DELETE FROM "DB_Table_Name" WHERE "target_idx"="comp_idx" AND "target_area"="target";
|
||||
/// </summary>
|
||||
/// <param name="DB_Table_Name">삭제할 대상이 있는 테이블명</param>
|
||||
/// <param name="target_idx">인덱스 대상이 있는 열명</param>
|
||||
/// <param name="comp_idx">삭제할 대상의 인덱스</param>
|
||||
/// <param name="target_area">삭제할 대상이 있는 열명</param>
|
||||
/// <param name="target">삭제할 대상</param>
|
||||
public void DB_Delete(string DB_Table_Name,
|
||||
string target_idx, string comp_idx,
|
||||
string target_area, string target)
|
||||
{
|
||||
string cmd = "DELETE FROM " + DB_Table_Name + " WHERE " +
|
||||
"`" + target_idx + "`=\"" + comp_idx + "\" AND" +
|
||||
"`" + target_area + "`=\"" + target + "\" LIMIT 1;";
|
||||
using (conn)
|
||||
{
|
||||
conn.Open();
|
||||
MySqlTransaction tran = conn.BeginTransaction();
|
||||
sqlcmd.Connection = conn;
|
||||
sqlcmd.Transaction = tran;
|
||||
try
|
||||
{
|
||||
sqlcmd.CommandText = cmd;
|
||||
sqlcmd.ExecuteNonQuery();
|
||||
|
||||
tran.Commit();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
tran.Rollback();
|
||||
MessageBox.Show(ex.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 대상 컬럼 삭제(리미트 없음) / DELETE FROM "DB_Table_Name" WHERE "target_idx"="comp_idx" AND "target_area"="target";
|
||||
/// </summary>
|
||||
/// <param name="DB_Table">대상 테이블명</param>
|
||||
/// <param name="target_idx">회사 인덱스 컬럼명</param>
|
||||
/// <param name="comp_idx">회사 인덱스</param>
|
||||
/// <param name="target_area">삭제 대상의 컬럼명</param>
|
||||
/// <param name="target">삭제 대상</param>
|
||||
public void DB_Delete_No_Limit(string DB_Table,
|
||||
string target_idx, string comp_idx,
|
||||
string[] target_area, string[] target)
|
||||
{
|
||||
string cmd = string.Format("DELETE FROM {0} WHERE `{1}`= \"{2}\" AND", DB_Table, target_idx, comp_idx);
|
||||
for(int a= 0; a < target_area.Length; a++)
|
||||
{
|
||||
cmd += string.Format("`{0}`=\"{1}\"", target_area[a], target[a]);
|
||||
if (a != target_area.Length - 1) { cmd += " AND"; }
|
||||
}
|
||||
cmd += ";";
|
||||
using (conn)
|
||||
{
|
||||
conn.Open();
|
||||
MySqlTransaction tran = conn.BeginTransaction();
|
||||
sqlcmd.Connection = conn;
|
||||
sqlcmd.Transaction = tran;
|
||||
try
|
||||
{
|
||||
sqlcmd.CommandText = cmd;
|
||||
sqlcmd.ExecuteNonQuery();
|
||||
|
||||
tran.Commit();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
tran.Rollback();
|
||||
MessageBox.Show(e.ToString(), "Error");
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 대상 컬럼 삭제 / DELETE FROM "DB_Table_Name" WHERE "target_idx"="comp_idx" AND "target_area"="target";
|
||||
/// </summary>
|
||||
public void DB_Delete_More_term(string DB_Table_Name,
|
||||
string target_idx, string comp_idx,
|
||||
string[] target_area, string[] target)
|
||||
{
|
||||
string cmd = "DELETE FROM " + DB_Table_Name + " WHERE " +
|
||||
"`" + target_idx + "`=\"" + comp_idx + "\" AND";
|
||||
for(int a = 0; a < target_area.Length; a++)
|
||||
{
|
||||
cmd += " `" + target_area[a] + "`=\"" + target[a] + "\" ";
|
||||
if (a == target_area.Length - 1) { cmd += "LIMIT 1;"; }
|
||||
else { cmd += "AND"; }
|
||||
}
|
||||
using (conn)
|
||||
{
|
||||
conn.Open();
|
||||
MySqlTransaction tran = conn.BeginTransaction();
|
||||
sqlcmd.Connection = conn;
|
||||
sqlcmd.Transaction = tran;
|
||||
try
|
||||
{
|
||||
sqlcmd.CommandText = cmd;
|
||||
sqlcmd.ExecuteNonQuery();
|
||||
|
||||
tran.Commit();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
tran.Rollback();
|
||||
MessageBox.Show(ex.ToString(), "Error");
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// "UPDATE \"" + DB_Tabel_Name + "\" SET \"" + Edit_colum + "\"=\"" + Edit_Name + "\" WHERE \""+Search_Name+"\"=\"" + Search_Data + "\";"
|
||||
/// </summary>
|
||||
/// <param name="DB_Tabel_Name">테이블명</param>
|
||||
/// <param name="Edit_colum">수정할 컬럼명</param>
|
||||
/// <param name="Edit_Name">수정하고 싶은 문구</param>
|
||||
/// <param name="Search_Name">검색할 컬럼명</param>
|
||||
/// <param name="Search_Data">검색할 데이터</param>
|
||||
public string DB_Update(string DB_Tabel_Name, string Edit_colum, string Edit_Name, string Search_Name, string Search_Data)
|
||||
{
|
||||
string cmd = "UPDATE `" + DB_Tabel_Name + "` SET `" + Edit_colum + "`=\"" + Edit_Name + "\" WHERE `"+Search_Name+"`=\"" + Search_Data + "\";";
|
||||
cmd = cmd.Replace("|", "");
|
||||
using (conn)
|
||||
{
|
||||
conn.Open();
|
||||
MySqlTransaction tran = conn.BeginTransaction();
|
||||
sqlcmd.Connection = conn;
|
||||
sqlcmd.Transaction = tran;
|
||||
|
||||
try
|
||||
{
|
||||
sqlcmd.CommandText = cmd;
|
||||
sqlcmd.ExecuteNonQuery();
|
||||
|
||||
tran.Commit();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
tran.Rollback();
|
||||
MessageBox.Show(ex.ToString());
|
||||
}
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
/// <summary>
|
||||
/// 많은 곳의 데이터를 변화시키고 싶을때. 테이블명을 제외하곤 다 배열. Edit와 Search끼리의 배열 인덱스값이 각자 서로 같아야함.
|
||||
/// </summary>
|
||||
/// <param name="DB_Table_Name">바꿀 데이터가 있는 테이블명</param>
|
||||
/// <param name="Edit_col">Edit_name인덱스와 같아야함</param>
|
||||
/// <param name="Edit_name">Edit_col인덱스와 같아야함</param>
|
||||
/// <param name="Search_col">Search_Name인덱스와 같아야함</param>
|
||||
/// <param name="Search_Name">Search_col인덱스와 같아야함</param>
|
||||
public void More_Update(String DB_Table_Name,
|
||||
String[] Edit_col, String[] Edit_name,
|
||||
String[] Search_col, String[] Search_Name)
|
||||
{
|
||||
string cmd = "UPDATE `" + DB_Table_Name + "` SET ";
|
||||
for(int a = 0; a < Edit_col.Length; a++)
|
||||
{
|
||||
cmd += "`" + Edit_col[a] + "` = \"" + Edit_name[a] + "\"";
|
||||
if (a != Edit_col.Length - 1) { cmd += ", "; }
|
||||
else { cmd += " "; }
|
||||
}
|
||||
cmd += "WHERE ";
|
||||
for(int a = 0; a < Search_col.Length; a++)
|
||||
{
|
||||
cmd += "`" + Search_col[a] + "` = \"" + Search_Name[a] + "\" ";
|
||||
if (a != Search_col.Length - 1) { cmd += "AND "; }
|
||||
}
|
||||
cmd += ";";
|
||||
cmd = cmd.Replace("|", "");
|
||||
|
||||
using (conn)
|
||||
{
|
||||
conn.Open();
|
||||
MySqlTransaction tran = conn.BeginTransaction();
|
||||
sqlcmd.Connection = conn;
|
||||
sqlcmd.Transaction = tran;
|
||||
try
|
||||
{
|
||||
sqlcmd.CommandText = cmd;
|
||||
sqlcmd.ExecuteNonQuery();
|
||||
tran.Commit();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
tran.Rollback();
|
||||
MessageBox.Show(ex.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// DB에 회사이름을 검색하여 만약 있는 회사일 경우 False 반환 / 없을경우 True반환
|
||||
/// </summary>
|
||||
/// <param name="Search_Data">검색할 회사 명</param>
|
||||
/// <returns></returns>
|
||||
public bool chk_comp(string Search_Data)
|
||||
{
|
||||
string cmd = "SELECT `comp_name` FROM `Comp`;";
|
||||
// DB연결
|
||||
conn.Open();
|
||||
// 쿼리 맵핑
|
||||
sqlcmd.CommandText = cmd;
|
||||
// 쿼리 날릴 곳은 conn, 즉 아까 연결한 DB
|
||||
sqlcmd.Connection = conn;
|
||||
// 쿼리 날리기, sqlDataReader에 결과값 저장
|
||||
sd = sqlcmd.ExecuteReader();
|
||||
// 한줄씩 불러오기
|
||||
while (sd.Read())
|
||||
{
|
||||
for (int cout = 0; cout < sd.FieldCount; cout++)
|
||||
{
|
||||
if(sd[cout].ToString() == Search_Data) { conn.Close(); return false; }
|
||||
}
|
||||
}
|
||||
conn.Close();
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// SQL문을 직접 만들어서 작성하여 사용해야함. (단, DELETE문/UPDATE문은 사용하지말 것!)
|
||||
/// </summary>
|
||||
/// <param name="cmd">등록할 SQL문</param>
|
||||
/// <returns></returns>
|
||||
public string self_Made_Cmd(string cmd)
|
||||
{
|
||||
cmd = cmd.Replace("|", "");
|
||||
|
||||
string result = "";
|
||||
if(cmd.Contains("DELETE")==true || cmd.Contains("UPDATE") == true) { return ""; }
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
sqlcmd.CommandText = cmd;
|
||||
sqlcmd.Connection = conn;
|
||||
sd = sqlcmd.ExecuteReader();
|
||||
while (sd.Read())
|
||||
{
|
||||
for (int cout = 0; cout < sd.FieldCount; cout++)
|
||||
{
|
||||
result += sd[cout].ToString() + "|";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MessageBox.Show("{0} Exception caught.\n"+ e.ToString());
|
||||
MessageBox.Show(cmd);
|
||||
}
|
||||
conn.Close();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
613
ISBN_Check_test/Skill.cs
Normal file
613
ISBN_Check_test/Skill.cs
Normal file
@@ -0,0 +1,613 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml;
|
||||
using System.Windows.Forms;
|
||||
using System.Reflection;
|
||||
using Excel = Microsoft.Office.Interop.Excel;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace WindowsFormsApp1
|
||||
{
|
||||
/// <summary>
|
||||
/// 여러 기능들이 추가될 예정.
|
||||
/// Excel_to_DataGridView
|
||||
/// </summary>
|
||||
class Skill_Grid
|
||||
{
|
||||
/// <summary>
|
||||
/// * Row헤더에 체크박스를 넣는 기능*
|
||||
/// 사용불가. 복사해서 가져가고 사양에 맞춰 수정할 것.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <param name="colCount">체크박스를 넣을 컬럼 위치</param>
|
||||
public void Add_Row_CheckBox(object sender, DataGridViewCellPaintingEventArgs e, int colCount)
|
||||
{
|
||||
if (e.ColumnIndex == colCount && e.RowIndex == -1)
|
||||
{
|
||||
string ori_name = ((DataGridView)sender).Name;
|
||||
((DataGridView)sender).Name = "Add_chkBox";
|
||||
e.PaintBackground(e.ClipBounds, false);
|
||||
|
||||
Point pt = e.CellBounds.Location;
|
||||
|
||||
int nChkBoxWidth = 15;
|
||||
int nChkBoxHeight = 15;
|
||||
int offsetX = (e.CellBounds.Width - nChkBoxWidth) / 2;
|
||||
int offsetY = (e.CellBounds.Height - nChkBoxHeight) / 2;
|
||||
|
||||
pt.X += offsetX;
|
||||
pt.Y += offsetY;
|
||||
|
||||
CheckBox cb = new CheckBox();
|
||||
cb.Size = new Size(nChkBoxWidth, nChkBoxHeight);
|
||||
cb.Location = pt;
|
||||
cb.CheckedChanged += new EventHandler(datagridview_checkBox_Click);
|
||||
((DataGridView)sender).Controls.Add(cb);
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
private void datagridview_checkBox_Click(object sender, EventArgs e)
|
||||
{
|
||||
foreach(DataGridViewRow r in ((DataGridView)sender).Rows)
|
||||
{
|
||||
r.Cells["chkbox"].Value = ((CheckBox)sender).Checked;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 엑셀에서 복사한 데이터를 DataGirdView에 붙여넣어주는 코드 (단, KeyDown에 넣어야함!!!!)
|
||||
/// 사전에 if ((e.Shift && e.KeyCode == Keys.Insert) || (e.Control && e.KeyCode == Keys.V))안에 들어가야함.
|
||||
/// </summary>
|
||||
/// <param name="sender">KeyDown의 object "sender"</param>
|
||||
/// <param name="e">KeyDown의 KeyEventArgs "e"</param>
|
||||
public void Excel_to_DataGridView(object sender, KeyEventArgs e)
|
||||
{
|
||||
//if user clicked Shift+Ins or Ctrl+V (paste from clipboard)
|
||||
if ((e.Shift && e.KeyCode == Keys.Insert) || (e.Control && e.KeyCode == Keys.V))
|
||||
{
|
||||
char[] rowSplitter = { '\r', '\n' };
|
||||
char[] columnSplitter = { '\t' };
|
||||
|
||||
//get the text from clipboard
|
||||
IDataObject dataInClipboard = Clipboard.GetDataObject();
|
||||
|
||||
string stringInClipboard = (string)dataInClipboard.GetData(DataFormats.Text);
|
||||
//split it into lines
|
||||
string[] rowsInClipboard = stringInClipboard.Split(rowSplitter, StringSplitOptions.RemoveEmptyEntries);
|
||||
//get the row and column of selected cell in dataGridView1
|
||||
int r = ((DataGridView)sender).SelectedCells[0].RowIndex;
|
||||
int c = ((DataGridView)sender).SelectedCells[0].ColumnIndex;
|
||||
//add rows into dataGridView1 to fit clipboard lines
|
||||
if (((DataGridView)sender).Rows.Count < (r + rowsInClipboard.Length))
|
||||
{
|
||||
((DataGridView)sender).Rows.Add(r + rowsInClipboard.Length - ((DataGridView)sender).Rows.Count);
|
||||
}
|
||||
// loop through the lines, split them into cells and place the values in the corresponding cell.
|
||||
for (int iRow = 0; iRow < rowsInClipboard.Length; iRow++)
|
||||
{
|
||||
//split row into cell values
|
||||
string[] valuesInRow = rowsInClipboard[iRow].Split(columnSplitter);
|
||||
//cycle through cell values
|
||||
for (int iCol = 0; iCol < valuesInRow.Length; iCol++)
|
||||
{
|
||||
//assign cell value, only if it within columns of the dataGridView1
|
||||
if (((DataGridView)sender).ColumnCount - 1 >= c + iCol)
|
||||
{
|
||||
((DataGridView)sender).Rows[r + iRow].Cells[c + iCol].Value = valuesInRow[iCol];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// DataGirdView의 활성화된 셀값을 삭제하는 코드 (단, KeyDown에 넣어야함!!!!)
|
||||
/// 사전에 if(e.KeyCode == Keys.Delete)안에 들어가야함.
|
||||
/// </summary>
|
||||
/// <param name="sender">KeyDown의 object "sender"</param>
|
||||
/// <param name="e">KeyDown의 KeyEventArgs "e"</param>
|
||||
public void DataGrid_to_Delete(object sender, KeyEventArgs e)
|
||||
{
|
||||
int rowIndex = ((DataGridView)sender).CurrentCell.RowIndex;
|
||||
int columnIndex = ((DataGridView)sender).CurrentCell.ColumnIndex;
|
||||
((DataGridView)sender).Rows[rowIndex].Cells[columnIndex].Value = "";
|
||||
}
|
||||
/// <summary>
|
||||
/// 그리드 앞 머리말에 넘버를 표시
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void Print_Grid_Num(Object sender, DataGridViewRowPostPaintEventArgs e)
|
||||
{
|
||||
// RowPostPaint 이벤트 핸들러
|
||||
// 행헤더 열영역에 행번호를 위해 장방형으로 처리
|
||||
|
||||
Rectangle rect = new Rectangle(e.RowBounds.Location.X,
|
||||
e.RowBounds.Location.Y,
|
||||
((DataGridView)sender).RowHeadersWidth - 4,
|
||||
e.RowBounds.Height);
|
||||
// 위에서 생성된 장방형내에 행번호를 보여주고 폰트색상 및 배경을 설정
|
||||
TextRenderer.DrawText(e.Graphics,
|
||||
(e.RowIndex + 1).ToString(),
|
||||
((DataGridView)sender).RowHeadersDefaultCellStyle.Font,
|
||||
rect,
|
||||
((DataGridView)sender).RowHeadersDefaultCellStyle.ForeColor,
|
||||
TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Grid에서 복사시 클립보드 글자깨짐방지
|
||||
/// 현재 효과없음
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void clipboard_not_crack(object sender, KeyEventArgs e)
|
||||
{
|
||||
Clipboard.SetDataObject(((DataGridView)sender).GetClipboardContent().GetText());
|
||||
}
|
||||
/// <summary>
|
||||
/// 엑셀 내보내기
|
||||
/// </summary>
|
||||
/// <param name="datagridview">사용할 데이터 그리드뷰</param>
|
||||
public void ExportToExcel(DataGridView datagridview)
|
||||
{
|
||||
Excel.Application excelApplication;
|
||||
Excel._Workbook workbook;
|
||||
Excel._Worksheet worksheet;
|
||||
|
||||
excelApplication = new Excel.Application();
|
||||
|
||||
if (excelApplication == null) {
|
||||
MessageBox.Show("엑셀이 설치되지 않았습니다");
|
||||
return;
|
||||
}
|
||||
|
||||
excelApplication.Visible = false;
|
||||
|
||||
workbook = excelApplication.Workbooks.Add(Missing.Value);
|
||||
worksheet = workbook.ActiveSheet as Excel._Worksheet;
|
||||
|
||||
object[,] headerValueArray = new object[1, datagridview.ColumnCount];
|
||||
|
||||
int gap = 0; // 숨김처리된 컬럼 격차 줄이기 위한 변수
|
||||
// 헤더 출력
|
||||
for (int a = 0; a < datagridview.Columns.Count; a++)
|
||||
{
|
||||
if (datagridview.Columns[a].Visible == false) { gap++; continue; }
|
||||
|
||||
headerValueArray[0, a - gap] = datagridview.Columns[a].HeaderText;
|
||||
}
|
||||
|
||||
Excel.Range startHeaderCell = worksheet.Cells[1, 1];
|
||||
Excel.Range endHeaderCell = worksheet.Cells[1, datagridview.ColumnCount - gap];
|
||||
|
||||
worksheet.get_Range(
|
||||
startHeaderCell as object, endHeaderCell as object).Font.Bold = true;
|
||||
worksheet.get_Range(
|
||||
startHeaderCell as object, endHeaderCell as object).VerticalAlignment=Excel.XlVAlign.xlVAlignCenter;
|
||||
worksheet.get_Range(
|
||||
startHeaderCell as object, endHeaderCell as object).Value2 = headerValueArray;
|
||||
|
||||
object[,] cellValueArray = new object[datagridview.RowCount, datagridview.ColumnCount];
|
||||
|
||||
gap = 0;
|
||||
// 내용 출력
|
||||
for(int a = 0; a < datagridview.RowCount; a++)
|
||||
{
|
||||
for(int b = 0; b < datagridview.ColumnCount; b++)
|
||||
{
|
||||
if (datagridview.Columns[b].Visible == false) { gap++; continue; }
|
||||
if (datagridview.Rows[a].Cells[b].ValueType.Name == "String") {
|
||||
cellValueArray[a, b-gap] = "'" + datagridview.Rows[a].Cells[b].Value.ToString();
|
||||
}
|
||||
else {
|
||||
cellValueArray[a, b] = datagridview.Rows[a].Cells[b].Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Excel.Range startCell = worksheet.Cells[2, 1];
|
||||
Excel.Range endCell = worksheet.Cells[datagridview.RowCount + 1, datagridview.ColumnCount-gap];
|
||||
worksheet.get_Range(startCell as object, endCell as object).Value2 = cellValueArray;
|
||||
|
||||
excelApplication.Visible = true;
|
||||
excelApplication.UserControl = true;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 텍스트 관련 함수.
|
||||
/// </summary>
|
||||
class String_Text
|
||||
{
|
||||
/// <summary>
|
||||
/// 텍스트박스 숫자만 입력받는 함수. KeyPress함수에 적용
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void Only_Int(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
if(!(char.IsDigit(e.KeyChar) || e.KeyChar == Convert.ToChar(Keys.Back)))
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// TextChanged이벤트 - 천단위 콤마찍어주기
|
||||
/// </summary>
|
||||
/// <param name="sender">object sender</param>
|
||||
/// <param name="e">EventArgs</param>
|
||||
public void Int_Comma(object sender, EventArgs e)
|
||||
{
|
||||
if (((TextBox)sender).Text != "") {
|
||||
string text;
|
||||
text = ((TextBox)sender).Text.Replace(",", "");
|
||||
((TextBox)sender).Text = String.Format("{0:#,###}", Convert.ToInt32(text));
|
||||
((TextBox)sender).SelectionStart = ((TextBox)sender).TextLength;
|
||||
((TextBox)sender).SelectionLength = 0;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 문자열 내에 한글이 들어가는지 체크
|
||||
/// </summary>
|
||||
/// <param name="value">대상 문자열</param>
|
||||
/// <returns>한글 포함시 true</returns>
|
||||
public bool isContainHangul(string value)
|
||||
{
|
||||
char[] charArr = value.ToCharArray();
|
||||
foreach(char c in charArr)
|
||||
{
|
||||
if (char.GetUnicodeCategory(c) == System.Globalization.UnicodeCategory.OtherLetter)
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// 대상 문자열안에 찾고 싶은 문자 찾기
|
||||
/// </summary>
|
||||
/// <param name="value">대상 문자열</param>
|
||||
/// <param name="chkString">찾고 싶은 문자</param>
|
||||
/// <returns>있을 경우 True반환</returns>
|
||||
public bool CheckString(string value, string chkString)
|
||||
{
|
||||
int index = value.IndexOf(chkString);
|
||||
if (index < 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
public int Char_count(string value, char chkString)
|
||||
{
|
||||
string[] res = value.Split(chkString);
|
||||
int count = res.Length;
|
||||
return count - 1;
|
||||
}
|
||||
/// <summary>
|
||||
/// 문자와 문자사이의 값 가져오기
|
||||
/// </summary>
|
||||
/// <param name="str">대상 문자열</param>
|
||||
/// <param name="begin">시작 문자열</param>
|
||||
/// <param name="end">마지막 문자열</param>
|
||||
/// <returns>문자 사이값</returns>
|
||||
public string GetMiddelString(string str, string begin, string end)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string result = null;
|
||||
if (str.IndexOf(begin) > -1)
|
||||
{
|
||||
str = str.Substring(str.IndexOf(begin) + begin.Length);
|
||||
if (str.IndexOf(end) > -1) result = str.Substring(0, str.IndexOf(end));
|
||||
else result = str;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public class API
|
||||
{
|
||||
/// <summary>
|
||||
/// https://blog.aladin.co.kr/openapi 참고
|
||||
/// </summary>
|
||||
/// <param name="Query"></param>
|
||||
/// <param name="QueryType"></param>
|
||||
/// <param name="Param"></param>
|
||||
/// <returns></returns>
|
||||
public string Aladin(string Query, string QueryType, string[] Param)
|
||||
{
|
||||
string result = string.Empty;
|
||||
// 쿼리 생성
|
||||
string key = "ttbgloriabook1512001";
|
||||
string site = "http://www.aladin.co.kr/ttb/api/ItemSearch.aspx";
|
||||
string query = string.Format("{0}?query={1}&TTBKey={2}&output=xml&querytype={3}&MaxResults={4}",
|
||||
site, Query, key, QueryType, 30.ToString());
|
||||
|
||||
// 쿼리를 입력인자로 WebRequest 개채 생성
|
||||
WebRequest request = WebRequest.Create(query);
|
||||
|
||||
// WebRequest개체의 헤더에 인증키 포함시키기.
|
||||
// request.Headers.Add("Authorization", header);
|
||||
|
||||
// WebResponse개체를 통해 서비스 요청.
|
||||
WebResponse response = request.GetResponse();
|
||||
|
||||
// 결과문자열 확인
|
||||
Stream stream = response.GetResponseStream();
|
||||
StreamReader reader = new StreamReader(stream, Encoding.UTF8);
|
||||
String xml = reader.ReadToEnd();
|
||||
stream.Close();
|
||||
// xml형식을 json형식으로 변환
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.LoadXml(xml);
|
||||
var json = JsonConvert.SerializeXmlNode(doc);
|
||||
|
||||
// json형식 분석을 위해 JavaScriptSerializer 개체 생성
|
||||
JavaScriptSerializer js = new JavaScriptSerializer();
|
||||
|
||||
// 런타임에 개체를 확인하여 사용할수 있는 dynamic을 이용해 역직렬화
|
||||
dynamic dob = js.Deserialize<dynamic>(json);
|
||||
|
||||
// "object"내에 있는것을 얻어오기 위해 다시 dynamic변수에 참조
|
||||
dynamic docs = "";
|
||||
try
|
||||
{
|
||||
docs = dob["object"]["item"];
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
}
|
||||
int length = 0;
|
||||
int ID_length = Param.Length;
|
||||
|
||||
// 검색 결과가 1개 이하일 경우, 오류가 발생하여 try/catch문 사용.
|
||||
try
|
||||
{
|
||||
// docs는 요소 컬렉션으로 object로 변환.
|
||||
object[] buf = docs;
|
||||
length = buf.Length;
|
||||
}
|
||||
catch
|
||||
{
|
||||
object buf = docs;
|
||||
length = 1;
|
||||
}
|
||||
for (int a = 0; a < length; a++)
|
||||
{
|
||||
List<string> tmp_data = new List<string>();
|
||||
for (int b = 0; b < ID_length; b++)
|
||||
{
|
||||
if (length == 1)
|
||||
{
|
||||
tmp_data.Add(docs[Param[b]]);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_data.Add(docs[a][Param[b]]);
|
||||
}
|
||||
result += tmp_data[b] + "|";
|
||||
}
|
||||
result += "\n";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public string Naver(string[] Query, string[] QueryType, string[] Param)
|
||||
{
|
||||
string result = string.Empty;
|
||||
string json = string.Empty;
|
||||
// url 생성
|
||||
string url = "https://openapi.naver.com/v1/search/book_adv?";
|
||||
|
||||
for (int a = 0; a < Query.Length; a++)
|
||||
{
|
||||
url += string.Format("{0}={1}&", QueryType[a], Query[a]);
|
||||
}
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
|
||||
request.Headers.Add("X-Naver-Client-Id", "wYr0JczCBoDopq1NKTyQ"); // 클라이언트 아이디
|
||||
request.Headers.Add("X-Naver-Client-Secret", "QHzeXadtO7"); // 클라이언트 시크릿
|
||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||
string status = response.StatusCode.ToString();
|
||||
if (status == "OK")
|
||||
{
|
||||
Stream stream = response.GetResponseStream();
|
||||
StreamReader reader = new StreamReader(stream, Encoding.UTF8);
|
||||
json = reader.ReadToEnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(status, "Error");
|
||||
return "Error";
|
||||
}
|
||||
|
||||
// json형식 분석을 위해 JavaScriptSerializer 개체 생성
|
||||
JavaScriptSerializer js = new JavaScriptSerializer();
|
||||
|
||||
// 런타임에 개체를 확인하여 사용할수 있는 dynamic을 이용해 역직렬화
|
||||
dynamic dob = js.Deserialize<dynamic>(json);
|
||||
|
||||
// "object"내에 있는것을 얻어오기 위해 다시 dynamic변수에 참조
|
||||
dynamic docs = "";
|
||||
try
|
||||
{
|
||||
// docs = dob["object"]["item"];
|
||||
docs = dob["items"];
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
}
|
||||
int length = 0;
|
||||
int ID_length = Param.Length;
|
||||
|
||||
// 검색 결과가 1개 이하일 경우, 오류가 발생하여 try/catch문 사용.
|
||||
try
|
||||
{
|
||||
// docs는 요소 컬렉션으로 object로 변환.
|
||||
object[] buf = docs;
|
||||
length = buf.Length;
|
||||
}
|
||||
catch
|
||||
{
|
||||
object buf = docs;
|
||||
length = 1;
|
||||
}
|
||||
for (int a = 0; a < length; a++)
|
||||
{
|
||||
List<string> tmp_data = new List<string>();
|
||||
for (int b = 0; b < ID_length; b++)
|
||||
{
|
||||
tmp_data.Add(docs[a][Param[b]]);
|
||||
result += tmp_data[b] + "|";
|
||||
}
|
||||
result += "\n\t";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public string Daum(string Query, string Type, string[] Param)
|
||||
{
|
||||
string result = string.Empty;
|
||||
|
||||
// url생성
|
||||
string url = "https://dapi.kakao.com/v3/search/book";
|
||||
string query = string.Format("{0}?query={1}&target={2}&", url, Query, Type);
|
||||
WebRequest request = WebRequest.Create(query);
|
||||
|
||||
string rKey = "e3935565b731a2a6f32880c90d76403a";
|
||||
string header = "KakaoAK " + rKey;
|
||||
|
||||
request.Headers.Add("Authorization", header);
|
||||
|
||||
WebResponse response = request.GetResponse();
|
||||
Stream stream = response.GetResponseStream();
|
||||
StreamReader reader = new StreamReader(stream, Encoding.UTF8);
|
||||
string json = reader.ReadToEnd();
|
||||
stream.Close();
|
||||
|
||||
JavaScriptSerializer js = new JavaScriptSerializer();
|
||||
dynamic dob = js.Deserialize<dynamic>(json);
|
||||
dynamic docs = dob["documents"];
|
||||
object[] buf = docs;
|
||||
|
||||
int length = buf.Length;
|
||||
int ID_length = Param.Length;
|
||||
|
||||
for (int a = 0; a < length; a++)
|
||||
{
|
||||
List<object> tmp_data = new List<object>();
|
||||
for (int b = 0; b < ID_length; b++)
|
||||
{
|
||||
if (Param[b] == "authors")
|
||||
{
|
||||
object[] tmp = docs[a][Param[b]];
|
||||
string tmp_str = string.Empty;
|
||||
for (int j = 0; j < tmp.Length; j++)
|
||||
{
|
||||
tmp_str += tmp[j];
|
||||
if (j < tmp.Length - 1)
|
||||
{
|
||||
tmp_str += ", ";
|
||||
}
|
||||
}
|
||||
tmp_data.Add(tmp_str);
|
||||
result += tmp_data[b] + "|";
|
||||
tmp_str = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_data.Add(docs[a][Param[b]]);
|
||||
result += tmp_data[b] + "|";
|
||||
}
|
||||
}
|
||||
result += "\n";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public class Skill_Search_Text
|
||||
{
|
||||
/// <summary>
|
||||
/// 검색용 박스 제작
|
||||
/// </summary>
|
||||
/// <param name="title">제목</param>
|
||||
/// <param name="promptText">내용</param>
|
||||
/// <param name="value">검색할 문자열</param>
|
||||
/// <returns></returns>
|
||||
public DialogResult InputBox(string title, string promptText, ref string value)
|
||||
{
|
||||
Form form = new Form();
|
||||
Label label = new Label();
|
||||
TextBox textBox = new TextBox();
|
||||
Button btnOk = new Button();
|
||||
Button btnCancel = new Button();
|
||||
form.Text = title;
|
||||
label.Text = promptText;
|
||||
textBox.Text = value;
|
||||
btnOk.Text = "OK";
|
||||
btnCancel.Text = "Cancel";
|
||||
btnOk.DialogResult = DialogResult.OK;
|
||||
btnCancel.DialogResult = DialogResult.Cancel;
|
||||
label.SetBounds(9, 20, 372, 13);
|
||||
textBox.SetBounds(12, 36, 372, 20);
|
||||
btnOk.SetBounds(228, 72, 75, 23);
|
||||
btnCancel.SetBounds(309, 72, 75, 23);
|
||||
label.AutoSize = true;
|
||||
textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
|
||||
btnOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
btnCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
form.ClientSize = new Size(396, 107);
|
||||
form.Controls.AddRange(new Control[] { label, textBox, btnOk, btnCancel });
|
||||
form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
|
||||
form.FormBorderStyle = FormBorderStyle.FixedDialog;
|
||||
form.StartPosition = FormStartPosition.CenterScreen;
|
||||
form.MinimizeBox = false;
|
||||
form.MaximizeBox = false;
|
||||
form.AcceptButton = btnOk;
|
||||
form.CancelButton = btnCancel;
|
||||
DialogResult dialogResult = form.ShowDialog();
|
||||
value = textBox.Text;
|
||||
return dialogResult;
|
||||
}
|
||||
/// <summary>
|
||||
/// 색상 변경함수(richTextBox에만 적용)
|
||||
/// </summary>
|
||||
/// <param name="strTarget"></param>
|
||||
public void Color_change(string strTarget, RichTextBox richText)
|
||||
{
|
||||
Regex regex = new Regex(strTarget);
|
||||
MatchCollection mc = regex.Matches(richText.Text);
|
||||
richText.Select(0, richText.Text.Length);
|
||||
richText.SelectionBackColor = Color.White;
|
||||
|
||||
int ICursorPosition = richText.SelectionStart;
|
||||
foreach (Match m in mc)
|
||||
{
|
||||
int istartidx = m.Index;
|
||||
int istopidx = m.Length + 1;
|
||||
int istopidx1 = m.Length;
|
||||
|
||||
if (strTarget == "▼" || strTarget == "▲") { richText.Select(istartidx, istopidx); }
|
||||
else { richText.Select(istartidx, istopidx1); }
|
||||
|
||||
if (strTarget == "▼") { richText.SelectionColor = Color.Blue; }
|
||||
else if (strTarget == "▲") { richText.SelectionColor = Color.Red; }
|
||||
else { richText.SelectionBackColor = Color.Orange; } // TODO: 색상 변경될수 있음.
|
||||
|
||||
richText.SelectionStart = ICursorPosition;
|
||||
if (strTarget == "▼" || strTarget == "▲") { richText.SelectionColor = Color.Black; }
|
||||
else { richText.SelectionBackColor = Color.Empty; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
524
unimarc/unimarc/Helper_DB.cs
Normal file
524
unimarc/unimarc/Helper_DB.cs
Normal file
@@ -0,0 +1,524 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using MySql.Data.MySqlClient;
|
||||
using Renci.SshNet;
|
||||
|
||||
namespace WindowsFormsApp1
|
||||
{
|
||||
/// <summary>
|
||||
/// DB접속을 도와주는 클래스
|
||||
/// </summary>
|
||||
class Helper_DB
|
||||
{
|
||||
// 접속
|
||||
MySqlConnection conn;
|
||||
|
||||
// 쿼리
|
||||
MySqlCommand sqlcmd = new MySqlCommand();
|
||||
MySqlDataReader sd;
|
||||
|
||||
public string comp_idx { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// DB를 사용하고 싶을 때 미리 저장된 DB의 기본 접속정보를 이용하여 DB에 접근한다.
|
||||
/// </summary>
|
||||
public void DBcon() // DB접속 함수
|
||||
{
|
||||
PasswordConnectionInfo connectionInfo = new PasswordConnectionInfo("1.215.250.130", 815, "gloriabook", "admin@!@#$");
|
||||
connectionInfo.Timeout = TimeSpan.FromSeconds(30);
|
||||
using (var client = new SshClient(connectionInfo))
|
||||
{
|
||||
client.Connect();
|
||||
if (client.IsConnected)
|
||||
{
|
||||
string strConnection = "Server=1.215.250.130;"
|
||||
+ "Port=3306;"
|
||||
+ "Database=unimarc;"
|
||||
+ "uid=root;"
|
||||
+ "pwd=Admin21234;";
|
||||
conn = new MySqlConnection(strConnection);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 국중DB를 사용하고 싶을 때 미리 저장된 DB의 기본 접속정보를 이용하여 DB에 접근한다.
|
||||
/// </summary>
|
||||
public void DBcon_cl() // DB접속 함수
|
||||
{
|
||||
PasswordConnectionInfo connectionInfo = new PasswordConnectionInfo("1.215.250.130", 815, "gloriabook", "admin@!@#$");
|
||||
connectionInfo.Timeout = TimeSpan.FromSeconds(30);
|
||||
using (var client = new SshClient(connectionInfo))
|
||||
{
|
||||
client.Connect();
|
||||
if (client.IsConnected)
|
||||
{
|
||||
string strConnection = "Server=1.215.250.130;"
|
||||
+ "Port=3306;"
|
||||
+ "Database=cl_marc;"
|
||||
+ "uid=root;"
|
||||
+ "pwd=Admin21234;";
|
||||
conn = new MySqlConnection(strConnection);
|
||||
}
|
||||
}
|
||||
}
|
||||
public string DB_Send_CMD_Search(string cmd)
|
||||
{
|
||||
// DB 연결
|
||||
conn.Open();
|
||||
// 쿼리 맵핑
|
||||
sqlcmd.CommandText = cmd;
|
||||
// 쿼리 날릴 곳은 conn
|
||||
sqlcmd.Connection = conn;
|
||||
// 쿼리 날리기, sqlDataReader에 결과값 저장
|
||||
sd = sqlcmd.ExecuteReader();
|
||||
string result = "";
|
||||
string change;
|
||||
// 한줄씩 불러와 한개의 값으로 변환
|
||||
while (sd.Read())
|
||||
{
|
||||
for (int count = 0; count < sd.FieldCount; count++)
|
||||
{
|
||||
change = sd[count].ToString().Replace("|", "");
|
||||
result += change + "|";
|
||||
}
|
||||
}
|
||||
conn.Close();
|
||||
return result;
|
||||
}
|
||||
public void DB_Send_CMD_reVoid(string cmd)
|
||||
{
|
||||
using (conn)
|
||||
{
|
||||
conn.Open();
|
||||
MySqlTransaction tran = conn.BeginTransaction();
|
||||
sqlcmd.Connection = conn;
|
||||
sqlcmd.Transaction = tran;
|
||||
try
|
||||
{
|
||||
sqlcmd.CommandText = cmd;
|
||||
sqlcmd.ExecuteNonQuery();
|
||||
tran.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
tran.Rollback();
|
||||
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// DBcon이 선진행되어야함.
|
||||
/// SELECT * FROM [DB_Table_Name] WHERE [DB_Where_Table] LIKE \"%DB_Search_Data%\"
|
||||
/// <summary>
|
||||
/// <param name="compidx"/>이용자 회사의 idx번호 단.none일 경우 다른 DB를 가져옴</param>
|
||||
/// <param name="DB_Table_Name">테이블명</param>
|
||||
/// <param name="DB_Where_Table">검색할 테이블</param>
|
||||
/// <param name="DB_Search_Data">검색할 텍스트</param>
|
||||
/// <returns>검색된 결과값이 반환됨.</returns>
|
||||
public string DB_Contains(string DB_Table_Name, string compidx,
|
||||
string DB_Where_Table = "", string DB_Search_Data = "",
|
||||
string Search_col = "",
|
||||
string DB_Where_Table1 = "", string DB_Search_Data1 = "" )
|
||||
{
|
||||
string cmd = "SELECT ";
|
||||
if (Search_col == "") { cmd += "*"; }
|
||||
else { cmd += Search_col; }
|
||||
cmd += " FROM ";
|
||||
cmd += DB_Table_Name;
|
||||
if (DB_Table_Name == "Obj_List") { cmd += " WHERE `comp_num` = \"" + compidx + "\""; }
|
||||
else if (DB_Table_Name == "Client") { cmd += " WHERE `campanyidx` = \"" + compidx + "\""; }
|
||||
else if (DB_Table_Name == "Purchase") { cmd += " WHERE `comparyidx` = \"" + compidx + "\""; }
|
||||
else if(compidx == "none") { cmd += " WHERE `grade` = \"2\""; }
|
||||
else { cmd += " WHERE `compidx` = \"" + compidx + "\""; }
|
||||
|
||||
if(DB_Search_Data != "")
|
||||
{
|
||||
cmd += " AND "+ DB_Where_Table + " LIKE\"%" + DB_Search_Data + "%\"";
|
||||
}
|
||||
if(DB_Search_Data1 != "")
|
||||
{
|
||||
cmd += " AND "+ DB_Where_Table1 + " LIKE\"%" + DB_Search_Data1 + "%\"";
|
||||
}
|
||||
cmd += ";";
|
||||
return cmd;
|
||||
}
|
||||
/// <summary>
|
||||
/// DBcon이 선진행되어야함. / SELECT * FROM DB_Table_Name WHERE DB_Where_Table = \"DB_Search_Data\";
|
||||
/// <summary>
|
||||
/// <param name="Search_Area">가져올 데이터의 위치</param>
|
||||
/// <param name="DB_Table_Name">테이블명</param>
|
||||
/// <param name="DB_Where_Table">검색할 테이블</param>
|
||||
/// <param name="DB_Search_Data">검색할 텍스트</param>
|
||||
/// <returns>검색된 결과값이 반환됨.</returns>
|
||||
public string DB_Select_Search(string Search_Area, string DB_Table_Name,
|
||||
string DB_Where_Table = "", string DB_Search_Data = "",
|
||||
string DB_Where_Table1 = "", string DB_Search_Data1 = "")
|
||||
{
|
||||
string cmd = string.Format("SELECT {0} FROM ", Search_Area);
|
||||
cmd += DB_Table_Name;
|
||||
if(DB_Where_Table != "" && DB_Search_Data != "")
|
||||
{
|
||||
cmd += string.Format(" WHERE `{0}` = \"{1}\"", DB_Where_Table, DB_Search_Data);
|
||||
}
|
||||
if(DB_Where_Table1 != "" && DB_Search_Data1 != "")
|
||||
{
|
||||
cmd += string.Format(" AND `{0}` = \"{1}\"", DB_Where_Table1, DB_Search_Data1);
|
||||
}
|
||||
cmd += ";";
|
||||
return cmd;
|
||||
}
|
||||
/// <summary>
|
||||
/// DBcon이 선진행되어야함. / SELECT * FROM DB_Table_Name WHERE DB_Where_Table = \"DB_Search_Data\";
|
||||
/// <summary>
|
||||
/// <param name="DB_Table_Name">테이블명</param>
|
||||
/// <param name="DB_Where_Table">검색할 테이블</param>
|
||||
/// <param name="DB_Search_Data">검색할 텍스트</param>
|
||||
/// <returns>검색된 결과값이 반환됨.</returns>
|
||||
public string DB_Search(string DB_Table_Name,
|
||||
string DB_Where_Table = "", string DB_Search_Data = "",
|
||||
string DB_Where_Table1 = "", string DB_Search_Data1 = "")
|
||||
{
|
||||
string cmd = "SELECT * FROM ";
|
||||
cmd += DB_Table_Name;// + " where id=\"id\"";
|
||||
if(DB_Search_Data != "")
|
||||
{
|
||||
cmd += " WHERE "+ DB_Where_Table + "=\"" + DB_Search_Data +"\"";
|
||||
}
|
||||
if (DB_Where_Table1 != "" && DB_Search_Data1 != "")
|
||||
{
|
||||
cmd += " AND `" + DB_Where_Table1 + "` =\"" + DB_Search_Data1 + "\"";
|
||||
}
|
||||
cmd += ";";
|
||||
return cmd;
|
||||
}
|
||||
/// <summary>
|
||||
/// 여러 조건이 있을때 사용 (단, Where_Table과 Search_Date의 배열길이는 같아야함)
|
||||
/// </summary>
|
||||
/// <param name="DB_Table_Name"></param>
|
||||
/// <param name="DB_Where_Table"></param>
|
||||
/// <param name="DB_Search_Data"></param>
|
||||
/// <param name="Search_Table">추출할 열의 이름."`num1`, `num2`" 이런식으로</param>
|
||||
/// <returns></returns>
|
||||
public string More_DB_Search(String DB_Table_Name, String[] DB_Where_Table,
|
||||
String[] DB_Search_Data, String Search_Table = "")
|
||||
{
|
||||
if(DB_Where_Table.Length != DB_Search_Data.Length) { return "오류발생"; }
|
||||
string cmd = "SELECT ";
|
||||
if(Search_Table == "") { cmd += "*"; }
|
||||
else { cmd += Search_Table; }
|
||||
cmd += " FROM " + DB_Table_Name + " WHERE ";
|
||||
for(int a = 0; a < DB_Where_Table.Length; a++)
|
||||
{
|
||||
cmd += "`" + DB_Where_Table[a] + "` = \"" + DB_Search_Data[a] + "\" ";
|
||||
if(a == DB_Where_Table.Length - 1) { cmd += ";"; }
|
||||
else { cmd += " AND "; }
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
/// <summary>
|
||||
/// DB상의 날짜의 사이값을 가져오기 위한 함수
|
||||
/// </summary>
|
||||
/// <param name="Table_name">가져올 테이블의 이름</param>
|
||||
/// <param name="Search_Table">프로그램상으로 가져올 DB데이터</param>
|
||||
/// <param name="Search_date">DB상의 날짜가 저장된 컬럼명</param>
|
||||
/// <param name="start_date">시작할 날짜 0000-00-00</param>
|
||||
/// <param name="end_date">끝낼 날짜 0000-00-00</param>
|
||||
/// <param name="compidx">회사 인덱스 main.com_idx</param>
|
||||
/// <returns></returns>
|
||||
public string Search_Date(string Table_name, string Search_Table, string Search_date,
|
||||
string start_date, string end_date, string compidx)
|
||||
{
|
||||
if (Search_Table == "") { Search_Table = "*"; }
|
||||
// select * from `table_name` where `날짜 컬럼` between date('start_date') and date('end_date')+1;
|
||||
string cmd = "SELECT " + Search_Table + " FROM `" + Table_name + "` " +
|
||||
"WHERE `comp_num` = '" + compidx + "' AND `" +
|
||||
Search_date + "` >= '" + start_date + "'";
|
||||
if(Table_name != "Obj_List") { cmd = cmd.Replace("`comp_num`", "`compidx`"); }
|
||||
if (end_date != "") { cmd += " AND `" + Search_date + "` <= '" + end_date + "';"; }
|
||||
else { cmd += ";"; }
|
||||
return cmd;
|
||||
}
|
||||
public string DB_INSERT(String DB_Table_name, String[] DB_col_name, String[] setData)
|
||||
{
|
||||
string cmd = "INSERT INTO " + DB_Table_name + "(";
|
||||
for(int a = 0; a < DB_col_name.Length; a++)
|
||||
{
|
||||
if (a == DB_col_name.Length - 1) { cmd += "`" + DB_col_name[a] + "`) "; }
|
||||
else { cmd += "`" + DB_col_name[a] + "`, "; }
|
||||
}
|
||||
cmd += "values(";
|
||||
for(int a = 0; a < setData.Length; a++)
|
||||
{
|
||||
setData[a] = setData[a].Replace("\"", "\"\"");
|
||||
if (a == setData.Length - 1) { cmd += "\"" + setData[a] + "\")"; }
|
||||
else { cmd += "\"" + setData[a] + "\", "; }
|
||||
}
|
||||
cmd += ";";
|
||||
cmd = cmd.Replace("|", "");
|
||||
return cmd;
|
||||
}
|
||||
public string DB_INSERT_SUB(string value, string[] setData)
|
||||
{
|
||||
string cmd = string.Format("(");
|
||||
if (value == "")
|
||||
{
|
||||
for (int a = 0; a < setData.Length; a++)
|
||||
{
|
||||
if (a == setData.Length - 1) { cmd += "`" + setData[a] + "`) "; }
|
||||
else { cmd += "`" + setData[a] + "`, "; }
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
for (int a = 0; a < setData.Length; a++)
|
||||
{
|
||||
setData[a] = setData[a].Replace("\"", "\"\"");
|
||||
if (a == setData.Length - 1) { cmd += "\"" + setData[a] + "\")"; }
|
||||
else { cmd += "\"" + setData[a] + "\", "; }
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
/// <summary>
|
||||
/// 대상 컬럼 삭제 / DELETE FROM "DB_Table_Name" WHERE "target_idx"="comp_idx" AND "target_area"="target";
|
||||
/// </summary>
|
||||
/// <param name="DB_Table_Name">삭제할 대상이 있는 테이블명</param>
|
||||
/// <param name="target_idx">인덱스 대상이 있는 열명</param>
|
||||
/// <param name="comp_idx">삭제할 대상의 인덱스</param>
|
||||
/// <param name="target_area">삭제할 대상이 있는 열명</param>
|
||||
/// <param name="target">삭제할 대상</param>
|
||||
public string DB_Delete(string DB_Table_Name,
|
||||
string target_idx, string comp_idx,
|
||||
string target_area, string target)
|
||||
{
|
||||
string cmd = "DELETE FROM " + DB_Table_Name + " WHERE " +
|
||||
"`" + target_idx + "`=\"" + comp_idx + "\" AND" +
|
||||
"`" + target_area + "`=\"" + target + "\" LIMIT 1;";
|
||||
return cmd;
|
||||
}
|
||||
/// <summary>
|
||||
/// 대상 컬럼 삭제(리미트 없음) / DELETE FROM "DB_Table_Name" WHERE "target_idx"="comp_idx" AND "target_area"="target";
|
||||
/// </summary>
|
||||
/// <param name="DB_Table">대상 테이블명</param>
|
||||
/// <param name="target_idx">회사 인덱스 컬럼명</param>
|
||||
/// <param name="comp_idx">회사 인덱스</param>
|
||||
/// <param name="target_area">삭제 대상의 컬럼명</param>
|
||||
/// <param name="target">삭제 대상</param>
|
||||
public string DB_Delete_No_Limit(string DB_Table,
|
||||
string target_idx, string comp_idx,
|
||||
string[] target_area, string[] target)
|
||||
{
|
||||
string cmd = string.Format("DELETE FROM {0} WHERE `{1}`= \"{2}\" AND", DB_Table, target_idx, comp_idx);
|
||||
for(int a= 0; a < target_area.Length; a++)
|
||||
{
|
||||
cmd += string.Format("`{0}`=\"{1}\"", target_area[a], target[a]);
|
||||
if (a != target_area.Length - 1) { cmd += " AND"; }
|
||||
}
|
||||
cmd += ";";
|
||||
return cmd;
|
||||
}
|
||||
/// <summary>
|
||||
/// 대상 컬럼 삭제 / DELETE FROM "DB_Table_Name" WHERE "target_idx"="comp_idx" AND "target_area"="target";
|
||||
/// </summary>
|
||||
public string DB_Delete_More_term(string DB_Table_Name,
|
||||
string target_idx, string comp_idx,
|
||||
string[] target_area, string[] target)
|
||||
{
|
||||
string cmd = "DELETE FROM " + DB_Table_Name + " WHERE " +
|
||||
"`" + target_idx + "`=\"" + comp_idx + "\" AND";
|
||||
for(int a = 0; a < target_area.Length; a++)
|
||||
{
|
||||
cmd += " `" + target_area[a] + "`=\"" + target[a] + "\" ";
|
||||
if (a == target_area.Length - 1) { cmd += "LIMIT 1;"; }
|
||||
else { cmd += "AND"; }
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
/// <summary>
|
||||
/// "UPDATE \"" + DB_Tabel_Name + "\" SET \"" + Edit_colum + "\"=\"" + Edit_Name + "\" WHERE \""+Search_Name+"\"=\"" + Search_Data + "\";"
|
||||
/// </summary>
|
||||
/// <param name="DB_Tabel_Name">테이블명</param>
|
||||
/// <param name="Edit_colum">수정할 컬럼명</param>
|
||||
/// <param name="Edit_Name">수정하고 싶은 문구</param>
|
||||
/// <param name="Search_Name">검색할 컬럼명</param>
|
||||
/// <param name="Search_Data">검색할 데이터</param>
|
||||
public string DB_Update(string DB_Tabel_Name, string Edit_colum, string Edit_Name, string Search_Name, string Search_Data)
|
||||
{
|
||||
string cmd = "UPDATE `" + DB_Tabel_Name + "` SET `" + Edit_colum + "`=\"" + Edit_Name + "\" WHERE `"+Search_Name+"`=\"" + Search_Data + "\";";
|
||||
cmd = cmd.Replace("|", "");
|
||||
return cmd;
|
||||
}
|
||||
/// <summary>
|
||||
/// 많은 곳의 데이터를 변화시키고 싶을때. 테이블명을 제외하곤 다 배열. Edit와 Search끼리의 배열 인덱스값이 각자 서로 같아야함.
|
||||
/// </summary>
|
||||
/// <param name="DB_Table_Name">바꿀 데이터가 있는 테이블명</param>
|
||||
/// <param name="Edit_col">대상 테이블명</param>
|
||||
/// <param name="Edit_name">바꿀 데이터값</param>
|
||||
/// <param name="Search_col">대상 테이블명</param>
|
||||
/// <param name="Search_Name">대상 데이터값</param>
|
||||
public string More_Update(String DB_Table_Name,
|
||||
String[] Edit_col, String[] Edit_name,
|
||||
String[] Search_col, String[] Search_Name, int limit = 0)
|
||||
{
|
||||
string cmd = "UPDATE `" + DB_Table_Name + "` SET ";
|
||||
for(int a = 0; a < Edit_col.Length; a++)
|
||||
{
|
||||
Edit_name[a] = Edit_name[a].Replace("\"", "\"\"");
|
||||
cmd += "`" + Edit_col[a] + "` = \"" + Edit_name[a] + "\"";
|
||||
if (a != Edit_col.Length - 1) { cmd += ", "; }
|
||||
else { cmd += " "; }
|
||||
}
|
||||
cmd += "WHERE ";
|
||||
for(int a = 0; a < Search_col.Length; a++)
|
||||
{
|
||||
cmd += "`" + Search_col[a] + "` = \"" + Search_Name[a] + "\" ";
|
||||
if (a != Search_col.Length - 1) { cmd += "AND "; }
|
||||
}
|
||||
if(limit != 0) { cmd += string.Format("LIMIT {0}", limit); }
|
||||
cmd += ";";
|
||||
cmd = cmd.Replace("|", "");
|
||||
return cmd;
|
||||
}
|
||||
/// <summary>
|
||||
/// DB에 회사이름을 검색하여 만약 있는 회사일 경우 False 반환 / 없을경우 True반환
|
||||
/// </summary>
|
||||
/// <param name="Search_Data">검색할 회사 명</param>
|
||||
/// <returns></returns>
|
||||
public bool chk_comp(string Search_Data)
|
||||
{
|
||||
string cmd = "SELECT `comp_name` FROM `Comp`;";
|
||||
// DB연결
|
||||
conn.Open();
|
||||
// 쿼리 맵핑
|
||||
sqlcmd.CommandText = cmd;
|
||||
// 쿼리 날릴 곳은 conn, 즉 아까 연결한 DB
|
||||
sqlcmd.Connection = conn;
|
||||
// 쿼리 날리기, sqlDataReader에 결과값 저장
|
||||
sd = sqlcmd.ExecuteReader();
|
||||
// 한줄씩 불러오기
|
||||
while (sd.Read())
|
||||
{
|
||||
for (int cout = 0; cout < sd.FieldCount; cout++)
|
||||
{
|
||||
if(sd[cout].ToString() == Search_Data) { conn.Close(); return false; }
|
||||
}
|
||||
}
|
||||
conn.Close();
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// SQL문을 직접 만들어서 작성하여 사용해야함. (단, DELETE문/UPDATE문은 사용하지말 것!)
|
||||
/// </summary>
|
||||
/// <param name="cmd">등록할 SQL문</param>
|
||||
/// <returns></returns>
|
||||
public string self_Made_Cmd(string cmd)
|
||||
{
|
||||
cmd = cmd.Replace("|", "");
|
||||
|
||||
string result = "";
|
||||
if (cmd.Contains("DELETE") == true || cmd.Contains("UPDATE") == true) { return ""; }
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
sqlcmd.CommandText = cmd;
|
||||
sqlcmd.Connection = conn;
|
||||
sd = sqlcmd.ExecuteReader();
|
||||
while (sd.Read())
|
||||
{
|
||||
for (int cout = 0; cout < sd.FieldCount; cout++)
|
||||
{
|
||||
result += sd[cout].ToString() + "|";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MessageBox.Show("{0} Exception caught.\n"+ e.ToString());
|
||||
MessageBox.Show(cmd);
|
||||
}
|
||||
conn.Close();
|
||||
return result;
|
||||
}
|
||||
|
||||
#region 추가
|
||||
|
||||
/// <summary>
|
||||
/// DBcon이 선진행되어야함. / SELECT * FROM DB_Table_Name WHERE DB_Where_Table = \"DB_Search_Data\";
|
||||
/// <summary>
|
||||
/// <param name="DB_Table_Name">테이블명</param>
|
||||
/// <param name="DB_Where_Table">검색할 테이블</param>
|
||||
/// <param name="DB_Search_Data">검색할 텍스트</param>
|
||||
/// <returns>검색된 결과값이 반환됨.</returns>
|
||||
public string DB_Search_Author(string DB_Table_Name, string Search_Area, string DB_Where_Table, string DB_Search_Data)
|
||||
{
|
||||
if (Search_Area == "") { Search_Area = "*"; }
|
||||
|
||||
string result = "";
|
||||
// SELECT * FROM `Author_Symbol` WHERE `Author` <= '겐서' ORDER BY `Author` DESC LIMIT 1
|
||||
string cmd = string.Format("SELECT `{0}` FROM `{1}` WHERE `{2}` <= \'{3}\' ORDER BY `{2}` DESC LIMIT 1;",
|
||||
Search_Area, DB_Table_Name, DB_Where_Table, DB_Search_Data);
|
||||
|
||||
// DB연결
|
||||
conn.Open();
|
||||
// 쿼리 맵핑
|
||||
sqlcmd.CommandText = cmd;
|
||||
// 쿼리 날릴 곳은 conn, 즉 아까 연결한 DB
|
||||
sqlcmd.Connection = conn;
|
||||
// 쿼리 날리기, sqlDataReader에 결과값 저장
|
||||
sd = sqlcmd.ExecuteReader();
|
||||
// 한줄씩 불러오기
|
||||
while (sd.Read())
|
||||
{
|
||||
for (int cout = 0; cout < sd.FieldCount; cout++)
|
||||
{
|
||||
result += sd[cout].ToString() + "|";
|
||||
}
|
||||
}
|
||||
conn.Close();
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// insert선 실행. 만약 값이 있을 경우 update로 전환
|
||||
/// </summary>
|
||||
/// <param name="Table"></param>
|
||||
/// <param name="InsertCol"></param>
|
||||
/// <param name="InsertData"></param>
|
||||
/// <returns></returns>
|
||||
public string DB_INSERT_DUPLICATE(string Table, string[] InsertCol, string[] InsertData)
|
||||
{
|
||||
string cmd = "INSERT INTO " + Table + "(";
|
||||
for (int a = 0; a < InsertCol.Length; a++)
|
||||
{
|
||||
if (a == InsertCol.Length - 1) { cmd += "`" + InsertCol[a] + "`) "; }
|
||||
else { cmd += "`" + InsertCol[a] + "`, "; }
|
||||
}
|
||||
cmd += "values(";
|
||||
for (int a = 0; a < InsertData.Length; a++)
|
||||
{
|
||||
InsertData[a] = InsertData[a].Replace("\"", "\"\"");
|
||||
if (a == InsertData.Length - 1) { cmd += "\"" + InsertData[a] + "\")"; }
|
||||
else { cmd += "\"" + InsertData[a] + "\", "; }
|
||||
}
|
||||
cmd = cmd.Replace("|", "");
|
||||
|
||||
cmd += "ON DUPLICATE KEY UPDATE";
|
||||
|
||||
string sub_cmd = "";
|
||||
for (int a = 0; a < InsertCol.Length; a++)
|
||||
{
|
||||
if (a == InsertCol.Length - 1)
|
||||
sub_cmd += string.Format("`{0}` = \"{1}\";", InsertCol[a], InsertData[a]);
|
||||
else
|
||||
sub_cmd += string.Format("`{0}` = \"{1}\",", InsertCol[a], InsertData[a]);
|
||||
}
|
||||
cmd += sub_cmd;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
3402
unimarc/unimarc/Skill.cs
Normal file
3402
unimarc/unimarc/Skill.cs
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
40
unimarc/unimarc/마크/Check_ISBN_Yes24.Designer.cs
generated
40
unimarc/unimarc/마크/Check_ISBN_Yes24.Designer.cs
generated
@@ -29,8 +29,8 @@ namespace UniMarc.마크
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
this.btn_change = new System.Windows.Forms.Button();
|
||||
this.btn_Close = new System.Windows.Forms.Button();
|
||||
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
||||
@@ -85,14 +85,14 @@ namespace UniMarc.마크
|
||||
this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Control;
|
||||
this.dataGridView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
|
||||
dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
|
||||
dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Control;
|
||||
dataGridViewCellStyle5.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
|
||||
dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.WindowText;
|
||||
dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle5;
|
||||
dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
|
||||
dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Control;
|
||||
dataGridViewCellStyle7.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
|
||||
dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.WindowText;
|
||||
dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle7;
|
||||
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.before_book_name,
|
||||
@@ -106,14 +106,14 @@ namespace UniMarc.마크
|
||||
this.dataGridView1.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGridView1.Name = "dataGridView1";
|
||||
this.dataGridView1.ReadOnly = true;
|
||||
dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
|
||||
dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Control;
|
||||
dataGridViewCellStyle6.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
|
||||
dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.WindowText;
|
||||
dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.dataGridView1.RowHeadersDefaultCellStyle = dataGridViewCellStyle6;
|
||||
dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
|
||||
dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Control;
|
||||
dataGridViewCellStyle8.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
|
||||
dataGridViewCellStyle8.ForeColor = System.Drawing.SystemColors.WindowText;
|
||||
dataGridViewCellStyle8.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle8.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.dataGridView1.RowHeadersDefaultCellStyle = dataGridViewCellStyle8;
|
||||
this.dataGridView1.RowHeadersWidth = 30;
|
||||
this.dataGridView1.RowTemplate.Height = 23;
|
||||
this.dataGridView1.Size = new System.Drawing.Size(579, 666);
|
||||
@@ -242,7 +242,7 @@ namespace UniMarc.마크
|
||||
//
|
||||
// tb_PW
|
||||
//
|
||||
this.tb_PW.Location = new System.Drawing.Point(761, 12);
|
||||
this.tb_PW.Location = new System.Drawing.Point(754, 12);
|
||||
this.tb_PW.Name = "tb_PW";
|
||||
this.tb_PW.Size = new System.Drawing.Size(100, 21);
|
||||
this.tb_PW.TabIndex = 6;
|
||||
@@ -259,7 +259,7 @@ namespace UniMarc.마크
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(736, 16);
|
||||
this.label2.Location = new System.Drawing.Point(729, 16);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(23, 12);
|
||||
this.label2.TabIndex = 7;
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace UniMarc.마크
|
||||
{
|
||||
int count = isbn.dataGridView1.Rows.Count;
|
||||
|
||||
for(int a= 0; a < count; a++)
|
||||
for (int a = 0; a < count; a++)
|
||||
{
|
||||
string book_name = isbn.dataGridView1.Rows[a].Cells["book_name"].Value.ToString();
|
||||
string author = isbn.dataGridView1.Rows[a].Cells["author"].Value.ToString();
|
||||
@@ -67,7 +67,7 @@ namespace UniMarc.마크
|
||||
string[] grid = {
|
||||
book_name, Replace_target(book_name, "book_name"),
|
||||
author, Replace_target(author, "author"),
|
||||
book_comp, Replace_target(book_comp, "book_comp"),
|
||||
book_comp, Replace_target(book_comp, "book_comp"),
|
||||
unit
|
||||
};
|
||||
dataGridView1.Rows.Add(grid);
|
||||
|
||||
@@ -163,14 +163,12 @@ namespace WindowsFormsApp1.Mac
|
||||
|
||||
if (row < 0) return;
|
||||
|
||||
string idx = dataGridView1.Rows[row].Cells["idx"].Value.ToString();
|
||||
|
||||
if (dataGridView1.Rows[row].Cells[col].ReadOnly) {
|
||||
string[] Marc = {
|
||||
dataGridView1.Rows[row].Cells["marc"].Value.ToString(),
|
||||
dataGridView1.Rows[row].Cells["midx"].Value.ToString(),
|
||||
dataGridView1.Rows[row].Cells["num"].Value.ToString(),
|
||||
idx,
|
||||
dataGridView1.Rows[row].Cells["idx"].Value.ToString(),
|
||||
dataGridView1.Rows[row].Cells["ISBN"].Value.ToString()
|
||||
};
|
||||
string[] symbol_Type = {
|
||||
|
||||
@@ -733,7 +733,7 @@ namespace UniMarc.마크
|
||||
this.etcBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.etcBox1.Location = new System.Drawing.Point(4, 4);
|
||||
this.etcBox1.Name = "etcBox1";
|
||||
this.etcBox1.Size = new System.Drawing.Size(233, 218);
|
||||
this.etcBox1.Size = new System.Drawing.Size(233, 220);
|
||||
this.etcBox1.TabIndex = 0;
|
||||
this.etcBox1.Text = "";
|
||||
//
|
||||
@@ -741,7 +741,7 @@ namespace UniMarc.마크
|
||||
//
|
||||
this.etcBox2.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.etcBox2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.etcBox2.Location = new System.Drawing.Point(4, 229);
|
||||
this.etcBox2.Location = new System.Drawing.Point(4, 231);
|
||||
this.etcBox2.Name = "etcBox2";
|
||||
this.etcBox2.Size = new System.Drawing.Size(233, 223);
|
||||
this.etcBox2.TabIndex = 0;
|
||||
@@ -754,19 +754,19 @@ namespace UniMarc.마크
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tableLayoutPanel1.Controls.Add(this.etcBox2, 0, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(this.etcBox1, 0, 0);
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(859, 267);
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(859, 266);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.RowCount = 2;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 229F));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(241, 456);
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(241, 458);
|
||||
this.tableLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// Marc_Plan_Sub_MarcEdit
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1109, 736);
|
||||
this.ClientSize = new System.Drawing.Size(1111, 736);
|
||||
this.Controls.Add(this.tableLayoutPanel1);
|
||||
this.Controls.Add(this.panel4);
|
||||
this.Controls.Add(this.panel2);
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace UniMarc.마크
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.tb_Search = new System.Windows.Forms.TextBox();
|
||||
this.cb_gu = new System.Windows.Forms.ComboBox();
|
||||
@@ -92,20 +92,20 @@ namespace UniMarc.마크
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(105, 6);
|
||||
this.label2.Location = new System.Drawing.Point(103, 6);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(29, 12);
|
||||
this.label2.Size = new System.Drawing.Size(33, 12);
|
||||
this.label2.TabIndex = 0;
|
||||
this.label2.Text = "검색";
|
||||
this.label2.Text = "검 색";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(6, 6);
|
||||
this.label1.Location = new System.Drawing.Point(4, 6);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(29, 12);
|
||||
this.label1.Size = new System.Drawing.Size(33, 12);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "구분";
|
||||
this.label1.Text = "구 분";
|
||||
//
|
||||
// btn_Search
|
||||
//
|
||||
@@ -172,14 +172,14 @@ namespace UniMarc.마크
|
||||
this.dataGridView1.AllowUserToAddRows = false;
|
||||
this.dataGridView1.AllowUserToDeleteRows = false;
|
||||
this.dataGridView1.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
|
||||
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
|
||||
dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control;
|
||||
dataGridViewCellStyle2.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
|
||||
dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText;
|
||||
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
|
||||
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
|
||||
dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control;
|
||||
dataGridViewCellStyle4.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
|
||||
dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText;
|
||||
dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4;
|
||||
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.idx,
|
||||
@@ -263,7 +263,6 @@ namespace UniMarc.마크
|
||||
//
|
||||
// btn_OpenFile
|
||||
//
|
||||
this.btn_OpenFile.Enabled = false;
|
||||
this.btn_OpenFile.Location = new System.Drawing.Point(680, 1);
|
||||
this.btn_OpenFile.Name = "btn_OpenFile";
|
||||
this.btn_OpenFile.Size = new System.Drawing.Size(61, 29);
|
||||
@@ -288,6 +287,8 @@ namespace UniMarc.마크
|
||||
this.ClientSize = new System.Drawing.Size(805, 357);
|
||||
this.Controls.Add(this.panel3);
|
||||
this.Controls.Add(this.panel2);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "Marc_Plan_Sub_SelectList";
|
||||
this.Text = "마크정리_목록선택";
|
||||
this.Load += new System.EventHandler(this.Marc_Plan_Sub_SelectList_Load);
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace UniMarc.마크
|
||||
try
|
||||
{
|
||||
System.IO.StreamReader r = new System.IO.StreamReader(filePath, Encoding.Default);
|
||||
InputGrid(r.ReadToEnd());
|
||||
InputGridByFileData(r.ReadToEnd());
|
||||
r.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -239,17 +239,60 @@ namespace UniMarc.마크
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region OpenFileSub
|
||||
|
||||
void InputGrid(string text)
|
||||
void InputGridByFileData(string text)
|
||||
{
|
||||
String_Text st = new String_Text();
|
||||
|
||||
/* "TODO: 마크 파일 내 마크만 표출하여 수정할 수 있게 추가작업 시작할 것."
|
||||
1. 목록을 만든다. (목록명은 파일명)
|
||||
ㄴ> 굳이 저장해서 더 보관할 필요가 있을까? 파일이 있는데?
|
||||
|
||||
2. 마크 파일내의 마크만 표출한다. ****
|
||||
ㄴ> 현재 소스파일 분석결과 idx가 없을 경우 몇몇 기능에 장애가 생김.
|
||||
ㄴ> 만약 저장기능만 제외하고 전부 쓸 수 있게 변경이 된다면?
|
||||
ㄴ> 현재로썬 가장 가능성있음. DB에 저장할 필요 자체가 없이 로컬로 작업하는 것도 필요하다고 느낌.
|
||||
*/
|
||||
|
||||
string[] grid = text.Split('');
|
||||
for (int a = 0; a < grid.Length - 1; a++)
|
||||
{
|
||||
string[] Search = {
|
||||
// 등록번호, 분류기호, 저자기호, 볼륨v, 복본c, 별치f
|
||||
"049i", "090a", "090b", "049v", "049c", "049f",
|
||||
// ISBN, 도서명, 총서명1, 총서번호1, 총서명2, 총서번호2, 출판사, 정가
|
||||
"020a", "245a", "440a", "440n", "490a", "490n", "260b", "950b" };
|
||||
string[] Search_Res = st.Take_Tag(grid[a], Search);
|
||||
|
||||
|
||||
string[] Author_Search = { "100a", "110", "111a" };
|
||||
string[] Author_Res = st.Take_Tag(grid[a], Author_Search);
|
||||
string author_Fin = "";
|
||||
foreach (string author in Author_Res)
|
||||
{
|
||||
if (author != "") {
|
||||
author_Fin = author;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
string[] AddGrid = {
|
||||
// idx, 연번, 등록번호, 분류, 저자기호
|
||||
"", "", Search_Res[0], Search_Res[1], Search_Res[2],
|
||||
// 볼륨v, 복본c, 별치f, 구분, isbn
|
||||
Search_Res[3], Search_Res[4], Search_Res[5], "", Search_Res[6],
|
||||
// 도서명, 총서명1, 총서번호1, 총서명1, 총서번호2
|
||||
Search_Res[7], Search_Res[8], Search_Res[9], Search_Res[10], Search_Res[11],
|
||||
// 저자, 출판사, 정가, midx, 마크
|
||||
author_Fin, Search_Res[12], Search_Res[13], "", grid[a],
|
||||
// 검색태그
|
||||
"" };
|
||||
mp.dataGridView1.Rows.Add(AddGrid);
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void btn_Close_Click(object sender, EventArgs e)
|
||||
|
||||
4
unimarc/unimarc/마크/Search_Infor.Designer.cs
generated
4
unimarc/unimarc/마크/Search_Infor.Designer.cs
generated
@@ -112,7 +112,7 @@
|
||||
this.dataGridView1.RowHeadersWidth = 20;
|
||||
this.dataGridView1.RowTemplate.Height = 23;
|
||||
this.dataGridView1.Size = new System.Drawing.Size(1449, 630);
|
||||
this.dataGridView1.TabIndex = 49;
|
||||
this.dataGridView1.TabIndex = 0;
|
||||
this.dataGridView1.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellDoubleClick);
|
||||
//
|
||||
// idx
|
||||
@@ -278,7 +278,7 @@
|
||||
this.panel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(1449, 36);
|
||||
this.panel1.TabIndex = 54;
|
||||
this.panel1.TabIndex = 0;
|
||||
//
|
||||
// panel5
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user