/// <summary> /// 换卡 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnICCardChange_Click(object sender, EventArgs e) { if (!CStaticClass.CheckPushService()) {// 检查服务 return; } if (CTxtICCardIDFind.Text.Trim().Length != 4) { MessageBox.Show("请输入四位用户卡号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } QueryServiceClient proxy = new QueryServiceClient(); PushServiceClient push = new PushServiceClient(new System.ServiceModel.InstanceContext(CStaticClass.myCallback)); try { CarLocationPanelLib.PushService.EnmFaultType type = CarLocationPanelLib.PushService.EnmFaultType.Fail; if (this.CTxtICCardIDOld.Visible) { if (string.IsNullOrEmpty(this.CTxtICCardIDFind.Text) || string.IsNullOrEmpty(this.CTxtICCardIDOld.Text)) { MessageBox.Show("用户卡号、换卡旧卡号都不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string strICCardID = CStaticClass.ConvertICCardID(this.CTxtICCardIDFind.Text.Trim()); string strICCardIDOld = CStaticClass.ConvertICCardID(this.CTxtICCardIDOld.Text.Trim()); ClearICCardControls(); type = push.ModifyICCard(strICCardIDOld, strICCardID); this.TxtICCardID.Text = strICCardID; // 用户卡号 this.CTxtICCardIDFind.Text = strICCardID; // 用户卡号 } else { if (string.IsNullOrEmpty(this.CTxtICCardIDFind.Text)) { MessageBox.Show("用户卡号不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string strPhysicalCardID = this.TxtICCardPhy.Text.Trim(); string strICCardID = CStaticClass.ConvertICCardID(this.CTxtICCardIDFind.Text.Trim()); ClearICCardControls(); type = push.ModifyPhyCard(strPhysicalCardID, strICCardID); this.TxtICCardID.Text = strICCardID; // 用户卡号 this.CTxtICCardIDFind.Text = strICCardID; // 用户卡号 } switch (type) { // 换卡成功 case CarLocationPanelLib.PushService.EnmFaultType.Success: { MessageBox.Show("换卡成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); break; } // 传入的参数卡号为空 case CarLocationPanelLib.PushService.EnmFaultType.Null: { MessageBox.Show("传入的参数卡号为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } // 当前IC卡未制卡 case CarLocationPanelLib.PushService.EnmFaultType.NoICCardInfo: { MessageBox.Show("当前IC卡未制卡!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } // IC卡注销或挂失 case CarLocationPanelLib.PushService.EnmFaultType.LossORCancel: { MessageBox.Show("IC卡注销或挂失!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } // IC卡类型不正确 case CarLocationPanelLib.PushService.EnmFaultType.NotMatch: { MessageBox.Show("IC卡类型不正确!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } // 新的IC卡有绑定用户 case CarLocationPanelLib.PushService.EnmFaultType.BoundUser: { MessageBox.Show("新的IC卡有绑定用户!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } // 旧卡或新卡正在作业 case CarLocationPanelLib.PushService.EnmFaultType.TaskOnICCard: { MessageBox.Show("旧卡或新卡正在作业!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } // 旧卡或新卡正在排队取车 case CarLocationPanelLib.PushService.EnmFaultType.Wait: { MessageBox.Show("旧卡或新卡正在排队取车!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } // 新的IC卡有车存在车库 case CarLocationPanelLib.PushService.EnmFaultType.CarInGarage: { MessageBox.Show("新的IC卡有车存在车库!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } // 更新数据库失败 case CarLocationPanelLib.PushService.EnmFaultType.FailToUpdate: { MessageBox.Show("更新数据库失败!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } case CarLocationPanelLib.PushService.EnmFaultType.Exception: { MessageBox.Show(CStaticClass.GetExceptionInfo(null), "连接异常", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } default: { MessageBox.Show("换卡失败", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } } } catch (TimeoutException) { MessageBox.Show("The service operation timed out. ", "超时", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (FaultException exception) { MessageBox.Show(CStaticClass.GetExceptionInfo(exception), "SOAP错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (CommunicationException exception) { MessageBox.Show("There was a communication problem. " + CStaticClass.GetExceptionInfo(exception), "通信错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception exception) { MessageBox.Show(CStaticClass.GetExceptionInfo(exception), "应用程序异常", MessageBoxButtons.OK, MessageBoxIcon.Error); } proxy.Close(); push.Close(); }