FrmStuffAdjust.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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.Control;
  11. using Core.Mes.Client.Comm.Tool;
  12. using Core.StlMes.Client.YdmStuffManage.Entity;
  13. using System.Collections;
  14. using Core.Mes.Client.Comm.Server;
  15. using Infragistics.Win.UltraWinGrid;
  16. using Infragistics.Win;
  17. using Core.Mes.Client.Comm.Format;
  18. namespace Core.StlMes.Client.YdmStuffManage
  19. {
  20. public partial class FrmStuffAdjust : FrmBase
  21. {
  22. public FrmStuffAdjust()
  23. {
  24. InitializeComponent();
  25. }
  26. private string strBound = "800603";//调差编码
  27. /// <summary>
  28. /// 重写基类方法
  29. /// </summary>
  30. /// <param name="sender"></param>
  31. /// <param name="ToolbarKey"></param>
  32. public override void ToolBar_Click(object sender, string ToolbarKey)
  33. {
  34. switch (ToolbarKey)
  35. {
  36. case "Query":
  37. if (!CheckQuery()) return;
  38. doQueryData();
  39. break;
  40. case "Add":
  41. doAdd();
  42. break;
  43. case"Export":
  44. exportData();
  45. break;
  46. case "Close":
  47. this.Close();
  48. break;
  49. }
  50. }
  51. /// <summary>
  52. /// 导出
  53. /// </summary>
  54. private void exportData()
  55. {
  56. GridHelper.ulGridToExcel(ultraGrid2, "调差实绩");
  57. }
  58. /// <summary>
  59. /// 新增
  60. /// </summary>
  61. private void doAdd()
  62. {
  63. this.ultraGrid1.UpdateData();
  64. string departId = ClsBaseInfo.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob);
  65. string departMent = ClsBaseInfo.GetDepartBySectionId(this.UserInfo.GetDeptid(), this.ob);
  66. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  67. if (checkMagRows.Count() == 0)
  68. {
  69. MessageUtil.ShowTips("请勾选需要调差的物料!");
  70. return;
  71. }
  72. ArrayList parmlist = new ArrayList();
  73. foreach (UltraGridRow row in checkMagRows)
  74. {
  75. if (Double.Parse(row.Cells["adjustActWeight"].Text.Trim()) + Double.Parse(row.Cells["actWeight"].Text.Trim())<0)
  76. {
  77. MessageUtil.ShowTips("调差量不允许大于库存量!");
  78. return;
  79. }
  80. MatGpMEntity matZcMEntity = (MatGpMEntity)row.ListObject;
  81. string matEntity = JSONFormat.Format(matZcMEntity);
  82. parmlist.Add(matEntity);
  83. }
  84. if (MessageUtil.ShowYesNoAndQuestion("是否调差?") == DialogResult.No)
  85. {
  86. return;
  87. }
  88. CoreClientParam ccp = new CoreClientParam();
  89. ccp.ServerName = "com.steering.pss.ydm.Stuffmanage.FrmStuffAdjust";
  90. ccp.MethodName = "doAddAdjust";
  91. ccp.ServerParams = new object[] { parmlist,strBound, this.UserInfo.GetUserName(),this.UserInfo.GetDeptid(), this.UserInfo.GetDepartment(), departId, departMent };
  92. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  93. if (ccp.ReturnCode != -1)
  94. {
  95. if (ccp.ReturnInfo.Equals("调差成功!"))
  96. {
  97. doQueryData();
  98. MessageUtil.ShowTips(ccp.ReturnInfo);
  99. }
  100. }
  101. else
  102. {
  103. MessageUtil.ShowTips(ccp.ReturnInfo);
  104. }
  105. }
  106. /// <summary>
  107. /// 查询
  108. /// </summary>
  109. private void doQueryData()
  110. {
  111. if (ultraTabControl1.SelectedTab.Key == "0")
  112. {
  113. doQueryMat();
  114. }
  115. else
  116. {
  117. doQueryStockData();
  118. }
  119. }
  120. /// <summary>
  121. /// 查询库存信息
  122. /// </summary>
  123. private void doQueryMat()
  124. {
  125. string strRegStart = "";
  126. string strRegEnd = "";
  127. string heatNo = "";
  128. string[] arr = BaseMethod.WarehousePermissions(this.CustomInfo, this.ValidDataPurviewIds, this.ob);
  129. ArrayList parm = new ArrayList();
  130. if (chkRegTime.Checked)
  131. {
  132. strRegStart = RegStartTime.Value.ToString();
  133. strRegEnd = RegEndTime.Value.ToString();
  134. }
  135. if (this.checkHeatNo.Checked)
  136. {
  137. heatNo = this.txt_heatNo.Text.Trim();
  138. }
  139. parm.Add(heatNo);
  140. List<MatGpMEntity> listSource = EntityHelper.GetData<MatGpMEntity>(
  141. "com.steering.pss.ydm.Stuffmanage.FrmStuffMoveOut.doQuery", new object[] { parm, strRegStart, strRegEnd, arr }, this.ob);
  142. MatGpMEntitybindingSource.DataSource = listSource;
  143. }
  144. /// <summary>
  145. /// 查询调差实绩
  146. /// </summary>
  147. private void doQueryStockData()
  148. {
  149. string strRegStart = "";
  150. string strRegEnd = "";
  151. string heatNo = "";
  152. string[] arr = BaseMethod.WarehousePermissions(this.CustomInfo, this.ValidDataPurviewIds, this.ob);
  153. ArrayList parm = new ArrayList();
  154. if (chkRegTime.Checked)
  155. {
  156. strRegStart = RegStartTime.Value.ToString();
  157. strRegEnd = RegEndTime.Value.ToString();
  158. }
  159. if (this.checkHeatNo.Checked)
  160. {
  161. heatNo = this.txt_heatNo.Text.Trim();
  162. }
  163. parm.Add(heatNo);
  164. List<YdmGpStocktakinglistEntity> listSource = EntityHelper.GetData<YdmGpStocktakinglistEntity>(
  165. "com.steering.pss.ydm.Stuffmanage.FrmStuffMoveOut.doQueryStock", new object[] { parm, strRegStart, strRegEnd, arr }, this.ob);
  166. YdmGpStocktakinglistEntitybindingSource.DataSource = listSource;
  167. }
  168. /// <summary>
  169. /// 数据验证
  170. /// </summary>
  171. /// <returns></returns>
  172. private bool CheckQuery()
  173. {
  174. if (DataTimeUtil.JudgeTime(DateTime.Parse(RegStartTime.Value.ToString()), DateTime.Parse(RegEndTime.Value.ToString())) == 0)
  175. {
  176. MessageUtil.ShowTips("开始时间不能大于结束时间!");
  177. return false;
  178. }
  179. if (checkHeatNo.Checked && string.IsNullOrEmpty(this.txt_heatNo.Text.Trim()))
  180. {
  181. MessageBox.Show("请输入炉号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  182. return false;
  183. }
  184. return true;
  185. }
  186. private void FrmStuffAdjust_Load(object sender, EventArgs e)
  187. {
  188. RegStartTime.Value = DateTime.Parse(DateTime.Today.ToString("yyyy-MM-dd") + " 00:00:00");
  189. RegEndTime.Value = DateTime.Parse(DateTime.Today.AddDays(1).AddSeconds(-1).ToString("yyyy-MM-dd") + " 23:59:59");
  190. BaseMethod.InitCellPosition(ultraGrid1, new string[] { "ActWeight", "ActCount", "ActLenMax", "ActLenMin", "ActTheoryWeight", "ActHeight", "ActDimater", "CuttingNum", "ActLen", "ActFixNum", "ActFixLen" });
  191. BaseMethod.InitCellPosition(ultraGrid2, new string[] { "ActWeight", "ActCount", "ActLenMax", "ActLenMin", "ActTheoryWeight", "ActHeight", "ActDimater", "CuttingNum", "ActLen", "ActFixNum", "ActFixLen" });
  192. EntityHelper.ShowGridCaption<MatGpMEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  193. EntityHelper.ShowGridCaption<YdmGpStocktakinglistEntity>(ultraGrid2.DisplayLayout.Bands[0]);
  194. InitBindColumn();
  195. }
  196. /// <summary>
  197. /// 绑定列
  198. /// </summary>
  199. private void InitBindColumn()
  200. {
  201. //材料状态
  202. this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150101", "材料产出等待");
  203. this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150102", "材料管理封锁");
  204. this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150103", "材料质量封锁");
  205. this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150104", "材料可编计划");
  206. this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150105", "材料已编计划");
  207. this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150106", "材料为余材");
  208. this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150201", "材料产出等待(未综合判定)");
  209. this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150202", "材料产出(已综合判定");
  210. this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150203", "材料为余材(已综合判定)");
  211. this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150204", "材料脱单余材(销售组织脱单)");
  212. this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150301", "材料可编计划(发运控制)");
  213. this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150302", "材料已编计划(发运控制)");
  214. this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("80150303", "销售出厂");
  215. //材料类别
  216. this.ultraGrid1.DisplayLayout.ValueLists[1].ValueListItems.Add("801401", "在制品");
  217. this.ultraGrid1.DisplayLayout.ValueLists[1].ValueListItems.Add("801402", "成品");
  218. this.ultraGrid1.DisplayLayout.ValueLists[1].ValueListItems.Add("801403", "商品");
  219. DataTable ds = ClsLoad.GetValueListDataTable("8014", this.ob);
  220. this.ultraGrid1.DisplayLayout.Bands[0].Columns["productFlag"].ValueList = ClsLoad.GeneralValuelist(ref ds, "BASECODE", "BASENAME");
  221. string[] arr = new string[3] { "801501", "801502", "801503" };
  222. DataTable dt = ClsLoad.GetValueListDataTable(arr, this.ob);
  223. this.ultraGrid1.DisplayLayout.Bands[0].Columns["matStatus"].ValueList = ClsLoad.GeneralValuelist(ref dt, "BASECODE", "BASENAME");
  224. }
  225. private void checkHeatNo_CheckedChanged(object sender, EventArgs e)
  226. {
  227. this.txt_heatNo.Enabled = this.checkHeatNo.Checked;
  228. }
  229. private void chkRegTime_CheckedChanged(object sender, EventArgs e)
  230. {
  231. RegStartTime.Enabled = this.chkRegTime.Checked;
  232. RegEndTime.Enabled = this.chkRegTime.Checked;
  233. }
  234. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  235. {
  236. if (toolMenu == null) return;
  237. if (ultraTabControl1.SelectedTab.Key == "0")
  238. {
  239. if (toolMenu.Toolbars[0].Tools.Exists("Export"))
  240. {
  241. toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.False;
  242. }
  243. if (toolMenu.Toolbars[0].Tools.Exists("Add"))
  244. {
  245. toolMenu.Toolbars[0].Tools["Add"].InstanceProps.Visible = DefaultableBoolean.True;
  246. }
  247. this.chkRegTime.Text = "入库时间";
  248. }
  249. else
  250. {
  251. if (toolMenu.Toolbars[0].Tools.Exists("Export"))
  252. {
  253. toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.True;
  254. }
  255. if (toolMenu.Toolbars[0].Tools.Exists("Add"))
  256. {
  257. toolMenu.Toolbars[0].Tools["Add"].InstanceProps.Visible = DefaultableBoolean.False;
  258. }
  259. this.chkRegTime.Text = "调差时间";
  260. }
  261. }
  262. private void FrmStuffAdjust_Shown(object sender, EventArgs e)
  263. {
  264. if (toolMenu == null) return;
  265. if (toolMenu.Toolbars[0].Tools.Exists("Export"))
  266. {
  267. toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.False;
  268. }
  269. }
  270. }
  271. }