/// <summary> /// press the user login button to deal with /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUserLogin_Click(object sender, EventArgs e) { string strBtn = btnUserLogin.Text; if (strBtn == Utility.StringUtil.ConvertString("Equipment users login")) { frm_AddDevice fLogin = new frm_AddDevice(); fLogin.ShowDialog(); if (fLogin.blnOKEnter == true) { //achieve the information of the equipment users deviceInfo = new NET_DEVICEINFO(); int error = 0; //equipment users login pLoginID = NETClient.NETLogin(fLogin.cmbDevIP.Text.ToString(), ushort.Parse(fLogin.txtDevProt.Text.ToString()), fLogin.txtName.Text.ToString(), fLogin.txtPassword.Text.ToString(), out deviceInfo, out error); if (pLoginID != 0) { strUserName = fLogin.txtDevName.Text; btnUserLogin.BackColor = Color.Yellow; btnUserLogin.Text = StringUtil.ConvertString("Equipment users logout"); grbMain.Enabled = true; } else { //report the error information of the last operation MessageUtil.ShowMsgBox(StringUtil.ConvertString(NETClient.LastOperationInfo.errMessage, "ErrorMessage"), StringUtil.ConvertString(pMsgTitle)); } } } else if (strBtn == Utility.StringUtil.ConvertString("Equipment users logout")) { bool result = NETClient.NETLogout(pLoginID); if (result == false) { //report the error information of the last operation MessageUtil.ShowMsgBox(StringUtil.ConvertString(NETClient.LastOperationInfo.errMessage, "ErrorMessage"), StringUtil.ConvertString(pMsgTitle)); } btnUserLogin.BackColor = Color.Transparent; btnUserLogin.Text = StringUtil.ConvertString("Equipment users login"); grbMain.Enabled = false; Utility.StringUtil.InitControlText(this); } }
/// <summary> /// 用户登录按钮按下处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUserLogin_Click(object sender, EventArgs e) { string strBtn = btnUserLogin.Text; if (strBtn == Utility.StringUtil.ConvertString("设备用户登录")) { frm_AddDevice fLogin = new frm_AddDevice(); fLogin.ShowDialog(); if (fLogin.blnOKEnter == true) { //设备用户信息获得 deviceInfo = new NET_DEVICEINFO(); int error = 0; //设备用户登录 pLoginID = DHClient.DHLogin(fLogin.cmbDevIP.Text.ToString(), ushort.Parse(fLogin.txtDevProt.Text.ToString()), fLogin.txtName.Text.ToString(), fLogin.txtPassword.Text.ToString(), out deviceInfo, out error); if (pLoginID != 0) { strUserName = fLogin.txtDevName.Text; btnUserLogin.BackColor = Color.Yellow; btnUserLogin.Text = StringUtil.ConvertString("设备用户注销"); grbMain.Enabled = true; } else { //报最后一次操作的错误信息 MessageUtil.ShowMsgBox(StringUtil.ConvertString(DHClient.LastOperationInfo.errMessage, "ErrorMessage"), StringUtil.ConvertString(pMsgTitle)); } } } else if (strBtn == Utility.StringUtil.ConvertString("设备用户注销")) { bool result = DHClient.DHLogout(pLoginID); if (result == false) { //报最后一次操作的错误信息 MessageUtil.ShowMsgBox(StringUtil.ConvertString(DHClient.LastOperationInfo.errMessage, "ErrorMessage"), StringUtil.ConvertString(pMsgTitle)); } btnUserLogin.BackColor = Color.Transparent; btnUserLogin.Text = StringUtil.ConvertString("设备用户登录"); grbMain.Enabled = false; Utility.StringUtil.InitControlText(this); } }
/// <summary> /// 用户登录按钮按下处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUserLogin_Click(object sender, EventArgs e) { switch (btnUserLogin.Text) { case "设备用户登录": frm_AddDevice fLogin = new frm_AddDevice(); fLogin.ShowDialog(); if (fLogin.blnOKEnter == true) { //设备用户信息获得 NET_DEVICEINFO deviceInfo = new NET_DEVICEINFO(); int error = 0; //设备用户登录 pLoginID = DHClient.DHLogin(fLogin.cmbDevIP.Text.ToString(), ushort.Parse(fLogin.txtDevProt.Text.ToString()), fLogin.txtName.Text.ToString(), fLogin.txtPassword.Text.ToString(), out deviceInfo, out error); if (pLoginID != 0) { btnUserLogin.BackColor = Color.Yellow; btnUserLogin.Text = "设备用户注销"; grbMain.Enabled = true; } else { //报最后一次操作的错误信息 MessageBox.Show(DHClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle); grbMain.Enabled = false; } } break; case "设备用户注销": bool result = DHClient.DHLogout(pLoginID); if (result == false) { //报最后一次操作的错误信息 MessageBox.Show(DHClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle); } btnUserLogin.BackColor = Color.Transparent; btnUserLogin.Text = "设备用户登录"; grbMain.Enabled = false; break; } }