frmOrderPriceDetails.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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.Server;
  11. using Core.Mes.Client.Comm.Control;
  12. using Infragistics.Win.UltraWinGrid;
  13. using Core.Mes.Client.Comm.Format;
  14. using System.Collections;
  15. using Core.Mes.Client.Comm.Tool;
  16. namespace Core.StlMes.Client.SaleOrder.Dialog
  17. {
  18. public partial class frmOrderPriceDetails : FrmBase
  19. {
  20. /// <summary>
  21. /// 合同号
  22. /// </summary>
  23. private String ordPk;
  24. public String OrdPk
  25. {
  26. get { return ordPk; }
  27. set { ordPk = value; }
  28. }
  29. private OpeBase ob;
  30. public OpeBase Ob
  31. {
  32. get { return ob; }
  33. set { ob = value; }
  34. }
  35. public frmOrderPriceDetails()
  36. {
  37. InitializeComponent();
  38. }
  39. private void frmOrderPriceDetails_Load(object sender, EventArgs e)
  40. {
  41. EntityHelper.ShowGridCaption<SlmOrderLineEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  42. setColumnsReadOnly();
  43. DoQuery();
  44. }
  45. private void setColumnsReadOnly()
  46. {
  47. foreach (UltraGridColumn ugc in ultraGrid1.DisplayLayout.Bands[0].Columns)
  48. {
  49. if (!ugc.Key.Equals("CHC"))
  50. {
  51. ugc.CellActivation = Activation.ActivateOnly;
  52. }
  53. }
  54. }
  55. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  56. {
  57. switch (e.Tool.Key)
  58. {
  59. case "Save":
  60. DoSave();
  61. break;
  62. case "Cancel":
  63. DoCancel();
  64. break;
  65. case "Commit":
  66. DoCommit();
  67. break;
  68. case "Close":
  69. this.Close();
  70. break;
  71. default:
  72. break;
  73. }
  74. }
  75. private void DoQuery()
  76. {
  77. if (ordPk.Length == 0)
  78. {
  79. return;
  80. }
  81. List<SlmOrderLineEntity> listSource = EntityHelper.GetData<SlmOrderLineEntity>(
  82. "com.steering.pss.sale.order.CoreOrderPriceDetails.getOrdLineByOrdPk", new object[] { ordPk }, ob);
  83. slmOrderLineEntityBindingSource.DataSource = listSource;
  84. }
  85. private void DoSave()
  86. {
  87. ultraGrid1.UpdateData();
  88. IQueryable<UltraGridRow> ultraGrid1CheckedRows = ultraGrid1.Rows.AsQueryable().Where(" CHC = 'True'");
  89. if (ultraGrid1CheckedRows.Count() == 0)
  90. {
  91. MessageUtil.ShowWarning("请选择合同行");
  92. return;
  93. }
  94. String priceBase = textBox1.Text.Trim();
  95. if (priceBase.Length == 0)
  96. {
  97. MessageUtil.ShowWarning("请填写定价内容");
  98. return;
  99. }
  100. String jsPrice = txtJsPrice.Value == null ? "" : txtJsPrice.Value.ToString().Trim();
  101. String ccPrice = txtCcPrice.Value == null ? "" : txtCcPrice.Value.ToString().Trim();
  102. String dzPrice = txtDzfPrice.Value == null ? "" : txtDzfPrice.Value.ToString().Trim();
  103. String yfPrice = txtYfPrice.Value == null ? "" : txtYfPrice.Value.ToString().Trim();
  104. if (jsPrice.Equals("") || ccPrice.Equals(""))
  105. {
  106. MessageUtil.ShowWarning("请填写出厂价/结算价");
  107. return;
  108. }
  109. //合同头状态
  110. if (MessageUtil.ShowYesNoAndQuestion("是否保存定价信息") == DialogResult.No)
  111. {
  112. return;
  113. }
  114. String[] statuses = getOrderHeadStatus(ordPk);
  115. if (statuses == null)
  116. {
  117. MessageUtil.ShowWarning("合同状态异常,不能维护定价");
  118. return;
  119. }
  120. String status = statuses[0];
  121. ArrayList list = new ArrayList() { "12020212", "12020213", "12020221", "12020223", "12020231", "12020241" };
  122. if (list.Contains(status))
  123. {
  124. ArrayList listStr = new ArrayList();
  125. String ordLnPk = "";
  126. foreach (UltraGridRow ugr in ultraGrid1CheckedRows)
  127. {
  128. SlmOrderLineEntity orderLineEntity = (SlmOrderLineEntity)ugr.ListObject;
  129. orderLineEntity.TrsPrice = yfPrice;
  130. orderLineEntity.BlaPrice = jsPrice;
  131. orderLineEntity.OutPrice = ccPrice;
  132. orderLineEntity.PakPrice = dzPrice;
  133. ordLnPk = orderLineEntity.OrdLnPk.ToString();
  134. orderLineEntity.OrderAddDesc = "";
  135. orderLineEntity.OrderSpecialDesc = "";
  136. string strJSON = JSONFormat.Format(orderLineEntity);
  137. listStr.Add(strJSON);
  138. }
  139. string saleOrg = ClsBaseInfo.GetSaleOrg(UserInfo.GetDeptid());
  140. CoreClientParam ccp = new CoreClientParam();
  141. ccp.ServerName = "com.steering.pss.sale.order.CoreOrderPriceDetails";
  142. ccp.MethodName = "savePrice";
  143. ccp.ServerParams = new object[] { listStr, ordPk, priceBase, UserInfo.GetUserName(), saleOrg };
  144. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  145. if (ccp.ReturnCode == -1)
  146. {
  147. return;
  148. }
  149. MessageUtil.ShowTips("保存成功!");
  150. DoQuery();
  151. activeRow(ultraGrid1, ordLnPk);
  152. }
  153. else
  154. {
  155. MessageUtil.ShowWarning("合同已审批,不能定价维护");
  156. return;
  157. }
  158. }
  159. private void DoCancel()
  160. {
  161. ultraGrid1.UpdateData();
  162. IQueryable<UltraGridRow> ultraGrid1CheckedRows = ultraGrid1.Rows.AsQueryable().Where(" CHC = 'True'");
  163. if (MessageUtil.ShowYesNoAndQuestion("是否撤销对此合同定价维护!") == DialogResult.No)
  164. {
  165. return;
  166. }
  167. String[] statuses = getOrderHeadStatus(ordPk);
  168. if (statuses == null)
  169. {
  170. MessageUtil.ShowWarning("合同状态异常,不能撤销合同定价");
  171. return;
  172. }
  173. String status = statuses[0];
  174. {
  175. if (status.Equals("12020220"))
  176. {
  177. MessageUtil.ShowWarning("合同已经审批,不能撤销合同定价");
  178. return;
  179. }
  180. }
  181. ArrayList listStr = new ArrayList();
  182. String ordLnPk = "";
  183. foreach (UltraGridRow ugr in ultraGrid1CheckedRows)
  184. {
  185. SlmOrderLineEntity orderLineEntity = (SlmOrderLineEntity)ugr.ListObject;
  186. orderLineEntity.TrsPrice = txtYfPrice.Value.ToString().Trim();
  187. orderLineEntity.BlaPrice = txtJsPrice.Value.ToString().Trim();
  188. orderLineEntity.OutPrice = txtCcPrice.Value.ToString().Trim();
  189. orderLineEntity.PakPrice = txtDzfPrice.Value.ToString().Trim();
  190. ordLnPk = orderLineEntity.OrdLnPk.ToString();
  191. orderLineEntity.OrderAddDesc = "";
  192. orderLineEntity.OrderSpecialDesc = "";
  193. string strJSON = JSONFormat.Format(orderLineEntity);
  194. listStr.Add(strJSON);
  195. }
  196. CoreClientParam ccp = new CoreClientParam();
  197. ccp.ServerName = "com.steering.pss.sale.order.CoreOrderPriceDetails";
  198. ccp.MethodName = "cancelPriceNo";
  199. ccp.ServerParams = new object[] { listStr, ordPk };
  200. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  201. if (ccp.ReturnCode == -1)
  202. {
  203. return;
  204. }
  205. MessageUtil.ShowTips("撤销成功!");
  206. DoQuery();
  207. activeRow(ultraGrid1, ordLnPk);
  208. }
  209. private void DoCommit()
  210. {
  211. if (MessageUtil.ShowYesNoAndQuestion("是否提交") == DialogResult.No)
  212. {
  213. return;
  214. }
  215. if (!checkPriceComplete(ordPk))
  216. {
  217. MessageUtil.ShowWarning("定价信息没有维护完整,不能提交");
  218. return;
  219. }
  220. this.Close();
  221. }
  222. /// <summary>
  223. /// 查询合同头状态/定价编号 2015/06/18
  224. /// </summary>
  225. /// <param name="ordPk">合同头号</param>
  226. /// <returns></returns>
  227. private String[] getOrderHeadStatus(String ordPk)
  228. {
  229. String[] status = null;
  230. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CopyOrderApproval.getOrdPkStatus", new Object[] { ordPk }, ob);
  231. if (dt != null && dt.Rows.Count > 0)
  232. {
  233. status = new String[2];
  234. status[0] = dt.Rows[0][0].ToString();
  235. status[1] = dt.Rows[0][1].ToString();
  236. }
  237. return status;
  238. }
  239. /// <summary>
  240. /// 查询定价内容
  241. /// </summary>
  242. /// <param name="priceNo"></param>
  243. /// <returns></returns>
  244. private String getPriceBase()
  245. {
  246. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderPriceDetails.getPriceBase", new Object[] { ordPk }, ob);
  247. if (dt != null && dt.Rows.Count > 0)
  248. {
  249. return dt.Rows[0][0].ToString();
  250. }
  251. else
  252. {
  253. return "";
  254. }
  255. }
  256. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  257. {
  258. ultraGrid1.UpdateData();
  259. UltraGridRow ugr = ultraGrid1.ActiveRow;
  260. if (ugr != null)
  261. {
  262. String priceBase = getPriceBase();
  263. textBox1.Text = priceBase;
  264. txtYfPrice.Value = ugr.Cells["TrsPrice"].Value;
  265. txtJsPrice.Value = ugr.Cells["BlaPrice"].Value;
  266. txtCcPrice.Value = ugr.Cells["OutPrice"].Value;
  267. txtDzfPrice.Value = ugr.Cells["PakPrice"].Value;
  268. }
  269. }
  270. private void frmOrderPriceDetails_FormClosing(object sender, FormClosingEventArgs e)
  271. {
  272. if (!checkPriceComplete(ordPk))
  273. {
  274. if (MessageUtil.ShowYesNoAndQuestion("合同定价维护不完整,是否退出") == DialogResult.No)
  275. {
  276. e.Cancel = true;
  277. }
  278. }
  279. }
  280. /// <summary>
  281. /// 验证合同头是否存在订价编号
  282. /// </summary>
  283. /// <param name="ordPk"></param>
  284. /// <returns></returns>
  285. private Boolean checkPriceComplete(String ordPk)
  286. {
  287. if (ordPk.Length == 0)
  288. {
  289. return false;
  290. }
  291. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderPriceDetails.getOrdHeadPriceNo", new Object[] { ordPk }, ob);
  292. if (dt != null && dt.Rows.Count > 0)
  293. {
  294. String str = dt.Rows[0][0].ToString();
  295. if (str.Length > 0)
  296. {
  297. return true;
  298. }
  299. else
  300. {
  301. return false;
  302. }
  303. }
  304. else
  305. {
  306. return false;
  307. }
  308. }
  309. private void activeRow(UltraGrid ug, String value)
  310. {
  311. foreach (UltraGridRow ugr in ug.Rows)
  312. {
  313. if (ugr.Cells["OrdLnPk"].Value.ToString().Equals(value))
  314. {
  315. ugr.Activate();
  316. }
  317. }
  318. }
  319. }
  320. }