示例#1
0
 private void btnConfirm_Click(object sender, EventArgs e)
 {
     if (btnConfirm.Text == "重新连接")
     {
         if (DMSDK.DM_CheckOnline("192.168.1.2", 80) < 0)
         {
             MessageBox.Show("未检测到在线仪器,请检查后重试!");
             btnConfirm.Text = "重新连接";
         }
         else
         {
             DMSDK.DM_Init();
             temp_OperateHandle = DMSDK.DM_Connect(ucPbx1.Handle, "192.168.1.2", 80);
             temp_ConnectHandle = DMSDK.DM_OpenMonitor(ucPbx1.Handle, "192.168.1.2", 5000, 0);
             DMSDK.DM_GetNetmask(temp_OperateHandle, SubMask);
             DMSDK.DM_GetGateway(temp_OperateHandle, GateWay);
             btnConfirm.Text = "确认修改";
         }
     }
     else if (btnConfirm.Text == "确认修改")
     {
         if (SubMask.ToString() == "" || GateWay.ToString() == "")
         {
             MessageBox.Show("参数异常!请重试!");
             return;
         }
         DMSDK.DM_SetIPAddr(temp_OperateHandle, ipAddressTextBox1.IPAdd.ToString(), SubMask.ToString(), GateWay.ToString());
         MessageBox.Show("修改完成");
         this.Close();
     }
 }
示例#2
0
 private void btnConfirm_Click(object sender, EventArgs e)
 {
     if (btnConfirm.Tag.ToString() == "Confirm")
     {
         btnConfirm.Text = "确认修改";
         if (Mac.Length == 0)
         {
             MessageBox.Show("MAC地址无效!重试!");
             return;
         }
         DMSDK.DM_SetIPAddr(tempConnect, IPAddressIP.IPAdd.ToString(), IPAddressSubMask.IPAdd.ToString(), IPAddressGateWay.IPAdd.ToString());
         sqlCreate.UpDate_CameraEnable(StaticClass.Temper_CameraId, "无", Convert.ToBoolean(cbxIsEnable.SelectedIndex), StaticClass.DataBaseName);
         MessageBox.Show("修改成功!请重新进入!");
         StaticClass.Temper_IsEnanle = Convert.ToBoolean(cbxIsEnable.SelectedIndex);
         this.Close();
     }
     else if (btnConfirm.Tag.ToString() == "Reconnect")
     {
         btnConfirm.Text = "重新连接";
         if (DMSDK.DM_CheckOnline(StaticClass.Temper_Ip, 80) < 0)// 离线检测  为离线
         {
             MessageBox.Show("无法连接探测器,请检查线路,或修改参数后重新连接!");
             btnConfirm.Tag              = "Reconnect";
             chbModifyGateWay.Enabled    = false;
             chbModifyMac.Enabled        = false;
             chbModifyNetMask.Enabled    = false;
             cbxIsEnable.SelectedIndex   = Convert.ToInt32(StaticClass.Temper_IsEnanle);
             StaticClass.Temper_IsEnanle = Convert.ToBoolean(cbxIsEnable.SelectedIndex);
         }
         else
         {
             tempConnect = DMSDK.DM_Connect(this.Handle, IPAddressIP.IPAdd.ToString(), 80);
             if (tempConnect < 0)
             {
                 MessageBox.Show("连接失败!请检查设备与参数后重试!");
                 return;
             }
             btnConfirm.Text = "确认修改";
             btnConfirm.Tag  = "Confirm";
             Mac             = new StringBuilder();
             SubMask         = new StringBuilder();
             GateWay         = new StringBuilder();
             DMSDK.DM_GetMAC(tempConnect, Mac);
             DMSDK.DM_GetNetmask(tempConnect, SubMask);
             DMSDK.DM_GetGateway(tempConnect, GateWay);
             cbxIsEnable.SelectedIndex   = Convert.ToInt32(StaticClass.Temper_IsEnanle);
             StaticClass.Temper_IsEnanle = Convert.ToBoolean(cbxIsEnable.SelectedIndex);
             Update_IpAddrGateWay(GateWay.ToString());
             Update_IpAddrSubMask(SubMask.ToString());
             tbxMAC.Text = Mac.ToString();
             tbxMAC.Text = Mac.ToString();
             chbModifyGateWay.Enabled = true;
             chbModifyMac.Enabled     = true;
             chbModifyNetMask.Enabled = true;
             cbxIsEnable.Enabled      = true;;
         }
     }
 }