본문 바로가기

   
Programming/Winform

윈폼(winform) 회원가입, 트레이 아이콘 예제

반응형

윈폼(winform) 회원가입, 트레이 아이콘 예제

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

 

namespace WindowsFormsTest

{

       public partial class 회원가입 : Form

       {

             public 회원가입()

             {

                    InitializeComponent();

             }

 

             private void 회원가입_Load(object sender, EventArgs e)

             {

                    comboBoxJob.SelectedIndex = 0;

             }

 

             private void button1_Click(object sender, EventArgs e)

             {

                    IdCheck id = new IdCheck();

                    id.Owner = this;

                    id.ShowDialog();

             }

 

             private void button2_Click(object sender, EventArgs e)

             {

                    Address address = new Address();

                    address.Owner = this;

                    address.ShowDialog();

             }

 

             private void button5_Click(object sender, EventArgs e)

             {

                    if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)

                    {

                           pictureBox1.Image = new Bitmap(openFileDialog1.FileName);

                    }

             }

 

             private void button3_Click(object sender, EventArgs e)

             {

                    //등록하기

                    //1. 아이디 검사 종료되면.. textBoxID.Text값이 존재 0

                    if (this.textBoxID.Text == string.Empty)

                    {

                           MessageBox.Show("아이디 중복검사를 하세요!!");

                           //종료 - 메서드를 종료

                           return;

                    }

 

                    //2. 이름 : 한글 2~5자이내

                    if (this.textBoxName.Text.Length < 2 || this.textBoxName.TextLength > 5)

                    {

                           MessageBox.Show("이름은 2~5자 이내");

                           this.textBoxName.Focus();

                           return;

                    }

 

                    //2.1 이름 : 한글

                    for (int i = 0; i < this.textBoxName.TextLength; i++)

                    {

                           char c = this.textBoxName.Text[i];

                           if (c < '' || c > '')

                           {

                                 MessageBox.Show("이름은 반드시 한글로");

                                 this.textBoxName.Focus();

                                 return;

                           }

                    }

 

                    //3. 비밀번호

                    if (this.textBoxPwd.TextLength < 4 || this.textBoxPwd.TextLength > 12)

                    {

                           MessageBox.Show("비밀번호는 4~12자 이내");

                           this.textBoxPwd.Focus();

                           return;

                    }

 

                    if (this.textBoxPwdCfm.TextLength < 4 || this.textBoxPwdCfm.TextLength > 12)

                    {

                           MessageBox.Show("비밀번호확인은 4~12자 이내");

                           this.textBoxPwd.Focus();

                           return;

                    }

 

                    if (this.textBoxPwd.Text != this.textBoxPwdCfm.Text)

                    {

                           MessageBox.Show("비밀번호값을 다시 확인 하세요");

                           this.textBoxPwd.Focus();

                           return;

                    }

 

                    //직업 - 선택하세요(기본값) 이외의 선택 필수

                    if (comboBoxJob.SelectedIndex == 0)

                    {

                           MessageBox.Show("직업을 선택하세요");

                           this.comboBoxJob.Focus();

                           return;

                    }

 

                    //사진 첨부?

                    if (pictureBox1.Image == null)

                    {

                           MessageBox.Show("사진을 첨부하셔야 됩니다.");

                           return;

                    }

 

 

 

                    //이곳까지 도착하면..회원가입 처리!!

                    MessageBox.Show("회원가입 성공!!");

             }

 

             private void textBoxJumin1_KeyUp(object sender, KeyEventArgs e)

             {

                    //앞자리 6자리 중 마지막 숫자를 입력할 떄

                    if (this.textBoxJumin1.Text.Length == 6)

                    {

                           //1. 뒷자리 텍스트박스로 포커스

                           this.textBoxJumin2.Focus();

 

                           //2. 생년, ,

                           this.textBoxYear.Text = "19" + this.textBoxJumin1.Text.Substring(0, 2);

                           this.textBoxMonth.Text = this.textBoxJumin1.Text.Substring(2, 2);

                           this.textBoxDay.Text = this.textBoxJumin1.Text.Substring(4, 2);

                    }

             }

 

             private void textBoxJumin2_KeyUp(object sender, KeyEventArgs e)

             {

                    //뒷자리 중 첫번쨰 숫자를 입력했을때..

                    if (textBoxJumin2.Text.Length == 1)

                    {

                           int num = int.Parse(textBoxJumin2.Text);

 

                           if (num % 2 == 1)

                                 radioButtonM.Checked = true;

                           else

                                 radioButtonF.Checked = true;

                    }

                   

             }

       }

}

 

 

반응형