frmSchedulingInfomation.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using CoreFS.CA06;
  10. using Core.Mes.Client.Comm.Tool;
  11. using System.Collections;
  12. using Core.Mes.Client.Comm.Server;
  13. using Infragistics.Win.UltraWinGrid;
  14. using Infragistics.Win.UltraWinMaskedEdit;
  15. using Core.Mes.Client.Comm.Control;
  16. namespace Core.StlMes.Client.SaleOrder.ReviewForm
  17. {
  18. public partial class frmSchedulingInfomation : FrmBase
  19. {
  20. public frmSchedulingInfomation()
  21. {
  22. IsLoadUserView = true;
  23. InitializeComponent();
  24. }
  25. private string flag = "0";
  26. public frmSchedulingInfomation(OpeBase _ob)
  27. {
  28. IsLoadUserView = true;
  29. InitializeComponent();
  30. this.ob = _ob;
  31. flag = "1";
  32. }
  33. private void frmSchedulingInfomation_Load(object sender, EventArgs e)
  34. {
  35. ultraCheckEditor2.Checked = true;
  36. EntityHelper.ShowGridCaption<SchedulingInfomationEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  37. InitDate();
  38. InitOrdNo();
  39. setOtherColumnReadOnly(ultraGrid1, new string[] { "" });
  40. InitCellPosition(ultraGrid1, new string[] { "OrderQty", "PlanedCount", "PlanedWeight", "AmountCount", "AmountWeight", "BillCount", "BillWeight", "OutCount", "OutWeight", "ZtCount", "ZtWeight" });
  41. GridColumnSum(ultraGrid1, new string[] { "OrderQty", "PlanedCount", "PlanedWeight", "AmountCount", "AmountWeight", "BillCount", "BillWeight", "OutCount", "OutWeight", "ZtCount", "ZtWeight" });
  42. setUltraGridColumnMaxInput(ultraGrid1, new string[] { "OrderQty", "PlanedWeight", "AmountWeight", "BillWeight", "OutWeight", "ZtWeight" });
  43. }
  44. public override void ToolBar_Click(object sender, string ToolbarKey)
  45. {
  46. switch (ToolbarKey)
  47. {
  48. case "Query":
  49. DoQuery();
  50. break;
  51. case "Export":
  52. GridHelper.ulGridToExcel(ultraGrid1, "排产信息");
  53. break;
  54. case "Close":
  55. this.Close();
  56. break;
  57. case "Refresh":
  58. InitOrdNo();
  59. break;
  60. default:
  61. break;
  62. }
  63. }
  64. private void DoQuery()
  65. {
  66. string orderNo = "";
  67. if (ultraCheckEditor1.Checked)
  68. {
  69. orderNo = ultraComboEditor1.Text.Trim();
  70. }
  71. string begintime = "";
  72. string endtime = "";
  73. if (ultraCheckEditor2.Checked && udtStart.Value != null && udtEnd.Value != null)
  74. {
  75. begintime = udtStart.Value.ToString();
  76. endtime = udtEnd.DateTime.ToString("yyyy-MM-dd") + " 23:59:59";
  77. }
  78. List<SchedulingInfomationEntity> listSource = EntityHelper.GetData<SchedulingInfomationEntity>(
  79. "com.steering.pss.sale.order.CoreSchedulingInfomation.getSchedulingInfo", new object[] { orderNo, begintime, endtime, this.ValidDataPurviewIds }, ob);
  80. schedulingInfomationEntityBindingSource.DataSource = listSource;
  81. }
  82. public void DoQueryByLnPk(string ordLnPk)
  83. {
  84. List<SchedulingInfomationEntity> listSource = EntityHelper.GetData<SchedulingInfomationEntity>(
  85. "com.steering.pss.sale.order.CoreSchedulingInfomation.getSchedulingInfoByLnPk", new object[] { ordLnPk }, ob);
  86. schedulingInfomationEntityBindingSource.DataSource = listSource;
  87. }
  88. private void InitOrdNo()
  89. {
  90. ultraComboEditor1.DataSource = null;
  91. String beginTime = udtStart.Value.ToString();
  92. String endTime = udtEnd.Value.ToString();
  93. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreConReviewInfo.getOrdNoByTime", new Object[] { beginTime, endTime }, this.ob);
  94. ultraComboEditor1.DataSource = dt;
  95. }
  96. /// <summary>
  97. /// 初始时间
  98. /// </summary>
  99. private void InitDate()
  100. {
  101. udtStart.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).AddMonths(-1);
  102. udtEnd.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).AddDays(1);
  103. }
  104. private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e)
  105. {
  106. if (ultraCheckEditor1.Checked)
  107. {
  108. ultraComboEditor1.ReadOnly = false;
  109. }
  110. else
  111. {
  112. ultraComboEditor1.ReadOnly = true;
  113. }
  114. }
  115. private void ultraCheckEditor2_CheckedChanged(object sender, EventArgs e)
  116. {
  117. if (ultraCheckEditor2.Checked)
  118. {
  119. udtStart.ReadOnly = false;
  120. udtEnd.ReadOnly = false;
  121. }
  122. else
  123. {
  124. udtStart.ReadOnly = true;
  125. udtEnd.ReadOnly = true;
  126. }
  127. }
  128. /// <summary>
  129. /// UltraGrid可读
  130. /// </summary>
  131. /// <param name="ugr">UltraGrid</param>
  132. /// <param name="keys">可编辑列</param>
  133. private void setOtherColumnReadOnly(UltraGrid ugr, string[] keys)
  134. {
  135. keys.ToArray();
  136. foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
  137. {
  138. if (!keys.Contains(ugc.Key))
  139. {
  140. ugc.CellActivation = Activation.ActivateOnly;
  141. }
  142. }
  143. }
  144. /// <summary>
  145. /// 设置列字段显示位置在右
  146. /// </summary>
  147. /// <param name="ug">UltraGrid</param>
  148. /// <param name="columnsKeys">要设置的列</param>
  149. private void InitCellPosition(UltraGrid ug, string[] columnsKeys)
  150. {
  151. columnsKeys.ToArray();
  152. foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[0].Columns)
  153. {
  154. if (columnsKeys.Contains(ugc.Key.ToString()))
  155. {
  156. ugc.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right;
  157. }
  158. }
  159. }
  160. /// <summary>
  161. /// 列求和
  162. /// </summary>
  163. /// <param name="ug">UltraGrid</param>
  164. /// <param name="columnKeys">列数组</param>
  165. private void GridColumnSum(UltraGrid ug, string[] columnKeys)
  166. {
  167. if (columnKeys.Length == 0)
  168. {
  169. return;
  170. }
  171. for (int i = 0; i < columnKeys.Length; i++)
  172. {
  173. SummarySettings summary = ug.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Sum, ug.DisplayLayout.Bands[0].Columns[columnKeys[i]], SummaryPosition.UseSummaryPositionColumn);
  174. summary.DisplayFormat = "{0}";
  175. summary.Appearance.TextHAlign = Infragistics.Win.HAlign.Right;
  176. }
  177. }
  178. /// <summary>
  179. /// 设置列显示位数
  180. /// </summary>
  181. /// <param name="ug"></param>
  182. /// <param name="arr"></param>
  183. private void setUltraGridColumnMaxInput(UltraGrid ug, string[] arr)
  184. {
  185. if (ug == null || arr == null || arr.Length == 0)
  186. {
  187. return;
  188. }
  189. arr.ToArray();
  190. foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[0].Columns)
  191. {
  192. if (arr.Contains(ugc.Key.ToString()))
  193. {
  194. ugc.MaskDisplayMode = MaskMode.IncludeLiterals;
  195. ugc.MaskInput = "{LOC}n,nnn,nnn.nnn";
  196. }
  197. }
  198. }
  199. private void ultraComboEditor1_KeyPress(object sender, KeyPressEventArgs e)
  200. {
  201. if (e.KeyChar == 13)
  202. {
  203. DoQuery();
  204. }
  205. }
  206. }
  207. }