public Form1(SqlConnection connection) { InitializeComponent(); this.connection = connection; this.state = new Default(this); }
public void ChangeState(IModeState newState) { if (state != null) { state.ExitState(this); } state = newState; state.EnterState(this); }
private void buttonRegister_Click(object sender, EventArgs e) { HumanResource hr = GetHumanResource(); if (null == hr) { return; } //社員がいたら更新 state.Register(hr, connection); state = new Default(this); state.EnableControl(); }
private void buttonDelete_Click(object sender, EventArgs e) { //削除時に不正チェックをする必要はない。 //HumanResource hr = GetHumanResource(); //if (null == hr) return; HumanResource hr = new HumanResource(this.textBox社員番号.Text, "", "", ""); var yesno = MessageBox.Show("削除してよろしいですか", "削除確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (yesno != DialogResult.Yes) { return; } state.Delete(hr, connection); state = new Default(this); state.EnableControl(); }
void Start() { buttonGoNext.onClick.AddListener(() => { state.GoNext(this); }); buttonDumpName.onClick.AddListener(() => { state.DumpName(this); }); buttonSpecialA.onClick.AddListener(() => { state.SpecialA(this); }); buttonSpecialB.onClick.AddListener(() => { state.SpecialB(this); }); state = ModeA.Instance; ChangeState(ModeB.Instance); ChangeState(ModeA.Instance); }
private void SearchEmployee(string employeeNumber) { StringBuilder sb = new StringBuilder(); sb.Append(@"select * from HumanResource where ""社員番号"" = '").Append(employeeNumber).Append(@"'"); using (var command = new SqlCommand() { Connection = connection, CommandText = sb.ToString() }) using (var reader = command.ExecuteReader()) { try { // SQLの実行 if (reader.Read()) { HumanResource hr = new HumanResource( reader["社員番号"].ToString(), reader["氏名"].ToString(), reader["入社日"].ToString(), reader["退職日"].ToString() ); state = new IsExistEmployee(this, hr); } else { state = new NotExistEmployee(this); } state.EnableControl(); } catch (SqlException ex) { throw; } } }