FormSetting.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using DbCommon.Enties.DbModels;
  2. using DbCommon.BusinessCore.BaseCore;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using ProjectManagementSystem.Common.Config;
  13. using ProjectManagementSystem.Common.Service;
  14. namespace ProjectManagementSystem.Forms
  15. {
  16. public partial class FormSetting : Form
  17. {
  18. public LocationProperty LocationProperty { get; set; }
  19. public FormSetting()
  20. {
  21. InitializeComponent();
  22. }
  23. public virtual void Init()
  24. {
  25. MaterialDetailManager materialDetailManager = new MaterialDetailManager();
  26. var materialList = materialDetailManager.GetList()
  27. .Select(d => d.MaterialId)
  28. .Distinct()
  29. .ToList();
  30. if(!string.IsNullOrEmpty(LocationProperty.MaterialId))
  31. {
  32. materialList.Add(LocationProperty.MaterialId);
  33. }
  34. materialList = materialList.Distinct().ToList();
  35. materialList.Add(string.Empty);
  36. cmbMaterial.DataSource = materialList;
  37. cmbMaterial.SelectedIndex = cmbMaterial.Items.Count - 1;
  38. }
  39. public virtual void UpdateDisplay()
  40. {
  41. if (LocationProperty == null) return;
  42. this.labArea.Text = LocationProperty.Area;
  43. this.labWareHouse.Text = LocationProperty.WareHouseCode;
  44. this.labLocation.Text = LocationProperty.LocationCode;
  45. if (string.IsNullOrEmpty(LocationProperty.MaterialId)) return;
  46. this.cmbMaterial.SelectedItem = LocationProperty.MaterialId;
  47. }
  48. private void FormSetting_Shown(object sender, EventArgs e)
  49. {
  50. }
  51. protected virtual void button1_Click(object sender, EventArgs e)
  52. {
  53. LocationStatus status = LocationProperty.Status;
  54. if(status == LocationStatus.Locked)
  55. {
  56. if(PmsTaskService.Instance.LocationHasTask(LocationProperty.LocationCode))
  57. {
  58. string msg = string.Format("状态为锁定,不能修改(需要强制修改请使用WMS)");
  59. MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  60. return;
  61. }
  62. }
  63. string material = this.cmbMaterial.Text;
  64. if(!string.IsNullOrEmpty(material))
  65. {
  66. status = LocationStatus.Filled;
  67. }
  68. var m_locationManager = new LocationPropertyManager();
  69. var data = m_locationManager.GetById(LocationProperty.LocationCode);
  70. data.Status = status;
  71. data.MaterialId = material;
  72. var result = m_locationManager.Update(data);
  73. if (result)
  74. {
  75. MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  76. this.Close();
  77. }
  78. else
  79. {
  80. MessageBox.Show("保存失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  81. }
  82. }
  83. }
  84. }