Example #1
0
        private void BtnThemPhieu_Click(object sender, EventArgs e)
        {
            int flag = 0;

            if (dataGridView2.RowCount <= 1)
            {
                MessageBox.Show("Không thể thêm chi tiết");
            }
            else
            {
                for (int i = 0; i < dataGridView2.RowCount - 1; i++)
                {
                    try
                    {
                        string        madd   = dataGridView2.Rows[i].Cells[0].Value.ToString();
                        int           thutu  = i + 1;
                        string        matour = txtMaTour.Text;
                        TourDetailDTO dto    = new TourDetailDTO(matour, madd, thutu);
                        if (bus1.ThemCTtour(dto))
                        {
                            flag = 1;
                        }
                        else
                        {
                            flag = 0;
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Đã xảy ra lỗi");
                    }
                }
            }
            if (flag == 1)
            {
                MessageBox.Show("Thêm thành công chi tiết tour");
            }
            else
            {
                MessageBox.Show("Thêm chi tiết tour thất bại");
            }
        }
Example #2
0
        public bool themCTTour(TourDetailDTO t)
        {
            try
            {
                _conn.Open();
                string     SQL = string.Format("INSERT INTO CTTOUR(MATOUR, MADD, THUTU) VALUES ('{0}', '{1}', '{2}')", t.MaTour1, t.MaDiaDiem1, t.thutu1);
                SqlCommand cmd = new SqlCommand(SQL, _conn);
                Console.WriteLine(SQL);
                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                _conn.Close();
            }

            return(false);
        }
Example #3
0
 public bool ThemCTtour(TourDetailDTO dto)
 {
     return(dal.themCTTour(dto));
 }