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

232 lines
8.6 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.Base.Config.AppConfig;
  10. using System.Data.Linq;
  11. using System.Linq;
  12. using ICSSoft.Base.Language.Tool;
  13. using System.Reflection;
  14. using ICSSoft.Base.Config.DBHelper;
  15. using ICSSoft.Base.ReferForm;
  16. using ICSSoft.Base.Report;
  17. using ICSSoft.Base.ReferForm.AppReferForm;
  18. using ICSSoft.Frame.Data.Entity;
  19. using ICSSoft.Frame.Data.BLL;
  20. namespace ICSSoft.Frame.APP
  21. {
  22. public partial class FormUser2ResAdd : DevExpress.XtraEditors.XtraForm
  23. {
  24. String guid = "";
  25. ICSUser2Res entity = new ICSUser2Res();
  26. #region 构造函数
  27. public FormUser2ResAdd()
  28. {
  29. InitializeComponent();
  30. }
  31. public FormUser2ResAdd(String id)
  32. {
  33. InitializeComponent();
  34. guid = id;
  35. }
  36. #endregion
  37. #region 关闭 退出
  38. private void btnClose_Click(object sender, EventArgs e)
  39. {
  40. this.Close();
  41. }
  42. #endregion
  43. #region 移动窗体
  44. private const int WM_NCHITTEST = 0x84;
  45. private const int HTCLIENT = 0x1;
  46. private const int HTCAPTION = 0x2;
  47. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  48. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  49. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  50. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  51. //重写窗体,使窗体可以不通过自带标题栏实现移动
  52. protected override void WndProc(ref Message m)
  53. {
  54. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  55. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  56. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  57. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  58. switch (m.Msg)
  59. {
  60. case WM_NCHITTEST:
  61. base.WndProc(ref m);
  62. if ((int)m.Result == HTCLIENT)
  63. m.Result = (IntPtr)HTCAPTION;
  64. return;
  65. }
  66. //拦截双击标题栏、移动窗体的系统消息
  67. if (m.Msg != 0xA3)
  68. {
  69. base.WndProc(ref m);
  70. }
  71. }
  72. #endregion
  73. #region 人员编码按钮
  74. private void txtUserCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  75. {
  76. ButtonEdit btn = (ButtonEdit)sender;
  77. string sql = "select distinct UserCode as [人员代码], UserName as [人员名称] from Sys_User with(nolock) WHERE 1=1";
  78. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  79. //if (obj == null)
  80. //{
  81. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  82. //}
  83. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  84. FormDataRefer reForm = new FormDataRefer();
  85. reForm.FormTitle = "人员信息";
  86. DataTable menuData = data;
  87. reForm.DataSource = menuData;
  88. reForm.MSelectFlag = false;
  89. reForm.RowIndexWidth = 35;
  90. reForm.HideCols.Add("ID");
  91. reForm.FormWidth = 500;
  92. reForm.FormHeight = 500;
  93. //reForm.FilterKey = btn.Text;
  94. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  95. if (reForm.ShowDialog() == DialogResult.OK)
  96. {
  97. DataTable retData = reForm.ReturnData;
  98. foreach (DataRow dr in retData.Rows)
  99. {
  100. txtUserCode.Text = dr["人员代码"].ToString();
  101. }
  102. }
  103. }
  104. #endregion
  105. #region 资源编码按钮
  106. private void txtResCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  107. {
  108. ButtonEdit btn = (ButtonEdit)sender;
  109. string sql = "select distinct RESCODE as [资源代码], RESDESC as [资源描述] from ICSRES a WHERE a.RESCODE NOT IN (SELECT RESCODE from dbo.ICSUser2Res WHERE USERCODE='" + txtUserCode.Text + "') and 1=1";
  110. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  111. //if (obj == null)
  112. //{
  113. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  114. //}
  115. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  116. FormDataRefer reForm = new FormDataRefer();
  117. reForm.FormTitle = "资源信息";
  118. DataTable menuData = data;
  119. reForm.DataSource = menuData;
  120. reForm.MSelectFlag = false;
  121. reForm.RowIndexWidth = 35;
  122. reForm.HideCols.Add("ID");
  123. reForm.FormWidth = 500;
  124. reForm.FormHeight = 500;
  125. //reForm.FilterKey = btn.Text;
  126. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  127. if (reForm.ShowDialog() == DialogResult.OK)
  128. {
  129. DataTable retData = reForm.ReturnData;
  130. foreach (DataRow dr in retData.Rows)
  131. {
  132. txtRESCODE.Text = dr["资源代码"].ToString();
  133. }
  134. }
  135. }
  136. #endregion
  137. #region 新增 修改
  138. private void save_Click(object sender, EventArgs e)
  139. {
  140. if (txtUserCode.Text.Trim() == "")
  141. {
  142. ICSBaseSimpleCode.AppshowMessageBox("人员代码不能为空!");
  143. }
  144. if (txtRESCODE.Text.Trim() == "")
  145. {
  146. ICSBaseSimpleCode.AppshowMessageBox("资源代码不能为空!");
  147. }
  148. DataTable dt2 = ICSSoft.Frame.Data.BLL.ICSUser2ResBLL.SelectUserID(txtUserCode.Text);
  149. if (dt2 != null && dt2.Rows.Count > 0)
  150. {
  151. entity.USERID = dt2.Rows[0][0].ToString();
  152. }
  153. DataTable dt1 = ICSSoft.Frame.Data.BLL.ICSUser2ResBLL.SelectResID(txtRESCODE.Text);
  154. if (dt1 != null && dt1.Rows.Count > 0)
  155. {
  156. entity.RESID = dt1.Rows[0][0].ToString();
  157. }
  158. entity.USERCODE = txtUserCode.Text.Trim();
  159. entity.RESCODE = txtRESCODE.Text.Trim();
  160. entity.MUSER = AppConfig.UserCode;
  161. entity.MUSERName = AppConfig.UserName;
  162. entity.MTIME = Convert.ToDateTime(AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString());
  163. try
  164. {
  165. ICSUser2ResBLL.AddandEdit(entity, AppConfig.AppConnectString);
  166. this.Close();
  167. ICSBaseSimpleCode.AppshowMessageBox("操作成功");
  168. }
  169. catch (Exception ex)
  170. {
  171. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  172. }
  173. }
  174. #endregion
  175. #region 取消
  176. private void can_Click(object sender, EventArgs e)
  177. {
  178. this.Close();
  179. }
  180. #endregion
  181. #region 页面加载
  182. private void FormICSUser2ResAdd_Load(object sender, EventArgs e)
  183. {
  184. //if (guid != "")
  185. //{
  186. // lblTitle.Text = "修改";
  187. // txtUserCode.Properties.ReadOnly = true;
  188. // entity = ICSDCTBLL.select(guid, AppConfig.AppConnectString);
  189. // txtUserCode.Text = entity.DCTCODE;
  190. // txtDCTESC.Text = entity.DCTDESC;
  191. // txtMUSER.Text = entity.MUSERName;
  192. // MTIME.Text = Convert.ToDateTime(entity.MTIME).ToString();
  193. //}
  194. //else
  195. //{
  196. lblTitle.Text = "新增";
  197. txtMUSER.Text = AppConfig.UserName;
  198. MTIME.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  199. //}
  200. }
  201. #endregion
  202. }
  203. }