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

310 lines
11 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Data.Linq;
  6. using System.Linq;
  7. using System.Drawing;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using DevExpress.XtraEditors;
  11. using DevExpress.XtraGrid.Views.BandedGrid;
  12. using DevExpress.XtraGrid.Columns;
  13. using DevExpress.XtraGrid;
  14. using System.IO;
  15. using System.Threading;
  16. using ICSSoft.Base.Language.Tool;
  17. using ICSSoft.Base.Config.AppConfig;
  18. using ICSSoft.Base.UserControl.MessageControl;
  19. using ICSSoft.Base.Config.DBHelper;
  20. using ICSSoft.Base.Report.Filter;
  21. using ICSSoft.Base.UserControl.FormControl;
  22. using ICSSoft.Base.Report.GridReport;
  23. using ICSSoft.Base.ReferForm.AppReferForm;
  24. using ICSSoft.Frame.Data.BLL;
  25. using ICSSoft.Frame.Data.Entity;
  26. using ICSSoft.Base.Lable.PrintTool;
  27. namespace ICSSoft.Frame.APP
  28. {
  29. public partial class FormICSPOArriveLOTPrint : DevExpress.XtraEditors.XtraForm
  30. {
  31. private string sqltxt = "";
  32. private string sqlconn = "";
  33. String guid = AppConfig.GetGuid();
  34. private DataTable dataSource = null;
  35. private DataTable Serialdata = null;
  36. #region 构造函数
  37. public FormICSPOArriveLOTPrint()
  38. {
  39. InitializeComponent();
  40. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  41. this.WindowState = FormWindowState.Maximized;
  42. }
  43. #endregion
  44. #region 操作权限
  45. public DataTable RightOfExute()
  46. {
  47. DataTable rData = new DataTable();
  48. rData.Columns.Add("BtnName");
  49. rData.Columns.Add("ActionName");
  50. //查看权限(必须有)
  51. DataRow seeRow = rData.NewRow();
  52. seeRow["BtnName"] = "see";
  53. seeRow["ActionName"] = "查看";
  54. rData.Rows.Add(seeRow);
  55. List<Control> ControlList = new List<Control>();
  56. ControlList.Add(btnPrint);
  57. ControlList.Add(btnPrint);
  58. foreach (Control ctr in ControlList)
  59. {
  60. if (ctr.GetType() == typeof(SimpleButton))
  61. {
  62. DataRow dr = rData.NewRow();
  63. dr["BtnName"] = ctr.Name;
  64. dr["ActionName"] = ctr.Text;
  65. rData.Rows.Add(dr);
  66. }
  67. }
  68. rData.AcceptChanges();
  69. return rData;
  70. }
  71. public DataTable RightOfData()// 数据权限
  72. {
  73. DataTable rData = new DataTable();
  74. rData.Columns.Add("BodyName");
  75. rData.Columns.Add("ControlName");
  76. rData.Columns.Add("ControlCaption");
  77. rData.AcceptChanges();
  78. return rData;
  79. }
  80. #endregion
  81. #region 退出
  82. private void btnClose_Click(object sender, EventArgs e)
  83. {
  84. AppConfig.CloseFormShow(this.Text);
  85. this.Close();
  86. }
  87. private void btnExit_Click(object sender, EventArgs e)
  88. {
  89. AppConfig.CloseFormShow(this.Text);
  90. this.Close();
  91. }
  92. #endregion
  93. #region 移动窗体
  94. private const int WM_NCHITTEST = 0x84;
  95. private const int HTCLIENT = 0x1;
  96. private const int HTCAPTION = 0x2;
  97. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  98. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  99. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  100. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  101. //重写窗体,使窗体可以不通过自带标题栏实现移动
  102. protected override void WndProc(ref Message m)
  103. {
  104. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  105. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  106. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  107. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  108. switch (m.Msg)
  109. {
  110. case WM_NCHITTEST:
  111. base.WndProc(ref m);
  112. if ((int)m.Result == HTCLIENT)
  113. m.Result = (IntPtr)HTCAPTION;
  114. return;
  115. }
  116. //拦截双击标题栏、移动窗体的系统消息
  117. if (m.Msg != 0xA3)
  118. {
  119. base.WndProc(ref m);
  120. }
  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. gridControl.DataSource = dataSource;
  140. gridView.BestFitColumns();
  141. _wait.Close();
  142. }
  143. catch (Exception ex)
  144. {
  145. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  146. _wait.Close();
  147. }
  148. }
  149. }
  150. #endregion
  151. #region 绑定数据源
  152. private void btnConfig_Click(object sender, EventArgs e)
  153. {
  154. if (AppConfig.UserCode.ToLower() != "demo")
  155. {
  156. ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
  157. return;
  158. }
  159. FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
  160. fdata.ShowDialog();
  161. }
  162. #endregion
  163. #region 过滤方法
  164. private void FormContainerManager_FormClosing(object sender, FormClosingEventArgs e)
  165. {
  166. AppConfig.DropTemTable(tempTableName);
  167. }
  168. #endregion
  169. #region 全选
  170. private void btnSelectAll_Click(object sender, EventArgs e)
  171. {
  172. gridView.PostEditor();
  173. this.Validate();
  174. for (int i = 0; i < gridView.RowCount; i++)
  175. {
  176. gridView.SetRowCellValue(i, coSelect, "Y");
  177. }
  178. }
  179. #endregion
  180. #region 全消
  181. private void btnCancelAll_Click(object sender, EventArgs e)
  182. {
  183. gridView.PostEditor();
  184. this.Validate();
  185. for (int i = 0; i < gridView.RowCount; i++)
  186. {
  187. gridView.SetRowCellValue(i, coSelect, "");
  188. }
  189. }
  190. #endregion
  191. #region 双击
  192. private void gridView_DoubleClick(object sender, EventArgs e)
  193. {
  194. if (gridView.FocusedRowHandle < 0)
  195. {
  196. return;
  197. }
  198. if (gridView.FocusedColumn == coSelect)
  199. {
  200. if (gridView.GetRowCellValue(gridView.FocusedRowHandle, coSelect).ToString() == "")
  201. {
  202. gridView.SetRowCellValue(gridView.FocusedRowHandle, coSelect, "Y");
  203. }
  204. else
  205. {
  206. gridView.SetRowCellValue(gridView.FocusedRowHandle, coSelect, "");
  207. }
  208. }
  209. }
  210. #endregion
  211. #region 列表
  212. private void gridView_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  213. {
  214. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  215. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  216. }
  217. #endregion
  218. #region 分页
  219. private void rptPage_PageIndexChanged(object Sender, EventArgs e)
  220. {
  221. DataTable data = AppConfig.GetPageData(Serialdata, rptPage.PageIndex, rptPage.PageSize).Copy();
  222. gridControl.DataSource = data;
  223. }
  224. #endregion
  225. #region CustomDrawCell
  226. private void gridView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
  227. {
  228. if (e.RowHandle >= 0 && e.Column.FieldName == "DCTCODE")
  229. {
  230. e.CellValue = "cccc";
  231. }
  232. }
  233. #endregion
  234. #region 打印
  235. private void btnPrint_Click(object sender, EventArgs e)
  236. {
  237. try
  238. {
  239. if (sender != null)
  240. {
  241. SimpleButton btntemp = (SimpleButton)sender;
  242. if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
  243. {
  244. ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
  245. return;
  246. }
  247. }
  248. List<PrintPara> parasList = new List<PrintPara>();
  249. List<ICSITEMLot> InfoList = new List<ICSITEMLot>();
  250. for (int i = 0; i < gridView.RowCount; i++)
  251. {
  252. if (gridView.GetRowCellValue(i, coSelect).ToString() == "Y")
  253. {
  254. string sql = @"SELECT A.LotNO FROM ICSITEMLot A WHERE A.TransNO = '{0}' AND A.TransLine = '{1}' ";
  255. sql = string.Format(sql, gridView.GetRowCellValue(i, cocCode).ToString(), gridView.GetRowCellValue(i, coirowno).ToString());
  256. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  257. if (dt.Rows.Count > 0 && dt != null)
  258. {
  259. foreach (DataRow dr in dt.Rows)
  260. {
  261. PrintPara para = new PrintPara();
  262. para.PrintKey = "LotNO";
  263. para.PrintValues = new object[] { dr["LotNO"].ToString() };
  264. parasList.Add(para);
  265. }
  266. }
  267. }
  268. }
  269. if (parasList.Count == 0)
  270. {
  271. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  272. return;
  273. }
  274. #region 修改打印模板逻辑
  275. FormPrintDialog f = new FormPrintDialog("001", this.Text, parasList, false, null);
  276. f.ShowDialog();
  277. #endregion
  278. //更新打印信息
  279. //FormICSPurchaseLOTBLL.updatePrint(InfoList, AppConfig.AppConnectString);
  280. }
  281. catch (Exception ex)
  282. {
  283. MessageBox.Show(ex.ToString());
  284. }
  285. }
  286. #endregion
  287. private void FormICSPOArriveLOT_Load(object sender, EventArgs e)
  288. {
  289. btnFilter_Click(sender, e);
  290. }
  291. }
  292. }