private void addButton_Click(object sender, EventArgs e) { if (nameBox.Text == "" || genderBox.Text == "" || ageBox.Text == "" || phoneBox.Text == "" || salaryBox.Text == "") { MessageBox.Show("Please give all information"); return; } string name = nameBox.Text; string gender = genderBox.Text; string age = ageBox.Text; string roomNo; if (roomComboBox.Items.Count == 0) { roomNo = ""; } else { roomNo = roomComboBox.SelectedItem.ToString(); } string phone = phoneBox.Text; string salary = salaryBox.Text; staffDTO st = new staffDTO(name, gender, age, roomNo, phone, salary); staffDAO sD = new staffDAO(); sD.createStaff(st); clearFields(); }
private void roomDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { bool blank = false; if (roomDataGridView.Rows[e.RowIndex].Cells[0].Value.ToString() == "") { blank = true; } if (roomDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString() == "") { blank = true; } if (roomDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString() == "") { blank = true; } if (roomDataGridView.Rows[e.RowIndex].Cells[3].Value.ToString() == "") { blank = true; } if (blank) { loadRoomsInfo(); return; } string roomNo = roomDataGridView.Rows[e.RowIndex].Cells[0].Value.ToString(); int price = Convert.ToInt32(roomDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString()); string roomType = roomDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString(); int staffId = Convert.ToInt32(roomDataGridView.Rows[e.RowIndex].Cells[3].Value.ToString()); DataSet ds = new DataSet(); roomDAO rD = new roomDAO(); staffDAO sD = new staffDAO(); ds = sD.getStaffs(); bool flag = false; foreach (DataRow row in ds.Tables[0].Rows) { int sI = Convert.ToInt32(row["staffId"].ToString()); if (staffId == sI) { flag = true; break; } } if (flag == false) { loadRoomsInfo(); return; } r = new roomDTO(roomNo, price, roomType, staffId); rD.updateRoom(r); loadRoomsInfo(); }
public addRoomInformationForm() { InitializeComponent(); staffDAO sD = new staffDAO(); DataSet ds = sD.getStaffs(); foreach (DataRow row in ds.Tables[0].Rows) { int staffId = Convert.ToInt32(row["staffId"].ToString()); string name = row["name"].ToString(); staffComboBox.Items.Add(staffId + "," + name); } if (staffComboBox.Items.Count > 0) { staffComboBox.SelectedIndex = 0; } }