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

302 lines
11 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. using System.Text.RegularExpressions;
  21. namespace ICSSoft.Frame.APP
  22. {
  23. public partial class FormICSINVInfoAdd : DevExpress.XtraEditors.XtraForm
  24. {
  25. String guid = "";
  26. ICSINVInfo entity = new ICSINVInfo();
  27. #region 构造函数
  28. public FormICSINVInfoAdd()
  29. {
  30. InitializeComponent();
  31. guid = "";
  32. }
  33. public FormICSINVInfoAdd(String id)
  34. {
  35. InitializeComponent();
  36. guid = id;
  37. }
  38. #endregion
  39. #region 关闭 退出
  40. private void btnClose_Click(object sender, EventArgs e)
  41. {
  42. this.Close();
  43. }
  44. #endregion
  45. #region 移动窗体
  46. private const int WM_NCHITTEST = 0x84;
  47. private const int HTCLIENT = 0x1;
  48. private const int HTCAPTION = 0x2;
  49. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  50. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  51. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  52. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  53. //重写窗体,使窗体可以不通过自带标题栏实现移动
  54. protected override void WndProc(ref Message m)
  55. {
  56. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  57. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  58. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  59. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  60. switch (m.Msg)
  61. {
  62. case WM_NCHITTEST:
  63. base.WndProc(ref m);
  64. if ((int)m.Result == HTCLIENT)
  65. m.Result = (IntPtr)HTCAPTION;
  66. return;
  67. }
  68. //拦截双击标题栏、移动窗体的系统消息
  69. if (m.Msg != 0xA3)
  70. {
  71. base.WndProc(ref m);
  72. }
  73. }
  74. #endregion
  75. #region 产品类别
  76. private void txtINVCLASS_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  77. {
  78. }
  79. #endregion
  80. #region 新增 修改
  81. private void save_Click(object sender, EventArgs e)
  82. {
  83. if (txtINVCODE.Text.Trim() == "")
  84. {
  85. ICSBaseSimpleCode.AppshowMessageBox("存货编码不能为空!");
  86. return;
  87. }
  88. if (lvl == "")
  89. {
  90. ICSBaseSimpleCode.AppshowMessageBox("产品等级不能为空!");
  91. return;
  92. }
  93. entity.ID = guid;
  94. entity.INVCODE = txtINVCODE.Text.Trim();
  95. entity.INVNAME = txtINVNAME.Text.Trim();
  96. entity.EATTRIBUTE5 = lvl;
  97. //entity.EATTRIBUTE6 = txtExemption.Text.Trim();
  98. //if (cbxiangjiao.Checked)
  99. //{
  100. // entity.EATTRIBUTE4 = "1";
  101. //}
  102. //else {
  103. // entity.EATTRIBUTE4 = "0";
  104. //}
  105. //entity.EATTRIBUTE5 = txtEATTRIBUTE5.Text.Trim();
  106. //entity.EATTRIBUTE6 = txtEATTRIBUTE6.Text.Trim();
  107. entity.MUSER = AppConfig.UserCode;
  108. entity.MUSERName = AppConfig.UserName;
  109. entity.MTIME = Convert.ToDateTime(AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString());
  110. entity.WorkPoint = AppConfig.WorkPointCode;
  111. try
  112. {
  113. ICSINVInfoBLL.AddandEdit(entity, AppConfig.AppConnectString);
  114. this.Close();
  115. ICSBaseSimpleCode.AppshowMessageBox("操作成功");
  116. }
  117. catch (Exception ex)
  118. {
  119. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  120. }
  121. }
  122. #endregion
  123. #region 取消
  124. private void can_Click(object sender, EventArgs e)
  125. {
  126. this.Close();
  127. }
  128. #endregion
  129. #region 页面加载
  130. private void FormICSINVENTORYAdd_Load(object sender, EventArgs e)
  131. {
  132. init();
  133. if (guid != "")
  134. {
  135. lblTitle.Text = "产品等级修改";
  136. txtINVCODE.Properties.ReadOnly = true;
  137. entity = ICSINVInfoBLL.select(guid, AppConfig.AppConnectString);
  138. txtINVCODE.Text = entity.INVCODE;
  139. txtINVNAME.Text = entity.INVNAME;
  140. txtProduceLvl.Text = entity.EATTRIBUTE5; ;
  141. //txtExemption.Text = entity.EATTRIBUTE6;
  142. //if (entity.EATTRIBUTE4 == "1") {
  143. // cbxiangjiao.Checked = true;
  144. //}
  145. txtMUSERName.Text = AppConfig.UserName;
  146. txtMTIME.Text = Convert.ToDateTime(entity.MTIME).ToString();
  147. }
  148. else
  149. {
  150. lblTitle.Text = "产品等级新增";
  151. txtMUSERName.Text = AppConfig.UserName;
  152. txtMTIME.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  153. }
  154. }
  155. #endregion
  156. #region 初始化查询条件
  157. private void init()
  158. {
  159. #region 生产订单号
  160. string sql1 = "select distinct INVCODE as [存货编码], INVNAME as [存货名称],INVSTD as [规格型号] from ICSINVENTORY with(nolock) WHERE WorkPoint='{0}'";
  161. sql1 = string.Format(sql1, AppConfig.WorkPointCode);
  162. DataTable dt1 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql1).Tables[0];
  163. txtINVCODE.Properties.ValueMember = "存货编码";
  164. txtINVCODE.Properties.DisplayMember = "存货编码";
  165. txtINVCODE.Properties.DataSource = dt1;
  166. txtINVCODE.Properties.NullText = "";//空时的值
  167. txtINVCODE.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  168. txtINVCODE.Properties.ValidateOnEnterKey = true;//回车确认
  169. txtINVCODE.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  170. txtINVCODE.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  171. //自适应宽度
  172. txtINVCODE.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  173. #endregion
  174. #region 产品等级
  175. string sql2 = @"SELECT EnumKey ,EnumValue AS 等级,EnumText AS 说明 FROM dbo.Sys_EnumValues WHERE EnumKey='00019' AND StartFlag=1 AND WorkPointCode='{0}' ORDER BY EnumKey ";
  176. sql2 = string.Format(sql2, AppConfig.WorkPointCode);
  177. DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql2).Tables[0];
  178. txtProduceLvl.Properties.ValueMember = "等级";
  179. txtProduceLvl.Properties.DisplayMember = "说明";
  180. txtProduceLvl.Properties.DataSource = dt2;
  181. txtProduceLvl.Properties.NullText = "";//空时的值
  182. txtProduceLvl.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  183. txtProduceLvl.Properties.ValidateOnEnterKey = true;//回车确认
  184. txtProduceLvl.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  185. txtProduceLvl.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  186. //自适应宽度
  187. txtProduceLvl.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  188. #endregion
  189. }
  190. #endregion
  191. private void txtINVCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  192. {
  193. ButtonEdit btn = (ButtonEdit)sender;
  194. string sql = "select distinct INVCODE as [存货编码], INVNAME as [存货名称] from ICSINVENTORY with(nolock) WHERE 1=1";
  195. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  196. FormDataRefer reForm = new FormDataRefer();
  197. reForm.FormTitle = "产品信息";
  198. DataTable menuData = data;
  199. reForm.DataSource = menuData;
  200. reForm.MSelectFlag = false;
  201. reForm.RowIndexWidth = 35;
  202. reForm.HideCols.Add("ID");
  203. reForm.FormWidth = 500;
  204. reForm.FormHeight = 500;
  205. //reForm.FilterKey = btn.Text;
  206. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  207. if (reForm.ShowDialog() == DialogResult.OK)
  208. {
  209. DataTable retData = reForm.ReturnData;
  210. foreach (DataRow dr in retData.Rows)
  211. {
  212. txtINVCODE.Text = dr["存货编码"].ToString();
  213. txtINVNAME.Text = dr["存货名称"].ToString();
  214. }
  215. }
  216. }
  217. private void txtItemCode_EditValueChanged(object sender, EventArgs e)
  218. {
  219. try
  220. {
  221. GridLookUpEdit lookUP = sender as GridLookUpEdit;
  222. if (!string.IsNullOrWhiteSpace(lookUP.EditValue.ToString()))
  223. {
  224. var o = lookUP.Properties.GetRowByKeyValue(lookUP.EditValue);
  225. if (o is DataRowView)
  226. {
  227. DataRowView view = o as DataRowView;
  228. txtINVNAME.Text = view.Row["存货名称"].ToString();
  229. }
  230. else
  231. txtINVNAME.Text = "";
  232. }
  233. }
  234. catch (Exception ex)
  235. {
  236. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  237. }
  238. }
  239. string lvl = "";
  240. private void txtProduceLvl_EditValueChanged(object sender, EventArgs e)
  241. {
  242. try
  243. {
  244. GridLookUpEdit lookUP = sender as GridLookUpEdit;
  245. if (!string.IsNullOrWhiteSpace(lookUP.EditValue.ToString()))
  246. {
  247. var o = lookUP.Properties.GetRowByKeyValue(lookUP.EditValue);
  248. if (o is DataRowView)
  249. {
  250. DataRowView view = o as DataRowView;
  251. lvl = view.Row[1].ToString();
  252. }
  253. else
  254. {
  255. lvl = "";
  256. }
  257. }
  258. }
  259. catch (Exception ex)
  260. {
  261. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  262. }
  263. }
  264. }
  265. }