https://www.youtube.com/watch?v=iylgmXBry9c&t=15s
결과 화면

로그인 폼
디자인 완료.

로그인 성공 시
Main Form 화면 출력.

로그인 실패 시
MessageBox.Show("아이디와 비밀번호를 확인해주세요");
소스 보기
Login 버튼 더블 클릭시 Form1.cs 화면에서
private void Login_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\cheon\Documents\Data.mdf;Integrated Security=True;Connect Timeout=30");
SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) from USERINFO where USERNAME='"+Id_text.Text+"' and PASSWORD='"+Pw_text.Text+"'", con);
DataTable newtable = new DataTable();
sda.Fill(newtable);
if (newtable.Rows[0][0].ToString() == "1")
{
//로그인 성공인 경우
this.Hide(); //숨김처리
MainForm mainForm1 = new MainForm();//객체생성
mainForm1.Show();
}
else
{
//로그인 실패시
MessageBox.Show("아이디와 비밀번호를 확인해주세요");
}
'iT-Programing > c#' 카테고리의 다른 글
Devexpress 그래프 그리기 (chart 범례/crosshair/계열/시리즈/이중축) (1) | 2020.04.09 |
---|---|
[C#, Devexpress Chart] Chart 설정 (0) | 2020.04.08 |
[c#] Data Type과 Overflow (0) | 2020.03.02 |
[c#] Winform "string" (0) | 2020.03.02 |
[c#] 도넛 차트 참고 (0) | 2020.02.28 |