FrmToolRepairPositionInfo.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. namespace Core.LgMes.Client.LgDeviceManager
  9. {
  10. public partial class FrmToolRepairPositionInfo : Form
  11. {
  12. private DataTable _dt;
  13. public DataTable dt { set { _dt = value; } get { return _dt; } }
  14. public FrmToolRepairPositionInfo()
  15. {
  16. InitializeComponent();
  17. }
  18. private void DataProcess(string strType)
  19. {
  20. string strSQL;
  21. string strMsgSucess;
  22. string strMsgFail;
  23. if (strType == "N")
  24. {
  25. strSQL = "INSERT INTO DEV_Item_In_Tool_Pos (OrderID,ItemTypeID, ToolType, ToolPos,Memo) VALUES((" +
  26. "Select nvl(Max(OrderID),0)+1 from DEV_Item_In_Tool_Pos" +"),'" +
  27. this.cboParaID.Text.Replace("'", "''") + "','" +
  28. this.cboToolName.Text.Replace("'", "''") + "','" +
  29. this.cboToolID.Text.Replace("'", "''") + "','" +
  30. this.txtMemo.Text.Replace("'", "''") + "')"
  31. ;
  32. strMsgSucess = "新增数据成功!";
  33. strMsgFail = "新增数据失败!";
  34. }
  35. else if (strType == "U")
  36. {
  37. strSQL = "UPDATE DEV_Item_In_Tool_Pos SET ItemTypeID='" + this.cboParaID.Text.Replace("'", "''") +
  38. "',ToolType='" + this.cboToolName.Text.Replace("'", "''") +
  39. "',ToolPos='" + this.cboToolID.Text.Replace("'", "''") +
  40. "',Memo='" + this.txtMemo.Text.Replace("'", "''") +
  41. "' WHERE OrderID='" + this.ulgrid.ActiveRow.Cells["序号"].Value.ToString() + "'";
  42. strMsgSucess = "修改数据成功!";
  43. strMsgFail = "修改数据失败!";
  44. }
  45. else
  46. {
  47. strSQL = "DELETE FROM DEV_Item_In_Tool_Pos WHERE OrderID='" + this.ulgrid.ActiveRow.Cells["序号"].Value.ToString() + "'";
  48. strMsgSucess = "删除数据成功!";
  49. strMsgFail = "删除数据失败!";
  50. }
  51. //Core.Mes.IBaseInterface.CallingMessage par = new Core.Mes.IBaseInterface.CallingMessage();
  52. //par.AssemblyName = "Core.LgMes.Server.LgDeviceManager";
  53. //par.ClassName = "Core.LgMes.Server.LgDeviceManager.LadleManager";
  54. //par.args = new object[] { strSQL };
  55. //par.MethodName = "ExecuteSQL";
  56. //par.ServerName = "LgDeviceManager";
  57. //string StrOut = "";
  58. object ob = null;// Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod(par, out StrOut);
  59. if ((int)ob > 0)
  60. {
  61. this.QueryData();
  62. MessageBox.Show(strMsgSucess, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  63. }
  64. else
  65. {
  66. MessageBox.Show(strMsgFail, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  67. }
  68. }
  69. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  70. {
  71. switch (e.Tool.Key)
  72. {
  73. case "Close":
  74. this.Close();
  75. break;
  76. case "New":
  77. if ( (this.cboToolName.Text.Trim() == "") || (this.cboToolID.Text.Trim() == ""))
  78. { break; }
  79. this.DataProcess("N");
  80. break;
  81. case "Update":
  82. if ((this.cboToolName.Text.Trim() == "") || (this.cboToolID.Text.Trim() == ""))
  83. { break; }
  84. if (this.ulgrid.ActiveRow != null)
  85. {
  86. this.DataProcess("U");
  87. }
  88. else
  89. {
  90. MessageBox.Show("请选择需要修改的行!", "提示");
  91. }
  92. break;
  93. case "Del":
  94. if (this.ulgrid.ActiveRow != null)
  95. {
  96. this.DataProcess("D");
  97. cboParaID.Text = "";
  98. cboToolID.Text = "";
  99. txtMemo.Text = "";
  100. }
  101. else
  102. {
  103. MessageBox.Show("请选择要删除的行!","提示");
  104. }
  105. break;
  106. default:
  107. break;
  108. }
  109. }
  110. private void QueryData()
  111. {
  112. string strSQL = " SELECT OrderID as 序号 ,ItemTypeID AS 材料类型编号,ToolType AS 适用工具类型, ToolPos AS 适用工具位置,Memo as 备注" +
  113. " FROM DEV_Item_In_Tool_Pos WHERE 1=1 ";
  114. if (this.chkToolName.Checked)
  115. {
  116. strSQL = strSQL + " AND tooltype='" + this.cboToolType.Text.ToString() + "' ";
  117. }
  118. strSQL = strSQL + " ORDER BY OrderID desc ";
  119. //Core.Mes.IBaseInterface.CallingMessage par = new Core.Mes.IBaseInterface.CallingMessage();
  120. //par.ServerName = "LgDeviceManager";
  121. //par.MethodName = "ReturnTable";
  122. //par.ClassName = "Core.LgMes.Server.LgDeviceManager.LadleManager";
  123. //par.AssemblyName = "Core.LgMes.Server.LgDeviceManager";
  124. //par.args = new object[] { strSQL };
  125. //string err = "";
  126. object ob = null;// Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod(par, out err);
  127. System.Data.DataSet ds = (DataSet)ob;
  128. this.ulgrid.DataSource = ds;
  129. this.ulgrid.DataBind();
  130. //Core.LgMes.Client.LgDeviceManager.FrmCLRepairDetail fcc = new Core.LgMes.Client.LgDeviceManager.FrmCLRepairDetail();
  131. //fcc.SetColumnWidth(ds, ulgrid, this.label1);
  132. }
  133. private void FrmToolRepairPositionInfo_Load(object sender, EventArgs e)
  134. {
  135. this.cboToolType.DataSource = this._dt;
  136. this.cboToolType.DisplayMember = "基础名称";
  137. cboToolName.DataSource = this._dt;
  138. cboToolName.DisplayMember = "基础名称";
  139. this.QueryData();
  140. }
  141. private void cboToolType_SelectedIndexChanged(object sender, EventArgs e)
  142. {
  143. //if (int.TryParse(this.cboToolType.SelectedItem.ToString(),out n))
  144. if (this.chkToolName.Checked)
  145. {
  146. this.QueryData();
  147. }
  148. }
  149. private void chkToolName_CheckedChanged(object sender, EventArgs e)
  150. {
  151. if (chkToolName.Checked)
  152. {
  153. cboToolType.Enabled = true;
  154. }
  155. else
  156. {
  157. cboToolType.Enabled = false;
  158. }
  159. this.QueryData();
  160. }
  161. private void ulgrid_Click(object sender, EventArgs e)
  162. {
  163. if (this.ulgrid.ActiveRow != null)
  164. {
  165. cboParaID.Text = ulgrid.ActiveRow.Cells["材料类型编号"].Value.ToString();
  166. cboToolName.Text = ulgrid.ActiveRow.Cells["适用工具类型"].Value.ToString();
  167. cboToolID.Text = ulgrid.ActiveRow.Cells["适用工具位置"].Value.ToString();
  168. txtMemo.Text = ulgrid.ActiveRow.Cells["备注"].Value.ToString();
  169. }
  170. else
  171. {
  172. cboParaID.Text = "";
  173. cboToolName.Text = "";
  174. cboToolID.Text = "";
  175. txtMemo.Text = "";
  176. }
  177. }
  178. }
  179. }