Files
Unimarc/unimarc/unimarc/마크/Mac_List_Add.cs
SeungHo Yang 87365c903e =====* UniMarc [0.0129] 버전 업데이트 내용 *=====
** ERP 작업 전면 중단 (마크우선) **
*** 마크작성 - 칸채우기 버그 수정을 위해 테스트 계정 제외하고 잠금***

1. 마크 목록
ㄴ> 목록 삭제할 경우 버그 수정.
  ㄴ> 도서 1개만 삭제되고 DB에 계속 남아있는 버그 수정.

2. 마크 목록 생성
ㄴ> 기존 목록을 유지할지 제거할지 선택할 경우 삭제및 수정에 대한 버그 수정.

3. 복본조사
ㄴ> 리미트 500권에서 10,000권으로 증가.

4. 마크 작성
ㄴ> 시방서 마크목록 생성이 안되는 버그 수정.
ㄴ> 칸채우기 버그 수정을 위해 테스트 계정 제외하고 잠금.
ㄴ> 외부마크 저장시 덮어씌워 저장되는 버그 수정.
2022-02-17 17:39:07 +09:00

181 lines
6.4 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WindowsFormsApp1;
namespace UniMarc.
{
public partial class Mac_List_Add : Form
{
Helper_DB db = new Helper_DB();
Skill_Grid sg = new Skill_Grid();
public Mac_List_Add()
{
InitializeComponent();
}
private void Mac_List_Add_Load(object sender, EventArgs e)
{
db.DBcon();
string compidx = Properties.Settings.Default.compidx;
string MyName = Properties.Settings.Default.User;
string CompQuery = string.Format("SELECT `comp_name` FROM `Comp` WHERE `idx` = {0}", compidx);
string cmd = string.Format("SELECT `name` FROM `User_Data` WHERE `affil` = ({0});", CompQuery);
string[] cmdResult = db.DB_Send_CMD_Search(cmd).Split('|');
foreach (string UserName in cmdResult)
{
if (UserName != "")
cb_User.Items.Add(UserName);
}
cb_User.SelectedItem = MyName;
}
private void Delivery_TextChanged(object sender, EventArgs e)
{
string divComp = tb_divComp.Text;
string divName = tb_divName.Text;
string ListName = string.Format("[{0}]{1}", divComp, divName);
tb_ExpectList.Text = ListName;
}
private void btn_Empty_Click(object sender, EventArgs e)
{
tb_divComp.Text = "";
tb_divName.Text = "";
dataGridView1.Rows.Clear();
}
private void btn_AddList_Click(object sender, EventArgs e)
{
string compidx = Properties.Settings.Default.compidx;
string Today = DateTime.Now.ToString("yyyy-MM-dd");
string listName = tb_ExpectList.Text;
string charge = cb_User.Text;
if (!CopyCheck(compidx, listName, Today)) {
MessageBox.Show("목록이 중복되었습니다! 다시 확인해주세요.", "Error");
return;
}
string InBook_Area = "`compidx`, `list_name`, `date`, `header`, `num`, " +
"`book_name`, `author`, `book_comp`, `pay`, `count`, " +
"`total`, `isbn_marc`";
List<string> InBook_List = new List<string>();
for (int a = 0; a < dataGridView1.Rows.Count; a++)
{
GridNotNull(a);
if (dataGridView1.Rows[a].Cells["BookName"].Value.ToString() == "")
break;
string header = dataGridView1.Rows[a].Cells["header"].Value.ToString();
string num = dataGridView1.Rows[a].Cells["num"].Value.ToString();
string bookname = dataGridView1.Rows[a].Cells["BookName"].Value.ToString();
string author = dataGridView1.Rows[a].Cells["Author"].Value.ToString();
string bookcomp = dataGridView1.Rows[a].Cells["BookComp"].Value.ToString();
string price = dataGridView1.Rows[a].Cells["Price"].Value.ToString().Replace(",", "");
string count = dataGridView1.Rows[a].Cells["Count"].Value.ToString().Replace(",", "");
string total = dataGridView1.Rows[a].Cells["Total"].Value.ToString().Replace(",", "");
string isbn = dataGridView1.Rows[a].Cells["ISBN"].Value.ToString();
string tmp = string.Format(
"(\"{0}\", \"{1}\", \"{2}\", \"{3}\", \"{4}\", " +
"\"{5}\", \"{6}\", \"{7}\", \"{8}\", \"{9}\", " +
"\"{10}\", \"{11}\")",
compidx, listName, Today, header, num,
bookname, author, bookcomp, price, count,
total, isbn );
InBook_List.Add(tmp);
}
int TotalCount = InBook_List.Count;
string[] InList_Tbl = { "comp_num", "date", "list_name", "m_charge", "state", "vol", "chk_marc" };
string[] InList_Col = { compidx, Today, listName, charge, "진행", TotalCount.ToString(), "1" };
string InList_Cmd = db.DB_INSERT("Obj_List", InList_Tbl, InList_Col);
string InBook_Col = string.Join(", ", InBook_List);
string InBook_Cmd = string.Format("INSERT INTO `Obj_List_Book` ({0}) VALUES {1};", InBook_Area, InBook_Col);
db.DB_Send_CMD_reVoid(InList_Cmd);
db.DB_Send_CMD_reVoid(InBook_Cmd);
MessageBox.Show("저장되었습니다!");
}
#region AddList_Sub
/// <summary>
/// INSERT할 목록 중복체크
/// </summary>
/// <param name="compidx"></param>
/// <param name="listName"></param>
/// <param name="date"></param>
/// <returns></returns>
bool CopyCheck(string compidx, string listName, string date)
{
string cmd = string.Format(
"SELECT `list_name` " +
"FROM `Obj_List` " +
"WHERE `comp_num` = \"{0}\" " +
"AND `list_name` = \"{1}\" " +
"AND `date` = \"{2}\";", compidx, listName, date);
string cmdResult = db.DB_Send_CMD_Search(cmd);
if (cmdResult.Length > 2)
return false;
return true;
}
/// <summary>
/// Grid에서 Null인 부분을 ""로 바꿔줌
/// </summary>
/// <param name="row">rowIndex</param>
void GridNotNull(int row)
{
for (int a = 0; a < dataGridView1.Columns.Count; a++)
{
if (dataGridView1.Columns[a].Name == "Count")
dataGridView1.Rows[row].Cells[a].Value = "1";
if (dataGridView1.Rows[row].Cells[a].Value == null)
dataGridView1.Rows[row].Cells[a].Value = "";
}
}
#endregion
private void btn_Close_Click(object sender, EventArgs e)
{
this.Close();
}
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
sg.Print_Grid_Num(sender, e);
}
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
sg.Excel_to_DataGridView(sender, e);
}
}
}