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

521 lines
17 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.Base.Language.Tool;
  10. using ICSSoft.Base.UserControl.MessageControl;
  11. using System.Data.SqlClient;
  12. using ICSSoft.Base.Config.AppConfig;
  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.Frame.Data.BLL;
  18. namespace ICSSoft.Frame.APP
  19. {
  20. public partial class FormICSEQPMaterialTRANS : DevExpress.XtraEditors.XtraForm
  21. {
  22. private string sqltxt = "";
  23. private string sqlconn = "";
  24. String guid = AppConfig.GetGuid();
  25. private DataTable dataSource = null;
  26. #region 构造函数
  27. public FormICSEQPMaterialTRANS()
  28. {
  29. InitializeComponent();
  30. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  31. this.WindowState = FormWindowState.Maximized;
  32. }
  33. #endregion
  34. #region 移动窗体
  35. private const int WM_NCHITTEST = 0x84;
  36. private const int HTCLIENT = 0x1;
  37. private const int HTCAPTION = 0x2;
  38. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  39. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  40. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  41. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  42. //重写窗体,使窗体可以不通过自带标题栏实现移动
  43. protected override void WndProc(ref Message m)
  44. {
  45. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  46. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  47. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  48. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  49. switch (m.Msg)
  50. {
  51. case WM_NCHITTEST:
  52. base.WndProc(ref m);
  53. if ((int)m.Result == HTCLIENT)
  54. m.Result = (IntPtr)HTCAPTION;
  55. return;
  56. }
  57. //拦截双击标题栏、移动窗体的系统消息
  58. if (m.Msg != 0xA3)
  59. {
  60. base.WndProc(ref m);
  61. }
  62. }
  63. #endregion
  64. #region SystemOptition
  65. /// <summary>
  66. /// 操作权限
  67. /// </summary>
  68. /// <returns></returns>
  69. public DataTable RightOfExute()
  70. {
  71. DataTable rData = new DataTable();
  72. rData.Columns.Add("BtnName");
  73. rData.Columns.Add("ActionName");
  74. //查看权限(必须有)
  75. DataRow seeRow = rData.NewRow();
  76. seeRow["BtnName"] = "see";
  77. seeRow["ActionName"] = "查看";
  78. rData.Rows.Add(seeRow);
  79. List<Control> ControlList = new List<Control>();
  80. ControlList.Add(btnConfig);
  81. //ControlList.Add(btnAdd);
  82. //ControlList.Add(btnEdit);
  83. //ControlList.Add(btnDelLable);
  84. foreach (Control ctr in ControlList)
  85. {
  86. if (ctr.GetType() == typeof(SimpleButton))
  87. {
  88. DataRow dr = rData.NewRow();
  89. dr["BtnName"] = ctr.Name;
  90. dr["ActionName"] = ctr.Text;
  91. rData.Rows.Add(dr);
  92. }
  93. }
  94. rData.AcceptChanges();
  95. return rData;
  96. }
  97. /// <summary>
  98. /// 数据权限
  99. /// </summary>
  100. /// <returns></returns>
  101. public DataTable RightOfData()
  102. {
  103. DataTable rData = new DataTable();
  104. rData.Columns.Add("BodyName");
  105. rData.Columns.Add("ControlName");
  106. rData.Columns.Add("ControlCaption");
  107. rData.AcceptChanges();
  108. return rData;
  109. }
  110. #endregion
  111. #region 退出
  112. private void btnClose_Click(object sender, EventArgs e)
  113. {
  114. AppConfig.CloseFormShow(this.Text);
  115. this.Close();
  116. }
  117. private void btnExit_Click(object sender, EventArgs e)
  118. {
  119. AppConfig.CloseFormShow(this.Text);
  120. this.Close();
  121. }
  122. #endregion
  123. #region 过滤
  124. private string tempTableName = "";
  125. private void btnFilter_Click(object sender, EventArgs e)
  126. {
  127. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
  128. filter.OldTempTableName = tempTableName;
  129. if (filter.ShowDialog() == DialogResult.OK)
  130. {
  131. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  132. try
  133. {
  134. _wait.Show();
  135. tempTableName = filter.NewTempTableName;
  136. sqltxt = filter.SqlText;
  137. sqlconn = filter.FilterConnectString;
  138. dataSource = filter.FilterData.Tables[0];
  139. grdDetail.DataSource = dataSource;
  140. grvDetail.BestFitColumns();
  141. rptPage.RecordNum = dataSource.Rows.Count;
  142. rptPage.PageSize = 499;
  143. rptPage.PageIndex = 1;
  144. rptPage.ReLoad();
  145. rptPage.PageSize = 500;
  146. rptPage.PageIndex = 1;
  147. rptPage.ReLoad();
  148. _wait.Close();
  149. }
  150. catch (Exception ex)
  151. {
  152. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  153. _wait.Close();
  154. }
  155. }
  156. }
  157. #endregion
  158. #region 分页
  159. private void rptPage_PageIndexChanged(object Sender, EventArgs e)
  160. {
  161. DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
  162. //DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
  163. grdDetail.DataSource = data;
  164. }
  165. #endregion
  166. #region 全选
  167. private void btnSelect_Click(object sender, EventArgs e)
  168. {
  169. for (int i = 0; i < grvDetail.RowCount; i++)
  170. {
  171. grvDetail.SetRowCellValue(i, colisSelect, "Y");
  172. }
  173. }
  174. #endregion
  175. #region 全消
  176. private void btnCanSelect_Click(object sender, EventArgs e)
  177. {
  178. for (int i = 0; i < grvDetail.RowCount; i++)
  179. {
  180. grvDetail.SetRowCellValue(i, colisSelect, "");
  181. }
  182. }
  183. #endregion
  184. #region 刷新
  185. private void btnFalsh_Click(object sender, EventArgs e)
  186. {
  187. if (sqlconn == null || sqlconn == "")
  188. {
  189. return;
  190. }
  191. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  192. try
  193. {
  194. _wait.Show();
  195. FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name), false);
  196. filter.OldTempTableName = tempTableName;
  197. //tempTableName = filter.NewTempTableName;
  198. //DataTable data = DBHelper.ExecuteDataset(AppConfig.FrameConnectString, CommandType.Text, "select * from " + tempTableName).Tables[0];
  199. dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0];
  200. grdDetail.DataSource = dataSource;
  201. grvDetail.BestFitColumns();
  202. rptPage.RecordNum = dataSource.Rows.Count;
  203. rptPage.PageIndex = 1;
  204. rptPage.ReLoad();
  205. _wait.Close();
  206. }
  207. catch (Exception ex)
  208. {
  209. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  210. _wait.Close();
  211. }
  212. }
  213. #endregion
  214. #region 列表
  215. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  216. {
  217. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  218. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  219. }
  220. #endregion
  221. #region 双击选择
  222. private void grvDetail_DoubleClick(object sender, EventArgs e)
  223. {
  224. if (grvDetail.FocusedRowHandle < 0)
  225. {
  226. return;
  227. }
  228. if (grvDetail.FocusedColumn == colisSelect)
  229. {
  230. if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "")
  231. {
  232. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "Y");
  233. }
  234. else
  235. {
  236. grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "");
  237. }
  238. }
  239. }
  240. #endregion
  241. #region 删除
  242. private void btnDel_Click(object sender, EventArgs e)
  243. {
  244. grvDetail.PostEditor();
  245. this.Validate();
  246. if (grvDetail.RowCount == 0)
  247. return;
  248. SimpleButton btntemp = (SimpleButton)sender;
  249. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  250. {
  251. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  252. }
  253. List<string> guidList = new List<string>();
  254. List<string> guidList1 = new List<string>();
  255. for (int i = 0; i < grvDetail.RowCount; i++)
  256. {
  257. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  258. {
  259. //guidList.Add(grvDetail.GetRowCellValue(i, colEQPID).ToString());
  260. }
  261. }
  262. if (guidList.Count == 0)
  263. {
  264. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  265. return;
  266. }
  267. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除该设备吗?设备删除后无法恢复,确定吗?") != DialogResult.OK)
  268. return;
  269. try
  270. {
  271. ICSEquipmentBLL.delete(guidList);
  272. ICSBaseSimpleCode.AppshowMessageBox(0, "删除成功");
  273. }
  274. catch (Exception ex)
  275. {
  276. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  277. }
  278. btnFalsh_Click(null, null);
  279. }
  280. #endregion
  281. #region 新增
  282. private void btnAdd_Click(object sender, EventArgs e)
  283. {
  284. SimpleButton btntemp = (SimpleButton)sender;
  285. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  286. {
  287. MessageBox.Show("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  288. return;
  289. }
  290. FormICSEQPMaterialINVAdd add = new FormICSEQPMaterialINVAdd();
  291. add.ShowDialog();
  292. btnFalsh_Click(null, null);
  293. }
  294. #endregion
  295. #region 绑定数据源
  296. private void btnConfig_Click(object sender, EventArgs e)//绑定数据源
  297. {
  298. if (AppConfig.UserCode.ToLower() != "demo")
  299. {
  300. //ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
  301. return;
  302. }
  303. FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
  304. fdata.ShowDialog();
  305. }
  306. #endregion
  307. private void FormICSShift_Load(object sender, EventArgs e)
  308. {
  309. btnFilter_Click(sender, e);
  310. }
  311. #region 修改
  312. private void btnEdit_Click(object sender, EventArgs e)
  313. {
  314. SimpleButton btntemp = (SimpleButton)sender;
  315. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  316. {
  317. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  318. return;
  319. }
  320. int count = 0;
  321. for (int i = 0; i < grvDetail.RowCount; i++)
  322. {
  323. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  324. {
  325. count++;
  326. }
  327. }
  328. if (count != 1)
  329. {
  330. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  331. return;
  332. }
  333. try
  334. {
  335. string id;
  336. for (int i = 0; i < grvDetail.RowCount; i++)
  337. {
  338. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  339. {
  340. //id = grvDetail.GetRowCellValue(i, colEQPID).ToString();
  341. //FormICSEquipmentAdd add = new FormICSEquipmentAdd(id);
  342. //add.ShowDialog();
  343. }
  344. }
  345. btnFalsh_Click(null, null);
  346. }
  347. catch (Exception ex)
  348. {
  349. //throw ex;
  350. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  351. }
  352. }
  353. #endregion
  354. private void btnOutPut_Click(object sender, EventArgs e)
  355. {
  356. FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
  357. foe.ShowDialog();
  358. }
  359. #region 领退详情按钮
  360. private void repositoryItemButtonEdit1_BottonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  361. {
  362. string mcode = "";
  363. if (grvDetail.FocusedColumn == colTransDetail)
  364. {
  365. mcode = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colMCODE).ToString();
  366. FormICSEQPMaterialTRANSDetail linkDetail = new FormICSEQPMaterialTRANSDetail(mcode);
  367. linkDetail.ShowDialog();
  368. }
  369. }
  370. #endregion
  371. //#region 设备处理按钮
  372. //private void repositoryItemButtonEdit2_BottonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  373. //{
  374. // //string eqpID = "";
  375. // //if (grvDetail.FocusedColumn == colEQPHandle)
  376. // //{
  377. // // eqpID = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colEQPID).ToString();
  378. // // FormICSEQPHandle linkDetail = new FormICSEQPHandle(eqpID);
  379. // // linkDetail.ShowDialog();
  380. // //}
  381. //}
  382. //#endregion
  383. //#region 设备报修按钮
  384. //private void repositoryItemButtonEdit3_BottonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  385. //{
  386. // //string eqpID = "";
  387. // //if (grvDetail.FocusedColumn == colEQPTS)
  388. // //{
  389. // // eqpID = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colEQPID).ToString();
  390. // // FormICSEQPTS linkDetail = new FormICSEQPTS(eqpID);
  391. // // linkDetail.ShowDialog();
  392. // //}
  393. //}
  394. //#endregion
  395. private void txtTrans_Click(object sender, EventArgs e)
  396. {
  397. SimpleButton btntemp = (SimpleButton)sender;
  398. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  399. {
  400. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  401. return;
  402. }
  403. int count = 0;
  404. for (int i = 0; i < grvDetail.RowCount; i++)
  405. {
  406. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  407. {
  408. count++;
  409. }
  410. }
  411. if (count != 1)
  412. {
  413. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  414. return;
  415. }
  416. try
  417. {
  418. string code;
  419. string mtype;
  420. for (int i = 0; i < grvDetail.RowCount; i++)
  421. {
  422. if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  423. {
  424. code = grvDetail.GetRowCellValue(i, colMCODE).ToString();
  425. mtype = grvDetail.GetRowCellValue(i, colMtype).ToString();
  426. FormICSEQPMaterialTRANSAdd add = new FormICSEQPMaterialTRANSAdd(code,mtype);
  427. add.ShowDialog();
  428. }
  429. }
  430. btnFalsh_Click(null, null);
  431. }
  432. catch (Exception ex)
  433. {
  434. //throw ex;
  435. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  436. }
  437. }
  438. }
  439. }