private void btnAlarm_Click(object sender, EventArgs e) { if (dgvAlarm.SelectedRows.Count == 0) { UMessageBox.Show("请选择数据!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } terminal_ID = dgvAlarm.CurrentRow.Cells[1].Value.ToString(); list = wellInfoService.GetWellInfo_List(terminal_ID); json = JsonConvert.SerializeObject(list); WebBrower.webBrower.ExecuteScriptAsync("searchData", json); }
private void timer1_Tick(object sender, EventArgs e) { this.timer1.Stop(); if (SerialPort.GetPortNames().Length != 0) { //读取配置文件 string portName = ReadWriteXml.ReadXml("PortName"); string baudRate = ReadWriteXml.ReadXml("BaudRate"); CDMASMS.Set(portName, Convert.ToInt32(baudRate)); if (CDMASMS.Open()) { string TSX = CDMASMS.SendAT("AT^MEID").Replace("\r\n", "").Replace("OK", ""); string production_Name = CDMASMS.SendAT("AT+CGMM").Replace("\r\n", "").Replace("OK", ""); if (TSX.Length == 14 && production_Name.IndexOf("MC323") != -1) { TSX = SysFunction.GetSecurit(TSX.Remove(3, 5)); if (tsx.Equals(TSX)) { string netstat = CDMASMS.SendAT("AT+CREG?").Replace("\r\n", "").Replace("OK", ""); if (netstat.Split(',')[1] == "1") { if (ReadWriteRegistry.ReadRegistry("isInvalid") == null) { ReadWriteRegistry.WriteRegistry("isInvalid", "false"); } if (ReadWriteRegistry.ReadRegistry("isInvalid") == "true") { this.DialogResult = DialogResult.Abort; } else { CDMASMS.DeviceInitialize(); this.DialogResult = DialogResult.OK; } this.Close(); } else { UMessageBox.Show("未注册到本地网络!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error); CDMASMS.Close(); this.Close(); } } else { UMessageBox.Show("硬件不匹配!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error); CDMASMS.Close(); this.Close(); } } else { UMessageBox.Show("串口打开失败,请在系统设置中重新配置串口数据。", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.No; this.Close(); } } else { UMessageBox.Show("串口打开失败,请在系统设置中重新配置串口数据。", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.No; this.Close(); } } else { UMessageBox.Show("读取硬件信息失败!请确认硬件设备连接正确。", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error); CDMASMS.Close(); this.Close(); } }
private void btnSure_Click(object sender, EventArgs e) { if (txtTerminal_ID.Text.Trim() == "") { UMessageBox.Show("请填写人井编号。", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtLongitude.Text.Trim() == "" && txtLatitude.Text.Trim() == "") { UMessageBox.Show("请填写经度纬度。", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtTerminal_Phone.Text.Trim() == "") { UMessageBox.Show("请填写终端手机号。", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (cbOperator.SelectedIndex == -1) { UMessageBox.Show("请选择值班人员。", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (tbReportInterval.Text.Trim() == "" && !isNumber(tbReportInterval.Text.Trim())) { UMessageBox.Show("请填写上报时间间隔。", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } this.DialogResult = DialogResult.OK; terminal_ID = wellInfo.Terminal_ID = txtTerminal_ID.Text.Trim(); wellInfo.Name = txtName.Text.Trim(); wellInfo.Longitude = txtLongitude.Text.Trim(); wellInfo.Latitude = txtLatitude.Text.Trim(); wellInfo.Place = txtPlace.Text.Trim(); wellInfo.Terminal_Phone = txtTerminal_Phone.Text.Trim(); wellInfo.Operator_ID = (int)cbOperator.SelectedValue; reportInterval = int.Parse(tbReportInterval.Text.Trim()); if (_isInsert) { if (wellInfoService.GetWellInfoByTerminal_ID(txtTerminal_ID.Text.Trim()) == null && wellInfoService.GetWellInfoByPhone(txtTerminal_Phone.Text.Trim()) == null) { wellInfoService.InsertWellInfo(wellInfo); wellStateService.InsertWellCurrentStateInfo(wellInfo.Terminal_ID, (int)cbState.SelectedValue); wellInfoService.InsertReportInfo(wellInfo.Terminal_ID, reportInterval); userLogHelper.InsertUserLog(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), "添加人井。", CommonClass.UserName, null, null); } else { UMessageBox.Show("当前人井已存在。", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else { wellInfoService.UpdateWellInfo(wellInfo); wellStateService.UpdateWellCurrentStateInfo((int)cbState.SelectedValue, wellInfo.Terminal_ID); wellInfoService.UpdateReportInterval(reportInterval, wellInfo.Terminal_ID); userLogHelper.InsertUserLog(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), "更新人井信息。", CommonClass.UserName, null, null); } UMessageBox.Show(this.Text + "成功!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); }
//确定添加/更新 private void btnSure_Click(object sender, EventArgs e) { operatorInfo = new OperatorInfo() { Area = txtArea.Text.Trim(), //区域 Work_ID = txtWorkID.Text.Trim(), //工号 RealName = txtName.Text.Trim(), //姓名 Telephone = txtTelephone.Text.Trim(), //联系方式 Gender = cmbGender.SelectedItem.ToString().Trim(), //性别 ReceiveMsg = cmbreceive.SelectedItem.ToString().Trim(), //接收消息 }; if (txtWorkID.Text.Trim() == "") { UMessageBox.Show("请输入值班人员工号!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtName.Text.Trim() == "") { UMessageBox.Show("请输入值班人员姓名!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtTelephone.Text.Trim() == "") { UMessageBox.Show("请输入值班人员手机号!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //添加 if (_isInsert) { if (userService.GetOperatorByWork_ID(txtWorkID.Text.Trim()) != null) { UMessageBox.Show("该值班人员已存在,请勿重复添加!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { int a = userService.InsertOperatorInfo(operatorInfo); if (a > 0) { UMessageBox.Show("数据添加成功!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); userLogHelper.InsertUserLog(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), "添加值班人员。", CommonClass.UserName, null, null); this.Close(); } else { UMessageBox.Show("数据添加失败!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } //更新 else { int a = userService.UpdateOperatorInfo(operatorInfo); if (a > 0) { UMessageBox.Show("数据修改成功!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); userLogHelper.InsertUserLog(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), "更新值班人员信息。", CommonClass.UserName, null, null); this.Close(); } else { UMessageBox.Show("数据修改失败!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
//确定添加/更新 private void btnSure_Click(object sender, EventArgs e) { usersInfo = new UsersInfo() { Work_ID = txtWorkID.Text.Trim(), //工号 RealName = txtRealName.Text.Trim(), //姓名 Gender = cmbGender.SelectedItem.ToString().Trim(), //性别 Telephone = txtTelephone.Text.Trim(), //联系方式 UserName = txtUserName.Text.Trim(), //用户名 PassWord = txtPassWord.Text.Trim() //密码 }; if (txtWorkID.Text.Trim() == "") { UMessageBox.Show("请输入人员工号!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtRealName.Text.Trim() == "") { UMessageBox.Show("请输入人员姓名!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtTelephone.Text.Trim() == "") { UMessageBox.Show("请输入人员手机号!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (userService.GetUsersByUserName(txtUserName.Text.Trim()) != null) { UMessageBox.Show("该用户名已存在,请修改!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //添加 if (_isInsert) { if (userService.GetUsersByWork_ID(txtWorkID.Text.Trim()) != null) { UMessageBox.Show("该人员已存在,请勿重复添加!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { int a = userService.InsertUserInfo(usersInfo); if (a > 0) { UMessageBox.Show("数据添加成功!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); userLogHelper.InsertUserLog(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), "添加用户信息。", CommonClass.UserName, null, null); this.Close(); } else { UMessageBox.Show("数据添加失败!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } //更新 else { int a = userService.UpdateUserInfo(usersInfo); if (a > 0) { UMessageBox.Show("数据修改成功!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information); userLogHelper.InsertUserLog(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), "更新用户信息。", CommonClass.UserName, null, null); this.Close(); } else { UMessageBox.Show("数据修改失败!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }