FrmUpdateCurrenMatureNum.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using DevComponents.DotNetBar;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using WCS.Data.Models;
  12. using WCS_Client.UC;
  13. namespace WCS_Client.Frm
  14. {
  15. public partial class FrmUpdateCurrenMatureNum : Office2007Form
  16. {
  17. DataRow dr = null;
  18. public FrmUpdateCurrenMatureNum(DataRow datarow)
  19. {
  20. InitializeComponent();
  21. dr = datarow;
  22. this.txt_BARCODE.Text = datarow["BARCODE"].ToString();
  23. this.txt_MatureRoomNo.Text = datarow["MatureRoomNo"].ToString();
  24. this.txt_MatureRoomName.Text = datarow["MatureRoomName"].ToString();
  25. this.txt_InMatureRoomDate.Text = datarow["InMatureRoomDate"].ToString();
  26. this.txt_MatureNum.Text = datarow["MatureNum"].ToString();
  27. this.txt_CurrentMatureNum.Text = datarow["CurrentMatureNum"].ToString();
  28. }
  29. private void button2_Click(object sender, EventArgs e)
  30. {
  31. this.Close();
  32. }
  33. private void button1_Click(object sender, EventArgs e)
  34. {
  35. if (Convert.ToInt32(this.txt_CurrentMatureNum.Text) == 0)
  36. {
  37. MessageUtil.ShowError("码垛编号不能为零!");
  38. return;
  39. }
  40. if (string.IsNullOrWhiteSpace(this.txt_CurrentMatureNum.Text))
  41. {
  42. MessageUtil.ShowError("当前熟化次数不能为空!");
  43. return;
  44. }
  45. if (Convert.ToInt32(this.txt_CurrentMatureNum.Text) > Convert.ToInt32(this.txt_MatureNum.Text))
  46. {
  47. MessageUtil.ShowError("当前熟化次数不能大于熟化次数!");
  48. return;
  49. }
  50. var palletizingCode = new MatureRoomCache();
  51. palletizingCode.CurrentMatureNum = Convert.ToInt32(txt_CurrentMatureNum.Text);
  52. string result = TryCachHelper.TryExecute((db) =>
  53. {
  54. if (db.Updateable<MatureRoomCache>()
  55. .UpdateColumns(it => new MatureRoomCache
  56. {
  57. CurrentMatureNum = palletizingCode.CurrentMatureNum
  58. })
  59. .Where(v => v.BARCODE == txt_BARCODE.Text && v.MatureRoomNo == txt_MatureRoomNo.Text).ExecuteCommand() < 0)
  60. {
  61. throw new Exception(string.Format("熟化房编号【{0}】中熟化架条码【{1}】修改参数失败", txt_BARCODE.Text, txt_MatureRoomNo.Text));
  62. }
  63. });
  64. if (string.IsNullOrWhiteSpace(result))
  65. {
  66. result = string.Format("熟化信息成功!");
  67. }
  68. MessageUtil.ShowTips(result);
  69. }
  70. }
  71. }