Exemplo n.º 1
0
        // Get 1 schedule theo MaDatPhong
        public dsOrderPhong get1Schedule(int MaDatPhong)
        {
            string sql = "Select * From datphong Where MaDatPhong=@MaDatPhong";

            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);

            cmd.Parameters.AddWithValue("MaDatPhong", MaDatPhong);
            SqlDataReader reader     = cmd.ExecuteReader();
            dsOrderPhong  dsDatPhong = null;

            if (reader.Read())
            {
                dsDatPhong            = new dsOrderPhong();
                dsDatPhong.MaDatPhong = (int)reader["MaDatPhong"];
                dsDatPhong.HoTen      = (string)reader["HoTen"];
                dsDatPhong.SDT        = (string)reader["sdt"];

                dsDatPhong.MaPhong     = (int)reader["MaPhong"];
                dsDatPhong.thoigianvao = (DateTime)reader["thoigianvao"];
                dsDatPhong.thoigianra  = (DateTime)reader["thoigianra"];
            }
            conn.Close();
            return(dsDatPhong);
        }
Exemplo n.º 2
0
        // Get ra danh sách đặt phòng đã đi vs MaDatPhong=0
        public List <dsOrderPhong> getdatphong1()
        {
            string sql = "Select * From datphong, phong where datphong.MaPhong=phong.MaPhong and datphong.TrangThai=1 ORDER BY MaDatPhong DESC";

            conn.Open();
            SqlCommand          cmd    = new SqlCommand(sql, conn);
            SqlDataReader       reader = cmd.ExecuteReader();
            List <dsOrderPhong> li     = new List <dsOrderPhong>();

            while (reader.Read())
            {
                dsOrderPhong schedule = new dsOrderPhong();
                schedule.MaDatPhong = (int)reader["MaDatPhong"];
                schedule.HoTen      = (string)reader["HoTen"];
                schedule.SDT        = (string)reader["sdt"];

                schedule.MaPhong     = (int)reader["MaPhong"];
                schedule.TenPhong    = (string)reader["TenPhong"];
                schedule.thoigianvao = (DateTime)reader["thoigianvao"];
                schedule.thoigianra  = (DateTime)reader["thoigianra"];
                schedule.TrangThai   = (Boolean)reader["TrangThai"];

                li.Add(schedule);
            }
            conn.Close();
            return(li);
        }
Exemplo n.º 3
0
        protected void btn_BookRoom_Click(object sender, EventArgs e)
        {
            dsOrderPhong orderPhong = new dsOrderPhong();

            orderPhong.HoTen       = txtFullname.Text;
            orderPhong.SDT         = txtPhone.Text;
            orderPhong.thoigianvao = DateTime.Parse(txtTimeStart.Text);
            orderPhong.thoigianra  = DateTime.Parse(txtTimeEnd.Text);
            orderPhong.MaPhong     = int.Parse(DDL_Phong.SelectedValue);
            DateTime DateIn  = (orderPhong.thoigianvao);
            DateTime DateOut = (orderPhong.thoigianra);
            TimeSpan tmp     = DateOut.Subtract(DateIn);
            double   soGio   = tmp.TotalMinutes;

            if (DateTime.Parse(txtTimeStart.Text) > DateTime.Parse(txtTimeEnd.Text))
            {
                err_msg.ForeColor = System.Drawing.Color.Aqua;
                err_msg.Text      = "Khoảng thời gian không hợp lệ";
            }
            else
            {
                try
                {
                    var MaPhong = int.Parse(DDL_Phong.SelectedValue);
                    if (datPhong.checkPhong(MaPhong))
                    {
                        err_msg.Text = "Phòng này đã có người đặt";
                    }
                    else
                    {
                        // Thêm đặt phòng
                        Int32 MaDatPhong = datPhong.ThemDatPhong(orderPhong);

                        // Cập nhật trạng thái phòng = 1
                        datPhong.phongdaSuDung(orderPhong.MaPhong);

                        datPhong.taoHoaDon(MaDatPhong, soGio);

                        err_msg.ForeColor = System.Drawing.Color.Aqua;
                        err_msg.Text      = "Bạn đã đặt phòng thành công!";
                    }
                }
                catch (Exception ex)
                {
                    err_msg.ForeColor = System.Drawing.Color.Red;
                    err_msg.Text      = "Đã xảy ra lỗi: " + ex.Message;
                }
            }
        }
Exemplo n.º 4
0
        // Update schedule
        public void updateSchedule(dsOrderPhong dsDatPhong)
        {
            string sql = "Update datphong Set HoTen=@HoTen, sdt=@sdt, MaPhong=@MaPhong, thoigianvao=@thoigianvao, thoigianra=@thoigianra Where MaDatPhong=@MaDatPhong";

            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);

            cmd.Parameters.AddWithValue("MaDatPhong", dsDatPhong.MaDatPhong);
            cmd.Parameters.AddWithValue("HoTen", dsDatPhong.HoTen);
            cmd.Parameters.AddWithValue("sdt", dsDatPhong.SDT);
            cmd.Parameters.AddWithValue("MaPhong", dsDatPhong.MaPhong);
            cmd.Parameters.AddWithValue("thoigianvao", dsDatPhong.thoigianvao);
            cmd.Parameters.AddWithValue("thoigianra", dsDatPhong.thoigianra);
            cmd.ExecuteNonQuery();
            conn.Close();
        }
Exemplo n.º 5
0
        // Khách hàng Thêm 1 đặt phòng
        public int ThemDatPhong(dsOrderPhong dsDatPhong)
        {
            string sql = "Insert into DatPhong(Hoten,sdt,thoigianvao,thoigianra,maphong) output INSERTED.MaDatPhong values (@hoten,@sdt,@timeIn,@timeOut,@maphong)";

            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);

            cmd.Parameters.AddWithValue("@hoten", dsDatPhong.HoTen);
            cmd.Parameters.AddWithValue("@sdt", dsDatPhong.SDT);
            cmd.Parameters.AddWithValue("@timeIn", dsDatPhong.thoigianvao);
            cmd.Parameters.AddWithValue("@timeOut", dsDatPhong.thoigianra);
            cmd.Parameters.AddWithValue("@maphong", dsDatPhong.MaPhong);
            int MaDatPhong = Convert.ToInt32(cmd.ExecuteScalar());

            conn.Close();
            return(MaDatPhong);
        }