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(); }
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; } } }
public void Delete(HumanResource hr, SqlConnection connection) { Delete button = new Delete(hr, connection); button.Execute(); }
public void Register(HumanResource hr, SqlConnection connection) { Update button = new Update(hr, connection); button.Execute(); }
public IsExistEmployee(Form1 form, HumanResource hr) { this.form = form; this.hr = hr; }
public void Delete(HumanResource hr, SqlConnection connection) { return; }
public void Register(HumanResource hr, SqlConnection connection) { Insert button = new Insert(hr, connection); button.Execute(); }
public void Register(HumanResource hr, SqlConnection connection) { return; }
internal Update(HumanResource hr, SqlConnection connection) { this.hr = hr; this.connection = connection; }
internal Insert(HumanResource hr, SqlConnection connection) { this.hr = hr; this.connection = connection; }
internal Delete(string employeeNumber, SqlConnection connection) { this.hr = new HumanResource(employeeNumber, "", "", ""); this.connection = connection; }