프로젝트에 category 추가, 컬럼명을 한글로 변경
This commit is contained in:
425
SubProject/FLG0000/LogSMTRepare/Add.cs
Normal file
425
SubProject/FLG0000/LogSMTRepare/Add.cs
Normal file
@@ -0,0 +1,425 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace FLG0000.LogData
|
||||
{
|
||||
public partial class Add : Form
|
||||
{
|
||||
|
||||
BindingSource bsManu;
|
||||
BindingSource bsModel;
|
||||
DSLog.Log_SMTRepare_DataRow dr;
|
||||
public Boolean repeatAdd = false;
|
||||
|
||||
public Add(DSLog.Log_SMTRepare_DataRow dr_)
|
||||
{
|
||||
InitializeComponent();
|
||||
bsManu = new BindingSource();
|
||||
bsModel = new BindingSource();
|
||||
this.dr = dr_;
|
||||
this.KeyPreview = true;
|
||||
this.StartPosition = FormStartPosition.CenterScreen;
|
||||
this.KeyDown += (s1, e1) =>
|
||||
{
|
||||
if (e1.KeyCode == Keys.Escape) this.Close();
|
||||
};
|
||||
|
||||
foreach (Control ctl in this.Controls)
|
||||
{
|
||||
if (ctl.GetType() == typeof(TextBox) || ctl.GetType() == typeof(ComboBox))
|
||||
{
|
||||
ctl.KeyDown += ctl_KeyDown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void __Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
////장비제조
|
||||
//var dt_dept = FCOMMON.DBM.getCodeTable("06");
|
||||
//bsManu.DataSource = dt_dept;
|
||||
//this.cbEQManu.DisplayMember = "Value";
|
||||
//this.cbEQManu.ValueMember = "Value";
|
||||
//this.cbEQManu.DataSource = bsManu;
|
||||
|
||||
dtPdate.Value = DateTime.Parse(dr.pdate);
|
||||
|
||||
tbLocation.Text = dr.location;
|
||||
tbReason.Text = dr.reason;
|
||||
tbResult.Text = dr.result;
|
||||
|
||||
tbLocation.Tag = tbLocation.Text;
|
||||
tbReason.Tag = tbReason.Text;
|
||||
tbResult.Tag = tbResult.Text;
|
||||
|
||||
tbRemark.Text = dr.remark;
|
||||
|
||||
this.Show();
|
||||
Application.DoEvents();
|
||||
textBox1.Focus();
|
||||
|
||||
}
|
||||
|
||||
void ctl_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
{
|
||||
Control ctl = sender as Control;
|
||||
string nm = ctl.Name.ToLower();
|
||||
string search = ctl.Text.Trim();
|
||||
|
||||
Console.WriteLine("inner keydown " + nm + ":" + search);
|
||||
|
||||
switch (nm)
|
||||
{
|
||||
case "tblocation":
|
||||
if (search == "")
|
||||
Lov_Location(search, false);
|
||||
else if (search.Contains("L")) //바코드입력
|
||||
{
|
||||
var itemList = taItem.GetData(FCOMMON.info.Login.gcode);
|
||||
var grpdata = itemList.Where(t => t.Barcode == search).FirstOrDefault(); // taItem.GetByBarcode(FCOMMON.info.Login.gcode, search);// FCOMMON.DBM.getCodeBySvalue("19", search);
|
||||
if (grpdata != null )
|
||||
{
|
||||
if (grpdata.code.Length > 6)
|
||||
{
|
||||
//각 깊이별 이름을 다 가져와야한다
|
||||
System.Text.StringBuilder sb = new StringBuilder();
|
||||
int itemCount = (int)((grpdata.code.Length - 6) / 2.0);
|
||||
for (int i = 6; i <= grpdata.code.Length; i += 2)
|
||||
{
|
||||
var codeStr = grpdata.code.Substring(0, i);
|
||||
var codeData = itemList.Where(t => t.code == codeStr).FirstOrDefault();// FCOMMON.DBM.getCodeByCode("19", codeStr);
|
||||
if (codeData != null)
|
||||
{
|
||||
if (sb.Length > 0) sb.Append('|');
|
||||
sb.Append(codeData.Title.Replace("|", ""));
|
||||
}
|
||||
}
|
||||
ctl.Text = sb.ToString();
|
||||
ctl.Tag = ctl.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
ctl.Text = grpdata.Title;
|
||||
ctl.Tag = ctl.Text;
|
||||
}
|
||||
SendKeys.Send("{TAB}");
|
||||
}
|
||||
else Lov_Location(search, false);
|
||||
}
|
||||
break;
|
||||
case "tbreason":
|
||||
if (search == "")
|
||||
Lov_Reason(search, false);
|
||||
else if (search.StartsWith("L")) //바코드입력
|
||||
{
|
||||
var itemList = taItem.GetData(FCOMMON.info.Login.gcode);
|
||||
var grpdata = itemList.Where(t => t.Barcode == search).FirstOrDefault(); // taItem.GetByBarcode(FCOMMON.info.Login.gcode, search);// FCOMMON.DBM.getCodeBySvalue("19", search);
|
||||
if (grpdata != null)
|
||||
{
|
||||
if (grpdata.code.Length > 6)
|
||||
{
|
||||
//각 깊이별 이름을 다 가져와야한다
|
||||
System.Text.StringBuilder sb = new StringBuilder();
|
||||
int itemCount = (int)((grpdata.code.Length - 6) / 2.0);
|
||||
for (int i = 6; i <= grpdata.code.Length; i += 2)
|
||||
{
|
||||
var codeStr = grpdata.code.Substring(0, i);
|
||||
var codeData = itemList.Where(t => t.code == codeStr).FirstOrDefault();// FCOMMON.DBM.getCodeByCode("19", codeStr);
|
||||
if (codeData != null)
|
||||
{
|
||||
if (sb.Length > 0) sb.Append('|');
|
||||
sb.Append(codeData.Title.Replace("|", ""));
|
||||
}
|
||||
}
|
||||
ctl.Text = sb.ToString();
|
||||
ctl.Tag = ctl.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
ctl.Text = grpdata.Title;
|
||||
ctl.Tag = ctl.Text;
|
||||
}
|
||||
SendKeys.Send("{TAB}");
|
||||
}
|
||||
else Lov_Reason(search, false);
|
||||
}
|
||||
break;
|
||||
case "tbresult":
|
||||
if (search.StartsWith("L"))
|
||||
{
|
||||
var itemList = taItem.GetData(FCOMMON.info.Login.gcode);
|
||||
var grpdata = itemList.Where(t => t.Barcode == search).FirstOrDefault(); // taItem.GetByBarcode(FCOMMON.info.Login.gcode, search);// FCOMMON.DBM.getCodeBySvalue("19", search);
|
||||
if (grpdata != null)
|
||||
{
|
||||
if (grpdata.code.Length > 6)
|
||||
{
|
||||
//각 깊이별 이름을 다 가져와야한다
|
||||
System.Text.StringBuilder sb = new StringBuilder();
|
||||
int itemCount = (int)((grpdata.code.Length - 6) / 2.0);
|
||||
for (int i = 6; i <= grpdata.code.Length; i += 2)
|
||||
{
|
||||
var codeStr = grpdata.code.Substring(0, i);
|
||||
var codeData = itemList.Where(t => t.code == codeStr).FirstOrDefault();// FCOMMON.DBM.getCodeByCode("19", codeStr);
|
||||
if (codeData != null)
|
||||
{
|
||||
if (sb.Length > 0) sb.Append('|');
|
||||
sb.Append(codeData.Title.Replace("|", ""));
|
||||
}
|
||||
}
|
||||
ctl.Text = sb.ToString();
|
||||
ctl.Tag = ctl.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
ctl.Text = grpdata.Title;
|
||||
ctl.Tag = ctl.Text;
|
||||
}
|
||||
btSave.Focus();
|
||||
}
|
||||
else Lov_Result(search, false);
|
||||
}
|
||||
else if (search != "")
|
||||
Lov_Result(search, false);
|
||||
break;
|
||||
default:
|
||||
SendKeys.Send("{TAB}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void linkLabel5_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
Lov_Location("", true);
|
||||
}
|
||||
|
||||
void Lov_Location(string search, Boolean allowAll)
|
||||
{
|
||||
var f = new Lov_LogItem("00", "00");
|
||||
if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
if (f.tbItem.Text.Trim() != "")
|
||||
this.tbLocation.Text = string.Format("{0}|{1}", f.tbGrp.Text, f.tbItem.Text);
|
||||
else
|
||||
this.tbLocation.Text = f.tbGrp.Text.Trim();
|
||||
this.tbLocation.Tag = this.tbLocation.Text;
|
||||
}
|
||||
}
|
||||
void Lov_Reason(string search, Boolean allowAll)
|
||||
{
|
||||
var f = new Lov_LogItem("00", "01");
|
||||
if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
if (f.tbItem.Text.Trim() != "")
|
||||
this.tbReason.Text = string.Format("{0}|{1}", f.tbGrp.Text, f.tbItem.Text);
|
||||
else
|
||||
this.tbReason.Text = f.tbGrp.Text.Trim();
|
||||
this.tbReason.Tag = this.tbReason.Text;
|
||||
}
|
||||
}
|
||||
void Lov_Result(string search, Boolean allowAll)
|
||||
{
|
||||
var f = new Lov_LogItem("00", "02");
|
||||
if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
if (f.tbItem.Text.Trim() != "")
|
||||
this.tbResult.Text = string.Format("{0}|{1}", f.tbGrp.Text, f.tbItem.Text);
|
||||
else
|
||||
this.tbResult.Text = f.tbGrp.Text.Trim();
|
||||
this.tbResult.Tag = this.tbResult.Text;
|
||||
}
|
||||
}
|
||||
private bool saveData()
|
||||
{
|
||||
this.Validate();
|
||||
|
||||
if (tbLocation.Text.isEmpty())
|
||||
{
|
||||
FCOMMON.Util.MsgE("위치정보가 없습니다.");
|
||||
tbLocation.Focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tbReason.Text == "")
|
||||
{
|
||||
FCOMMON.Util.MsgE("원인을 입력하세요.");
|
||||
tbReason.Focus();
|
||||
return false;
|
||||
}
|
||||
//if (tbResult.Text == "")
|
||||
//{
|
||||
// FCOMMON.Util.MsgE("결과를 입력하세요.");
|
||||
// tbResult.Focus();
|
||||
// return false;
|
||||
//}
|
||||
|
||||
var itemList = taItem.GetData(FCOMMON.info.Login.gcode);
|
||||
|
||||
//임의 기록데이터가 있다면 신규 목록을 추가 한다.
|
||||
if (tbLocation.Text != tbLocation.Tag.ToString())
|
||||
{
|
||||
|
||||
var list = tbLocation.Text.Split('|');
|
||||
int depth = 0;
|
||||
string codeHeader = "";
|
||||
string baseCode = "00" + "00"; //location 은 00,reason 01, 조치 02
|
||||
for (int i = 0; i < list.Length; i++)
|
||||
{
|
||||
var strData = list[i];
|
||||
if (strData.Trim() == "") continue;
|
||||
|
||||
//이 데이터가 존재하지 않으면 추가한다.
|
||||
var existData = itemList.Where(t => t.Title == strData).FirstOrDefault(); // FCOMMON.DBM.getCodeByMemo("19", strData);
|
||||
if (existData != null && existData.code.StartsWith(baseCode)) baseCode = existData.code;
|
||||
else
|
||||
{
|
||||
//없으므로 신규추가해준다.
|
||||
int codeLen = 6 + depth * 2;
|
||||
var filterStr = string.Format("code like '{0}%' and len(code) = {1}", baseCode.Substring(0, codeLen - 2), codeLen);
|
||||
var preList = itemList.Select(filterStr, "code desc");
|
||||
var newCode = "";
|
||||
if (preList.Length == 0)
|
||||
{
|
||||
newCode = baseCode + "00";
|
||||
}
|
||||
else
|
||||
{
|
||||
//동일코드가 하나도 없다.
|
||||
var lastCode = preList[0]["code"].ToString();
|
||||
var lastNo = lastCode.Substring(baseCode.Length, 2);
|
||||
newCode = baseCode + string.Format("{0:00}", int.Parse(lastNo) + 1);
|
||||
}
|
||||
|
||||
taItem.Insert(FCOMMON.info.Login.gcode, newCode, strData, "LA" + newCode, "", FCOMMON.info.Login.no, DateTime.Now);
|
||||
//FCOMMON.DBM.insertCommonCode("19", newCode, strData, "LA" + newCode);
|
||||
baseCode = newCode;
|
||||
}
|
||||
depth += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (this.tbReason.Text != tbReason.Tag.ToString())
|
||||
{
|
||||
|
||||
var list = tbReason.Text.Split('|');
|
||||
int depth = 0;
|
||||
string codeHeader = "";
|
||||
string baseCode = "00" + "01"; //location 은 00,reason 01, 조치 02
|
||||
for (int i = 0; i < list.Length; i++)
|
||||
{
|
||||
var strData = list[i];
|
||||
if (strData.Trim() == "") continue;
|
||||
|
||||
//이 데이터가 존재하지 않으면 추가한다.
|
||||
var existData = FCOMMON.DBM.getCodeByMemo("19", strData);
|
||||
if (existData.title != "" && existData.code.StartsWith(baseCode)) baseCode = existData.code;
|
||||
else
|
||||
{
|
||||
//없으므로 신규추가해준다.
|
||||
int codeLen = 6 + depth * 2;
|
||||
var filterStr = string.Format("code like '{0}%' and len(code) = {1}", baseCode.Substring(0, codeLen - 2), codeLen);
|
||||
var preList = itemList.Select(filterStr, "code desc");
|
||||
var newCode = "";
|
||||
if (preList.Length == 0)
|
||||
{
|
||||
newCode = baseCode + "00";
|
||||
}
|
||||
else
|
||||
{
|
||||
//동일코드가 하나도 없다.
|
||||
var lastCode = preList[0]["code"].ToString();
|
||||
var lastNo = lastCode.Substring(baseCode.Length, 2);
|
||||
newCode = baseCode + string.Format("{0:00}", int.Parse(lastNo) + 1);
|
||||
}
|
||||
taItem.Insert(FCOMMON.info.Login.gcode, newCode, strData, "LB" + newCode, "", FCOMMON.info.Login.no, DateTime.Now);
|
||||
// FCOMMON.DBM.insertCommonCode("19", newCode, strData, "LB" + newCode);
|
||||
baseCode = newCode;
|
||||
}
|
||||
depth += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.tbResult.Text != tbResult.Tag.ToString())
|
||||
{
|
||||
|
||||
var list = tbReason.Text.Split('|');
|
||||
int depth = 0;
|
||||
string codeHeader = "";
|
||||
string baseCode = "00" + "02"; //location 은 00,reason 01, 조치 02
|
||||
for (int i = 0; i < list.Length; i++)
|
||||
{
|
||||
var strData = list[i];
|
||||
if (strData.Trim() == "") continue;
|
||||
|
||||
//이 데이터가 존재하지 않으면 추가한다.
|
||||
var existData = FCOMMON.DBM.getCodeByMemo("19", strData);
|
||||
if (existData.title != "" && existData.code.StartsWith(baseCode)) baseCode = existData.code;
|
||||
else
|
||||
{
|
||||
//없으므로 신규추가해준다.
|
||||
int codeLen = 6 + depth * 2;
|
||||
var filterStr = string.Format("code like '{0}%' and len(code) = {1}", baseCode.Substring(0, codeLen - 2), codeLen);
|
||||
var preList = itemList.Select(filterStr, "code desc");
|
||||
var newCode = "";
|
||||
if (preList.Length == 0)
|
||||
{
|
||||
newCode = baseCode + "00";
|
||||
}
|
||||
else
|
||||
{
|
||||
//동일코드가 하나도 없다.
|
||||
var lastCode = preList[0]["code"].ToString();
|
||||
var lastNo = lastCode.Substring(baseCode.Length, 2);
|
||||
newCode = baseCode + string.Format("{0:00}", int.Parse(lastNo) + 1);
|
||||
}
|
||||
taItem.Insert(FCOMMON.info.Login.gcode, newCode, strData, "LC" + newCode, "", FCOMMON.info.Login.no, DateTime.Now);
|
||||
//FCOMMON.DBM.insertCommonCode("19", newCode, strData, "LC" + newCode);
|
||||
baseCode = newCode;
|
||||
}
|
||||
depth += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dr.gcode = FCOMMON.info.Login.gcode;
|
||||
dr.pdate = this.dtPdate.Value.ToShortDateString();
|
||||
dr.location = tbLocation.Text.Trim().Replace("|", "");
|
||||
dr.reason = tbReason.Text.Trim().Replace("|", "");
|
||||
dr.result = tbResult.Text.Trim().Replace("|", "");
|
||||
dr.remark = tbRemark.Text.Trim();
|
||||
dr.EndEdit();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!saveData()) return;
|
||||
DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
}
|
||||
|
||||
|
||||
private void linkLabel6_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
//lov 공급처
|
||||
Lov_Reason("", true);
|
||||
}
|
||||
|
||||
private void linkLabel7_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
//lov 프로젝트
|
||||
Lov_Result("", true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user