锐腾搅拌上料功能
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.

573 lines
27 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 ICSSoft.Frame.WorkPoint.Entity;
  10. using ICSSoft.Frame.WorkPoint.BLL;
  11. using ICSSoft.Base.Config.AppConfig;
  12. using ICSSoft.Base.Config.DBHelper;
  13. using System.Text.RegularExpressions;
  14. using ICSSoft.Frame.Data.Entity;
  15. using ICSSoft.Base.ReferForm.AppReferForm;
  16. using ICSSoft.Frame.Data.BLL;
  17. using ICSSoft.Frame.Helper;
  18. namespace ICSSoft.Frame.APP
  19. {
  20. public partial class FormICSEquipmentAdd : DevExpress.XtraEditors.XtraForm
  21. {
  22. FormICSEquipmentUIModel equipmentUIModel;
  23. bool add = false;
  24. string eqpid = "";
  25. #region 构造函数
  26. /// <summary>
  27. /// add new
  28. /// </summary>
  29. public FormICSEquipmentAdd()
  30. {
  31. add = true;
  32. InitializeComponent();
  33. tabControl1.ItemSize = new Size(0, 1);
  34. cboEQPSetting.SelectedIndex = 0;
  35. }
  36. /// <summary>
  37. /// edit
  38. /// </summary>
  39. /// <param name="cPersonCode"></param>
  40. public FormICSEquipmentAdd(string id)
  41. {
  42. add = false;
  43. this.eqpid = id;
  44. InitializeComponent();
  45. tabControl1.ItemSize = new Size(0, 1);
  46. }
  47. #endregion
  48. private void chargeFormState(bool add)
  49. {
  50. if (add)
  51. {
  52. //txtModel.Properties.ReadOnly = false;
  53. //txtEQPStatus.Properties.ReadOnly = false;
  54. txtMUSERName.Text = AppConfig.UserName;
  55. txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString();
  56. txtMUSERName.Properties.ReadOnly = true;
  57. txtMTIME.Properties.ReadOnly = true;
  58. txtEQPStatus.Text = "新增";
  59. txtEQPStatus.Properties.ReadOnly = true;
  60. //txtType.Text = "001";
  61. txtType.Properties.ReadOnly = true;
  62. }
  63. else
  64. {
  65. txtEQPCode.Properties.ReadOnly = true;
  66. //txtType.Properties.ReadOnly = true;
  67. txtEQPStatus.Properties.ReadOnly = true;
  68. txtMUSERName.Properties.ReadOnly = true;
  69. txtMTIME.Properties.ReadOnly = true;
  70. }
  71. }
  72. #region 移动窗体
  73. private const int WM_NCHITTEST = 0x84;
  74. private const int HTCLIENT = 0x1;
  75. private const int HTCAPTION = 0x2;
  76. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  77. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  78. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  79. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  80. //重写窗体,使窗体可以不通过自带标题栏实现移动
  81. protected override void WndProc(ref Message m)
  82. {
  83. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  84. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  85. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  86. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  87. switch (m.Msg)
  88. {
  89. case WM_NCHITTEST:
  90. base.WndProc(ref m);
  91. if ((int)m.Result == HTCLIENT)
  92. m.Result = (IntPtr)HTCAPTION;
  93. return;
  94. }
  95. //拦截双击标题栏、移动窗体的系统消息
  96. if (m.Msg != 0xA3)
  97. {
  98. base.WndProc(ref m);
  99. }
  100. }
  101. #endregion
  102. #region 页面加载
  103. private void FormICSEquipmentAdd_Load(object sender, EventArgs e)
  104. {
  105. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在加载");
  106. _wait.Show();
  107. try
  108. {
  109. #region 设备属性(使用/维修/报废/闲置)
  110. string sql = @"SELECT EnumText as 设备属性 FROM Sys_EnumValues WHERE EnumKey='00009' AND WorkPointCode='" + AppConfig.WorkPointCode + "' ";
  111. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  112. txtProperty.Properties.ValueMember = "设备属性";
  113. txtProperty.Properties.DisplayMember = "设备属性";
  114. txtProperty.Properties.DataSource = dt;
  115. txtProperty.Properties.NullText = "";//空时的值
  116. txtProperty.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  117. txtProperty.Properties.ValidateOnEnterKey = true;//回车确认
  118. txtProperty.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  119. txtProperty.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  120. //自适应宽度
  121. txtProperty.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  122. #endregion
  123. #region 车间
  124. sql = @"SELECT SEGCODE 车间代码,SEGDESC 车间说明 FROM ICSSEG WHERE WorkPoint='" + AppConfig.WorkPointCode + "' ";
  125. DataTable dtSEG = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  126. lookupSEG.Properties.ValueMember = "车间代码";
  127. lookupSEG.Properties.DisplayMember = "车间代码";
  128. lookupSEG.Properties.DataSource = dtSEG;
  129. lookupSEG.Properties.NullText = "";//空时的值
  130. lookupSEG.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  131. lookupSEG.Properties.ValidateOnEnterKey = true;//回车确认
  132. lookupSEG.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  133. lookupSEG.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  134. //自适应宽度
  135. txtProperty.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  136. #endregion
  137. #region 六大维度
  138. string sql3 = @"SELECT LTRIM(RTRIM(EnumText)) as 类型 FROM Sys_EnumValues WHERE EnumKey='30001' AND LTRIM(RTRIM(EnumText))<>'' AND WorkPointCode='" + AppConfig.WorkPointCode + "'";
  139. DataTable dt30001 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql3).Tables[0];
  140. lookupClass.Properties.ValueMember = "类型";
  141. lookupClass.Properties.DisplayMember = "类型";
  142. lookupClass.Properties.DataSource = dt30001;
  143. lookupClass.Properties.NullText = "";
  144. lookupClass.Properties.ImmediatePopup = true;
  145. lookupClass.Properties.ValidateOnEnterKey = true;
  146. sql3 = @"SELECT LTRIM(RTRIM(EnumText)) as 刀柄 FROM Sys_EnumValues WHERE EnumKey='30002' AND LTRIM(RTRIM(EnumText))<>'' AND WorkPointCode='" + AppConfig.WorkPointCode + "'";
  147. DataTable dt30002 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql3).Tables[0];
  148. lookupHandles.Properties.ValueMember = "刀柄";
  149. lookupHandles.Properties.DisplayMember = "刀柄";
  150. lookupHandles.Properties.DataSource = dt30002;
  151. lookupHandles.Properties.NullText = "";
  152. lookupHandles.Properties.ImmediatePopup = true;
  153. lookupHandles.Properties.ValidateOnEnterKey = true;
  154. sql3 = @"SELECT LTRIM(RTRIM(EnumText)) as 轴数 FROM Sys_EnumValues WHERE EnumKey='30003' AND LTRIM(RTRIM(EnumText))<>'' AND WorkPointCode='" + AppConfig.WorkPointCode + "'";
  155. DataTable dt30003 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql3).Tables[0];
  156. lookupAxis.Properties.ValueMember = "轴数";
  157. lookupAxis.Properties.DisplayMember = "轴数";
  158. lookupAxis.Properties.DataSource = dt30003;
  159. lookupAxis.Properties.NullText = "";
  160. lookupAxis.Properties.ImmediatePopup = true;
  161. lookupAxis.Properties.ValidateOnEnterKey = true;
  162. sql3 = @"SELECT LTRIM(RTRIM(EnumText)) as 刀库数量 FROM Sys_EnumValues WHERE EnumKey='30004' AND LTRIM(RTRIM(EnumText))<>'' AND WorkPointCode='" + AppConfig.WorkPointCode + "'";
  163. DataTable dt30004 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql3).Tables[0];
  164. lookupToolMagazine.Properties.ValueMember = "刀库数量";
  165. lookupToolMagazine.Properties.DisplayMember = "刀库数量";
  166. lookupToolMagazine.Properties.DataSource = dt30004;
  167. lookupToolMagazine.Properties.NullText = "";
  168. lookupToolMagazine.Properties.ImmediatePopup = true;
  169. lookupToolMagazine.Properties.ValidateOnEnterKey = true;
  170. sql3 = @"SELECT LTRIM(RTRIM(EnumText)) as 可加工外形 FROM Sys_EnumValues WHERE EnumKey='30005' AND LTRIM(RTRIM(EnumText))<>'' AND WorkPointCode='" + AppConfig.WorkPointCode + "'";
  171. DataTable dt30005 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql3).Tables[0];
  172. lookupMachinableProfiles.Properties.ValueMember = "可加工外形";
  173. lookupMachinableProfiles.Properties.DisplayMember = "可加工外形";
  174. lookupMachinableProfiles.Properties.DataSource = dt30005;
  175. lookupMachinableProfiles.Properties.NullText = "";
  176. lookupMachinableProfiles.Properties.ImmediatePopup = true;
  177. lookupMachinableProfiles.Properties.ValidateOnEnterKey = true;
  178. sql3 = @"SELECT LTRIM(RTRIM(EnumText)) as 精度 FROM Sys_EnumValues WHERE EnumKey='30006' AND LTRIM(RTRIM(EnumText))<>'' AND WorkPointCode='" + AppConfig.WorkPointCode + "'";
  179. DataTable dt30006 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql3).Tables[0];
  180. lookupAccuracy.Properties.ValueMember = "精度";
  181. lookupAccuracy.Properties.DisplayMember = "精度";
  182. lookupAccuracy.Properties.DataSource = dt30006;
  183. lookupAccuracy.Properties.NullText = "";
  184. lookupAccuracy.Properties.ImmediatePopup = true;
  185. lookupAccuracy.Properties.ValidateOnEnterKey = true;
  186. #endregion
  187. #region 类型
  188. //sql3 = @"SELECT LTRIM(RTRIM(EnumText)) as 分类 FROM Sys_EnumValues WHERE EnumKey='30007' AND LTRIM(RTRIM(EnumText))<>'' AND WorkPointCode='" + AppConfig.WorkPointCode + "'";
  189. sql3 = @"SELECT TypeCODE 分类,TypeDESC 说明 FROM [dbo].[ICSEquipmentType] where WorkPoint='" + AppConfig.WorkPointCode + "'";
  190. DataTable dtType = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql3).Tables[0];
  191. lookupType.Properties.ValueMember = "分类";
  192. lookupType.Properties.DisplayMember = "分类";
  193. lookupType.Properties.DataSource = dtType;
  194. lookupType.Properties.NullText = "";
  195. lookupType.Properties.ImmediatePopup = true;
  196. lookupType.Properties.ValidateOnEnterKey = true;
  197. #endregion
  198. #region 品牌
  199. sql = @"select EnumValue as 品牌代码,EnumText as 品牌名称 from Sys_EnumValues where EnumKey='30007' and WorkPointCode='" + AppConfig.WorkPointCode + "' ";
  200. dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  201. txtModel.Properties.ValueMember = "品牌代码";
  202. txtModel.Properties.DisplayMember = "品牌代码";
  203. txtModel.Properties.DataSource = dt;
  204. txtModel.Properties.NullText = "";//空时的值
  205. txtModel.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  206. txtModel.Properties.ValidateOnEnterKey = true;//回车确认
  207. txtModel.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  208. txtModel.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  209. //自适应宽度
  210. txtModel.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  211. #endregion
  212. #region 车削类型
  213. sql = @"select EnumText as 车削类型 from Sys_EnumValues where enumkey='300010' and WorkPointcode='" + AppConfig.WorkPointCode + "' ";
  214. dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  215. txtcxtype.Properties.ValueMember = "车削类型";
  216. txtcxtype.Properties.DisplayMember = "车削类型";
  217. txtcxtype.Properties.DataSource = dt;
  218. txtcxtype.Properties.NullText = "";
  219. txtcxtype.Properties.ImmediatePopup = true;
  220. txtcxtype.Properties.ValidateOnEnterKey = true;
  221. #endregion
  222. #region 车削精度
  223. sql = @"select EnumText as 车削精度 from Sys_EnumValues where enumkey='300011' and WorkPointcode='" + AppConfig.WorkPointCode + "' order by EnumText";
  224. dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  225. txtcxjd.Properties.ValueMember = "车削精度";
  226. txtcxjd.Properties.DisplayMember = "车削精度";
  227. txtcxjd.Properties.DataSource = dt;
  228. txtcxjd.Properties.NullText = "";
  229. txtcxjd.Properties.ImmediatePopup = true;
  230. txtcxjd.Properties.ValidateOnEnterKey = true;
  231. #endregion
  232. if (!add)
  233. {
  234. SearchShiftInfo(eqpid);
  235. }
  236. chargeFormState(add);
  237. _wait.Close();
  238. }
  239. catch (Exception)
  240. {
  241. _wait.Close();
  242. throw;
  243. }
  244. }
  245. #endregion
  246. private void SearchShiftInfo(string id)
  247. {
  248. equipmentUIModel = ICSEquipmentBLL.SearchEquipmentInfoByCode(id, AppConfig.AppConnectString);
  249. txtEQPCode.Text = equipmentUIModel.EQPCode;
  250. txtEQPName.Text = equipmentUIModel.EQPName;
  251. txtModel.Text = equipmentUIModel.Model;
  252. txtType.Text = equipmentUIModel.Type;
  253. txtEQPStatus.Text = equipmentUIModel.EQPStatus;
  254. txtFIXOP.Text = equipmentUIModel.FIXOP;
  255. txtEQPTypeCode.Text = equipmentUIModel.EType;
  256. txtCompany.Text = equipmentUIModel.Company;
  257. txtAddress.Text = equipmentUIModel.Address;
  258. txtTelPhone.Text = equipmentUIModel.TelPhone;
  259. txtMUSERName.Text = AppConfig.UserName;
  260. txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString();
  261. eqpid = equipmentUIModel.EQPID;
  262. txtProperty.Text = equipmentUIModel.USEStatus;
  263. if (string.IsNullOrEmpty(equipmentUIModel.MCCode) || equipmentUIModel.MCCode == "加工中心")
  264. {
  265. cboEQPSetting.SelectedIndex = 0;
  266. lookupClass.Text = equipmentUIModel.cClass;
  267. lookupHandles.Text = equipmentUIModel.cHandles.ToString();
  268. lookupAxis.Text = equipmentUIModel.cAxis.ToString();
  269. lookupToolMagazine.Text = equipmentUIModel.cToolMagazine.ToString();
  270. lookupMachinableProfiles.Text = equipmentUIModel.cMachinableProfiles.ToString();
  271. lookupAccuracy.Text = equipmentUIModel.cAccuracy;
  272. }
  273. else {
  274. cboEQPSetting.SelectedIndex =1;
  275. txtcxtype.Text = equipmentUIModel.CXType;
  276. txtcxjd.Text = equipmentUIModel.CXJD;
  277. }
  278. lookupType.Text = equipmentUIModel.EType;
  279. lookupSEG.Text = equipmentUIModel.EATTRIBUTE2;
  280. }
  281. #region 关闭
  282. private void btnCancle_Click(object sender, EventArgs e)
  283. {
  284. this.Close();
  285. this.DialogResult = DialogResult.Cancel;
  286. }
  287. private void btnClose_Click(object sender, EventArgs e)
  288. {
  289. this.Close();
  290. this.DialogResult = DialogResult.Cancel;
  291. }
  292. #endregion
  293. #region 产线代码按钮
  294. private void txtSSCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  295. {
  296. ButtonEdit btn = (ButtonEdit)sender;
  297. string sql = "select distinct SSCODE as [产线代码],SSDESC as [产线描述] from dbo.ICSSS with(nolock) WHERE 1=1 AND WorkPoint='" + AppConfig.WorkPointCode + "'";
  298. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  299. //if (obj == null)
  300. //{
  301. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  302. //}
  303. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  304. FormDataRefer reForm = new FormDataRefer();
  305. reForm.FormTitle = "产线信息";
  306. DataTable menuData = data;
  307. reForm.DataSource = menuData;
  308. reForm.MSelectFlag = false;
  309. reForm.RowIndexWidth = 35;
  310. reForm.HideCols.Add("ID");
  311. reForm.FormWidth = 500;
  312. reForm.FormHeight = 500;
  313. //reForm.FilterKey = btn.Text;
  314. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  315. if (reForm.ShowDialog() == DialogResult.OK)
  316. {
  317. DataTable retData = reForm.ReturnData;
  318. foreach (DataRow dr in retData.Rows)
  319. {
  320. txtSSCode.Text = dr["产线代码"].ToString();
  321. //txtItemName.Text = dr["存货名称"].ToString();
  322. }
  323. }
  324. }
  325. #endregion
  326. #region 设备类型按钮
  327. private void txtEType_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  328. {
  329. ButtonEdit btn = (ButtonEdit)sender;
  330. string sql = "select distinct TypeCODE as [设备组编码],TypeDESC as [设备组描述] from ICSEquipmentType with(nolock) WHERE 1=1 AND WorkPoint='" + AppConfig.WorkPointCode + "'";
  331. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  332. //if (obj == null)
  333. //{
  334. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  335. //}
  336. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  337. FormDataRefer reForm = new FormDataRefer();
  338. reForm.FormTitle = "设备类型信息";
  339. DataTable menuData = data;
  340. reForm.DataSource = menuData;
  341. reForm.MSelectFlag = false;
  342. reForm.RowIndexWidth = 35;
  343. reForm.HideCols.Add("ID");
  344. reForm.FormWidth = 500;
  345. reForm.FormHeight = 500;
  346. //reForm.FilterKey = btn.Text;
  347. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  348. if (reForm.ShowDialog() == DialogResult.OK)
  349. {
  350. DataTable retData = reForm.ReturnData;
  351. foreach (DataRow dr in retData.Rows)
  352. {
  353. txtEQPTypeCode.Text = dr["设备组编码"].ToString();
  354. //txtItemName.Text = dr["存货名称"].ToString();
  355. }
  356. }
  357. }
  358. #endregion
  359. #region 新增 修改
  360. private void btnOK_Click(object sender, EventArgs e)
  361. {
  362. string EQPCode = txtEQPCode.Text.Trim();
  363. string EQPName = txtEQPName.Text.Trim();
  364. string EQPStatus = txtProperty.Text.Trim();
  365. string cClass = lookupClass.Text;
  366. string Handles = lookupHandles.Text;
  367. string Axis = lookupAxis.Text;
  368. string ToolMagazine = lookupToolMagazine.Text;
  369. string MachinableProfiles = lookupMachinableProfiles.Text;
  370. string Accuracy = lookupAccuracy.Text;
  371. string FIXOP = txtFIXOP.Text.Trim().Trim(',').ToUpper();
  372. if (FIXOP != "")
  373. {
  374. //每组以字母开始,只能包含字母数字,3位 ; 多组时, 逗号分割
  375. string patten = "^(?:[A-Z][A-Z0-9]{2})(?:,[A-Z][A-Z0-9]{2})*$";
  376. if (!Regex.IsMatch(FIXOP, patten))
  377. {
  378. ICSBaseSimpleCode.AppshowMessageBox("固定设备对应工序只能是3位,以字母开始,多组时用逗号隔开,不能有其他字符");
  379. return;
  380. }
  381. }
  382. if (EQPStatus == "")
  383. {
  384. ICSBaseSimpleCode.AppshowMessageBox("设备状态不能为空!");
  385. return;
  386. }
  387. if (EQPCode == "")
  388. {
  389. ICSBaseSimpleCode.AppshowMessageBox("设备编号不能为空!");
  390. return;
  391. }
  392. if (EQPName == "")
  393. {
  394. ICSBaseSimpleCode.AppshowMessageBox("设备名称不能为空!");
  395. return;
  396. }
  397. if (lookupSEG.Text == "")
  398. {
  399. ICSBaseSimpleCode.AppshowMessageBox("所属车间不能为空!");
  400. return;
  401. }
  402. if (lookupType.Text == "")
  403. {
  404. ICSBaseSimpleCode.AppshowMessageBox("设备类型不能为空!");
  405. return;
  406. }
  407. if (tabControl1.SelectedIndex == 0)
  408. {
  409. if (cClass == "")
  410. {
  411. ICSBaseSimpleCode.AppshowMessageBox("类别不能为空!");
  412. return;
  413. }
  414. if (Handles == "")
  415. {
  416. ICSBaseSimpleCode.AppshowMessageBox("刀柄不能为空!");
  417. return;
  418. }
  419. if (Axis == "")
  420. {
  421. ICSBaseSimpleCode.AppshowMessageBox("轴数不能为空!");
  422. return;
  423. }
  424. if (ToolMagazine == "")
  425. {
  426. ICSBaseSimpleCode.AppshowMessageBox("刀库不能为空!");
  427. return;
  428. }
  429. if (MachinableProfiles == "")
  430. {
  431. ICSBaseSimpleCode.AppshowMessageBox("可加工外形不能为空!");
  432. return;
  433. }
  434. if (Accuracy == "")
  435. {
  436. ICSBaseSimpleCode.AppshowMessageBox("精度不能为空!");
  437. return;
  438. }
  439. }
  440. else if (tabControl1.SelectedIndex == 1)
  441. {
  442. if (txtcxtype.Text == "") {
  443. ICSBaseSimpleCode.AppshowMessageBox("车削类型不能为空!");
  444. return;
  445. }
  446. if (txtcxjd.Text == "")
  447. {
  448. ICSBaseSimpleCode.AppshowMessageBox("车床不能为空!");
  449. return;
  450. }
  451. }
  452. FormICSEquipmentUIModel equipmentInfo = new FormICSEquipmentUIModel();
  453. equipmentInfo.EQPID = eqpid;
  454. equipmentInfo.EQPCode = txtEQPCode.Text.Trim();
  455. equipmentInfo.EQPName = txtEQPName.Text.Trim();
  456. equipmentInfo.Model = txtModel.Text.Trim();//品牌
  457. equipmentInfo.Type = txtType.Text.Trim();
  458. equipmentInfo.EQPStatus = txtEQPStatus.Text.Trim();
  459. equipmentInfo.EQPDESC = txtEQPName.Text.Trim();
  460. equipmentInfo.Company = txtCompany.Text.Trim();
  461. equipmentInfo.Address = txtAddress.Text.Trim();
  462. equipmentInfo.TelPhone = txtTelPhone.Text.Trim();
  463. equipmentInfo.MUSER = AppConfig.UserId;
  464. equipmentInfo.MUSERName = AppConfig.UserName;
  465. equipmentInfo.MTIME = System.DateTime.Parse(txtMTIME.Text);
  466. equipmentInfo.WorkPoint = AppConfig.WorkPointCode;
  467. equipmentInfo.USEStatus = EQPStatus;//设备属性:使用/维修/报废/闲置
  468. if (tabControl1.SelectedIndex == 0) {
  469. equipmentInfo.MCCode = "加工中心";
  470. equipmentInfo.cClass = cClass;
  471. equipmentInfo.cHandles = Convert.ToInt32(Handles);
  472. equipmentInfo.cAxis = Convert.ToInt32(Axis);
  473. equipmentInfo.cToolMagazine = Convert.ToInt32(ToolMagazine);
  474. equipmentInfo.cMachinableProfiles = Convert.ToInt32(MachinableProfiles);
  475. equipmentInfo.cAccuracy = Accuracy;
  476. }
  477. else {
  478. equipmentInfo.MCCode = "车削中心";
  479. equipmentInfo.CXJD = txtcxjd.Text;
  480. equipmentInfo.CXType = txtcxtype.Text;
  481. }
  482. equipmentInfo.EType = lookupType.Text;//F,M
  483. equipmentInfo.EATTRIBUTE2 = lookupSEG.Text;//车间,阿威特只有车间没有线
  484. //equipmentInfo.EATTRIBUTE2 = String.Join(",", cClass, Handles, Axis, ToolMagazine, MachinableProfiles, Accuracy);
  485. equipmentInfo.FIXOP = txtFIXOP.Text;
  486. equipmentInfo.MTStatus = "否";//是否范威设备,阿为特没用
  487. try
  488. {
  489. ICSEquipmentBLL.Add(equipmentInfo, AppConfig.AppConnectString);
  490. this.Close();
  491. ICSBaseSimpleCode.AppshowMessageBox("操作成功");
  492. }
  493. catch (Exception ex)
  494. {
  495. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  496. }
  497. }
  498. private void cboEQPSetting_SelectedIndexChanged(object sender, EventArgs e)
  499. {
  500. tabControl1.SelectedIndex = cboEQPSetting.SelectedIndex;
  501. }
  502. #endregion
  503. //private void FormICSShiftAdd_Load()
  504. //{
  505. // DataTable dt = new DataTable();
  506. // dt = ICSShiftBLL.GetShiftCode();
  507. // string str = dt.Rows[0]["SHIFTCODE"].ToString();
  508. // if (str == "1101000001")
  509. // {
  510. // txtModel.Text = (int.Parse(str) + 1).ToString();
  511. // }
  512. // else
  513. // {
  514. // str = "1101000001";
  515. // }
  516. //}
  517. }
  518. }