示例#1
0
        private void addPhieuDatCho(PhieuDatCho m)
        {
            try
            {
                if (!isInputValid())
                {
                    return;
                }

                bool kq = phieuDatChoDB.add(m);
                if (kq)
                {
                    ClearInput();
                    MessageBox.Show("Them thanh cong");
                }
                else
                {
                    MessageBox.Show("Them ko thanh cong");
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Khong the thuc hien duoc: " + e.Message);
            }
        }
示例#2
0
        public bool update(PhieuDatCho c)
        {
            String sql = "update PhieuDatCho set maChuyenDi = @maChuyenDi, maHanhKhach = @maHanhKhach, giaTien = @giaTien, ngayDat = @ngayDat where maPhieuDatCho = @maPhieuDatCho";

            SqlParameter p1 = new SqlParameter("@maPhieuDatCho", c.MaPhieuDatCho);
            SqlParameter p2 = new SqlParameter("@maChuyenDi", c.MaChuyenDi);
            SqlParameter p3 = new SqlParameter("@maHanhKhach", c.MaHanhKhach);
            SqlParameter p4 = new SqlParameter("@giaTien", c.GiaTien);
            SqlParameter p5 = new SqlParameter("@ngayDat", c.NgayDat);

            SqlParameter[] param = { p1, p2, p3, p4, p5 };

            return(manager.executeUpdate(sql, param));
        }
示例#3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (lblSoGheTrong.Text == "0")
            {
                MessageBox.Show("Đã hết vé! Không thể thêm");
                return;
            }

            string   maPhieuDatCho = txtMaPhieuDatCho.Text.Trim();
            string   maChuyenDi    = cbbMaChuyenDi.Text.Trim();
            string   maHanhKhach   = cbbMaHanhKhach.Text.Trim();
            decimal  giaTien       = Convert.ToDecimal(txtGiaTien.Text.Trim());
            DateTime ngayDat       = dtpNgayDat.Value;

            PhieuDatCho m = new PhieuDatCho(maPhieuDatCho, maChuyenDi, maHanhKhach, giaTien, ngayDat);

            addPhieuDatCho(m);
        }
示例#4
0
        public bool add(PhieuDatCho c)
        {
            try
            {
                String sql = "insert into PhieuDatCho values(@maPhieuDatCho, @maChuyenDi, @maHanhKhach, @giaTien, @ngayDat)";

                SqlParameter p1 = new SqlParameter("@maPhieuDatCho", c.MaPhieuDatCho);
                SqlParameter p2 = new SqlParameter("@maChuyenDi", c.MaChuyenDi);
                SqlParameter p3 = new SqlParameter("@maHanhKhach", c.MaHanhKhach);
                SqlParameter p4 = new SqlParameter("@giaTien", c.GiaTien);
                SqlParameter p5 = new SqlParameter("@ngayDat", c.NgayDat);

                SqlParameter[] param = { p1, p2, p3, p4, p5 };

                return(manager.executeUpdate(sql, param));
            }
            catch (Exception e)
            {
                return(false);
            }
        }
示例#5
0
        public List <PhieuDatCho> getAll()
        {
            String    sql   = "select * from PhieuDatCho";
            DataTable table = manager.executeQuery(sql);

            List <PhieuDatCho> list = new List <PhieuDatCho>();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                DataRow row = table.Rows[i];

                string   maPhieuDatCho = (string)row["maPhieuDatCho"];
                string   maChuyenDi    = (string)row["maChuyenDi"];
                string   maHanhKhach   = (string)row["maHanhKhach"];
                decimal  giaTien       = (decimal)row["giaTien"];
                DateTime ngayDat       = (DateTime)row["ngayDat"];

                PhieuDatCho c = new PhieuDatCho(maPhieuDatCho, maChuyenDi, maHanhKhach, giaTien, ngayDat);

                list.Add(c);
            }

            return(list);
        }