F_PM_2110.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_2110.cs
  5. * 2.功能描述:清除在产回收站残留数据
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2015/08/11 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Text;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.Basics.DockPanel;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.Controls;
  18. using Dongke.IBOSS.PRD.Client.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.PMModule
  22. {
  23. public partial class F_PM_2110 : DKDockPanelBase
  24. {
  25. #region 成员变量
  26. // 窗体的单例模式
  27. private static F_PM_2110 _instance;
  28. //默认清空工序,重置回用户当前权限工序
  29. private string _currentUserPurview = null;
  30. //默认清空生产线,重置回用户当前权限生产线
  31. private string _currentUserLinePuview = null;
  32. #endregion
  33. #region 构造函数
  34. public F_PM_2110()
  35. {
  36. InitializeComponent();
  37. //自动适应列宽
  38. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  39. //关闭
  40. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  41. //查询
  42. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  43. // 清除选择
  44. this.tsbtnClearSelected.Text = ButtonText.TSBTN_CLEARSELECTED;
  45. //批量清除
  46. this.tsbtnAllClear.Text = ButtonText.TSBTN_CLEARALL;
  47. //清空条件
  48. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  49. //查询条件
  50. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  51. // 窗体显示的Title
  52. this.Text = FormTitles.F_PM_2110;
  53. }
  54. #endregion
  55. #region 单例模式
  56. /// <summary>
  57. /// 单例模式,防止重复创建窗体
  58. /// </summary>
  59. public static F_PM_2110 Instance
  60. {
  61. get
  62. {
  63. if (_instance == null || _instance.IsDisposed)
  64. {
  65. _instance = new F_PM_2110();
  66. }
  67. return _instance;
  68. }
  69. }
  70. #endregion
  71. #region 事件
  72. /// <summary>
  73. /// 窗体加载事件
  74. /// </summary>
  75. /// <param name="sender"></param>
  76. /// <param name="e"></param>
  77. private void F_PM_2110_Load(object sender, EventArgs e)
  78. {
  79. try
  80. {
  81. // 加载权限
  82. FormPermissionManager.FormPermissionControl(this.Name, this,
  83. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  84. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  85. // 设置表格不自动创建列
  86. this.dgvInProduction.AutoGenerateColumns = false;
  87. // 初始化时间控件为当前日期
  88. //this.dtpCreateTimeStart.Value = DateTime.Now.Date;
  89. //this.dtpCreateTimeEnd.Value = DateTime.Now.Date;
  90. this.dtpUpdateTimeStart.Value = DateTime.Now.Date;
  91. this.dtpUpdateTimeEnd.Value = DateTime.Now.Date;
  92. this.dtpScrapDate.Value = DateTime.Now.Date;
  93. this.dtpScrapDateEnd.Value = DateTime.Now.Date;
  94. this.dtpUpdateTimeStart.Enabled = false;
  95. this.dtpUpdateTimeEnd.Enabled = false;
  96. this.dtpScrapDate.Enabled = false;
  97. this.dtpScrapDateEnd.Enabled = false;
  98. //绑定产品分级
  99. BindGoodsType();
  100. }
  101. catch (Exception ex)
  102. {
  103. // 对异常进行共通处理
  104. ExceptionManager.HandleEventException(this.ToString(),
  105. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  106. }
  107. }
  108. /// <summary>
  109. /// 窗体关闭事件
  110. /// </summary>
  111. /// <param name="sender"></param>
  112. /// <param name="e"></param>
  113. private void F_PM_2110_FormClosed(object sender, FormClosedEventArgs e)
  114. {
  115. _instance = null;
  116. }
  117. /// <summary>
  118. /// 关闭按钮事件
  119. /// </summary>
  120. /// <param name="sender"></param>
  121. /// <param name="e"></param>
  122. private void tsbtnClose_Click(object sender, EventArgs e)
  123. {
  124. this.Close();
  125. }
  126. /// <summary>
  127. /// 查询按钮事件
  128. /// </summary>
  129. /// <param name="sender"></param>
  130. /// <param name="e"></param>
  131. private void btnSearch_Click(object sender, EventArgs e)
  132. {
  133. try
  134. {
  135. this.dgvInProduction.DataSource = null;
  136. this.dgvInProduction.DataSource = this.GetSearchData();
  137. }
  138. catch (Exception ex)
  139. {
  140. this.btnSearch.Enabled = true;
  141. this.btnClearCondition.Enabled = true;
  142. // 对异常进行共通处理
  143. ExceptionManager.HandleEventException(this.ToString(),
  144. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  145. }
  146. }
  147. /// <summary>
  148. /// 自动适应列宽
  149. /// </summary>
  150. /// <param name="sender"></param>
  151. /// <param name="e"></param>
  152. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  153. {
  154. this.dgvInProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  155. }
  156. /// <summary>
  157. /// 清空条件按钮事件
  158. /// </summary>
  159. /// <param name="sender"></param>
  160. /// <param name="e"></param>
  161. private void btnClearCondition_Click(object sender, EventArgs e)
  162. {
  163. //清空更多条件内容
  164. this.dkProcedureSearchBox.ClearControl();
  165. this.dkproductionLineSearchBox.ClearControl();
  166. this.dtpUpdateTimeStart.Value = DateTime.Now.Date;
  167. this.dtpUpdateTimeEnd.Value = DateTime.Now.Date;
  168. this.dtpScrapDate.Value = DateTime.Now.Date;
  169. this.dtpScrapDateEnd.Value = DateTime.Now.Date;
  170. this.comGoodsType.SelectedValue = 8;
  171. this.dkProcedureSearchBox.ProcedureIDS = this._currentUserPurview;
  172. this.dkproductionLineSearchBox.ProductionLineIDS = this._currentUserLinePuview;
  173. this.txtBarcode.Text = "";
  174. this.chkDateTime.Checked = false;
  175. this.chkScrapDate.Checked = false;
  176. }
  177. /// <summary>
  178. /// 清除选择按钮事件
  179. /// </summary>
  180. /// <param name="sender"></param>
  181. /// <param name="e"></param>
  182. private void tsbtnClearSelected_Click(object sender, EventArgs e)
  183. {
  184. try
  185. {
  186. DataTable dt = this.dgvInProduction.DataSource as DataTable;
  187. if (dt == null)
  188. {
  189. return;
  190. }
  191. dt.AcceptChanges();
  192. DataRow[] dr = dt.Select("Sel=1");
  193. if (dr.Length == 0)
  194. {
  195. MessageBox.Show("请选择清除在产回收站的产品",
  196. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  197. return;
  198. }
  199. DialogResult dialogResult
  200. = MessageBox.Show("确认是否清除选中的在产回收站产品?",
  201. this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  202. if (dialogResult.Equals(DialogResult.No))
  203. {
  204. return;
  205. }
  206. string barcodes = "";
  207. foreach (DataRow r in dr)
  208. {
  209. barcodes += r["barcode"].ToString() + ",";
  210. }
  211. barcodes = barcodes.TrimEnd(',');
  212. // 清除
  213. int result = (int)DoAsync(() =>
  214. {
  215. return PMModuleProxy.Service.SaveClearInproductionTrash(barcodes);
  216. });
  217. if (result > Constant.INT_IS_ZERO)
  218. {
  219. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "在产回收站产品", "清除数据"),
  220. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  221. // 刷新窗口数据
  222. this.btnSearch_Click(sender, e);
  223. }
  224. else
  225. {
  226. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "在产回收站产品", "清除数据"),
  227. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  228. return;
  229. }
  230. }
  231. catch (Exception ex)
  232. {
  233. // 对异常进行共通处理
  234. ExceptionManager.HandleEventException(this.ToString(),
  235. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  236. }
  237. }
  238. /// <summary>
  239. /// 批量清除按钮事件
  240. /// </summary>
  241. /// <param name="sender"></param>
  242. /// <param name="e"></param>
  243. private void tsbtnAllClear_Click(object sender, EventArgs e)
  244. {
  245. try
  246. {
  247. F_PM_2111 frmPM2111 = new F_PM_2111();
  248. DialogResult dialogResult = frmPM2111.ShowDialog();
  249. // 重新加载GridView
  250. if (dialogResult == DialogResult.OK)
  251. {
  252. btnSearch_Click(sender, e);
  253. }
  254. }
  255. catch (Exception ex)
  256. {
  257. // 对异常进行共通处理
  258. ExceptionManager.HandleEventException(this.ToString(),
  259. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  260. }
  261. }
  262. /// <summary>
  263. /// 表格状态自动提交
  264. /// </summary>
  265. /// <param name="sender"></param>
  266. /// <param name="e"></param>
  267. private void dgvInProduction_CurrentCellDirtyStateChanged(object sender, EventArgs e)
  268. {
  269. try
  270. {
  271. if (this.dgvInProduction.CurrentRow != null && this.dgvInProduction.IsCurrentCellDirty)
  272. {
  273. if ("Sel".Equals(this.dgvInProduction.Columns
  274. [this.dgvInProduction.CurrentCell.ColumnIndex].Name))
  275. {
  276. this.dgvInProduction.CommitEdit(DataGridViewDataErrorContexts.Commit);
  277. }
  278. }
  279. }
  280. catch (Exception ex)
  281. {
  282. // 对异常进行共通处理
  283. ExceptionManager.HandleEventException(this.ToString(),
  284. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  285. }
  286. }
  287. private void chkDateTime_CheckedChanged(object sender, EventArgs e)
  288. {
  289. dtpUpdateTimeStart.Enabled = chkDateTime.Checked;
  290. dtpUpdateTimeEnd.Enabled = chkDateTime.Checked;
  291. }
  292. private void chkScrapDate_CheckedChanged(object sender, EventArgs e)
  293. {
  294. dtpScrapDate.Enabled = chkScrapDate.Checked;
  295. dtpScrapDateEnd.Enabled = chkScrapDate.Checked;
  296. }
  297. #endregion
  298. #region 私有方法
  299. /// <summary>
  300. /// 根据界面查询条件获取数据集
  301. /// </summary>
  302. private DataTable GetSearchData()
  303. {
  304. try
  305. {
  306. FPM2110_SE se = new FPM2110_SE();
  307. se.ProductionLineIDS = dkproductionLineSearchBox.ProductionLineIDS;
  308. se.ProcedureIDS = dkProcedureSearchBox.ProcedureIDS;
  309. if (chkDateTime.Checked)
  310. {
  311. se.UpdateTimeStart = DateTime.Parse(this.dtpUpdateTimeStart.Value.ToString("yyyy-MM-dd") + " 0:0:0");
  312. se.UpdateTimeEnd = DateTime.Parse(this.dtpUpdateTimeEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59");
  313. }
  314. if (chkScrapDate.Checked)
  315. {
  316. //报废日期
  317. se.ScrapDataStart = DateTime.Parse(this.dtpScrapDate.Value.ToString("yyyy-MM-dd") + " 0:0:0");
  318. se.ScrapDataEnd = DateTime.Parse(this.dtpScrapDateEnd.Value.ToString("yyyy-MM-dd") + " 0:0:0");
  319. }
  320. se.GooddLevelTypeID = Convert.ToInt32(comGoodsType.SelectedValue);
  321. se.Barcode = this.txtBarcode.Text.Trim();
  322. // 调用服务器端获取数据集
  323. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  324. {
  325. return PMModuleProxy.Service.GetPM2110Data(se);
  326. }
  327. );
  328. if (sre.Status == Constant.ServiceResultStatus.Success)
  329. {
  330. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  331. {
  332. // 提示未查找到数据
  333. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  334. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  335. //清空数据
  336. return null;
  337. }
  338. return sre.Data.Tables[0];
  339. }
  340. return null;
  341. }
  342. catch (Exception ex)
  343. {
  344. throw ex;
  345. }
  346. }
  347. /// <summary>
  348. /// 绑定产品分级
  349. /// </summary>
  350. private void BindGoodsType()
  351. {
  352. DataTable dt = new DataTable();
  353. dt.Columns.Add("GoodsLevelTypeID");
  354. dt.Columns.Add("GoodsLevelTypeName");
  355. DataRow dr = dt.NewRow();
  356. dr["GoodsLevelTypeID"] = 8;
  357. dr["GoodsLevelTypeName"] = "损坯";
  358. dt.Rows.Add(dr);
  359. dr = dt.NewRow();
  360. dr["GoodsLevelTypeID"] = 7;
  361. dr["GoodsLevelTypeName"] = "次品";
  362. dt.Rows.Add(dr);
  363. dr = dt.NewRow();
  364. dr["GoodsLevelTypeID"] = 3;
  365. dr["GoodsLevelTypeName"] = "废品";
  366. dt.Rows.Add(dr);
  367. dr = dt.NewRow();
  368. dr["GoodsLevelTypeID"] = 13;
  369. dr["GoodsLevelTypeName"] = "不合格";
  370. dt.Rows.Add(dr);
  371. dr = dt.NewRow();
  372. dr["GoodsLevelTypeID"] = 14;
  373. dr["GoodsLevelTypeName"] = "不合格(返)";
  374. dt.Rows.Add(dr);
  375. this.comGoodsType.DataSource = dt;
  376. this.comGoodsType.DisplayMember = "GoodsLevelTypeName";
  377. this.comGoodsType.ValueMember = "GoodsLevelTypeID";
  378. }
  379. #endregion
  380. }
  381. }