/// <summary> /// 填充操作员信息 /// </summary> /// <param name="obj"></param> public void FillOperatorInfo(COperatorDto operatorDto) { //this.TxtPassWord.Text = "******";// 2 this.CTxtCode.Text = operatorDto.optcode; this.CTxtName.Text = operatorDto.optname; this.CTxtPassWord.Text = operatorDto.optpassword; this.CTxtNewPassWord.Text = operatorDto.optpassword; this.CTxtPhone.Text = operatorDto.optphone; this.TxtAddr.Text = operatorDto.optaddr; this.CboType.Enabled = false; this.CboType.Text = CStaticClass.ConvertOperatorType(operatorDto.opttype); this.LtbAssignedPermission.Items.Clear(); this.LtbAssignedPermission.Items.AddRange(CStaticClass.ConvertOptPermission(operatorDto.optpermission)); if (string.IsNullOrEmpty(this.CTxtCode.Text)) { this.CTxtCode.Enabled = true; this.BtnSave.Enabled = true; this.BtnModify.Enabled = false; this.BtnDelete.Enabled = false; } else { this.CTxtCode.Enabled = false; this.BtnSave.Enabled = false; this.BtnModify.Enabled = true; this.BtnDelete.Enabled = true; } }
/// <summary> /// 移除界面操作员列表行数据 /// </summary> /// <param name="strOptCode"></param> public bool RemoveDgvOperatorRow(COperatorDto operatorDto) { // 删除 return(this.CupttsOpt.DeleteDataItem(operatorDto)); //BindingList<COperatorDto> dataBingList = (BindingList<COperatorDto>)this.DgvOperator.DataSource; //COperatorDto dgvr = dataBingList.SingleOrDefault(s => s.optcode == operatorDto.optcode); //return ((BindingList<COperatorDto>)this.DgvOperator.DataSource).Remove(dgvr); }
/// <summary> /// 移除数据列表 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public bool DeleteDataList(object data) { bool flag = true; // 所有列表处理 if (data.GetType() == typeof(COperatorDto)) { COperatorDto dto = (COperatorDto)data; flag = m_lstOperator.RemoveAll(s => s.optcode == dto.optcode) > 0 ? true : false; } else if (data.GetType() == typeof(struCustomerInfo)) { struCustomerInfo dto = (struCustomerInfo)data; flag = m_lstStruCUSTInfo.RemoveAll(s => s.strICCardID == dto.strICCardID && s.strName == dto.strName) > 0 ? true : false; } else if (data.GetType() == typeof(CSoundDto)) { CSoundDto dto = (CSoundDto)data; flag = m_lstSound.RemoveAll(s => s.soundcode == dto.soundcode) > 0 ? true : false; } else if (data.GetType() == typeof(CLedContentDto)) { CLedContentDto dto = (CLedContentDto)data; flag = m_lstLedContent.RemoveAll(s => s.id == dto.id) > 0 ? true : false; } else if (data.GetType() == typeof(CICCardLogDto)) { CICCardLogDto dto = (CICCardLogDto)data; flag = m_lstICCardLog.RemoveAll(s => s.id == dto.id) > 0 ? true : false; } else if (data.GetType() == typeof(CSystemLogDto)) { CSystemLogDto dto = (CSystemLogDto)data; flag = m_lstSystemLog.RemoveAll(s => s.logid == dto.logid) > 0 ? true : false; } else if (data.GetType() == typeof(CTelegramLogDto)) { CTelegramLogDto dto = (CTelegramLogDto)data; flag = m_lstTelegramLog.RemoveAll(s => s.id == dto.id) > 0 ? true : false; } else if (data.GetType() == typeof(CDeviceFaultLogDto)) { CDeviceFaultLogDto dto = (CDeviceFaultLogDto)data; flag = m_lstDeviceFaultLog.RemoveAll(s => s.id == dto.id) > 0 ? true : false; } else if (data.GetType() == typeof(CDeviceStatusLogDto)) { CDeviceStatusLogDto dto = (CDeviceStatusLogDto)data; flag = m_lstDeviceStatusLog.RemoveAll(s => s.id == dto.id) > 0 ? true : false; } else if (data.GetType() == typeof(CTariffDto)) { CTariffDto dto = (CTariffDto)data; flag = m_lstTariff.RemoveAll(s => s.id == dto.id) > 0 ? true : false; } return(flag); }
/// <summary> /// 修改界面操作员列表行数据 /// </summary> /// <param name="strOptCode"></param> public bool ModifyDgvOperatorRow(COperatorDto operatorDto) {// 更新 this.CupttsOpt.ModifyDataItem(operatorDto); //BindingList<COperatorDto> dataBingList = (BindingList<COperatorDto>)this.DgvOperator.DataSource; //COperatorDto dgvr = dataBingList.SingleOrDefault(s => s.optcode == operatorDto.optcode); //int index = dataBingList.IndexOf(dgvr); //dataBingList.Remove(dgvr); //dataBingList.Insert(index, operatorDto); return(true); }
/// <summary> /// 对比COperatorDto两个表格是否相等 /// </summary> /// <param name="operatorDto1"></param> /// <param name="operatorDto2"></param> /// <returns></returns> private bool CompareOperatorDto(COperatorDto operatorDto1, COperatorDto operatorDto2) { if (null == operatorDto1 || null == operatorDto2) { return(false); } if (operatorDto1.optcode == operatorDto2.optcode && operatorDto1.optname == operatorDto2.optname && operatorDto1.optpassword == operatorDto2.optpassword && operatorDto1.optphone == operatorDto2.optphone && operatorDto1.opttype == operatorDto2.opttype && operatorDto1.optaddr == operatorDto2.optaddr) { return(true); } return(false); }
/// <summary> /// 获取操作员信息实例 /// </summary> /// <returns></returns> public COperatorDto getOperatorInfo() { List <object> lstObject = new List <object>(); foreach (object obj in this.LtbAssignedPermission.Items) { lstObject.Add(obj); } COperatorDto operatorDto = new COperatorDto { optcode = this.CTxtCode.Text.Trim(), optname = this.CTxtName.Text.Trim(), optpassword = this.CTxtPassWord.Text.Trim(), optphone = this.CTxtPhone.Text.Trim(), optaddr = this.TxtAddr.Text.Trim(), opttype = (int)CStaticClass.ConvertOperatorType(this.CboType.Text), optpermission = CStaticClass.ConvertOptPermission(lstObject.ToArray()) }; return(operatorDto); }
/// <summary> /// 系统登陆密码验证 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnOk_Click(object sender, EventArgs e) { if (!CStaticClass.CheckPushService()) {// 检查服务 return; } QueryServiceClient proxy = new QueryServiceClient(); try { if (string.IsNullOrEmpty(this.TxtName.Text) || string.IsNullOrEmpty(this.TxtPassWord.Text)) { MessageBox.Show("账户和密码都不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } COperatorDto operatorTBL = new COperatorDto(); operatorTBL.optcode = this.TxtName.Text.Trim(); operatorTBL.optpassword = this.TxtPassWord.Text.Trim(); CarLocationPanelLib.QueryService.EnmFaultType type = proxy.CheckPassword(ref operatorTBL); switch (type) { case CarLocationPanelLib.QueryService.EnmFaultType.Success: { CStaticClass.myOperator = operatorTBL; this.Close(); this.DialogResult = DialogResult.Yes; this.timer1.Start(); break; } case CarLocationPanelLib.QueryService.EnmFaultType.UserNameError: { MessageBox.Show("账户错误,请重新输入!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); m_nlogNumb++; if (m_nlogNumb == 3) { this.Close(); } break; } case CarLocationPanelLib.QueryService.EnmFaultType.PasswordError: { MessageBox.Show("密码错误,请重新输入!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); m_nlogNumb++; if (m_nlogNumb == 3) { this.Close(); } break; } case CarLocationPanelLib.QueryService.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(); }
/// <summary> /// 插入界面操作员列表行数据 /// </summary> /// <param name="strOptCode"></param> public bool SaveDgvOperatorRow(COperatorDto operatorDto) {// 插入 this.CupttsOpt.AddDataItem(operatorDto); //((BindingList<COperatorDto>)this.DgvOperator.DataSource).Add(operatorDto); return(true); }
/// <summary> /// 删除选择 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnDeleteSel_Click(object sender, EventArgs e) { if (!CStaticClass.CheckPushService()) {// 检查服务 return; } QueryServiceClient proxy = new QueryServiceClient(); try { // 判断是否选择当前操作员 foreach (DataGridViewRow dgvr in this.DgvOperator.SelectedRows) { if (((COperatorDto)dgvr.DataBoundItem).optcode == CStaticClass.myOperator.optcode) { MessageBox.Show("不允许删除当前操作员的信息!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } DialogResult dr = MessageBox.Show("确认删除?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); if (dr == DialogResult.Cancel) { return; } foreach (DataGridViewRow dgvr in this.DgvOperator.SelectedRows) { COperatorDto operatorDto = (COperatorDto)dgvr.DataBoundItem; bool flag = proxy.DeleteOperator(operatorDto); if (flag) { this.CupttsOpt.DeleteDataList(operatorDto); //((BindingList<COperatorDto>)this.DgvOperator.DataSource).Remove(operatorDto); } //else //{ // MessageBox.Show("没有该操作员", "删除失败", MessageBoxButtons.OK, MessageBoxIcon.Error); //} } MessageBox.Show("删除成功", "成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.CupttsOpt.UpdatePages(); } 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(); }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnSave_Click(object sender, EventArgs e) { if (!CStaticClass.CheckPushService()) {// 检查服务 return; } QueryServiceClient proxy = new QueryServiceClient(); try { if (string.IsNullOrEmpty(this.CTxtCode.Text) || string.IsNullOrEmpty(this.CTxtPassWord.Text) || string.IsNullOrEmpty(this.CboType.Text)) { MessageBox.Show("用户名,密码,类型都不能为空", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.CTxtPassWord.Text.Trim() != this.CTxtNewPassWord.Text.Trim()) { MessageBox.Show("两次填写的密码不一致,请重新输入!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } COperatorDto operatorDto = getOperatorInfo(); EnmFaultType type = proxy.AddOperator(operatorDto); switch (type) { case EnmFaultType.Success: { if (null != this.Owner && typeof(CFormOperatorManage) == this.Owner.GetType()) { ((CFormOperatorManage)this.Owner).SaveDgvOperatorRow(operatorDto); } DialogResult dr = MessageBox.Show("保存成功,是否继续添加?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); if (dr == DialogResult.OK) { ClearOperatorControls(); return; } //MessageBox.Show("保存成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.Close(); break; } case EnmFaultType.FailToUpdate: { MessageBox.Show("更新数据库失败!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } case EnmFaultType.OPRTypeNull: { MessageBox.Show("操作管理员类型为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } case EnmFaultType.FailToInsert: { MessageBox.Show("插入数据库失败!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } case 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(); }
/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnDelete_Click(object sender, EventArgs e) { if (!CStaticClass.CheckPushService()) {// 检查服务 return; } QueryServiceClient proxy = new QueryServiceClient(); try { if (string.IsNullOrEmpty(this.CTxtCode.Text)) { MessageBox.Show("用户名不能为空", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (CStaticClass.myOperator.optcode == this.CTxtCode.Text.Trim()) { MessageBox.Show("不允许删除当前操作员的信息!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } COperatorDto operatorDto = getOperatorInfo(); bool flag = proxy.DeleteOperator(operatorDto); if (!flag) { MessageBox.Show("删除数据库失败!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // 移除界面操作员列表行数据 if (null != this.Owner && typeof(CFormOperatorManage) == this.Owner.GetType() && ((CFormOperatorManage)this.Owner).RemoveDgvOperatorRow(operatorDto)) { MessageBox.Show("删除成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.Close(); } else { MessageBox.Show("没有该操作员!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } 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(); }
/// <summary> /// 修改数据项 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ModifyDataItem(object data) { // 所有列表处理 if (data.GetType() == typeof(COperatorDto)) { COperatorDto dto = (COperatorDto)data; int index = m_lstOperator.FindIndex(s => s.optcode == dto.optcode); if (-1 == index) { m_lstOperator.Add(dto); } else { m_lstOperator.RemoveAt(index); m_lstOperator.Insert(index, dto); } } else if (data.GetType() == typeof(struCustomerInfo)) { struCustomerInfo dto = (struCustomerInfo)data; int index = m_lstStruCUSTInfo.FindIndex(s => s.strICCardID == dto.strICCardID); if (-1 == index) { m_lstStruCUSTInfo.Add(dto); } else { m_lstStruCUSTInfo.RemoveAt(index); m_lstStruCUSTInfo.Insert(index, dto); } } else if (data.GetType() == typeof(CSoundDto)) { CSoundDto dto = (CSoundDto)data; int index = m_lstSound.FindIndex(s => s.soundcode == dto.soundcode); if (-1 == index) { m_lstSound.Add(dto); } else { m_lstSound.RemoveAt(index); m_lstSound.Insert(index, dto); } } else if (data.GetType() == typeof(CLedContentDto)) { CLedContentDto dto = (CLedContentDto)data; int index = m_lstLedContent.FindIndex(s => s.id == dto.id); if (-1 == index) { m_lstLedContent.Add(dto); } else { m_lstLedContent.RemoveAt(index); m_lstLedContent.Insert(index, dto); } } else if (data.GetType() == typeof(CICCardLogDto)) { CICCardLogDto dto = (CICCardLogDto)data; int index = m_lstICCardLog.FindIndex(s => s.id == dto.id); if (-1 == index) { m_lstICCardLog.Add(dto); } else { m_lstICCardLog.RemoveAt(index); m_lstICCardLog.Insert(index, dto); } } else if (data.GetType() == typeof(CSystemLogDto)) { CSystemLogDto dto = (CSystemLogDto)data; int index = m_lstSystemLog.FindIndex(s => s.logid == dto.logid); if (-1 == index) { m_lstSystemLog.Add(dto); } else { m_lstSystemLog.RemoveAt(index); m_lstSystemLog.Insert(index, dto); } } else if (data.GetType() == typeof(CTelegramLogDto)) { CTelegramLogDto dto = (CTelegramLogDto)data; int index = m_lstTelegramLog.FindIndex(s => s.id == dto.id); if (-1 == index) { m_lstTelegramLog.Add(dto); } else { m_lstTelegramLog.RemoveAt(index); m_lstTelegramLog.Insert(index, dto); } } else if (data.GetType() == typeof(CDeviceFaultLogDto)) { CDeviceFaultLogDto dto = (CDeviceFaultLogDto)data; int index = m_lstDeviceFaultLog.FindIndex(s => s.id == dto.id); if (-1 == index) { m_lstDeviceFaultLog.Add(dto); } else { m_lstDeviceFaultLog.RemoveAt(index); m_lstDeviceFaultLog.Insert(index, dto); } } else if (data.GetType() == typeof(CDeviceStatusLogDto)) { CDeviceStatusLogDto dto = (CDeviceStatusLogDto)data; int index = m_lstDeviceStatusLog.FindIndex(s => s.id == dto.id); if (-1 == index) { m_lstDeviceStatusLog.Add(dto); } else { m_lstDeviceStatusLog.RemoveAt(index); m_lstDeviceStatusLog.Insert(index, dto); } } else if (data.GetType() == typeof(CTariffDto)) { CTariffDto dto = (CTariffDto)data; int index = m_lstTariff.FindIndex(s => s.id == dto.id); if (-1 == index) { m_lstTariff.Add(dto); } else { m_lstTariff.RemoveAt(index); m_lstTariff.Insert(index, dto); } } UpdatePages(); }