CNAS取数仪器端升级
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

ShuiFenUIOperation.cs 7.7KB

4 miesięcy temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. using CnasSynchronusClient;
  2. using CnasSynchrousModel;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. namespace CNAS_BalanceClient
  9. {
  10. public class ShuiFenUIOperation
  11. {
  12. /// <summary>
  13. /// 更改水分数据
  14. /// </summary>
  15. /// <param name="dgvShuiFen"></param>
  16. /// <param name="balanceWeight"></param>
  17. /// <param name="laboratoryTests"></param>
  18. public void UpdateShuiFenData(System.Windows.Forms.DataGridView dgvShuiFen, double balanceWeight, List<LaboratoryTest> laboratoryTests)
  19. {
  20. //更改内存值
  21. bool bIfUpdate = true;
  22. string strID = dgvShuiFen.Rows[dgvShuiFen.CurrentCell.RowIndex].Cells[0].Value.ToString();
  23. var query = laboratoryTests.Where(s => s.GUID == strID).ToList<LaboratoryTest>();
  24. if (query.Count == 1)
  25. {
  26. switch (dgvShuiFen.CurrentCell.ColumnIndex.ToString())
  27. {
  28. case "4": //空坩埚重
  29. query[0].Empty_Crucible_Weight = CalculateOperation.GetShowDoubleValueN4(balanceWeight);
  30. dgvShuiFen.CurrentRow.Cells[6].Value = CalculateOperation.GetShowDoubleValueN4(query[0].Empty_Crucible_Weight + query[0].Sample_Weight);
  31. break;
  32. case "5": //样重
  33. if (balanceWeight < 0.9 || balanceWeight > 1.1)
  34. {
  35. MessageBox.Show("样重范围是0.9g~1.1g", "提示");
  36. bIfUpdate = false;
  37. }
  38. else
  39. {
  40. query[0].Sample_Weight = CalculateOperation.GetShowDoubleValueN4(balanceWeight);
  41. dgvShuiFen.CurrentRow.Cells[6].Value = CalculateOperation.GetShowDoubleValueN4(query[0].Empty_Crucible_Weight + query[0].Sample_Weight);
  42. }
  43. break;
  44. case "6"://加样重
  45. //query[0].AddSample_Weight = balanceWeight;
  46. break;
  47. case "7"://烘干重
  48. if (query[0].AddSample_Weight != 0 && balanceWeight > query[0].AddSample_Weight)
  49. {
  50. MessageBox.Show("烘干重不能大于加样重,请调整后再传入。", "提示");
  51. bIfUpdate = false;
  52. }
  53. else
  54. {
  55. double oldvaue = query[0].Drying_Weight;
  56. query[0].Drying_Weight = CalculateOperation.GetShowDoubleValueN4(balanceWeight);
  57. if (!UpdateMoisturePercentColumn(dgvShuiFen, laboratoryTests, dgvShuiFen.CurrentCell.RowIndex))
  58. {
  59. query[0].Drying_Weight = CalculateOperation.GetShowDoubleValueN4(oldvaue);
  60. bIfUpdate = false;
  61. }
  62. };
  63. break;
  64. case "8"://二次烘干重
  65. if (query[0].AddSample_Weight != 0 && balanceWeight > query[0].AddSample_Weight)
  66. {
  67. MessageBox.Show("烘干重不能大于加样重,请调整后再传入。", "提示");
  68. bIfUpdate = false;
  69. }
  70. else
  71. {
  72. double oldvaue = query[0].SecondDrying_Weight;
  73. query[0].SecondDrying_Weight = CalculateOperation.GetShowDoubleValueN4(balanceWeight);
  74. if (!UpdateMoisturePercentColumn(dgvShuiFen, laboratoryTests, dgvShuiFen.CurrentCell.RowIndex))
  75. {
  76. query[0].SecondDrying_Weight = CalculateOperation.GetShowDoubleValueN4(oldvaue);
  77. bIfUpdate = false;
  78. }
  79. }
  80. break;
  81. case "9"://三次烘干重
  82. if (query[0].AddSample_Weight != 0 && balanceWeight > query[0].AddSample_Weight)
  83. {
  84. MessageBox.Show("烘干重不能大于加样重,请调整后再传入。", "提示");
  85. bIfUpdate = false;
  86. }
  87. else
  88. {
  89. double oldvaue = query[0].ThirdDrying_Weight;
  90. query[0].ThirdDrying_Weight = CalculateOperation.GetShowDoubleValueN4(balanceWeight);
  91. if (!UpdateMoisturePercentColumn(dgvShuiFen, laboratoryTests, dgvShuiFen.CurrentCell.RowIndex))
  92. {
  93. query[0].ThirdDrying_Weight = CalculateOperation.GetShowDoubleValueN4(oldvaue);
  94. bIfUpdate = false;
  95. }
  96. }
  97. break;
  98. }
  99. if (bIfUpdate)
  100. {
  101. query[0].Operator = GlobalCommonOperation.strUserName;
  102. query[0].OperaDateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  103. if (query[0].OperationType == null || query[0].OperationType == "")
  104. query[0].OperationType = "update";
  105. //更改显示值
  106. dgvShuiFen.CurrentCell.Value = CalculateOperation.GetShowDoubleValueN4(balanceWeight);
  107. }
  108. }
  109. }
  110. /// <summary>
  111. /// 更改水分百分比
  112. /// </summary>
  113. /// <param name="dgvShuiFen"></param>
  114. /// <param name="laboratoryTests"></param>
  115. /// <returns></returns>
  116. public bool UpdateMoisturePercentColumn(DataGridView dgvShuiFen, List<LaboratoryTest> laboratoryTests, int CurrentRowIndex)
  117. {
  118. bool IfUpdate = true;
  119. string strID = dgvShuiFen.Rows[CurrentRowIndex].Cells[0].Value.ToString();
  120. var query = laboratoryTests.Where(s => s.GUID == strID).ToList<LaboratoryTest>();
  121. if (query.Count == 1)
  122. {
  123. if (query[0].Sample_Weight != 0 && query[0].AddSample_Weight != 0 && query[0].Drying_Weight != 0)
  124. {
  125. double percentdouble = 0;
  126. if (query[0].SecondDrying_Weight == 0)
  127. {
  128. percentdouble = CalculateOperation.CalculateDecrement(query[0].AddSample_Weight, new double[1] { query[0].Drying_Weight });
  129. dgvShuiFen.Rows[CurrentRowIndex].Cells["DecrementValue1"].Value = percentdouble;
  130. }
  131. else if (query[0].ThirdDrying_Weight == 0)
  132. {
  133. percentdouble = CalculateOperation.CalculateDecrement(query[0].AddSample_Weight, new double[2] { query[0].Drying_Weight, query[0].SecondDrying_Weight });
  134. dgvShuiFen.Rows[CurrentRowIndex].Cells["DecrementValue1"].Value = percentdouble;
  135. }
  136. else
  137. {
  138. percentdouble = CalculateOperation.CalculateDecrement(query[0].AddSample_Weight, new double[3] { query[0].Drying_Weight, query[0].SecondDrying_Weight, query[0].ThirdDrying_Weight });
  139. dgvShuiFen.Rows[CurrentRowIndex].Cells["DecrementValue1"].Value = percentdouble;
  140. }
  141. query[0].DecrementValue = Convert.ToDouble(dgvShuiFen.Rows[CurrentRowIndex].Cells["DecrementValue1"].Value);
  142. }
  143. }
  144. return IfUpdate;
  145. }
  146. }
  147. }