锐腾搅拌上料功能
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.

148 lines
5.2 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 ICSSoft.Frame.User.BLL;
  10. using ICSSoft.Base.Language.Tool;
  11. using ICSSoft.Base.UserControl.MessageControl;
  12. using System.Data.SqlClient;
  13. using ICSSoft.Base.Config.AppConfig;
  14. using ICSSoft.Base.Report.Filter;
  15. using ICSSoft.Base.Config.DBHelper;
  16. using ICSSoft.Base.UserControl.FormControl;
  17. using ICSSoft.Base.ReferForm.AppReferForm;
  18. using ICSSoft.Base.Lable.PrintTool;
  19. using ICSSoft.Frame.Data.DAL;
  20. using ICSSoft.Frame.Data.BLL;
  21. using ICSSoft.Frame.Data.Entity;
  22. namespace ICSSoft.Frame.APP
  23. {
  24. public partial class FormICSFACTORYAdd : DevExpress.XtraEditors.XtraForm
  25. {
  26. FormICSFactoryUIModel factoryUIModel;
  27. int flag;
  28. public FormICSFACTORYAdd()
  29. {
  30. InitializeComponent();
  31. chargeFormState("Add");
  32. txtWorkPointCode.Text=AppConfig.WorkPointCode;
  33. //txtFACCODE.Text = Convert.ToString(Convert.ToInt32(ICSFACTORYBLL.SearchMaxCode(AppConfig.AppConnectString)) + 1);
  34. flag = 0;
  35. }
  36. public FormICSFACTORYAdd(string FACCODE)
  37. {
  38. InitializeComponent();
  39. chargeFormState("Edit");
  40. SearchTypeInfo(FACCODE);
  41. txtWorkPointCode.Text = AppConfig.WorkPointCode;
  42. flag = 1;
  43. }
  44. private void chargeFormState(string state)
  45. {
  46. switch (state)
  47. {
  48. case "Add":
  49. txtFACCODE.Properties.ReadOnly = false;
  50. txtFACDESC.Properties.ReadOnly = false;
  51. txtMuser.Text = AppConfig.UserName;
  52. txtMtime.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString();
  53. txtMuser.Properties.ReadOnly = true;
  54. txtMtime.Properties.ReadOnly = true;
  55. break;
  56. case "Edit":
  57. txtFACCODE.Properties.ReadOnly = true;
  58. txtFACDESC.Properties.ReadOnly = false;
  59. txtMuser.Text = AppConfig.UserName;
  60. txtMtime.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString();
  61. txtMuser.Properties.ReadOnly = true;
  62. txtMtime.Properties.ReadOnly = true;
  63. break;
  64. }
  65. }
  66. private void SearchTypeInfo(string FACCODE)
  67. {
  68. factoryUIModel=ICSFACTORYBLL.SearchFactoryInfoByCode(FACCODE, AppConfig.AppConnectString);
  69. txtFACCODE.Text = factoryUIModel.FACCODE;
  70. txtFACDESC.Text = factoryUIModel.FACDESC;
  71. }
  72. private void btnOK_Click(object sender, EventArgs e)
  73. {
  74. try
  75. {
  76. if (txtFACCODE.Text.Trim() == "")
  77. throw new Exception("不能为空");
  78. if (flag == 0)
  79. {
  80. bool b = ICSFACTORYBLL.IsIncluding(txtFACCODE.Text.Trim(), AppConfig.AppConnectString);
  81. if (!b)
  82. throw new Exception("工厂代码已经存在");
  83. //if (txtFACCODE.Text.Substring(0, 3) != "110")
  84. // throw new Exception("班制代码为110格式,1101000001~1101999999");
  85. //if (txtFACCODE.Text.Length>3||txtFACCODE.Text.Length<3)
  86. // throw new Exception("长度为3,001~999");
  87. }
  88. FormICSFactoryUIModel factoryInfo = new FormICSFactoryUIModel();
  89. factoryInfo.FACCODE = txtFACCODE.Text;
  90. factoryInfo.FACDESC = txtFACDESC.Text;
  91. factoryInfo.WorkPoint = AppConfig.WorkPointCode;
  92. //以下DAL中做了处理
  93. // factoryInfo.ID = AppConfig.GetGuid();
  94. //typeInfo.EFFDATE = Convert.ToDateTime(txtEffDate.Text);
  95. //typeInfo.IVLDATE = Convert.ToDateTime(txtIvlDate.Text);
  96. //factoryInfo.MUSER = AppConfig.UserId;
  97. //factoryInfo.MUSERName = AppConfig.UserName;
  98. //factoryInfo.MTIME = DateTime.Now;
  99. ICSFACTORYBLL.Add(factoryInfo, AppConfig.AppConnectString);
  100. ICSBaseSimpleCode.AppshowMessageBox("保存成功!");
  101. }
  102. catch (Exception ex) {
  103. MessageBox.Show(ex.Message);
  104. }
  105. this.Close();
  106. this.DialogResult = DialogResult.Yes;
  107. }
  108. #region 关闭
  109. private void btnCancle_Click(object sender, EventArgs e)
  110. {
  111. this.Close();
  112. //this.DialogResult = DialogResult.Cancel;
  113. }
  114. private void btnClose_Click(object sender, EventArgs e)
  115. {
  116. this.Close();
  117. //this.DialogResult = DialogResult.Cancel;
  118. }
  119. #endregion
  120. //private void txtShiftTypeCode_KeyPress(object sender, KeyPressEventArgs e)
  121. //{
  122. // if (!Char.IsNumber(e.KeyChar))
  123. // e.Handled = true;
  124. //}
  125. //private void txtShiftTypeCode_KeyDown(object sender, KeyEventArgs e)
  126. //{
  127. // this.txtShiftTypeCode.Text = "110"+e.KeyValue;
  128. //}
  129. }
  130. }