华恒Mes鼎捷代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
6.2 KiB

5 months ago
  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. using DevExpress.XtraEditors;
  9. using System.Data.SqlClient;
  10. using ICSSoft.Frame.Data.BLL;
  11. using ICSSoft.Base.Language.Tool;
  12. using ICSSoft.Base.UserControl.MessageControl;
  13. using ICSSoft.Base.Report.Filter;
  14. using ICSSoft.Base.Config.DBHelper;
  15. using ICSSoft.Base.UserControl.FormControl;
  16. using ICSSoft.Base.ReferForm.AppReferForm;
  17. using ICSSoft.Base.Lable.PrintTool;
  18. using ICSSoft.Base.Config.AppConfig;
  19. using ICSSoft.Base.Report.GridReport;
  20. using ICSSoft.Frame.APP.Entity;
  21. using ICSSoft.Frame.APP;
  22. using ICSSoft.Frame.Data.Entity;
  23. using ICSSoft.Frame.Common;
  24. namespace ICSSoft.Frame.APP
  25. {
  26. public partial class FormICSAgvKgOrWg : DevExpress.XtraEditors.XtraForm
  27. {
  28. string Lotno; string Opcode; string Eqpcode; string Type;string Itemcode;decimal OnQty;
  29. public FormICSAgvKgOrWg()
  30. {
  31. InitializeComponent();
  32. }
  33. public FormICSAgvKgOrWg(string Lotno,string Opcode,string Eqpcode,string Type,string Itemcode, decimal OnQty)
  34. {
  35. InitializeComponent();
  36. this.Lotno = Lotno;
  37. this.Opcode = Opcode;
  38. this.Eqpcode = Eqpcode;
  39. this.Type = Type;
  40. this.Itemcode = Itemcode;
  41. this.OnQty = OnQty;
  42. init();
  43. }
  44. private string check()
  45. {
  46. string msg = "";
  47. if (TxtLocation.Text.Trim() == "")
  48. msg += "请选择点位!\n";
  49. return msg;
  50. }
  51. private void btnOK_Click(object sender, EventArgs e)
  52. {
  53. try
  54. {
  55. string msg = check();
  56. if (!string.IsNullOrEmpty(msg))
  57. {
  58. ICSBaseSimpleCode.AppshowMessageBox(msg);
  59. return;
  60. }
  61. ICSAGVTASKLOG Log = new ICSAGVTASKLOG();
  62. AGVCreateTaskModel model = new AGVCreateTaskModel();
  63. Log.ID = AppConfig.GetGuid();
  64. Log.Lotno = Lotno;
  65. Log.Opcode = Opcode;
  66. Log.Itemcode = Itemcode;
  67. Log.LocationCode = TxtLocation.EditValue.ToString();
  68. Log.Mtime= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  69. Log.MuserName = AppConfig.UserName;
  70. Log.Qty = OnQty;
  71. switch (Type) {
  72. case "开工"://区域到点位
  73. Log.TaskType = "中间工序开工";
  74. Log.Area = ICSAGVBLL.GetAreaCode("00088", "7", AppConfig.AppConnectString,AppConfig.WorkPointCode).Split('@')[0].Split(':')[0];
  75. model.type = "true";
  76. break;
  77. case "完工"://点位到待检区域
  78. Log.TaskType = "工序完工";
  79. Log.Area = ICSAGVBLL.GetAreaCode("00088", "1", AppConfig.AppConnectString, AppConfig.WorkPointCode).Split('@')[1].Split(':')[0];
  80. model.type = "false";
  81. break;
  82. default:
  83. throw new Exception("类型参数不正确");
  84. }
  85. model.area = Log.Area;
  86. model.station = Log.LocationCode;
  87. model.materialCode = Log.Itemcode;
  88. model.trackingNumber = Lotno;
  89. model.qty = (int)OnQty;
  90. model.trackingNumber = Lotno;
  91. var mes=ICSAGVBLL.CreateAGVTaskJJorBack(new List<AGVCreateTaskModel>() { model },new List<ICSAGVTASKLOG>() { Log },AppConfig.AppConnectString,AppConfig.WorkPointCode);
  92. if (string.IsNullOrEmpty(mes))
  93. {
  94. ICSBaseSimpleCode.AppshowMessageBox("调用成功!");
  95. this.Close();
  96. }
  97. else
  98. throw new Exception(mes);
  99. }
  100. catch (Exception ex) {
  101. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  102. }
  103. }
  104. #region 关闭
  105. private void btnCancle_Click(object sender, EventArgs e)
  106. {
  107. this.Close();
  108. //this.DialogResult = DialogResult.Cancel;
  109. }
  110. private void btnClose_Click(object sender, EventArgs e)
  111. {
  112. this.Close();
  113. //this.DialogResult = DialogResult.Cancel;
  114. }
  115. #endregion
  116. #region 初始化查询条件
  117. private void init()
  118. {
  119. #region 点位
  120. string sql = @"select a.locationcode as 点位编码,b.LocationName as 点位名称 from IcsEqpWithLocation a left join IcsAGVLocation b on a.locationcode=b.locationcode where eqpcode='{0}'";
  121. sql = string.Format(sql,Eqpcode);
  122. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  123. TxtLocation.Properties.ValueMember = "点位编码";
  124. TxtLocation.Properties.DisplayMember = "点位编码";
  125. TxtLocation.Properties.DataSource = dt;
  126. TxtLocation.Properties.NullText = "";//空时的值
  127. TxtLocation.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  128. TxtLocation.Properties.ValidateOnEnterKey = true;//回车确认
  129. TxtLocation.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  130. TxtLocation.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  131. //自适应宽度
  132. TxtLocation.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  133. #endregion
  134. }
  135. #endregion
  136. private void TxtLocation_EditValueChanged(object sender, EventArgs e)
  137. {
  138. var o=TxtLocation.Properties.GetRowByKeyValue(TxtLocation.EditValue);
  139. if (o is DataRowView)
  140. {
  141. DataRowView RowView = o as DataRowView;
  142. TxtLocationName.Text = RowView.Row["点位名称"].ToString();
  143. }
  144. }
  145. }
  146. }