324 lines
12 KiB
C#
324 lines
12 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.Windows.Forms;
|
|
using System.CodeDom.Compiler;
|
|
using System.Reflection;
|
|
using Microsoft.CSharp;
|
|
|
|
namespace Project._Management
|
|
{
|
|
public partial class fEquipment : Form
|
|
{
|
|
public enum eTabletype
|
|
{
|
|
MOLD,
|
|
FOL,
|
|
BUMP
|
|
}
|
|
string tableName = string.Empty;
|
|
eTabletype dataType = eTabletype.FOL;
|
|
|
|
public fEquipment(eTabletype type_)
|
|
{
|
|
InitializeComponent();
|
|
dataType = type_;
|
|
if (dataType == eTabletype.MOLD)
|
|
{
|
|
rade.Checked = true;
|
|
tableName = "EquipmentME";
|
|
this.dsEQ.EquipmentME.TableNewRow += Equipment_TableNewRow;
|
|
dvc_param.Visible = false;
|
|
}
|
|
else if (dataType == eTabletype.FOL)
|
|
{
|
|
radf.Checked = true;
|
|
tableName = "EquipmentF";
|
|
this.dsEQ.EquipmentF.TableNewRow += Equipment_TableNewRow;
|
|
dvc_param.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
radb.Checked = true;
|
|
tableName = "EquipmentB";
|
|
this.dsEQ.EquipmentB.TableNewRow += Equipment_TableNewRow;
|
|
dvc_param.Visible = true;
|
|
}
|
|
this.FormClosed += fEquipment_FormClosed;
|
|
}
|
|
|
|
void fEquipment_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
var form = this as Form;
|
|
Pub.SetFormStatus(ref form, this.Name + this.tableName, false);
|
|
}
|
|
|
|
void RefreshDate()
|
|
{
|
|
//등록된 날짜 목록을 가져온다.
|
|
var taDateList = new dsEQTableAdapters.EqDateListTableAdapter();
|
|
DataTable dtList = null;
|
|
if (radb.Checked) dtList = taDateList.GetDateListB();
|
|
else if (radf.Checked) dtList = taDateList.GetDateListF();
|
|
else dtList = taDateList.GetDateListME();
|
|
|
|
if (dtList != null)
|
|
{
|
|
foreach (DataRow dr in dtList.Rows)
|
|
{
|
|
this.cmbDate.Items.Add(dr["pdate"].ToString());
|
|
}
|
|
}
|
|
if (this.cmbDate.Items.Count > 0) this.cmbDate.SelectedIndex = 0;
|
|
}
|
|
private void __Load(object sender, EventArgs e)
|
|
{
|
|
var form = this as Form;
|
|
Pub.SetFormStatus(ref form, this.Name + this.tableName,true);
|
|
this.Show();
|
|
Application.DoEvents();
|
|
|
|
RefreshDate();
|
|
|
|
//목록을 가져온다.
|
|
var grpList = Manager.DatabaseManager.getEQGroupLiist("grp", this.tableName);
|
|
var lcList = Manager.DatabaseManager.getEQGroupLiist("linecode", this.tableName);
|
|
var manuList = Manager.DatabaseManager.getEQGroupLiist("manu", this.tableName);
|
|
var typeList = Manager.DatabaseManager.getEQGroupLiist("type", this.tableName);
|
|
|
|
cmbGrp.Items.Add("-- All --");
|
|
cmbLine.Items.Add("-- All --");
|
|
cmbManu.Items.Add("-- All --");
|
|
cmbType.Items.Add("-- All --");
|
|
|
|
foreach (var item in grpList) this.cmbGrp.Items.Add(item);
|
|
foreach (var item in lcList) this.cmbLine.Items.Add(item);
|
|
foreach (var item in manuList) this.cmbManu.Items.Add(item);
|
|
foreach (var item in typeList) this.cmbType.Items.Add(item);
|
|
|
|
if (this.cmbGrp.Items.Count > 0) cmbGrp.SelectedIndex = 0;
|
|
if (this.cmbLine.Items.Count > 0) cmbLine.SelectedIndex = 0;
|
|
if (this.cmbManu.Items.Count > 0) cmbManu.SelectedIndex = 0;
|
|
if (this.cmbType.Items.Count > 0) cmbType.SelectedIndex = 0;
|
|
|
|
}
|
|
|
|
private void equipmentBindingNavigatorSaveItem_Click(object sender, EventArgs e)
|
|
{
|
|
this.Validate();
|
|
this.bsB.EndEdit();
|
|
this.bsF.EndEdit();
|
|
this.bsME.EndEdit();
|
|
try
|
|
{
|
|
if (radb.Checked)
|
|
{
|
|
this.taB.Update(this.dsEQ.EquipmentB);
|
|
}
|
|
else if (rade.Checked)
|
|
{
|
|
this.taME.Update(this.dsEQ.EquipmentME);
|
|
}
|
|
else
|
|
{
|
|
this.taF.Update(this.dsEQ.EquipmentF);
|
|
}
|
|
this.dsEQ.AcceptChanges();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Util.MsgE(ex.Message);
|
|
}
|
|
}
|
|
|
|
|
|
void Equipment_TableNewRow(object sender, DataTableNewRowEventArgs e)
|
|
{
|
|
e.Row["wuid"] = Pub.Login.no;
|
|
e.Row["wdate"] = DateTime.Now;
|
|
}
|
|
|
|
private void btSearch_Click(object sender, EventArgs e)
|
|
{
|
|
if (cmbDate.SelectedIndex < 0)
|
|
{
|
|
Util.MsgE("No Date");
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
//select query
|
|
string newSQL = "select * from {0}";
|
|
string newWhere = string.Empty;
|
|
if (cmbGrp.SelectedIndex != 0 && !cmbGrp.Text.isEmpty())
|
|
{
|
|
if (!newWhere.isEmpty()) newWhere += " and ";
|
|
newWhere += "grp='" + cmbGrp.Text + "'";
|
|
}
|
|
if (this.cmbManu.SelectedIndex != 0 && !cmbManu.Text.isEmpty())
|
|
{
|
|
if (!newWhere.isEmpty()) newWhere += " and ";
|
|
newWhere += "manu='" + cmbManu.Text + "'";
|
|
}
|
|
if (this.cmbLine.SelectedIndex != 0 && !cmbLine.Text.isEmpty())
|
|
{
|
|
if (!newWhere.isEmpty()) newWhere += " and ";
|
|
newWhere += "linecode='" + cmbLine.Text + "'";
|
|
}
|
|
if (this.cmbType.SelectedIndex != 0 && !cmbType.Text.isEmpty())
|
|
{
|
|
if (!newWhere.isEmpty()) newWhere += " and ";
|
|
newWhere += "[type]='" + cmbType.Text + "'";
|
|
}
|
|
if (!this.tbSearch.Text.isEmpty())
|
|
{
|
|
if (!newWhere.isEmpty()) newWhere += " and ";
|
|
newWhere += string.Format("(asset like '%{0}%' or model like '%{0}%' or serial like '%{0}%')", tbSearch.Text);
|
|
}
|
|
if (radexpn.Checked)
|
|
{
|
|
if (!newWhere.isEmpty()) newWhere += " and ";
|
|
newWhere += string.Format("isnull([except],0) = 0");
|
|
}
|
|
if (radexpy.Checked)
|
|
{
|
|
if (!newWhere.isEmpty()) newWhere += " and ";
|
|
newWhere += string.Format("isnull([except],0) = 1");
|
|
}
|
|
if (this.radprionly.Checked)
|
|
{
|
|
if (!newWhere.isEmpty()) newWhere += " and ";
|
|
newWhere += string.Format("isnull([primary],0) = 1");
|
|
}
|
|
|
|
string CommandText = newSQL;
|
|
if (!newWhere.isEmpty()) CommandText += " where " + newWhere;
|
|
|
|
if (radb.Checked)
|
|
{
|
|
//select command
|
|
if (this.taB.Adapter.SelectCommand == null)
|
|
this.taB.Adapter.SelectCommand = new System.Data.SqlClient.SqlCommand();
|
|
this.taB.Adapter.SelectCommand.CommandText = string.Format(CommandText, "equipmentB");
|
|
this.dsEQ.EquipmentB.Clear();
|
|
taB.Fill(this.dsEQ.EquipmentB, this.cmbDate.Text);
|
|
this.dsEQ.EquipmentB.AcceptChanges();
|
|
dv.DataSource = bsB;
|
|
bn.BindingSource = bsB;
|
|
}
|
|
else if (radf.Checked)
|
|
{
|
|
//select command
|
|
if (this.taF.Adapter.SelectCommand == null)
|
|
this.taF.Adapter.SelectCommand = new System.Data.SqlClient.SqlCommand();
|
|
this.taF.Adapter.SelectCommand.CommandText = string.Format(CommandText, "equipmentF");
|
|
this.dsEQ.EquipmentF.Clear();
|
|
taF.Fill(this.dsEQ.EquipmentF, this.cmbDate.Text);
|
|
this.dsEQ.EquipmentF.AcceptChanges();
|
|
dv.DataSource = bsF;
|
|
bn.BindingSource = bsF;
|
|
}
|
|
else
|
|
{
|
|
//select command
|
|
if (this.taME.Adapter.SelectCommand == null)
|
|
this.taME.Adapter.SelectCommand = new System.Data.SqlClient.SqlCommand();
|
|
this.taME.Adapter.SelectCommand.CommandText = string.Format(CommandText, "equipmentME");
|
|
this.dsEQ.EquipmentME.Clear();
|
|
taME.Fill(this.dsEQ.EquipmentME, this.cmbDate.Text);
|
|
this.dsEQ.EquipmentME.AcceptChanges();
|
|
dv.DataSource = bsME;
|
|
bn.BindingSource = bsME;
|
|
}
|
|
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
_Management.rpt_equipmentB f = new _Management.rpt_equipmentB(dataType, this.cmbDate.Text);
|
|
f.Show();
|
|
}
|
|
|
|
private void button4_Click(object sender, EventArgs e)
|
|
{
|
|
_Management.EQfilter f = new EQfilter(this.tableName);
|
|
if(f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
{
|
|
var filter = f.filter;
|
|
var apply = f.apply;
|
|
if (filter.isEmpty() || apply.isEmpty())
|
|
{
|
|
Util.MsgE("no data");
|
|
return;
|
|
}
|
|
|
|
var dlg = Util.MsgQ("다음 매크로를 적용 하시겠습니까?\nFilter:" + filter + "\n" +
|
|
"apply : " + apply);
|
|
if (dlg != System.Windows.Forms.DialogResult.Yes) return;
|
|
|
|
var cnt = applyFilter(filter, apply);
|
|
if (cnt == -1) Util.MsgE("오류로 인해 실행되지 않았습니다.");
|
|
else Util.MsgI(cnt.ToString() + "건의 자료가 변경되었습니다.");
|
|
}
|
|
}
|
|
|
|
private int applyFilter(string filter, string apply)
|
|
{
|
|
if (filter.isEmpty() || apply.isEmpty()) return -1;
|
|
|
|
try
|
|
{
|
|
var dRows = this.dsEQ.EquipmentB.Select(filter);
|
|
int cnt = 0;
|
|
foreach(dsEQ.EquipmentBRow dr in dRows)
|
|
{
|
|
var appList = apply.Split(';');
|
|
foreach (var item in appList)
|
|
{
|
|
if(item.isEmpty()) continue;
|
|
var field = item.Split('=')[0].Trim();
|
|
var value = item.Split('=')[1].Trim();
|
|
dr[field] =value;
|
|
}
|
|
cnt += 1;
|
|
}
|
|
//this.bsB.Filter = filter;
|
|
//Util.MsgI(string.Format("{0} 건의 자료가 업데이트 되었습니다.",cnt));
|
|
return cnt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Util.MsgE(ex.Message);
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
private void toolStripButton1_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.bsB.Filter = tbFilter.Text;
|
|
if (tbFilter.Text.isEmpty()) tbFilter.BackColor = Color.White;
|
|
else tbFilter.BackColor = Color.Lime;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Util.MsgE(ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
_Management.fImpEquipment f = new _Management.fImpEquipment(dataType);
|
|
f.ShowDialog();
|
|
RefreshDate();
|
|
}
|
|
}
|
|
}
|