/////// Sửa thành viên public bool suaGia(GiaTourDTO l) { try { _conn.Open(); string SQL = string.Format("UPDATE GIATOUR SET GIATIEN = {0} WHERE MAGIA = '{1}'", l.GiaTien1, l.MaGia1); SqlCommand cmd = new SqlCommand(SQL, _conn); if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception e) { Console.WriteLine(e.Message); } finally { // Dong ket noi _conn.Close(); } return(false); }
private void button2_Click(object sender, EventArgs e) { if (txtMagia.Text != "" && txtGia.Text != "") { GiaTourDTO dto = new GiaTourDTO(txtMagia.Text, txtMatour.Text, float.Parse(txtGia.Text), txtBd.Text, txtKt.Text); if (bus1.suaGia(dto)) { MessageBox.Show("Sửa thành công"); dataGridView1.DataSource = bus.XemGiaTheoTour(txtMatour.Text); } else { MessageBox.Show("Sửa thất bại"); } } txtMatour.Text = ""; txtMagia.Text = ""; }
private void btnAdd_Click(object sender, EventArgs e) { if (cbbMaTour.GetItemText(cbbMaTour.SelectedItem) != "" && txtBD.Text != "" && txtMa.Text != "" && txtGia.Text != "" && txtKT.Text != "") { String maTour = cbbMaTour.GetItemText(cbbMaTour.SelectedItem); GiaTourDTO DTO = new GiaTourDTO(txtMa.Text, maTour, float.Parse(txtGia.Text), txtBD.Text, txtKT.Text); if (bus.themGia(DTO)) { MessageBox.Show("Thêm thành công"); BangGia.DataSource = bus.getGiaTour(); } else { MessageBox.Show("Thêm ko thành công"); } } else { MessageBox.Show("Xin hãy nhập đầy đủ"); } }
public bool themGia(GiaTourDTO t) { try { _conn.Open(); string SQL = string.Format("INSERT INTO GIATOUR(MAGIA, GIATIEN, TGBD, TGKT, MATOUR) VALUES ('{0}', {1}, '{2}', '{3}', '{4}')", t.MaGia1, t.GiaTien1, t.TGBD1, t.TGKT1, t.MaTour1); SqlCommand cmd = new SqlCommand(SQL, _conn); if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception e) { Console.WriteLine(e.Message); } finally { _conn.Close(); } return(false); }
public bool suaGia(GiaTourDTO l) { return(dal.suaGia(l)); }
public bool themGia(GiaTourDTO l) { return(dal.themGia(l)); }