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();
        }
コード例 #2
0
        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;
            }
        }
 public void loadStaffsInfo()
 {
     staffDataGridView.DataSource = sD.getStaffs().Tables[0];
 }