FromMain.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. using CCWin;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Runtime.InteropServices;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using WCS_Client.Utility;
  13. namespace WCS_Client.From
  14. {
  15. public partial class FromMain : Form
  16. {
  17. System.Timers.Timer _timer;
  18. public FromMain()
  19. {
  20. InitializeComponent();
  21. InitFrm();
  22. }
  23. private void InitFrm()
  24. {
  25. #region 初始化任务栏
  26. string sX = "";
  27. try
  28. {
  29. DateTime D = CurrentHelper.User.Use_LoginTime;
  30. switch (D.DayOfWeek)
  31. {
  32. case DayOfWeek.Sunday:
  33. sX = "日";
  34. break;
  35. case DayOfWeek.Monday:
  36. sX = "一";
  37. break;
  38. case DayOfWeek.Tuesday:
  39. sX = "二";
  40. break;
  41. case DayOfWeek.Wednesday:
  42. sX = "三";
  43. break;
  44. case DayOfWeek.Thursday:
  45. sX = "四";
  46. break;
  47. case DayOfWeek.Friday:
  48. sX = "五";
  49. break;
  50. case DayOfWeek.Saturday:
  51. sX = "六";
  52. break;
  53. }
  54. }
  55. catch
  56. {
  57. }
  58. toolStripStatusLabel1.Text = string.Format("【{0}】【{1}】【{2}】【星期{3}】", CurrentHelper.User.Use_Name, CurrentHelper.User.Use_RoleName, CurrentHelper.User.Use_LoginTime, sX);
  59. toolStripStatusLabel2.Text = "苏州博众精工科技有限公司版权所有";
  60. this.MainMenuStrip = skinMenuStrip1;
  61. #endregion
  62. }
  63. private void tsmtUser_Click(object sender, EventArgs e)
  64. {
  65. if (CurrentHelper.User.Use_RoleName == "系统管理员")
  66. {
  67. FromUser fu = FromUser.ChildFromInstanc;
  68. if (fu != null)
  69. {
  70. fu.ShowIcon = false;
  71. fu.MdiParent = this;
  72. fu.Show();//显示子窗体
  73. }
  74. }
  75. else
  76. {
  77. MessageBox.Show("普通管理员无权限打开该页面。");
  78. }
  79. }
  80. private void tsmt_Calc_Click(object sender, EventArgs e)
  81. {
  82. #region [ 启动计算器 ]
  83. System.Diagnostics.Process Proc;
  84. try
  85. {
  86. // 启动计算器
  87. Proc = new System.Diagnostics.Process();
  88. Proc.StartInfo.FileName = "calc.exe";
  89. Proc.StartInfo.UseShellExecute = false;
  90. Proc.StartInfo.RedirectStandardInput = true;
  91. Proc.StartInfo.RedirectStandardOutput = true;
  92. Proc.Start();
  93. }
  94. catch
  95. {
  96. Proc = null;
  97. }
  98. #endregion
  99. }
  100. #region [ API: 记事本 ]
  101. /// <summary>
  102. /// 传递消息给记事本
  103. /// </summary>
  104. /// <param name="hWnd"></param>
  105. /// <param name="Msg"></param>
  106. /// <param name="wParam"></param>
  107. /// <param name="lParam"></param>
  108. /// <returns></returns>
  109. [DllImport("User32.DLL")]
  110. public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, string lParam);
  111. /// <summary>
  112. /// 查找句柄
  113. /// </summary>
  114. /// <param name="hwndParent"></param>
  115. /// <param name="hwndChildAfter"></param>
  116. /// <param name="lpszClass"></param>
  117. /// <param name="lpszWindow"></param>
  118. /// <returns></returns>
  119. [DllImport("User32.DLL")]
  120. public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
  121. /// <summary>
  122. /// 记事本需要的常量
  123. /// </summary>
  124. public const uint WM_SETTEXT = 0x000C;
  125. #endregion
  126. private void tsmt_Book_Click(object sender, EventArgs e)
  127. {
  128. #region [ 启动记事本 ]
  129. System.Diagnostics.Process Proc;
  130. try
  131. {
  132. // 启动记事本
  133. Proc = new System.Diagnostics.Process();
  134. Proc.StartInfo.FileName = "notepad.exe";
  135. Proc.StartInfo.UseShellExecute = false;
  136. Proc.StartInfo.RedirectStandardInput = true;
  137. Proc.StartInfo.RedirectStandardOutput = true;
  138. Proc.Start();
  139. }
  140. catch
  141. {
  142. Proc = null;
  143. }
  144. #endregion
  145. #region [ 传递数据给记事本 ]
  146. if (Proc != null)
  147. {
  148. // 调用 API, 传递数据
  149. while (Proc.MainWindowHandle == IntPtr.Zero)
  150. {
  151. Proc.Refresh();
  152. }
  153. IntPtr vHandle = FindWindowEx(Proc.MainWindowHandle, IntPtr.Zero, "Edit", null);
  154. // 传递数据给记事本
  155. SendMessage(vHandle, WM_SETTEXT, 0, "");
  156. }
  157. #endregion
  158. }
  159. private void tsmt_SysReset_Click(object sender, EventArgs e)
  160. {
  161. Application.Restart();
  162. }
  163. private void tsmt_SysExit_Click(object sender, EventArgs e)
  164. {
  165. Application.Exit();
  166. }
  167. private void skinMenuStrip1_ItemAdded(object sender, ToolStripItemEventArgs e)
  168. {
  169. //若需要保留还原及最小化按钮,条件仅需e.Item.Text.Length == 0
  170. if (e.Item.Text.Length == 0 || e.Item.Text == "还原(&R)" || e.Item.Text == "最小化(&N)")
  171. {
  172. e.Item.Visible = false;
  173. }
  174. }
  175. private void tsmt_task_Click(object sender, EventArgs e)
  176. {
  177. Form_Task fu = Form_Task.ChildFromInstanc;
  178. if (fu != null)
  179. {
  180. fu.ShowIcon = false;
  181. fu.MdiParent = this;
  182. fu.Show();//显示子窗体
  183. }
  184. }
  185. private void tsmt_TaskDis_Click(object sender, EventArgs e)
  186. {
  187. Form_TaskDis fu = Form_TaskDis.ChildFromInstanc;
  188. if (fu != null)
  189. {
  190. fu.ShowIcon = false;
  191. fu.MdiParent = this;
  192. fu.Show();//显示子窗体
  193. }
  194. }
  195. private void tsmaterInMontior_Click(object sender, EventArgs e)
  196. {
  197. Form_Monitior fu = Form_Monitior.ChildFromInstanc;
  198. if (fu != null)
  199. {
  200. //fu.ShowIcon = false;
  201. //fu.MdiParent = this;
  202. fu.Show();//显示子窗体
  203. }
  204. }
  205. private void tsmtQueryLog_Click(object sender, EventArgs e)
  206. {
  207. System.Diagnostics.Process.Start(@"D:\项目\科勒\Code\WCS\BZ_WCS\WCSService\App_Log");
  208. }
  209. private void tsmtSystemSet_Click(object sender, EventArgs e)
  210. {
  211. if (CurrentHelper.User.Use_RoleName == "系统管理员")
  212. {
  213. Form_SystemSet systemSet = Form_SystemSet.ChildFromInstanc;
  214. if (systemSet != null)
  215. {
  216. systemSet.ShowIcon = false;
  217. systemSet.MdiParent = this;
  218. systemSet.Show();
  219. }
  220. }
  221. else
  222. {
  223. MessageBox.Show("普通管理员无权限打开该页面。");
  224. }
  225. }
  226. private void tsmtSrmDataQuery_Click(object sender, EventArgs e)
  227. {
  228. Form_SrmData sd = Form_SrmData.ChildFromInstanc;
  229. if (sd != null)
  230. {
  231. sd.ShowIcon = false;
  232. sd.MdiParent = this;
  233. sd.Show();//显示子窗体
  234. }
  235. }
  236. private void tsmiEquLockQuery_Click(object sender, EventArgs e)
  237. {
  238. if (CurrentHelper.User.Use_RoleName == "系统管理员")
  239. {
  240. Form_EquLockQuery systemSet = Form_EquLockQuery.ChildFromInstanc;
  241. if (systemSet != null)
  242. {
  243. systemSet.ShowIcon = false;
  244. systemSet.MdiParent = this;
  245. systemSet.Show();
  246. }
  247. }
  248. else
  249. {
  250. MessageBox.Show("普通管理员无权限打开该页面。");
  251. }
  252. }
  253. private void FromMain_Load(object sender, EventArgs e)
  254. {
  255. _timer = new System.Timers.Timer(5000);
  256. _timer.Elapsed += new System.Timers.ElapsedEventHandler(theout);//到达时间的时候执行事件;
  257. _timer.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
  258. _timer.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件;
  259. }
  260. private void theout(object sender, EventArgs e)
  261. {
  262. CommHelper.ClearMemory();
  263. }
  264. private void 立体库料箱物流设备监控ToolStripMenuItem_Click(object sender, EventArgs e)
  265. {
  266. Form_Monitior_Box fu = Form_Monitior_Box.ChildFromInstanc;
  267. if (fu != null)
  268. {
  269. //fu.ShowIcon = false;
  270. //fu.MdiParent = this;
  271. fu.Show();//显示子窗体
  272. }
  273. }
  274. static DataTable dt = null;
  275. private static DataTable Dt
  276. {
  277. get
  278. {
  279. if (dt == null)
  280. {
  281. dt = new DataTable();
  282. dt.Columns.Add("USER_NO");
  283. }
  284. return dt;
  285. }
  286. }
  287. private void 修改密码ToolStripMenuItem_Click(object sender, EventArgs e)
  288. {
  289. DataRow row = Dt.NewRow();
  290. row["USER_NO"] = CurrentHelper.User.USER_NO;
  291. var editpwd = new FormEditPwd(row);
  292. editpwd.ShowDialog();
  293. }
  294. private void 历史报警记录查询ToolStripMenuItem_Click(object sender, EventArgs e)
  295. {
  296. var alaramrecord = FrmALARAMRECORD.ChildFromInstanc;
  297. if (alaramrecord != null)
  298. {
  299. alaramrecord.ShowIcon = false;
  300. alaramrecord.MdiParent = this;
  301. alaramrecord.Show();//显示子窗体
  302. }
  303. }
  304. //private void tsmtTwo_Click(object sender, EventArgs e)
  305. //{
  306. // Form_materInMontior fu = Form_materInMontior.ChildFromInstanc;
  307. // if (fu != null)
  308. // {
  309. // //fu.ShowIcon = false;
  310. // //fu.MdiParent = this;
  311. // fu.Show();//显示子窗体
  312. // }
  313. //}
  314. }
  315. }