item, project 를 별도 분리
lov 생성 personalInventoryToolStripMenuItem_Click 기능 추가
This commit is contained in:
300
SubProject/FCM0000/fInventory.cs
Normal file
300
SubProject/FCM0000/fInventory.cs
Normal file
@@ -0,0 +1,300 @@
|
||||
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 FCM0000
|
||||
{
|
||||
public partial class fInventory : Form
|
||||
{
|
||||
public fInventory()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.FormClosed += __Closed;
|
||||
this.dsMSSQL.Inventory.TableNewRow += Inventory_TableNewRow;
|
||||
|
||||
var invtypeList = new FCOMMON.keyValuedataTable();
|
||||
invtypeList.Add("I1", "입고");
|
||||
invtypeList.Add("I2", "입고(대여)");
|
||||
invtypeList.Add("O1", "출고");
|
||||
invtypeList.Add("O2", "출고(대여)");
|
||||
invtypeList.Add("ET", "기타");
|
||||
dvc_iffnvtype.DataSource = invtypeList.DataTable;
|
||||
dvc_iffnvtype.ValueMember = "key";
|
||||
dvc_iffnvtype.DisplayMember = "Value";
|
||||
this.dtSD.KeyDown += dtSD_KeyDown;
|
||||
this.dtED.KeyDown += dtSD_KeyDown;
|
||||
}
|
||||
|
||||
void dtSD_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
{
|
||||
ToolStripTextBox tb = sender as ToolStripTextBox;
|
||||
var vale = tb.Text.Trim();
|
||||
var datestring = string.Empty;
|
||||
if (FCOMMON.Util.MakeDateString(vale, out datestring))
|
||||
{
|
||||
tb.Text = datestring;
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
SendKeys.Send("{TAB}");
|
||||
}
|
||||
else
|
||||
{
|
||||
FCOMMON.Util.MsgE("날짜형식으로 입력하세요.\n\n18-01-01");
|
||||
tb.SelectAll();
|
||||
tb.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void __Closed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
var form = this as Form;
|
||||
FCOMMON.Util.SetFormStatus(ref form, this.Name, false);
|
||||
}
|
||||
|
||||
private void __Load(object sender, EventArgs e)
|
||||
{
|
||||
var form = this as Form;
|
||||
FCOMMON.Util.SetFormStatus(ref form, this.Name, true);
|
||||
this.Show();
|
||||
Application.DoEvents();
|
||||
|
||||
//마지막 자료를 가져온날을 찾는다.
|
||||
var dateList = FCOMMON.DBM.getDateList("Inventory", "uid='" + FCOMMON.info.Login.no + "'");
|
||||
dtED.Text = DateTime.Now.ToShortDateString();
|
||||
|
||||
if (dateList.Count > 0) dtSD.Text = dateList[dateList.Count - 1];
|
||||
else dtSD.Text = DateTime.Now.AddDays(-7).ToShortDateString();
|
||||
|
||||
btSearch.PerformClick();
|
||||
|
||||
}
|
||||
private void btSearch_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string sd = dtSD.Text;
|
||||
string ed = dtED.Text;
|
||||
this.ta.FillByUID(this.dsMSSQL.Inventory, sd, ed, FCOMMON.info.Login.no);
|
||||
this.dsMSSQL.Inventory.AcceptChanges();
|
||||
dv1.AutoResizeColumns();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FCOMMON.Util.MsgE(ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
private void inventoryBindingNavigatorSaveItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Validate();
|
||||
this.bs.EndEdit();
|
||||
|
||||
var dlg = FCOMMON.Util.MsgQ("변경된 사항을 저장 하시겠습니까?");
|
||||
if (dlg != System.Windows.Forms.DialogResult.Yes) return;
|
||||
|
||||
try
|
||||
{
|
||||
this.tam.UpdateAll(this.dsMSSQL);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FCOMMON.Util.MsgE(ex.Message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void Inventory_TableNewRow(object sender, DataTableNewRowEventArgs e)
|
||||
{
|
||||
|
||||
e.Row["wuid"] = FCOMMON.info.Login.no;
|
||||
e.Row["uid"] = FCOMMON.info.Login.no;
|
||||
e.Row["wdate"] = DateTime.Now;
|
||||
e.Row["pdate"] = DateTime.Now.ToShortDateString();
|
||||
e.Row["dr_qty"] = 0;
|
||||
e.Row["dr_amt"] = 0;
|
||||
e.Row["invtype"] = "I1";
|
||||
}
|
||||
|
||||
private void inventoryDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void toolStripTextBox1_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void toolStripTextBox1_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void toolStripTextBox1_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
{
|
||||
string inputstr = toolStripTextBox1.Text.Trim();
|
||||
if (inputstr == "")
|
||||
{
|
||||
bs.Filter = "";
|
||||
toolStripTextBox1.BackColor = Color.White;
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] collist = new string[] { "projectName", "itemName", "memo", "serial" };
|
||||
System.Text.StringBuilder filter = new StringBuilder();
|
||||
foreach (var col in collist)
|
||||
{
|
||||
if (filter.Length > 0) filter.Append(" or ");
|
||||
filter.Append(col + " like '%" + inputstr + "%'");
|
||||
}
|
||||
try
|
||||
{
|
||||
bs.Filter = filter.ToString();
|
||||
toolStripTextBox1.BackColor = Color.Lime;
|
||||
toolStripTextBox1.SelectAll();
|
||||
toolStripTextBox1.Focus();
|
||||
}
|
||||
catch (Exception eX)
|
||||
{
|
||||
toolStripTextBox1.BackColor = Color.Red;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void autoColumnsSizeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
dv1.AutoResizeColumns();
|
||||
}
|
||||
|
||||
private void dv1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex < 0 || e.RowIndex < 0) return;
|
||||
var col = dv1.Columns[e.ColumnIndex];
|
||||
switch (col.DataPropertyName)
|
||||
{
|
||||
case "itemName":
|
||||
var valuen = dv1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||||
if (valuen != null)
|
||||
{
|
||||
string inputtext = valuen.ToString().Trim();
|
||||
if (inputtext.isEmpty())
|
||||
{
|
||||
dv1.Rows[e.RowIndex].Cells["dvc_itemName"].Value = inputtext;
|
||||
}
|
||||
else
|
||||
{
|
||||
//검색을 실행해서 보여준다.
|
||||
var SearchDT = taItem.GetSearch("%" + inputtext + "%");
|
||||
if (SearchDT == null || SearchDT.Rows.Count < 1)
|
||||
{
|
||||
FCOMMON.Util.MsgE("검색 결과가 없습니다.");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//검색된 결과를 표시해서 보여준다.
|
||||
var f = new fLovItem("%" + inputtext + "%");
|
||||
if(f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
dv1.Rows[e.RowIndex].Cells["dvc_item"].Value = f.Item;
|
||||
dv1.Rows[e.RowIndex].Cells["dvc_itemName"].Value = f.itemName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "item":
|
||||
var value = dv1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||||
if (value != null)
|
||||
{
|
||||
int idx = (int)value;
|
||||
if (idx != -1)
|
||||
{
|
||||
var item = this.taItem.GetIDX(idx);
|
||||
if (item.Count == 1)
|
||||
{
|
||||
//1개만 찾았다면 그것을 사용한다.
|
||||
var itemnameValue = item[0]["name"];
|
||||
if (itemnameValue != null)
|
||||
dv1.Rows[e.RowIndex].Cells["dvc_itemName"].Value = itemnameValue.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
FCOMMON.Util.MsgE("해당 아이템이 존재하지 않습니다.");
|
||||
dv1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = DBNull.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "project":
|
||||
var valuep = dv1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||||
if (valuep != null)
|
||||
{
|
||||
int idx = (int)valuep;
|
||||
if (idx != -1)
|
||||
{
|
||||
var item = this.taPrj.GetData(idx);
|
||||
if (item.Count == 1)
|
||||
{
|
||||
//1개만 찾았다면 그것을 사용한다.
|
||||
var itemnameValue = item[0]["name"];
|
||||
if (itemnameValue != null)
|
||||
dv1.Rows[e.RowIndex].Cells["dvc_projectName"].Value = itemnameValue.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
FCOMMON.Util.MsgE("해당 프로젝트가 존재하지 않습니다.");
|
||||
dv1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = DBNull.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "projectName":
|
||||
var valuepn = dv1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||||
if (valuepn != null)
|
||||
{
|
||||
string inputtext = valuepn.ToString().Trim();
|
||||
if (inputtext.isEmpty())
|
||||
{
|
||||
dv1.Rows[e.RowIndex].Cells["dvc_projectname"].Value = inputtext;
|
||||
}
|
||||
else
|
||||
{
|
||||
//검색을 실행해서 보여준다.
|
||||
var SearchDT = this.taPrj.GetSearch("%" + inputtext + "%");
|
||||
if (SearchDT == null || SearchDT.Rows.Count < 1)
|
||||
{
|
||||
FCOMMON.Util.MsgE("검색 결과가 없습니다.");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//검색된 결과를 표시해서 보여준다.
|
||||
var f = new fLovProject("%" + inputtext + "%");
|
||||
if(f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
dv1.Rows[e.RowIndex].Cells["dvc_project"].Value = f.Project;
|
||||
dv1.Rows[e.RowIndex].Cells["dvc_projectname"].Value = f.ProjectName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user