Ejemplo n.º 1
0
        private void testDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            bool blank = false;

            if (testDataGridView.Rows[e.RowIndex].Cells[0].Value.ToString() == "")
            {
                blank = true;
            }
            if (testDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString() == "")
            {
                blank = true;
            }
            if (testDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString() == "")
            {
                blank = true;
            }
            if (testDataGridView.Rows[e.RowIndex].Cells[3].Value.ToString() == "")
            {
                blank = true;
            }

            if (blank)
            {
                loadTestsInfo();
                //MessageBox.Show("Error in here");
                return;
            }


            int    testId   = Convert.ToInt32(testDataGridView.Rows[e.RowIndex].Cells[0].Value.ToString());
            string name     = testDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString();
            string category = testDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString();
            string roomNo   = testDataGridView.Rows[e.RowIndex].Cells[3].Value.ToString();
            int    price    = Convert.ToInt32(testDataGridView.Rows[e.RowIndex].Cells[4].Value.ToString());

            DataSet ds = new DataSet();
            roomDAO rD = new roomDAO();

            ds = rD.getRooms();
            bool flag = false;

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                string rN = row["roomNo"].ToString();
                if (roomNo == rN)
                {
                    flag = true;
                    break;
                }
            }
            if (flag == false)
            {
                loadTestsInfo();
                //MessageBox.Show("went to middle");
                return;
            }


            t = new testDTO(testId, name, category, roomNo, price);
            tD.updateTest(t);
            loadTestsInfo();
            //MessageBox.Show("went to last");
        }