锐腾搅拌上料功能
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
4.4 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using DevExpress.XtraEditors;
  9. using System.Data.SqlClient;
  10. using ICSSoft.Frame.APP;
  11. using System.Configuration;
  12. using ICSSoft.Frame.APP.Helper;
  13. using ICSSoft.Frame.APP.Model;
  14. using DevExpress.XtraGrid.Columns;
  15. using System.Linq;
  16. namespace ICSSoft.Frame.APP
  17. {
  18. public partial class FormEcAdd : DevExpress.XtraEditors.XtraForm
  19. {
  20. List<SelectItemExt> ItemList = new List<SelectItemExt>();
  21. public List<IcsLotEcDataDto> EcDatas { get; set; }
  22. public FormEcAdd( Func<List<SelectItemExt>> GetEcMes, List<IcsLotEcDataDto> ecDatas)
  23. {
  24. InitializeComponent();
  25. this.ItemList= GetEcMes.Invoke();
  26. this.EcDatas = ecDatas;
  27. }
  28. public void LoadEcSource()
  29. {
  30. try
  31. {
  32. txtEcCode.Properties.ValueMember = "Value";
  33. txtEcCode.Properties.DisplayMember = "Text";
  34. txtEcCode.Properties.DataSource = ItemList;
  35. var column= txtEcCode.Properties.View.Columns;
  36. txtEcCode.Properties.NullText = "";//空时的值
  37. txtEcCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  38. txtEcCode.Properties.ValidateOnEnterKey = true;//回车确认
  39. txtEcCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  40. txtEcCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容 //自适应宽度
  41. txtEcCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  42. grdDetail.DataSource = EcDatas;
  43. grvDetail.RefreshData();
  44. //grvDetail.BestFitColumns();
  45. }
  46. catch (Exception ex)
  47. {
  48. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  49. }
  50. }
  51. private void btnOK_Click(object sender, EventArgs e)
  52. {
  53. this.DialogResult = DialogResult.OK;
  54. this.Close();
  55. }
  56. private void FormEcAdd_Load(object sender, EventArgs e)
  57. {
  58. LoadEcSource();
  59. }
  60. private void btnBigenOrSuspend_Click(object sender, EventArgs e)
  61. {
  62. try
  63. {
  64. if (string.IsNullOrEmpty(txtEcCode.EditValue?.ToString()))
  65. throw new Exception("请先选择不良代码!");
  66. if (string.IsNullOrEmpty(txtEcQty.EditValue?.ToString()))
  67. throw new Exception("请先输入不良数量!");
  68. if (EcDatas.Where(a => a.EcCode == txtEcCode.EditValue.ToString()).FirstOrDefault() != null)
  69. throw new Exception("已录入改不良代码,请勿重复操作!");
  70. IcsLotEcDataDto ecDto = new IcsLotEcDataDto();
  71. ecDto.EcCode = txtEcCode.EditValue.ToString();
  72. ecDto.EcName = txtEcCode.Text.ToString();
  73. ecDto.OpNgQty =Convert.ToDecimal(txtEcQty.EditValue);
  74. EcDatas.Add(ecDto);
  75. grvDetail.RefreshData();
  76. }
  77. catch (Exception ex)
  78. {
  79. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  80. }
  81. }
  82. private void btnEditDel_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  83. {
  84. try
  85. {
  86. var selectValue = grvDetail.GetFocusedRowCellValue(colEcCode).ToString();
  87. EcDatas.Remove(EcDatas.Where(a => a.EcCode == selectValue).FirstOrDefault());
  88. grvDetail.RefreshData();
  89. }
  90. catch (Exception ex)
  91. {
  92. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  93. }
  94. }
  95. private void btnCancle_Click(object sender, EventArgs e)
  96. {
  97. this.DialogResult = DialogResult.Cancel;
  98. this.Close();
  99. }
  100. private void btnClose_Click(object sender, EventArgs e)
  101. {
  102. this.DialogResult = DialogResult.Cancel;
  103. this.Close();
  104. }
  105. }
  106. }