Beispiel #1
0
        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();
        }