Query_MacAddress.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using Seagull.BarTender.Print;
  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.Net.NetworkInformation;
  9. using System.Net.Sockets;
  10. using System.Net;
  11. using System.Text;
  12. using System.Windows.Forms;
  13. using UAS_MES_NEW.DataOperate;
  14. using UAS_MES_NEW.Entity;
  15. using UAS_MES_NEW.PublicMethod;
  16. using System.Net.Mail;
  17. namespace UAS_MES_NEW.Query
  18. {
  19. public partial class Query_MacAddress : Form
  20. {
  21. DataHelper dh = SystemInf.dh;
  22. Engine engine;
  23. public Query_MacAddress()
  24. {
  25. InitializeComponent();
  26. }
  27. private void Export_Click(object sender, EventArgs e)
  28. {
  29. }
  30. //选择导出Excel时是选择导出数据的还是模板
  31. private void ExcelExport(string DataOrTemplet)
  32. {
  33. }
  34. DataTable _dt;
  35. private void Query_SpecialReport_Load(object sender, EventArgs e)
  36. {
  37. NetworkInterface[] allNetworkInterface = NetworkInterface.GetAllNetworkInterfaces();
  38. foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
  39. {
  40. if (nic.OperationalStatus == OperationalStatus.Up)
  41. {
  42. Mac.Items.Add(nic.GetPhysicalAddress());
  43. }
  44. }
  45. }
  46. private void Sn_KeyDown(object sender, KeyEventArgs e)
  47. {
  48. if (e.KeyData == Keys.Enter)
  49. {
  50. }
  51. }
  52. private void Print_Click(object sender, EventArgs e)
  53. {
  54. }
  55. private void PrintBarcode_Click(object sender, EventArgs e)
  56. {
  57. DataTable dt = (DataTable)dh.ExecuteSql("select * from DeviceMacAddress where DMA_MAC='" + Mac.Text + "'", "select");
  58. if (dt.Rows.Count > 0)
  59. {
  60. string logout_confirm = MessageBox.Show(this.ParentForm, "已存在MAC" + Mac.Text + "对应设备名称" + dt.Rows[0]["DMA_MACHINENAME"].ToString() + "是否继续覆盖", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  61. string dma_id = dt.Rows[0]["dma_id"].ToString();
  62. if (logout_confirm == "Yes")
  63. {
  64. dh.ExecuteSql("delete from DeviceMacAddress where dma_id=" + dma_id, "delete");
  65. dh.ExecuteSql("insert into DeviceMacAddress(dma_id, DMA_MAC, DMA_INMAN, DMA_INDATE, DMA_MACHINENAME)" +
  66. "values(DeviceMacAddress_seq.nextval,'" + Mac.Text + "','" + User.UserName + "',sysdate,'" + de_name.Text + "')", "insert");
  67. OperateResult.AppendText("MAC" + Mac.Text + "上传成功", Color.Green);
  68. }
  69. }
  70. else
  71. {
  72. dh.ExecuteSql("insert into DeviceMacAddress(dma_id, DMA_MAC, DMA_INMAN, DMA_INDATE, DMA_MACHINENAME)" +
  73. "values(DeviceMacAddress_seq.nextval,'" + Mac.Text + "','" + User.UserName + "',sysdate,'" + de_name.Text + "')", "insert");
  74. OperateResult.AppendText("MAC" + Mac.Text + "上传成功", Color.Green);
  75. }
  76. }
  77. }
  78. }