..
This commit is contained in:
		| @@ -6,52 +6,85 @@ 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 fEquipment() | ||||
|         public enum eTabletype | ||||
|         { | ||||
|             MOLD, | ||||
|             FOL, | ||||
|             BUMP | ||||
|         } | ||||
|         string tableName = string.Empty; | ||||
|  | ||||
|         public fEquipment(eTabletype type) | ||||
|         { | ||||
|             InitializeComponent(); | ||||
|             this.dsEQ.Equipment.TableNewRow += Equipment_TableNewRow; | ||||
|  | ||||
|             if (type == eTabletype.MOLD) | ||||
|             { | ||||
|                 rade.Checked = true; | ||||
|                 tableName = "EquipmentME"; | ||||
|                 this.dsEQ.EquipmentME.TableNewRow += Equipment_TableNewRow; | ||||
|                 dvc_param.Visible = false; | ||||
|             } | ||||
|             else if (type == 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; | ||||
|         } | ||||
|  | ||||
|         private void equipmentBindingNavigatorSaveItem_Click(object sender, EventArgs e) | ||||
|         void fEquipment_FormClosed(object sender, FormClosedEventArgs e) | ||||
|         { | ||||
|             this.Validate(); | ||||
|             this.bs.EndEdit(); | ||||
|             try | ||||
|             { | ||||
|                 this.ta.Update(this.dsEQ.Equipment); | ||||
|                 this.dsEQ.Equipment.AcceptChanges(); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 Util.MsgE(ex.Message); | ||||
|             } | ||||
|             var form = this as Form; | ||||
|             Pub.SetFormStatus(ref form, this.Name + this.tableName, false); | ||||
|         } | ||||
|  | ||||
|         | ||||
|         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(); | ||||
|  | ||||
|             //등록된 날짜 목록을 가져온다. | ||||
|             dsEQTableAdapters.EqDateListTableAdapter taDate = new dsEQTableAdapters.EqDateListTableAdapter(); | ||||
|             var dateList = taDate.GetData(); | ||||
|             if (dateList != null) | ||||
|             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(dsEQ.EqDateListRow dr in dateList.Rows) | ||||
|                 foreach (DataRow dr in dtList.Rows) | ||||
|                 { | ||||
|                     this.cmbDate.Items.Add(dr.pdate); | ||||
|                     this.cmbDate.Items.Add(dr["pdate"].ToString()); | ||||
|                 } | ||||
|             } | ||||
|             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"); | ||||
|             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 --"); | ||||
| @@ -63,13 +96,42 @@ namespace Project._Management | ||||
|             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; | ||||
|             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; | ||||
| @@ -78,16 +140,16 @@ namespace Project._Management | ||||
|  | ||||
|         private void btSearch_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             if(cmbDate.SelectedIndex < 0) | ||||
|             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 newSQL = "select * from {0}"; | ||||
|             string newWhere = string.Empty; | ||||
|             if (cmbGrp.SelectedIndex != 0 && !cmbGrp.Text.isEmpty()) | ||||
|             { | ||||
| @@ -129,13 +191,122 @@ namespace Project._Management | ||||
|                 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(); | ||||
|             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(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); | ||||
|             } | ||||
|              | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 chikyun.kim
					chikyun.kim