Exemplo n.º 1
0
        public void deleteTest(testDTO t)
        {
            s.sqlConnection.Open();
            string query = "delete from tests where testId = '" + t.TestId + "'";

            s.sqlCommand = new SqlCommand(query, s.sqlConnection);
            s.sqlCommand.ExecuteNonQuery();
            s.sqlConnection.Close();
        }
Exemplo n.º 2
0
        private void testDataGridView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
        {
            int    testId   = Convert.ToInt32(testDataGridView.Rows[e.Row.Index].Cells[0].Value.ToString());
            string name     = testDataGridView.Rows[e.Row.Index].Cells[1].Value.ToString();
            string category = testDataGridView.Rows[e.Row.Index].Cells[2].Value.ToString();
            string roomNo   = testDataGridView.Rows[e.Row.Index].Cells[3].Value.ToString();
            int    price    = Convert.ToInt32(testDataGridView.Rows[e.Row.Index].Cells[4].Value.ToString());

            t = new testDTO(testId, name, category, roomNo, price);
        }
Exemplo n.º 3
0
        public void createTest(testDTO t)
        {
            s.sqlConnection.Open();
            string query = "insert into tests values('" + t.Name + "','"
                           + t.Category + "','"
                           + t.RoomNo + "','"
                           + t.Price + "')";

            s.sqlCommand = new SqlCommand(query, s.sqlConnection);
            s.sqlCommand.ExecuteNonQuery();
            s.sqlConnection.Close();
        }
Exemplo n.º 4
0
        public void updateTest(testDTO t)
        {
            s.sqlConnection.Open();
            string query = "update tests set name = '"
                           + t.Name + "', category = '"
                           + t.Category + "', roomNo = '"
                           + t.RoomNo + "', price = '"
                           + t.Price + "' where testId = '"
                           + t.TestId + "' ";

            s.sqlCommand = new SqlCommand(query, s.sqlConnection);
            s.sqlCommand.ExecuteNonQuery();
            s.sqlConnection.Close();
        }
        private void addButton_Click(object sender, EventArgs e)
        {
            if (testNameBox.Text == "" || testCategoryBox.Text == "" || testPriceBox.Text == "" || roomComboBox.Items.Count == 0)
            {
                MessageBox.Show("Please give all information");
                return;
            }

            string  name     = testNameBox.Text;
            string  category = testCategoryBox.Text;
            string  roomNo   = roomComboBox.SelectedItem.ToString();
            int     price    = Convert.ToInt32(testPriceBox.Text);
            testDTO t        = new testDTO(name, category, roomNo, price);
            testDAO tD       = new testDAO();

            tD.createTest(t);
            clearFields();
        }
Exemplo n.º 6
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            if (testDataGridView.SelectedRows.Count == 0)
            {
                MessageBox.Show("Select a row from table");
                return;
            }

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

            t = new testDTO(testId, name, category, roomNo, price);
            tD.deleteTest(t);
            loadTestsInfo();
        }
Exemplo n.º 7
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");
        }