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

200 lines
7.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.WorkPoint.Entity;
  10. using ICSSoft.Frame.WorkPoint.BLL;
  11. using ICSSoft.Base.Config.AppConfig;
  12. using ICSSoft.Base.Config.DBHelper;
  13. using System.Text.RegularExpressions;
  14. using ICSSoft.Frame.Data.Entity;
  15. using ICSSoft.Base.ReferForm.AppReferForm;
  16. using ICSSoft.Frame.Data.BLL;
  17. using ICSSoft.Frame.Helper;
  18. namespace ICSSoft.Frame.APP
  19. {
  20. public partial class FromICSDateDiffAdd : DevExpress.XtraEditors.XtraForm
  21. {
  22. string guid = "";
  23. /// <summary>
  24. /// add new
  25. /// </summary>
  26. public FromICSDateDiffAdd()
  27. {
  28. InitializeComponent();
  29. InitWeek();
  30. }
  31. /// <summary>
  32. /// edit
  33. /// </summary>
  34. /// <param name="cPersonCode"></param>
  35. public FromICSDateDiffAdd(string id)
  36. {
  37. InitializeComponent();
  38. this.guid = id;
  39. InitWeek();
  40. SearchData(id);
  41. }
  42. void InitWeek()
  43. {
  44. cboWeekDayName.Properties.Items.Clear();
  45. string[] ww = new string[]{
  46. "星期日",
  47. "星期一",
  48. "星期二",
  49. "星期三",
  50. "星期四",
  51. "星期五",
  52. "星期六"
  53. };
  54. cboWeekDayName.Properties.Items.AddRange(ww);
  55. cboWeekDayName.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
  56. }
  57. void SearchData(string id)
  58. {
  59. if (id == "")
  60. {
  61. chkAVA.Checked = true;
  62. txtMTIME.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  63. txtMUSERName.Text = AppConfig.UserName;
  64. return;
  65. }
  66. string sql = @"SELECT NAME,WEEKDAYNAME,BEGINTIME,ENDTIME,Available,MUSERName,MTIME FROM [ICSDateDiff] WHERE ID='" + id + "'";
  67. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  68. if (dt.Rows.Count == 0)
  69. {
  70. throw new Exception("此条数据已被删除");
  71. }
  72. txtName.Text = dt.Rows[0]["NAME"].ToString();
  73. cboWeekDayName.Text = dt.Rows[0]["WEEKDAYNAME"].ToString();
  74. txtBeginTime.EditValue = dt.Rows[0]["BEGINTIME"].ToString();
  75. txtEndTime.EditValue = dt.Rows[0]["ENDTIME"].ToString();
  76. chkAVA.Checked = Convert.ToBoolean(dt.Rows[0]["Available"]);
  77. txtMUSERName.Text = dt.Rows[0]["MUSERName"].ToString();
  78. txtMTIME.Text = dt.Rows[0]["MTIME"].ToString();
  79. }
  80. #region 新增 修改
  81. private void btnOK_Click(object sender, EventArgs e)
  82. {
  83. if (txtName.Text.Trim() == "")
  84. {
  85. ICSBaseSimpleCode.AppshowMessageBox("名称不能为空");
  86. return;
  87. }
  88. if (cboWeekDayName.Text.Trim() == "")
  89. {
  90. ICSBaseSimpleCode.AppshowMessageBox("必须选择是周几");
  91. return;
  92. }
  93. if (txtBeginTime.Text.Trim() == "")
  94. {
  95. ICSBaseSimpleCode.AppshowMessageBox("开始时间不能为空");
  96. return;
  97. }
  98. if (txtEndTime.Text.Trim() == "")
  99. {
  100. ICSBaseSimpleCode.AppshowMessageBox("结束时间不能为空");
  101. return;
  102. }
  103. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在执行...请稍等...");
  104. _wait.Show();
  105. try
  106. {
  107. string[] bt = txtBeginTime.Text.Split(':');
  108. string[] et = txtEndTime.Text.Split(':');
  109. ICSDateDiff info = new ICSDateDiff();
  110. info.ID = guid;
  111. info.NAME = txtName.Text.Trim();
  112. info.WEEKDAYNAME = cboWeekDayName.Text;
  113. info.BEGINTIME = new TimeSpan(Convert.ToInt32(bt[0]), Convert.ToInt32(bt[1]), Convert.ToInt32(bt[2]));
  114. info.ENDTIME = new TimeSpan(Convert.ToInt32(et[0]), Convert.ToInt32(et[1]), Convert.ToInt32(et[2]));
  115. if (info.BEGINTIME > info.ENDTIME)
  116. {
  117. ICSBaseSimpleCode.AppshowMessageBox("开始时间必须<结束时间");
  118. return;
  119. }
  120. info.MTIME = DateTime.Now;
  121. info.MUSERName = AppConfig.UserName;
  122. info.TYPE = "RPS";
  123. info.Available = chkAVA.Checked;
  124. info.WorkPoint = AppConfig.WorkPointCode;
  125. ICSDateDiffBLL.Edit(info, AppConfig.AppConnectString);
  126. this.Close();
  127. _wait.Close();
  128. this.DialogResult = DialogResult.OK;
  129. }
  130. catch (Exception ex)
  131. {
  132. _wait.Close();
  133. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  134. }
  135. }
  136. #endregion
  137. #region 移动窗体
  138. private const int WM_NCHITTEST = 0x84;
  139. private const int HTCLIENT = 0x1;
  140. private const int HTCAPTION = 0x2;
  141. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  142. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  143. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  144. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  145. //重写窗体,使窗体可以不通过自带标题栏实现移动
  146. protected override void WndProc(ref Message m)
  147. {
  148. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  149. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  150. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  151. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  152. switch (m.Msg)
  153. {
  154. case WM_NCHITTEST:
  155. base.WndProc(ref m);
  156. if ((int)m.Result == HTCLIENT)
  157. m.Result = (IntPtr)HTCAPTION;
  158. return;
  159. }
  160. //拦截双击标题栏、移动窗体的系统消息
  161. if (m.Msg != 0xA3)
  162. {
  163. base.WndProc(ref m);
  164. }
  165. }
  166. #endregion
  167. #region 关闭
  168. private void btnCancle_Click(object sender, EventArgs e)
  169. {
  170. this.Close();
  171. this.DialogResult = DialogResult.Cancel;
  172. }
  173. private void btnClose_Click(object sender, EventArgs e)
  174. {
  175. this.Close();
  176. this.DialogResult = DialogResult.Cancel;
  177. }
  178. #endregion
  179. private void FromICSDateDiffAdd_Load(object sender, EventArgs e)
  180. {
  181. }
  182. }
  183. }