Exemple #1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (BangLoaiTour.SelectedRows.Count > 0)
            {
                if (txtMa.Text != "" && txtTen.Text != "")
                {
                    if (ValadateTen(txtTen.Text))
                    {
                        MessageBox.Show("Tên tác giả tại sao lại chứa kí tự lạ hả!!!", "Thông báo");
                        txtTen.Text = "";
                        txtTen.Focus();
                    }
                    else
                    if (ValadateTen(txtMa.Text))
                    {
                        MessageBox.Show("Mã đọc giả tại sao lại chứa kí tự lạ hả!!!", "Thông báo");
                        txtMa.Text = "";
                        txtMa.Focus();
                    }
                    else
                    {
                        DataGridViewRow row = BangLoaiTour.SelectedRows[0];
                        string          ma  = row.Cells[0].Value.ToString();

                        LoaiTourDTO sDTO = new LoaiTourDTO(ma, txtTen.Text);

                        // Sửa
                        if (bus.suaLoai(sDTO))
                        {
                            MessageBox.Show("Sửa thành công");
                            BangLoaiTour.DataSource = bus.getLoaiTour(); // refresh datagridview
                        }
                        else
                        {
                            MessageBox.Show("Sửa ko thành công");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Xin hãy nhập đầy đủ");
                }
            }
            else
            {
                MessageBox.Show("Hãy chọn tác giả muốn sửa");
            }
        }
Exemple #2
0
        /// Thêm thành viên

        public bool themLoai(LoaiTourDTO l)
        {
            try
            {
                _conn.Open();
                string     SQL = string.Format("INSERT INTO LOAITOUR(MALOAI, TENLOAI) VALUES ('{0}', '{1}')", l.MaLoai1, l.TenLoai1);
                SqlCommand cmd = new SqlCommand(SQL, _conn);
                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
            }
            finally
            {
                _conn.Close();
            }

            return(false);
        }
Exemple #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtMa.Text != "" && txtTen.Text != "")
            {
                // Tạo DTo
                LoaiTourDTO dto = new LoaiTourDTO(txtMa.Text, txtTen.Text);

                // Them
                if (bus.themLoai(dto))
                {
                    MessageBox.Show("Thêm thành công");
                    BangLoaiTour.DataSource = bus.getLoaiTour(); // refresh datagridview
                }
                else
                {
                    MessageBox.Show("Thêm ko thành công");
                }
            }
            else
            {
                MessageBox.Show("Xin hãy nhập đầy đủ");
            }
        }
Exemple #4
0
        /////// Sửa thành viên

        public bool suaLoia(LoaiTourDTO l)
        {
            try
            {
                _conn.Open();
                string     SQL = string.Format("UPDATE LOAITOUR SET TENLOAI = '{0}' WHERE MALOAI = '{1}'", l.TenLoai1, l.MaLoai1);
                SqlCommand cmd = new SqlCommand(SQL, _conn);

                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
            }
            finally
            {
                // Dong ket noi
                _conn.Close();
            }

            return(false);
        }
Exemple #5
0
 public bool suaLoai(LoaiTourDTO l)
 {
     return(dal.suaLoia(l));
 }
Exemple #6
0
 public bool themLoai(LoaiTourDTO l)
 {
     return(dal.themLoai(l));
 }