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

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