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

272 lines
9.8 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 FormICSSEGAdd : DevExpress.XtraEditors.XtraForm
  25. {
  26. FormICSSEGUIModel segUIModel;
  27. int flag;
  28. public FormICSSEGAdd()
  29. {
  30. InitializeComponent();
  31. chargeFormState("Add");
  32. flag = 0;
  33. }
  34. public FormICSSEGAdd(string code)
  35. {
  36. InitializeComponent();
  37. chargeFormState("Edit");
  38. SearchSEGInfo(code);
  39. flag = 1;
  40. }
  41. private void chargeFormState(string state)
  42. {
  43. switch (state)
  44. {
  45. case "Add":
  46. txtSEGCODE.Properties.ReadOnly = false;
  47. txtMUSERName.Text = AppConfig.UserName;
  48. txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString();
  49. txtMUSERName.Properties.ReadOnly = true;
  50. txtMTIME.Properties.ReadOnly = true;
  51. break;
  52. case "Edit":
  53. txtSEGCODE.Properties.ReadOnly = true;
  54. txtMUSERName.Text = AppConfig.UserName;
  55. txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString();
  56. txtMUSERName.Properties.ReadOnly = true;
  57. txtMTIME.Properties.ReadOnly = true;
  58. break;
  59. }
  60. }
  61. private void SearchSEGInfo(string segCODE)
  62. {
  63. segUIModel = ICSSEGBLL.SearchSEGInfoByCode(segCODE, AppConfig.AppConnectString);
  64. txtSEGCODE.Text = segUIModel.SEGCODE;
  65. //txtSEGSEQ.Text = Convert.ToString(segUIModel.SEGSEQ);
  66. txtSEGDESC.Text = segUIModel.SEGDESC;
  67. //txtSEGManager.Text = segUIModel.SEGManager;
  68. //txtSHIFTTYPECODE.Tag = segUIModel.shifType as FormICSShifTypeUIModel;
  69. txtSHIFTTYPECODE.Text = "";
  70. if (segUIModel.fac != null)
  71. {
  72. txtFACCODE.Tag = segUIModel.fac as FormICSFactoryUIModel;
  73. txtFACCODE.Text = segUIModel.fac.FACDESC;
  74. }
  75. }
  76. #region 车间主任代码按钮
  77. private void txtSEGManager_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  78. {
  79. ButtonEdit btn = (ButtonEdit)sender;
  80. string sql = @"select distinct ID as [人员ID],UserCode as [人员代码],USERName as [人员名称] from dbo.Sys_User with(nolock)
  81. WHERE 1=1";
  82. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  83. //if (obj == null)
  84. //{
  85. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  86. //}
  87. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  88. FormDataRefer reForm = new FormDataRefer();
  89. reForm.FormTitle = "人员信息";
  90. DataTable menuData = data;
  91. reForm.DataSource = menuData;
  92. reForm.MSelectFlag = false;
  93. reForm.RowIndexWidth = 35;
  94. reForm.HideCols.Add("人员ID");
  95. reForm.FormWidth = 500;
  96. reForm.FormHeight = 500;
  97. //reForm.FilterKey = btn.Text;
  98. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  99. if (reForm.ShowDialog() == DialogResult.OK)
  100. {
  101. DataTable retData = reForm.ReturnData;
  102. foreach (DataRow dr in retData.Rows)
  103. {
  104. txtSEGManager.Text = dr["人员代码"].ToString();
  105. //username = dr["人员名称"].ToString();
  106. }
  107. }
  108. }
  109. #endregion
  110. #region 工厂
  111. private void txtFACCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  112. {
  113. DataTable dt = ICSSEGBLL.SearchFacInfoList(AppConfig.AppConnectString);
  114. FormDataRefer reForm = new FormDataRefer();
  115. reForm.FormTitle = "工厂";
  116. reForm.DataSource = dt;
  117. reForm.MSelectFlag = false;
  118. reForm.RowIndexWidth = 35;
  119. reForm.HideCols.Add("guid");
  120. reForm.FormWidth = 500;
  121. reForm.FormHeight = 500;
  122. if (reForm.ShowDialog() == DialogResult.OK)
  123. {
  124. DataTable retData = reForm.ReturnData;
  125. foreach (DataRow dr in retData.Rows)
  126. {
  127. FormICSFactoryUIModel fac = new FormICSFactoryUIModel();
  128. fac.ID = dr["guid"].ToString();
  129. fac.FACCODE = dr["工厂代码"].ToString();
  130. fac.FACDESC = dr["工厂描述"].ToString();
  131. txtFACCODE.Text = fac.FACCODE;
  132. txtFACCODE.Tag = fac;
  133. break;
  134. }
  135. }
  136. }
  137. #endregion
  138. #region 关闭
  139. private void btnClose_Click(object sender, EventArgs e)
  140. {
  141. this.Close();
  142. this.DialogResult = DialogResult.Cancel;
  143. }
  144. private void btnCancle_Click(object sender, EventArgs e)
  145. {
  146. this.Close();
  147. this.DialogResult = DialogResult.Cancel;
  148. }
  149. #endregion
  150. private void btnOK_Click(object sender, EventArgs e)
  151. {
  152. try
  153. {
  154. #region 判断是否为空
  155. if (txtSEGCODE.Text.Trim() == "")
  156. {
  157. ICSBaseSimpleCode.AppshowMessageBox("车间代码不能为空");
  158. return;
  159. }
  160. //if (txtSEGSEQ.Text.Trim() == "")
  161. //{
  162. // ICSBaseSimpleCode.AppshowMessageBox("车间次序不能为空");
  163. // return;
  164. //}
  165. //if (txtSEGManager.Text.Trim() == "")
  166. //{
  167. // ICSBaseSimpleCode.AppshowMessageBox("请选择车间主任");
  168. // return;
  169. //}
  170. //if (txtSHIFTTYPECODE.Text.Trim() == "")
  171. //{
  172. // ICSBaseSimpleCode.AppshowMessageBox("班制不能为空");
  173. // return;
  174. //}
  175. #endregion
  176. if (flag == 0)
  177. {
  178. bool b = ICSSEGBLL.IsIncluding(txtSEGCODE.Text.Trim(), AppConfig.AppConnectString);
  179. if (b)
  180. {
  181. ICSBaseSimpleCode.AppshowMessageBox("车间代码已经存在");
  182. return;
  183. }
  184. }
  185. FormICSSEGUIModel segInfo = new FormICSSEGUIModel();
  186. segInfo.SEGCODE = txtSEGCODE.Text;
  187. //segInfo.SEGSEQ = Convert.ToInt32(txtSEGSEQ.Text);
  188. segInfo.SEGDESC = txtSEGDESC.Text;
  189. segInfo.SEGManager = "";
  190. segInfo.MUSER = AppConfig.UserCode;
  191. segInfo.MUSERName = AppConfig.UserName;
  192. segInfo.MTIME = System.DateTime.Parse(txtMTIME.Text);
  193. segInfo.WorkPoint = AppConfig.WorkPointCode;
  194. //segInfo.shifType = new FormICSShifTypeUIModel();
  195. //segInfo.shifType = txtSHIFTTYPECODE.Tag as FormICSShifTypeUIModel;
  196. if (txtFACCODE.Tag != null)
  197. {
  198. segInfo.fac = new FormICSFactoryUIModel();
  199. segInfo.fac = txtFACCODE.Tag as FormICSFactoryUIModel;
  200. }
  201. ICSSEGBLL.Add(segInfo,AppConfig.AppConnectString);
  202. if (flag == 0)
  203. {
  204. ICSBaseSimpleCode.AppshowMessageBox("增加成功");
  205. }
  206. else if (flag == 1)
  207. {
  208. ICSBaseSimpleCode.AppshowMessageBox("修改成功");
  209. }
  210. }
  211. catch (Exception ex)
  212. {
  213. MessageBox.Show(ex.Message);
  214. }
  215. this.Close();
  216. this.DialogResult = DialogResult.Yes;
  217. }
  218. //private void txtSHIFTTYPECODE_KeyDown(object sender, KeyEventArgs e)
  219. //{
  220. // this.txtSHIFTTYPECODE.Text = "";
  221. // this.txtSHIFTTYPECODE.Tag = null;
  222. //}
  223. //private void txtFACCODE_KeyDown(object sender, KeyEventArgs e)
  224. //{
  225. // this.txtFACCODE.Text = "";
  226. // this.txtFACCODE.Tag = null;
  227. //}
  228. //private void txtSHIFTTYPECODE_KeyPress(object sender, KeyPressEventArgs e)
  229. //{
  230. // if (e.KeyChar != (char)Keys.Back)
  231. // {
  232. // e.Handled = true;
  233. // }
  234. //}
  235. //private void txtFACCODE_KeyPress(object sender, KeyPressEventArgs e)
  236. //{
  237. // if (e.KeyChar != (char)Keys.Back)
  238. // {
  239. // e.Handled = true;
  240. // }
  241. //}
  242. //private void txtSEGSEQ_KeyPress(object sender, KeyPressEventArgs e)
  243. //{
  244. // if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
  245. // {
  246. // e.Handled = true;
  247. // }
  248. //}
  249. }
  250. }