frmIlUse.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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 frmIlUse : frmModelFormStyle
  11. {
  12. private DataSet dsUse;
  13. public frmIlUse()
  14. {
  15. InitializeComponent();
  16. dsUse = new DataSet();
  17. }
  18. private void frmIlUse_Load(object sender, EventArgs e)
  19. {
  20. this.InitCmbx(true,true);
  21. }
  22. private void PutDataToScreen(int i)
  23. {
  24. this.txtCurAge.Text = dsUse.Tables[0].Rows[i]["age"].ToString();
  25. this.txtInstance.Text = dsUse.Tables[0].Rows[i]["instance"].ToString();
  26. this.txtIronInstance.Text = dsUse.Tables[0].Rows[i]["waterinstance"].ToString();
  27. this.txtPositionID.Text = dsUse.Tables[0].Rows[i]["positionid"].ToString();
  28. this.txtRionQdy.Text = dsUse.Tables[0].Rows[i]["btl"].ToString();
  29. this.txtUseDetailMemo.Text = dsUse.Tables[0].Rows[i]["memo"].ToString();
  30. this.cboNowPosition.Text = dsUse.Tables[0].Rows[i]["nowposition"].ToString();
  31. this.cboIsNew.Text = dsUse.Tables[0].Rows[i]["isnewe"].ToString();
  32. //this.cboCyc.Text = dsUse.Tables[0].Rows[i]["age"].ToString();
  33. //this.cboStatus.Text = dsUse.Tables[0].Rows[i]["nowstatus"].ToString();
  34. this.dtpUseEndTime.Text = dsUse.Tables[0].Rows[i]["endtime"].ToString();
  35. this.dtpUseStartTime.Text = dsUse.Tables[0].Rows[i]["begintime"].ToString();
  36. }
  37. /// <summary>
  38. /// 初始化
  39. /// </summary>
  40. /// <param name="bl">判断是否是初始化</param>
  41. /// <param name="blOp">判断是什么操作(修改不刷新)</param>
  42. private void InitCmbx(bool bl,bool blOp)
  43. {
  44. if (bl)
  45. {
  46. FrmIronLadleManage frm = (FrmIronLadleManage)this.Tag;
  47. this.cboCyc.Items.Clear();
  48. this.txtLadleUseNum.Text = frm.ugrdTBinfo.ActiveRow.Cells["铁包编号"].Value.ToString();
  49. //ladleid, cycid, class, nowposition, positionid, nowstatus,
  50. //waterinstance, age, begintime, endtime, skatefactory, stufffactory, ironqdy, btl, instance, isnewe, memo
  51. }
  52. string strSQL = "SELECT * FROM DEV_TB_Use_Detail WHERE ladleid='" + this.txtLadleUseNum.Text.Replace("'", "''") + "' ORDER BY cycid desc ";
  53. //Core.Mes.IBaseInterface.CallingMessage par = new Core.Mes.IBaseInterface.CallingMessage();
  54. //par.AssemblyName = "Core.LgMes.Server.LgDeviceManager";
  55. //par.ClassName = "Core.LgMes.Server.LgDeviceManager.LadleManager";
  56. //par.args = new object[] { strSQL };
  57. //par.MethodName = "ReturnTable";
  58. //par.ServerName = "LgDeviceManager";
  59. //string StrOut = "";
  60. object ob = null;// Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod(par, out StrOut);
  61. if (dsUse != null)
  62. {
  63. dsUse.Dispose();
  64. }
  65. //增加,删除执行
  66. if (blOp == true)
  67. {
  68. dsUse = (DataSet)ob;
  69. this.cboCyc.DataSource = dsUse.Tables[0];
  70. this.cboCyc.DisplayMember = "cycid";
  71. }
  72. if (bl)
  73. {
  74. //par.args = new object[] { "8005", "" };
  75. //par.MethodName = "GetComboBoxData";
  76. ////par.ServerName = "LgDeviceManager";
  77. ////string StrOut = "";
  78. System.Data.DataSet ds = new DataSet();
  79. ob = null;// Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod(par, out StrOut);
  80. ds = (DataSet)ob;
  81. this.cboNowPosition.Items.Clear();
  82. this.cboNowPosition.DataSource = ds.Tables[0];
  83. this.cboNowPosition.DisplayMember = "基础名称";
  84. //cboStatus
  85. //par.args = new object[] { "8004", "" };
  86. //par.MethodName = "GetComboBoxData";
  87. ////par.ServerName = "LgDeviceManager";
  88. ////string StrOut = "";
  89. ////System.Data.DataSet ds = new DataSet();
  90. ob = null;// Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod(par, out StrOut);
  91. ds = (DataSet)ob;
  92. //this.cboStatus.Items.Clear();
  93. //this.cboStatus.DataSource = ds.Tables[0];
  94. //this.cboStatus.DisplayMember = "基础名称";
  95. ///装载数据到屏幕
  96. ///
  97. if (dsUse.Tables[0].Rows.Count > 0)
  98. {
  99. this.PutDataToScreen(0);
  100. }
  101. }
  102. }
  103. private void cboCyc_SelectedIndexChanged(object sender, EventArgs e)
  104. {
  105. this.PutDataToScreen(this.cboCyc.SelectedIndex);
  106. }
  107. private void brnDel_Click(object sender, EventArgs e)
  108. {
  109. if (MessageBox.Show("真的删除该记录么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  110. {
  111. string strSQL = "DELETE FROM DEV_TB_Use_Detail WHERE LadleID='" + this.txtLadleUseNum.Text.Replace("'", "''")
  112. + "' AND CycID=" + this.cboCyc.Text ;
  113. //Core.Mes.IBaseInterface.CallingMessage par = new Core.Mes.IBaseInterface.CallingMessage();
  114. //par.AssemblyName = "Core.LgMes.Server.LgDeviceManager";
  115. //par.ClassName = "Core.LgMes.Server.LgDeviceManager.LadleManager";
  116. //par.args = new object[] { strSQL };
  117. //par.MethodName = "ExecuteSQL";
  118. //par.ServerName = "LgDeviceManager";
  119. //string StrOut = "";
  120. object ob = null;// Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod(par, out StrOut);
  121. int i = (int)ob;
  122. if (i > 0)
  123. {
  124. MessageBox.Show("删除数据成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  125. this.InitCmbx(false,true);
  126. FrmIronLadleManage frm = (FrmIronLadleManage)this.Tag;
  127. //frm.SetDetailData();
  128. }
  129. else
  130. {
  131. MessageBox.Show("删除数据失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  132. }
  133. }
  134. }
  135. private void btnAdd_Click(object sender, EventArgs e)
  136. {
  137. if (this.dtpUseStartTime.Value > dtpUseEndTime.Value)
  138. {
  139. MessageBox.Show("起始时间大于结束时间!\n请重新选择时间!", "提示");
  140. return;
  141. }
  142. string strSQL = "INSERT INTO DEV_TB_Use_Detail(ladleid, cycid,nowposition, positionid," +
  143. " waterinstance, age, begintime, endtime,btl," +
  144. "instance, isnewe, memo) VALUES('" +
  145. this.txtLadleUseNum.Text.Replace("'", "''") + "',(SELECT nvl(MAX(cycid),0)+1 FROM DEV_TB_Use_Detail WHERE ladleid='"
  146. + this.txtLadleUseNum.Text.Replace("'", "''") + "'),'" + this.cboNowPosition.Text + "','" + this.txtPositionID.Text + "','" +
  147. this.txtIronInstance.Text + "','" +
  148. this.txtCurAge.Text + "',to_date('" +
  149. this.dtpUseStartTime.Value.ToString() + "','yyyy-MM-dd HH24:Mi:ss'),to_date('" +
  150. this.dtpUseEndTime.Value.ToString() + "','yyyy-MM-dd HH24:Mi:ss'),'" +
  151. this.txtRionQdy.Text + "','" + this.txtInstance.Text + "','" +
  152. this.cboIsNew.Text + "','" + this.txtUseDetailMemo.Text + "')";
  153. ;//WHERE LadleID='" + this.txtLadleUseNum.Text.Replace("'", "''")
  154. //+ "' AND CycID=" + this.cboCyc.Text;
  155. //Core.Mes.IBaseInterface.CallingMessage par = new Core.Mes.IBaseInterface.CallingMessage();
  156. //par.AssemblyName = "Core.LgMes.Server.LgDeviceManager";
  157. //par.ClassName = "Core.LgMes.Server.LgDeviceManager.LadleManager";
  158. //par.args = new object[] { strSQL };
  159. //par.MethodName = "ExecuteSQL";
  160. //par.ServerName = "LgDeviceManager";
  161. //string StrOut = "";
  162. object ob = null;// Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod(par, out StrOut);
  163. int i = (int)ob;
  164. if (i > 0)
  165. {
  166. MessageBox.Show("添加数据成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  167. //dsUse.Tables[0].Rows.Add(new object[] { });
  168. //this.dsUse.Tables[0].Rows.Add(dr);
  169. this.InitCmbx(false,true );
  170. FrmIronLadleManage frm= (FrmIronLadleManage) this.Tag;
  171. //frm.SetDetailData();
  172. }
  173. else
  174. {
  175. MessageBox.Show("添加数据失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  176. }
  177. }
  178. private void btnUpdate_Click(object sender, EventArgs e)
  179. {
  180. if (this.dtpUseStartTime.Value > dtpUseEndTime.Value)
  181. {
  182. MessageBox.Show("起始时间大于结束时间!\n请重新选择时间!", "提示");
  183. return;
  184. }
  185. string strSQL = "UPDATE DEV_TB_Use_Detail SET nowposition='" + this.cboNowPosition.Text.Replace("'","''") +
  186. "',positionid='" + this.txtPositionID.Text.Replace("'","''") +
  187. "',waterinstance='" + this.txtIronInstance.Text.Replace("'", "''") +
  188. "',age='" + this.txtCurAge.Text.Replace("'", "''") +
  189. "',begintime=To_date('" + this.dtpUseStartTime.Value.ToString() +
  190. "','yyyy-MM-dd HH24:Mi:ss')" +
  191. ",endtime=To_date('" + this.dtpUseEndTime.Value.ToString() +
  192. "','yyyy-MM-dd HH24:Mi:ss')" +
  193. ",btl='" + this.txtRionQdy.Text.Replace("'", "''") +
  194. "',instance='" + this.txtInstance.Text.Replace("'", "''") +
  195. "',isnewe='" + this.cboIsNew.Text.Replace("'", "''") +
  196. "',memo='" + this.txtUseDetailMemo.Text.Replace("'", "''") +
  197. "' WHERE LadleID='" + this.txtLadleUseNum.Text.Replace("'", "''")+
  198. "' AND CycID=" + this.cboCyc.Text;
  199. //Core.Mes.IBaseInterface.CallingMessage par = new Core.Mes.IBaseInterface.CallingMessage();
  200. //par.AssemblyName = "Core.LgMes.Server.LgDeviceManager";
  201. //par.ClassName = "Core.LgMes.Server.LgDeviceManager.LadleManager";
  202. //par.args = new object[] { strSQL };
  203. //par.MethodName = "ExecuteSQL";
  204. //par.ServerName = "LgDeviceManager";
  205. //string StrOut = "";
  206. object ob = null;// Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod(par, out StrOut);
  207. int i = (int)ob;
  208. if (i > 0)
  209. {
  210. MessageBox.Show("修改数据成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  211. this.InitCmbx(false,false);
  212. FrmIronLadleManage frm = (FrmIronLadleManage)this.Tag;
  213. //frm.SetDetailData();
  214. }
  215. else
  216. {
  217. MessageBox.Show("修改数据失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  218. }
  219. }
  220. private void btnclose_Click(object sender, EventArgs e)
  221. {
  222. this.Close();
  223. }
  224. private void txtCurAge_KeyPress(object sender, KeyPressEventArgs e)
  225. {
  226. if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '.' || e.KeyChar == '\b'))
  227. {
  228. e.Handled = true;
  229. }
  230. }
  231. }
  232. }