구매 엑셀 업로드 기능 완료 및 메뉴얼 작성

This commit is contained in:
chi
2023-08-02 15:38:02 +09:00
parent d8ddd7cfa7
commit 20e36a3624
16 changed files with 924 additions and 640 deletions

View File

@@ -1,4 +1,5 @@
using System;
using FCOMMON;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@@ -12,12 +13,56 @@ namespace FEQ0000
public partial class fPurchase_excelimport : Form
{
BindingSource bsModel;
public fPurchase_excelimport()
bool crmode = false;
public fPurchase_excelimport(bool cr)
{
InitializeComponent();
Properties.Settings.Default["gwcs"] = FCOMMON.info.CS;
Properties.Settings.Default["EEEntities"] = FCOMMON.info.CS;
this.FormClosed += __Closed;
crmode = cr;
this.Text = $"구매내역 가져오기({(crmode ? "CR" : "NR")})";
if (cr == true)
{
cbProcess.Enabled = false;
cbManuProc.Enabled = false;
cbEQManu.Enabled = false;
cbEQModel.Enabled = false;
assetLabel.Visible = false;
label22.Visible = false;
label23.Visible = false;
processLabel.Visible = false;
}
else
{
//장비제조
var dt_dept = FCOMMON.DBM.getCodeTable("06");
BindingSource bsManu = new BindingSource(dt_dept, "");
this.cbEQManu.DisplayMember = "Value";
this.cbEQManu.ValueMember = "Value";
this.cbEQManu.DataSource = bsManu;
//장비모델
var dt_asset = FCOMMON.DBM.getCodeTable("07");
bsModel = new BindingSource(dt_asset, "");
bsModel.Filter = "svalue='그런거없다'";
this.cbEQModel.DisplayMember = "Value";
this.cbEQModel.ValueMember = "Value";
this.cbEQModel.DataSource = bsModel;
//제조공정
var dt_manuproc = FCOMMON.DBM.getCodeTable("08");
this.cbManuProc.DisplayMember = "Value";
this.cbManuProc.ValueMember = "Value";
this.cbManuProc.DataSource = dt_manuproc;
//장비기술공정
var dt_eetproc = FCOMMON.DBM.getCodeTable("09");
this.cbProcess.DisplayMember = "Value";
this.cbProcess.ValueMember = "Value";
this.cbProcess.DataSource = dt_eetproc;
}
}
private void __Load(object sender, EventArgs e)
@@ -28,72 +73,21 @@ namespace FEQ0000
this.cmbState.ValueMember = "Value";
this.cmbState.DataSource = stateList;
//장비제조
var dt_dept = FCOMMON.DBM.getCodeTable("06");
BindingSource bsManu = new BindingSource(dt_dept, "");
this.cbEQManu.DisplayMember = "Value";
this.cbEQManu.ValueMember = "Value";
this.cbEQManu.DataSource = bsManu;
//장비모델
var dt_asset = FCOMMON.DBM.getCodeTable("07");
bsModel = new BindingSource(dt_asset, "");
bsModel.Filter = "svalue='그런거없다'";
this.cbEQModel.DisplayMember = "Value";
this.cbEQModel.ValueMember = "Value";
this.cbEQModel.DataSource = bsModel;
//제조공정
var dt_manuproc = FCOMMON.DBM.getCodeTable("08");
this.cbManuProc.DisplayMember = "Value";
this.cbManuProc.ValueMember = "Value";
this.cbManuProc.DataSource = dt_manuproc;
//장비기술공정
var dt_eetproc = FCOMMON.DBM.getCodeTable("09");
this.cbProcess.DisplayMember = "Value";
this.cbProcess.ValueMember = "Value";
this.cbProcess.DataSource = dt_eetproc;
//string namestr = string.Format("{0}({1})", FCOMMON.info.Login.nameK, FCOMMON.info.Login.no);
//if (FCOMMON.info.Login.no == "dev") namestr = "김치균(395552)";
//this.cmbRequest.Items.Clear();
//this.cmbRequest.Items.Add(namestr);
//try
//{
// var cn = FCOMMON.DBM.getCn();
// cn.Open();
// string sql = "select [id],[name] " +
// " from users" +
// " where gcode='{1}' and id <> '{0}'" +
// " order by [name]";
// sql = string.Format(sql, FCOMMON.info.Login.no, FCOMMON.info.Login.gcode);
// var cmd = new System.Data.SqlClient.SqlCommand(sql, cn);
// var rdr = cmd.ExecuteReader();
// while (rdr.Read())
// {
// string cmbdata = string.Format("{1}({0})", rdr[0].ToString(), rdr[1].ToString());
// this.cmbRequest.Items.Add(cmbdata);
// }
// cmd.Dispose();
// cn.Close();
// cn.Dispose();
//}
//catch (Exception ex)
//{
// FCOMMON.Util.MsgE("User List Error\n\n" + ex.Message);
//}
//cmbRequest.Text = namestr;// FCOMMON.info.Login.nameK;
//dtPdate.Value = DateTime.Now;
loadsetting(this);
textBox1.Text = FCOMMON.Setting.system.Xml.get_Data(this.Name, "FILE");
if (crmode)
textBox1.Text = FCOMMON.Setting.system.Xml.get_Data(this.Name, "FILE_CR");
else
textBox1.Text = FCOMMON.Setting.system.Xml.get_Data(this.Name, "FILE_NR");
cmbState.Text = "PO"; //po에서 변경 200423 - JBS요청
//기준값이 없다면 기본값으로 설정한다
if (nudPumName.Value == 0 && nudSid.Value == 0 && nudPdate.Value == 0)
linkLabel3_LinkClicked(null, null);
}
void __Closed(object sender, FormClosedEventArgs e)
@@ -119,6 +113,7 @@ namespace FEQ0000
{
var nud = ctrls.Parent as NumericUpDown;
var section = "input_" + this.Name;
if (crmode) section += "_CR";
var value = FCOMMON.Setting.system.Xml.get_Data(section, "nud_" + nud.Name, "0");
var n = decimal.Parse(value);
if (n >= nud.Minimum) nud.Value = decimal.Parse(value);
@@ -141,6 +136,7 @@ namespace FEQ0000
{
var nud = ctrls.Parent as NumericUpDown;
var section = "input_" + this.Name;
if (crmode) section += "_CR";
FCOMMON.Setting.system.Xml.set_Data(section, "nud_" + nud.Name, nud.Value.ToString());
}
}
@@ -221,48 +217,67 @@ namespace FEQ0000
var itemCount = 0;
foreach (ListViewItem lv in this.listView1.Items)
{
var dr = lv.Tag as dsPurchase.PurchaseRow;
if (lv.Checked == false) dr.AcceptChanges();
if (crmode)
{
var dr = lv.Tag as dsPurchase.EETGW_PurchaseCRRow;
if (lv.Checked == false) dr.AcceptChanges();
else
{
itemCount += 1;
// dr.request = userNo;
dr.asset = cbEQModel.Text;
dr.dept = cbEQManu.Text;
dr.manuproc = cbManuProc.Text;
dr.process = cbProcess.Text.Trim();
dr.state = cmbState.Text.Trim();
// dr.pdate = dtPdate.Value.ToShortDateString();
dr.project = tbProject.Text.Trim();
dr.AcceptChanges();
dr.SetAdded();
itemAmt += dr.pumamt;
}
}
else
{
itemCount += 1;
// dr.request = userNo;
dr.asset = cbEQModel.Text;
dr.dept = cbEQManu.Text;
dr.manuproc = cbManuProc.Text;
dr.process = cbProcess.Text.Trim();
dr.state = cmbState.Text.Trim();
// dr.pdate = dtPdate.Value.ToShortDateString();
dr.project = tbProject.Text.Trim();
dr.AcceptChanges();
dr.SetAdded();
itemAmt += dr.pumamt;
var dr = lv.Tag as dsPurchase.PurchaseRow;
if (lv.Checked == false) dr.AcceptChanges();
else
{
itemCount += 1;
// dr.request = userNo;
dr.asset = cbEQModel.Text;
dr.dept = cbEQManu.Text;
dr.manuproc = cbManuProc.Text;
dr.process = cbProcess.Text.Trim();
dr.state = cmbState.Text.Trim();
// dr.pdate = dtPdate.Value.ToShortDateString();
dr.project = tbProject.Text.Trim();
dr.AcceptChanges();
dr.SetAdded();
itemAmt += dr.pumamt;
}
}
}
//part 목록을 조회해서 NR에 등록해줘야 함
var dlg2 = FCOMMON.Util.MsgQ("해당 파트리스트를 NR구매 목록에 등록 하시겠습니까?\n" +
var dlg2 = FCOMMON.Util.MsgQ($"해당 파트리스트를 ({(crmode ? "CR":"NR")})구매 목록에 등록 하시겠습니까?\n" +
itemCount.ToString() + "건 " + itemAmt.ToString("N0") + "원");
if (dlg2 != System.Windows.Forms.DialogResult.Yes) return;
if (crmode)
taCR.Update(this.dsPRJ.EETGW_PurchaseCR);
else
taNR.Update(this.dsPRJ.Purchase);
ta.Update(this.dsPRJ.Purchase);
dsPRJ.Purchase.AcceptChanges();
dsPRJ.AcceptChanges();
FCOMMON.Util.MsgI("Save OK");
}
bool checkCombo()
{
if (cbProcess.Text.isEmpty() == true)
if (crmode == false && cbProcess.Text.isEmpty() == true)
{
FCOMMON.Util.MsgE("프로세스를 선택하세요.");
cbProcess.Focus();
@@ -278,7 +293,7 @@ namespace FEQ0000
return false;
}
}
if (this.cbProcess.Text.isEmpty() == true)
if (crmode == false && this.cbProcess.Text.isEmpty() == true)
{
{
@@ -291,7 +306,7 @@ namespace FEQ0000
return false;
}
}
if (cbManuProc.Text.isEmpty() == true)
if (crmode == false && cbManuProc.Text.isEmpty() == true)
{
{
@@ -304,7 +319,7 @@ namespace FEQ0000
return false;
}
}
if (this.cbEQManu.Text.isEmpty() == true)
if (crmode == false && this.cbEQManu.Text.isEmpty() == true)
{
{
@@ -337,6 +352,12 @@ namespace FEQ0000
return;
}
if(nudPdate.Value <1 || nudSid.Value < 1 || nudPumName.Value < 1)
{
Util.MsgE($"요청일/SID/품명은 반드시 설정되어야 합니다");
return;
}
libxl.Book book;// = new libxl.BinBook();
@@ -370,14 +391,15 @@ namespace FEQ0000
MinRow = (int)Math.Max(MinRow, nudS.Value - 1);
this.progressBar1.Value = 0;
this.progressBar1.Maximum = MaxRow - MinRow + 1;
this.listView1.Items.Clear();
this.listView1.Visible = false;
this.dsPRJ.Purchase.Clear();
this.dsPRJ.Purchase.AcceptChanges();
this.dsPRJ.Clear();
this.dsPRJ.AcceptChanges();
var db = new DataClasses1DataContext();
decimal sumamt = 0;
@@ -407,6 +429,8 @@ namespace FEQ0000
string = string.Empty;
string = string.Empty;
string CostCode = string.Empty;
string LIneCode = string.Empty;
var cf_qty = sheet.cellType(r, (int)nudQty.Value - 1);
var cf_price = sheet.cellType(r, (int)nudPrice.Value - 1);
@@ -456,7 +480,7 @@ namespace FEQ0000
else
{
if (int.TryParse(daybuf[0], out mm) == false) mm = 0;
if (int.TryParse(daybuf[1].Replace("일",""), out dd) == false) dd = 0;
if (int.TryParse(daybuf[1].Replace("일", ""), out dd) == false) dd = 0;
}
if (mm == 0 || dd == 0 || yy == 0)
= orgstr;
@@ -490,9 +514,9 @@ namespace FEQ0000
= sheet.readStr(r, (int)nudReq.Value - 1).Trim();
= sheet.readStr(r, (int)nudRecv.Value - 1).Trim();
if(.isEmpty()==false)
if (.isEmpty() == false)
{
var requser=db.vGroupUser.Where(t => t.gcode == FCOMMON.info.Login.gcode && t.name == ).FirstOrDefault();
var requser = db.vGroupUser.Where(t => t.gcode == FCOMMON.info.Login.gcode && t.name == ).FirstOrDefault();
if (requser != null) = requser.id;
}
if (.isEmpty() == false)
@@ -520,6 +544,11 @@ namespace FEQ0000
if (nudPo.Value > 0) PO = sheet.readStr(r, (int)nudPo.Value - 1).Trim();
if (nudMemo.Value > 0) = sheet.readStr(r, (int)nudMemo.Value - 1).Trim();
if (nudCost.Value > 0) CostCode = sheet.readStr(r, (int)nudCost.Value - 1).Trim();
if (nudLine.Value > 0) LIneCode = sheet.readStr(r, (int)nudLine.Value - 1).Trim();
//sid 공백과 - _ 제거 200506
SID = SID.Replace(" ", "").Replace("-", "").Replace("_", "").Trim();
@@ -555,10 +584,6 @@ namespace FEQ0000
newitem.Checked = false;
newitem.SubItems.Add();
newitem.SubItems.Add(SC);
newitem.SubItems.Add(CRCF);
newitem.SubItems.Add(SID);
newitem.SubItems.Add();
newitem.SubItems.Add();
@@ -567,35 +592,78 @@ namespace FEQ0000
newitem.SubItems.Add(d_price.ToString());
newitem.SubItems.Add(d_amt.ToString());
newitem.SubItems.Add(v_공급처);
newitem.SubItems.Add(PO);
newitem.SubItems.Add();
newitem.SubItems.Add(PO);
newitem.SubItems.Add(SC);
newitem.SubItems.Add(CRCF);
newitem.SubItems.Add();
newitem.SubItems.Add();
newitem.SubItems.Add(CostCode);
newitem.SubItems.Add(LIneCode);
//데이터도 추가를 해준다
var newdr = this.dsPRJ.Purchase.NewPurchaseRow();
newdr.wuid = FCOMMON.info.Login.no;
newdr.wdate = DateTime.Now;
newdr.gcode = FCOMMON.info.Login.gcode;
newdr.sc = SC;
newdr.orderno = CRCF;
newdr.sid = SID;
newdr.pumname = ;
newdr.pumscale = ;
newdr.pumqty = d_qty;
newdr.pumprice = d_price;
newdr.pumamt = d_amt;
newdr.supply = v_공급처;
newdr.supplyidx = v_공급처코드;
newdr.po = PO;
newdr.bigo = ;
newdr.indate = ;
newdr.pdate = ;
newdr.request = ;
newdr.receive = ;
newdr.import = true;
newitem.Tag = newdr;
this.dsPRJ.Purchase.AddPurchaseRow(newdr);
if (crmode)
{
var newdr = this.dsPRJ.EETGW_PurchaseCR.NewEETGW_PurchaseCRRow();
newdr.wuid = FCOMMON.info.Login.no;
newdr.wdate = DateTime.Now;
newdr.gcode = FCOMMON.info.Login.gcode;
newdr.sc = SC;
newdr.orderno = CRCF;
newdr.sid = SID;
newdr.pumname = ;
newdr.pumscale = ;
newdr.pumqty = d_qty;
newdr.pumprice = d_price;
newdr.pumamt = d_amt;
newdr.supply = v_공급처;
newdr.supplyidx = v_공급처코드;
newdr.po = PO;
newdr.bigo = ;
newdr.indate = ;
newdr.pdate = ;
newdr.request = ;
newdr.receive = ;
newdr.import = true;
newdr.costcenter = CostCode;
newdr.linecode = LIneCode;
newitem.Tag = newdr;
this.dsPRJ.EETGW_PurchaseCR.AddEETGW_PurchaseCRRow(newdr);
}
else
{
var newdr = this.dsPRJ.Purchase.NewPurchaseRow();
newdr.wuid = FCOMMON.info.Login.no;
newdr.wdate = DateTime.Now;
newdr.gcode = FCOMMON.info.Login.gcode;
newdr.sc = SC;
newdr.orderno = CRCF;
newdr.sid = SID;
newdr.pumname = ;
newdr.pumscale = ;
newdr.pumqty = d_qty;
newdr.pumprice = d_price;
newdr.pumamt = d_amt;
newdr.supply = v_공급처;
newdr.supplyidx = v_공급처코드;
newdr.po = PO;
newdr.bigo = ;
newdr.indate = ;
newdr.pdate = ;
newdr.request = ;
newdr.receive = ;
newdr.import = true;
newdr.costcenter = CostCode;
newdr.linecode = LIneCode;
newitem.Tag = newdr;
this.dsPRJ.Purchase.AddPurchaseRow(newdr);
}
@@ -677,5 +745,38 @@ namespace FEQ0000
{
}
private void nudSc_TabIndexChanged(object sender, EventArgs e)
{
}
private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
var idx = 1;
nudPdate.Value = idx++;
nudReq.Value = idx++;
nudSid.Value = idx++;
nudPumName.Value = idx++;
nudScale.Value = idx++;
nudQty.Value = idx++;
nudUnit.Value = idx++;
nudPrice.Value = idx++;
idx++;//nudAmkt.Value = 6;
nudSupplty.Value = idx++;
nudMemo.Value = idx++;
nudPo.Value = idx++;
nudSc.Value = idx++;
nudCr.Value = idx++;
nudInDate.Value = idx++;
nudRecv.Value = idx++;
nudCost.Value = idx++;
nudLine.Value = idx++;
}
private void label25_Click(object sender, EventArgs e)
{
}
}
}