frmMotoriaTareSave.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using com.hnshituo.core.webapp.vo;
  2. using Common;
  3. using Infragistics.Win;
  4. using Infragistics.Win.UltraWinGrid;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. namespace RailMeterSystem
  15. {
  16. public partial class frmMotoriaTareSave : Form
  17. {
  18. public frmMotoriaTareSave()
  19. {
  20. InitializeComponent();
  21. }
  22. private void frmMotoriaTareSave_Load(object sender, EventArgs e)
  23. {
  24. txtCarNum.Value = iCnt;
  25. txtWgtPj.Value = (decimal)getDt.railwayWeight.Value;
  26. txtWgt.Value = (decimal)dWgt;
  27. ValueList vlistSpot = new ValueList();
  28. vlistSpot.ValueListItems.Add("001019002", "动态轨道衡");
  29. cbSpotType.ValueList = vlistSpot;
  30. cbSpotType.Value = "001019002";
  31. //cbCalibrationType
  32. string sql = @"SELECT base_code baseCode,base_name baseName,memo FROM Com_Base_Info where p_base_code='001032' and valid_Flag='1' and memo='" + getDt.tareType + "'";
  33. PbModelDbService<List<ComBaseInfo>> pb = new PbModelDbService<List<ComBaseInfo>>();
  34. RESTfulResult<List<ComBaseInfo>> rmType = pb.executeSqlDataWf(sql);
  35. if (rmType.Succeed && rmType.Data != null && rmType.Data.Count > 0)
  36. {
  37. ValueList vlist = new ValueList();
  38. foreach (ComBaseInfo cbi in rmType.Data)
  39. {
  40. vlist.ValueListItems.Add(cbi.baseCode, cbi.baseName);
  41. }
  42. cbCalibrationType.ValueList = vlist;
  43. cbCalibrationType.SelectedIndex = 0;
  44. }
  45. else
  46. {
  47. MessageBox.Show("留皮类型获取失败!");
  48. }
  49. }
  50. public MeterBaseRailwayWeight getDt { get; set; }
  51. public decimal dWgt = 0;
  52. public int iCnt = 0;
  53. private void btnClose_Click(object sender, EventArgs e)
  54. {
  55. this.Close();
  56. }
  57. MeterBaseRailwayWeightService baseRailwayWgt = new MeterBaseRailwayWeightService();
  58. private void btnSave_Click(object sender, EventArgs e)
  59. {
  60. if (cbCalibrationType.Text.Trim() == "" || cbCalibrationType.Value == null)
  61. {
  62. MessageBox.Show("请选择留皮类型");
  63. return;
  64. }
  65. DialogResult dr = MessageBox.Show("确认进行保存吗?", "提示", MessageBoxButtons.OKCancel);
  66. if (dr == DialogResult.OK)
  67. {
  68. getDt.tareTypeNo = cbCalibrationType.Value.ToString();
  69. getDt.tareTypeName = cbCalibrationType.Text.Trim();
  70. getDt.railwayWeight = txtWgtPj.Value * 1000;
  71. btnSave.Enabled = false;
  72. List<MeterBaseRailwayWeight> lt = new List<MeterBaseRailwayWeight>();
  73. lt.Add(getDt);
  74. RESTfulResult<string> rm = baseRailwayWgt.doSaveWf(lt);
  75. if (rm.Succeed)
  76. {
  77. this.DialogResult = DialogResult.OK;
  78. this.Close();
  79. }
  80. else
  81. {
  82. MessageBox.Show("保存失败,请稍后重试或联系管理员" + rm.Message);
  83. btnSave.Enabled = true;
  84. }
  85. }
  86. }
  87. }
  88. }