frmSaleCostCountZG.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using CoreFS.CA06;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Windows.Forms;
  12. namespace Core.StlMes.Client.PnCost
  13. {
  14. public partial class frmSaleCostCountZG : FrmBase
  15. {
  16. #region 初始化
  17. public frmSaleCostCountZG()
  18. {
  19. InitializeComponent();
  20. }
  21. private void frmSaleCostCountZG_Load(object sender, EventArgs e)
  22. {
  23. for (int i = 2000; i < 2051; i++)
  24. {
  25. yeardrop.Items.Add(i);
  26. }
  27. string str1 = "";
  28. for (int i = 1; i < 10; i++)
  29. {
  30. str1 = "0" + i.ToString2();
  31. monthdrop.Items.Add(str1);
  32. }
  33. monthdrop.Items.Add(10);
  34. monthdrop.Items.Add(11);
  35. monthdrop.Items.Add(12);
  36. yeardrop.Value = System.DateTime.Now.Year.ToString2();
  37. monthdrop.Value = System.DateTime.Now.Month.ToString2();
  38. }
  39. #endregion
  40. #region 方法
  41. public override void ToolBar_Click(object sender, string ToolbarKey)
  42. {
  43. base.ToolBar_Click(sender, ToolbarKey);
  44. switch (ToolbarKey)
  45. {
  46. case "Query":
  47. Query();
  48. break;
  49. case "Refresh":
  50. Refresh();
  51. break;
  52. case "Close":
  53. this.Close();
  54. break;
  55. }
  56. }
  57. /// 查询方法
  58. /// <summary>
  59. /// 查询方法
  60. /// </summary>
  61. private void Query()
  62. {
  63. #region 条件验证
  64. //年月
  65. string year = yeardrop.Value.ToString2();
  66. string month = monthdrop.Value.ToString2();
  67. if (Convert.ToDecimal(month) < 10)
  68. {
  69. month = month.Substring(1);
  70. }
  71. string mon = "CBT.MONTH_" + month;
  72. #endregion
  73. DataTable dt = ServerHelper.GetData("com.steering.pss.pncost.base.ComSaleCostCountZG.query",
  74. new object[] { year + "-" + monthdrop.Value.ToString2(), year, mon }, ob);
  75. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  76. if (ultraGrid1.Rows.Count == 0)
  77. {
  78. return;
  79. }
  80. for (int i = 0; i < ultraGrid1.Rows.Count; i++)//根据产线,投入产出物料取小时能力
  81. {
  82. string chanxian = ultraGrid1.Rows[i].Cells["PLINE_CODE"].Value.ToString2();
  83. string zhebiao = "";
  84. string zonge = "";//分摊总额
  85. #region 说明4(折标加工费)
  86. string monthyue = ultraGrid1.Rows[i].Cells["PRO_MONTH"].Value.ToString2().Substring(5, 2);//取出有产线的月份
  87. string one = monthyue + "one";
  88. string weight = "";
  89. string all = "";
  90. DataTable dtjiage = ServerHelper.GetData("com.steering.pss.pncost.base.ComBaseProcesscost.queryjiage",
  91. new object[] { ultraGrid1.Rows[i].Cells["PLINE_CODE"].Value.ToString2(), ultraGrid1.Rows[i].Cells["WEIGTH_S"].Value.ToString2() }, ob);
  92. if (dtjiage.Rows.Count == 0)
  93. {
  94. one = "0";
  95. }
  96. else
  97. {
  98. one = dtjiage.Rows[0][0].ToString3();
  99. }
  100. for (int j = 0; j < dt.Rows.Count; j++)
  101. {
  102. if (dt.Rows[j]["PLINE_CODE"].ToString2() == chanxian)
  103. {
  104. weight = (Convert.ToDecimal(dt.Rows[j]["WEIGTH_S"].ToString3()) + Convert.ToDecimal(weight.ToString3())).ToString3();
  105. }
  106. }
  107. all = ultraGrid1.Rows[i].Cells["MONTH"].Value.ToString3();
  108. zonge = (Convert.ToDecimal(one) * Convert.ToDecimal(weight) + Convert.ToDecimal(all)).ToString3();
  109. for (int j = 0; j < dt.Rows.Count; j++)
  110. {
  111. //&& touru ==dt.Rows[j]["INWL_ID"].ToString2()
  112. // && chanchu == dt.Rows[j]["OUTWL_ID"].ToString2()
  113. if (dt.Rows[j]["PLINE_CODE"].ToString2() == chanxian)
  114. {
  115. zhebiao = (Convert.ToDecimal(dt.Rows[j]["WEIGTH_S"].ToString3()) + Convert.ToDecimal(zhebiao.ToString3())).ToString3();
  116. }
  117. }
  118. ultraGrid1.Rows[i].Cells["EXPLAIN4"].Value = (Convert.ToDecimal(zonge.ToString3())
  119. * Convert.ToDecimal(ultraGrid1.Rows[i].Cells["WEIGTH_S"].Value.ToString3())
  120. / Convert.ToDecimal(zhebiao.ToString3())).ToString2();
  121. #endregion
  122. #region 说明1(返回总额赋值)
  123. DataTable changhui = ServerHelper.GetData("com.steering.pss.pncost.base.ComSaleCostCountZG.querychanghui",
  124. new object[] { year, chanxian }, ob);
  125. string say1 = "0";
  126. string chengcai = ((100 - Convert.ToDecimal(ultraGrid1.Rows[i].Cells["PRD_RATE"].Value.ToString3()))/100).ToString2();//1-成材率
  127. for (int j = 0; j < changhui.Rows.Count; j++)
  128. {
  129. string yuefen = "MONTH_" + month;
  130. say1 = (Convert.ToDecimal(say1) + Convert.ToDecimal(chengcai) * Convert.ToDecimal(changhui.Rows[j][yuefen].ToString3())
  131. * Convert.ToDecimal(changhui.Rows[j]["PERCENT"].ToString3())/100).ToString2();
  132. }
  133. ultraGrid1.Rows[i].Cells["EXPLAIN1"].Value = say1.ToString2();
  134. #endregion
  135. }
  136. ultraGrid1.UpdateData();
  137. ultraGrid1.ActiveRow = ultraGrid1.Rows[0];
  138. }
  139. #endregion
  140. #region 事件
  141. #endregion
  142. }
  143. }