142 lines
5.2 KiB
C#
142 lines
5.2 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;
|
|
|
|
namespace Project._Management
|
|
{
|
|
public partial class fEquipment : Form
|
|
{
|
|
public fEquipment()
|
|
{
|
|
InitializeComponent();
|
|
this.dsEQ.Equipment.TableNewRow += Equipment_TableNewRow;
|
|
}
|
|
|
|
private void equipmentBindingNavigatorSaveItem_Click(object sender, EventArgs e)
|
|
{
|
|
this.Validate();
|
|
this.bs.EndEdit();
|
|
try
|
|
{
|
|
this.ta.Update(this.dsEQ.Equipment);
|
|
this.dsEQ.Equipment.AcceptChanges();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Util.MsgE(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void __Load(object sender, EventArgs e)
|
|
{
|
|
|
|
//등록된 날짜 목록을 가져온다.
|
|
dsEQTableAdapters.EqDateListTableAdapter taDate = new dsEQTableAdapters.EqDateListTableAdapter();
|
|
var dateList = taDate.GetData();
|
|
if (dateList != null)
|
|
{
|
|
foreach(dsEQ.EqDateListRow dr in dateList.Rows)
|
|
{
|
|
this.cmbDate.Items.Add(dr.pdate);
|
|
}
|
|
}
|
|
if (this.cmbDate.Items.Count > 0) this.cmbDate.SelectedIndex = 0;
|
|
|
|
//목록을 가져온다.
|
|
var grpList = Manager.DatabaseManager.getEQGroupLiist("grp");
|
|
var lcList = Manager.DatabaseManager.getEQGroupLiist("linecode");
|
|
var manuList = Manager.DatabaseManager.getEQGroupLiist("manu");
|
|
var typeList = Manager.DatabaseManager.getEQGroupLiist("type");
|
|
|
|
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);
|
|
|
|
cmbGrp.SelectedIndex = 0;
|
|
cmbLine.SelectedIndex = 0;
|
|
cmbManu.SelectedIndex = 0;
|
|
cmbType.SelectedIndex = 0;
|
|
|
|
}
|
|
|
|
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 command
|
|
if (this.ta.Adapter.SelectCommand == null) this.ta.Adapter.SelectCommand = new System.Data.SqlClient.SqlCommand();
|
|
|
|
//select query
|
|
string newSQL = "select * from Equipment";
|
|
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");
|
|
}
|
|
if (newWhere.isEmpty()) ta.Adapter.SelectCommand.CommandText = newSQL;
|
|
else ta.Adapter.SelectCommand.CommandText = newSQL + " where " + newWhere;
|
|
|
|
//refresh data
|
|
this.dsEQ.Equipment.Clear();
|
|
ta.Fill(this.dsEQ.Equipment, this.cmbDate.Text);
|
|
this.dsEQ.Equipment.AcceptChanges();
|
|
}
|
|
}
|
|
}
|