frmOrderInsidePrice.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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.StlMes.Client.SaleOrder;
  11. using System.Collections;
  12. using Core.Mes.Client.Comm.Control;
  13. using Core.StlMes.Client.SaleComm;
  14. using Infragistics.Win.UltraWinGrid;
  15. using Core.Mes.Client.Comm.Tool;
  16. using Core.Mes.Client.Comm.Server;
  17. using Core.StlMes.Client.SaleOrder.ReviewForm;
  18. using Core.StlMes.Client.SaleOrder.Dialog;
  19. using Core.Mes.Client.Comm;
  20. using Infragistics.Win;
  21. using System.Text.RegularExpressions;
  22. namespace Core.StlMes.Client.SaleOrder
  23. {
  24. public partial class frmOrderInsidePrice : FrmBase
  25. {
  26. public frmOrderInsidePrice()
  27. {
  28. InitializeComponent();
  29. this.IsLoadUserView = true;
  30. }
  31. private void frmOrderInsidePrice_Load(object sender, EventArgs e)
  32. {
  33. DateTime Today = DateTime.Now;
  34. this.date_starte.DateTime = Today.Date.AddMonths(-1);
  35. this.date_end.DateTime = DateTime.Today;
  36. ValueList list = new ValueList();
  37. Infragistics.Win.ValueListItem[] items = new Infragistics.Win.ValueListItem[] {
  38. new Infragistics.Win.ValueListItem("0", "元"),
  39. new Infragistics.Win.ValueListItem("1", "‰"),
  40. };
  41. //设置下拉框等高
  42. foreach (Infragistics.Win.ValueListItem item in items)
  43. {
  44. if (Regex.IsMatch(item.DisplayText.ToString2(), @"[\u4e00-\u9fa5]+"))
  45. {
  46. item.Appearance.FontData.SizeInPoints = 9.0F;
  47. }
  48. else
  49. {
  50. item.Appearance.FontData.SizeInPoints = 10.5F;
  51. }
  52. }
  53. list.ValueListItems.AddRange(items);
  54. efforder_seq.DisplayLayout.Bands[0].Columns["PRICE_UNIT"].ValueList = list;
  55. GridHelper.SetColumnsActivateAndColor(efforder_seq.Rows.Band, "INSIDE_PRICE", "BALNCE_PRICE_ORG", "PRICE_UNIT");
  56. }
  57. public override void ToolBar_Click(object sender, string ToolbarKey)
  58. {
  59. switch (ToolbarKey)
  60. {
  61. case "doQuery":
  62. doQuery();
  63. break;
  64. case "doSavePrice":
  65. doSavePrice();
  66. break;
  67. case "doClose":
  68. this.Close();
  69. break;
  70. }
  71. }
  72. private void doSavePrice()
  73. {
  74. if (gffect_oder.ActiveRow == null)
  75. return;
  76. string ordPk = gffect_oder.ActiveRow.Cells["ORD_PK"].Value.ToString();
  77. ArrayList parm = new ArrayList();
  78. foreach (UltraGridRow row in efforder_seq.Rows)
  79. {
  80. double price = 0;
  81. if (!double.TryParse(row.Cells["BALNCE_PRICE_ORG"].Value.ToString(), out price))
  82. {
  83. MessageUtil.ShowTips("内部结算价填写错误或未填写");
  84. return;
  85. }
  86. ArrayList list = new ArrayList();
  87. list.Add(row.Cells["BALNCE_PRICE_ORG"].Value.ToString());
  88. list.Add(row.Cells["ORD_LN_PK"].Value.ToString());
  89. parm.Add(list);
  90. }
  91. CoreClientParam ccp = new CoreClientParam();
  92. ccp.ServerName = "com.steering.pss.sale.order.frmOrderEffect";
  93. ccp.MethodName = "saveInsidePrice";
  94. ccp.ServerParams = new object[] { parm };
  95. ccp.IfShowErrMsg = false;
  96. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  97. if (ccp != null)
  98. {
  99. if (ccp.ReturnCode == -1)
  100. {
  101. MessageUtil.ShowWarning(ccp.ReturnInfo);
  102. return;
  103. }
  104. MessageUtil.ShowTips("保存成功!");
  105. doQuery();
  106. foreach (UltraGridRow row in gffect_oder.Rows)
  107. {
  108. if (ordPk.Equals(row.Cells["ORD_PK"].Value.ToString()))
  109. {
  110. row.Activate();
  111. break;
  112. }
  113. }
  114. }
  115. }
  116. public void doQuery()
  117. {
  118. //签约时间
  119. string date = "";
  120. String orderStart = "";
  121. String orderEnd = "";
  122. if (che_date.Checked)
  123. {
  124. orderStart = Convert.ToDateTime(date_starte.Value).ToString("yyyy-MM-dd") + " 00:00:01";
  125. orderEnd = Convert.ToDateTime(date_end.Value).ToString("yyyy-MM-dd") + " 23:59:59";
  126. }
  127. else
  128. {
  129. orderStart = "1000-01-01 00:00:01";
  130. orderEnd = "9999-12-31 23:59:59";
  131. }
  132. //合同号
  133. string order = "";
  134. if (ord_no.Checked)
  135. order = orde_cho.Text.Trim();
  136. DataTable dt = Globals.GetData("com.steering.pss.sale.order.frmOrderEffect.CoreOrderInsidePriceQuery", new Object[] { order,orderStart, orderEnd }, this.ob);
  137. gffect_oder.DataSource = dt;
  138. //列自适应
  139. GridHelper.RefreshAndAutoSizeExceptColumns(gffect_oder, new UltraGridColumn[] { });
  140. }
  141. private void che_date_CheckedChanged(object sender, EventArgs e)
  142. {
  143. date_starte.Enabled = che_date.Checked;
  144. date_end.Enabled = che_date.Checked;
  145. }
  146. private void ord_no_CheckedChanged(object sender, EventArgs e)
  147. {
  148. orde_cho.Enabled = ord_no.Checked;
  149. }
  150. private void gffect_oder_AfterRowActivate(object sender, EventArgs e)
  151. {
  152. UltraGridRow ugr = gffect_oder.ActiveRow;
  153. if (ugr == null)
  154. return;
  155. this.doQueryeffect(gffect_oder.ActiveRow.Cells["ORD_PK"].Text);
  156. this.doQueryeffect_mol(gffect_oder.ActiveRow.Cells["ORDER_MODEL_NO"].Value.ToString());
  157. this.queryPriceInfo(gffect_oder.ActiveRow.Cells["ORD_PK"].Text);
  158. }
  159. private void queryPriceInfo(string ordPk)
  160. {
  161. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.frmOrderEffect.queryPriceInfo", new object[] { ordPk }, this.ob);
  162. if (dt != null && dt.Rows.Count > 0)
  163. {
  164. txtPrice.Text = dt.Rows[0][0].ToString();
  165. }
  166. }
  167. private void doQueryeffect_mol(string ordermodel)
  168. {
  169. DataTable dt = Globals.GetData("com.steering.pss.sale.order.frmOrderEffect.CoreOrderEffectinfo", new Object[] { ordermodel }, this.ob);
  170. efforder_mol.DataSource = dt;
  171. //列自适应
  172. GridHelper.RefreshAndAutoSizeExceptColumns(efforder_mol, new UltraGridColumn[] {
  173. });
  174. }
  175. private void doQueryeffect(string order)
  176. {
  177. DataTable dt = Globals.GetData("com.steering.pss.sale.order.frmOrderEffect.CoreOrderInsideSqeQuery", new Object[] { order }, this.ob);
  178. GridHelper.CopyDataToDatatable(ref dt, ref this.orderLineDt, true);
  179. //列自适应
  180. GridHelper.RefreshAndAutoSizeExceptColumns(efforder_seq, new UltraGridColumn[] { });
  181. }
  182. private void gffect_oder_ClickCellButton(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  183. {
  184. string acustom = gffect_oder.ActiveCell.Value.ToString();
  185. dlgBuyerInfo spt = new dlgBuyerInfo();
  186. spt.oPbd = this.ob;
  187. spt.customer = acustom;
  188. spt.FilePath = "checker";
  189. spt.ShowDialog();
  190. }
  191. private void efforder_seq_AfterRowActivate(object sender, EventArgs e)
  192. {
  193. if (efforder_seq.ActiveRow != null)
  194. {
  195. //DataRow orderLine = dataSet1.Tables["orderLineDt"].Rows[efforder_seq.ActiveRow.Index];
  196. //ctrlOrderLineChild1.loadOrderLineChild(this.ob, orderLine);
  197. }
  198. }
  199. private void orde_cho_KeyPress(object sender, KeyPressEventArgs e)
  200. {
  201. if (e.KeyChar == 13)
  202. doQuery();
  203. }
  204. private void efforder_seq_CellDataError(object sender, CellDataErrorEventArgs e)
  205. {
  206. e.RaiseErrorEvent = false; // 阻止弹出错误提示窗口
  207. e.RestoreOriginalValue = true; // 恢复原始值
  208. e.StayInEditMode = true; // 继续保留在编辑模式
  209. }
  210. private void efforder_seq_CellChange(object sender, CellEventArgs e)
  211. {
  212. try
  213. {
  214. efforder_seq.UpdateData();
  215. }
  216. catch { }
  217. //if (e.Cell.Column.Key.Equals("INSIDE_PRICE")&& !Convert.ToBoolean(e.Cell.Row.Cells["CHK"].Value))
  218. //{
  219. // if (e.Cell.Value.ToString() == "")
  220. // return;
  221. // int rCount = e.Cell.Row.Index;
  222. // for (int i = rCount + 1; i < efforder_seq.Rows.Count; i++)
  223. // {
  224. // UltraGridRow row = efforder_seq.Rows[i];
  225. // if (!Convert.ToBoolean(row.Cells["CHK"].Value))
  226. // row.Cells["INSIDE_PRICE"].Value = e.Cell.Value;
  227. // }
  228. //}
  229. //else if (e.Cell.Column.Key.Equals("PRICE_UNIT") )
  230. //{
  231. // if (e.Cell.Value.ToString() == "")
  232. // return;
  233. // int rCount = e.Cell.Row.Index;
  234. // for (int i = rCount + 1; i < efforder_seq.Rows.Count; i++)
  235. // {
  236. // UltraGridRow row = efforder_seq.Rows[i];
  237. // row.Cells["PRICE_UNIT"].Value = e.Cell.Value;
  238. // }
  239. //}
  240. if (e.Cell.Column.Key.Equals("INSIDE_PRICE") || e.Cell.Column.Key.Equals("PRICE_UNIT"))
  241. {
  242. double insidePrice = 0;
  243. double balancePrice = 0;
  244. UltraGridRow row = efforder_seq.ActiveRow;
  245. if (!double.TryParse(row.Cells["INSIDE_PRICE"].Value.ToString(), out insidePrice))
  246. return;
  247. if (!double.TryParse(row.Cells["BALNCE_PRICE"].Value.ToString(), out balancePrice))
  248. return;
  249. if (row.Cells["PRICE_UNIT"].Value.ToString() == "0")
  250. {
  251. row.Cells["BALNCE_PRICE_ORG"].Value = Math.Round(balancePrice - insidePrice, 2);
  252. }
  253. else if (row.Cells["PRICE_UNIT"].Value.ToString() == "1")
  254. {
  255. row.Cells["BALNCE_PRICE_ORG"].Value = Math.Round(balancePrice * (1000 - insidePrice) / 1000, 2);
  256. }
  257. else
  258. {
  259. return;
  260. }
  261. }
  262. }
  263. }
  264. }