초기 커밋.
This commit is contained in:
65
ControlServer/Form2.cs
Normal file
65
ControlServer/Form2.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ControlServer
|
||||
{
|
||||
public partial class Form2 : Form
|
||||
{
|
||||
public TerminalInfo TerminalData { get; private set; } = new TerminalInfo();
|
||||
|
||||
public Form2()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
btnRegister.Enabled = false; // 저장버튼 비활성화
|
||||
// 모든 텍스트박스의 값이 변할 때마다 실행될 이벤트 연결
|
||||
txtBoxName.TextChanged += ValidateInputs;
|
||||
txtBoxIP.TextChanged += ValidateInputs;
|
||||
txtBoxPort.TextChanged += ValidateInputs;
|
||||
}
|
||||
|
||||
private void ValidateInputs(object? sender, EventArgs e)
|
||||
{
|
||||
// 모든 텍스트박스가 공백이 아닐 때만 true
|
||||
bool isValid = !string.IsNullOrWhiteSpace(txtBoxName.Text) &&
|
||||
!string.IsNullOrWhiteSpace(txtBoxIP.Text) &&
|
||||
!string.IsNullOrWhiteSpace(txtBoxPort.Text);
|
||||
|
||||
// 저장 버튼 활성화 상태 조절
|
||||
btnRegister.Enabled = isValid;
|
||||
}
|
||||
|
||||
private void btnCancel_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
// 취소 버튼
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void btnRegister_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
// 1. DB 중복 데이터 확인
|
||||
|
||||
// 2. 중복 데이터 없을 경우 DB에 데이터 추가
|
||||
// DB 가져오면 데이터 넘겨주는게 아니라 테이블에 데이터 추가하고 Form1 화면에서 데이터 가져와 리스트 보여주는 형식으로 변경할 예정
|
||||
Popup popup = new Popup("등록되었습니다.");
|
||||
|
||||
if (popup.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
this.TerminalData = new TerminalInfo
|
||||
{
|
||||
TerminalName = txtBoxName.Text.Trim(),
|
||||
IP = txtBoxIP.Text.Trim(),
|
||||
Port = txtBoxPort.Text.Trim()
|
||||
};
|
||||
}
|
||||
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user