public static TinhTrangChuyen GetInfo(string HanhTrinh)
 {
     DataTable dt = ShipBookingData.FillDataTable("spTinhTrangChuyen_SelectByID", "@HanhTrinh", HanhTrinh);
     TinhTrangChuyen obj = new TinhTrangChuyen();
     if (dt.Rows.Count > 0)
     {
         obj.HanhTrinh = dt.Rows[0]["HanhTrinh"].ToString();
         obj.TinhTrang = dt.Rows[0]["TinhTrang"].ToString();
         obj.MaTPDi = dt.Rows[0]["MaTPDi"].ToString();
         obj.MaTPDen = dt.Rows[0]["MaTPDen"].ToString();
         obj.GiaVe1 = dt.Rows[0]["GiaVe1"].ToString();
         obj.GiaVe2 = dt.Rows[0]["GiaVe2"].ToString();
         obj.GiaVe3 = dt.Rows[0]["GiaVe3"].ToString();
         obj.GiaVe1_TreEm = dt.Rows[0]["GiaVe1_TreEm"].ToString();
         obj.GiaVe2_TreEm = dt.Rows[0]["GiaVe2_TreEm"].ToString();
         obj.GiaVe3_TreEm = dt.Rows[0]["GiaVe3_TreEm"].ToString();
         obj.MaSoTau = dt.Rows[0]["MaSoTau"].ToString();
         obj.SoLuongVe1 = dt.Rows[0]["SoLuongVe1"].ToString();
         obj.SoLuongVe2 = dt.Rows[0]["SoLuongVe2"].ToString();
         obj.SoLuongVe3 = dt.Rows[0]["SoLuongVe3"].ToString();
         obj.GioKhoiHanh_Thu2 = DateTime.Parse(dt.Rows[0]["GioKhoiHanh_Thu2"].ToString());
         obj.GioKhoiHanh_Thu3 = DateTime.Parse(dt.Rows[0]["GioKhoiHanh_Thu3"].ToString());
         obj.GioKhoiHanh_Thu4 = DateTime.Parse(dt.Rows[0]["GioKhoiHanh_Thu4"].ToString());
         obj.GioKhoiHanh_Thu5 = DateTime.Parse(dt.Rows[0]["GioKhoiHanh_Thu5"].ToString());
         obj.GioKhoiHanh_Thu6 = DateTime.Parse(dt.Rows[0]["GioKhoiHanh_Thu6"].ToString());
         obj.GioKhoiHanh_Thu7 = DateTime.Parse(dt.Rows[0]["GioKhoiHanh_Thu7"].ToString());
         obj.GioKhoiHanh_ChuNhat = DateTime.Parse(dt.Rows[0]["GioKhoiHanh_ChuNhat"].ToString());
         obj.GioDen_Thu2 = DateTime.Parse(dt.Rows[0]["GioDen_Thu2"].ToString());
         obj.GioDen_Thu3 = DateTime.Parse(dt.Rows[0]["GioDen_Thu3"].ToString());
         obj.GioDen_Thu4 = DateTime.Parse(dt.Rows[0]["GioDen_Thu4"].ToString());
         obj.GioDen_Thu5 = DateTime.Parse(dt.Rows[0]["GioDen_Thu5"].ToString());
         obj.GioDen_Thu6 = DateTime.Parse(dt.Rows[0]["GioDen_Thu6"].ToString());
         obj.GioDen_Thu7 = DateTime.Parse(dt.Rows[0]["GioDen_Thu7"].ToString());
         obj.GioDen_ChuNhat = DateTime.Parse(dt.Rows[0]["GioDen_ChuNhat"].ToString());
         obj.SoGhe = dt.Rows[0]["SoGhe"].ToString();
     }
     else
     {
         obj = null;
     }
     return obj;
 }
        protected void GetBookingData()
        {
            bf.LoaiChuyen = rblLoaiHanhTrinh.SelectedItem.Text;
            if (ddlNoiDen.Items.Count > 0)
            {
                bf.NoiDi = ddlNoiDi.SelectedItem.Text;
            }
            else
            {
                return;
            }
            if (ddlNoiDi.Items.Count > 0)
            {
                bf.NoiDen = ddlNoiDen.SelectedItem.Text;
            }
            else
            {
                return;
            }
            bf.NgayDi = DateTime.Parse(txtNgayDi.Text.Trim());
            if (rblLoaiHanhTrinh.SelectedValue == "KhuHoi")
            {
                if (CheckDateNgayVe() == true)
                {
                    bf.NgayVe = DateTime.Parse(txtNgayVe.Text.Trim());
                }
                else
                {
                    return;
                }
            }
            else
            {
                bf.NgayVe = DateTime.Parse(txtNgayDi.Text.Trim());
            }

            bf.ThoiGian = ddlThoiGian.SelectedItem.Text;
            if (chkOpen.Checked == true)
            {
                bf.OpenChecking = true;
            }
            else
            {
                bf.OpenChecking = false;
            }
            bf.LoaiVe = ddlLoaiVe.SelectedItem.Text;
            if (rdbSoGhe.SelectedItem != null)
            {
                bf.SoGhe = rdbSoGhe.SelectedItem.Text;
            }
            else
            {
                bf.SoGhe = "";
            }

            string strHanhTrinh = GetHanhTrinh();

            TinhTrangChuyen obj = new TinhTrangChuyen();
            obj = TinhTrangChuyenDB.GetInfo(strHanhTrinh);

            if (ddlLoaiVe.SelectedValue == "HangThuong")
            {
                bf.GiaTien = obj.GiaVe1;
            }
            else if (ddlLoaiVe.SelectedValue == "HangDoanhNhan")
            {
                bf.GiaTien = obj.GiaVe2;
            }
            else
            {
                bf.GiaTien = obj.GiaVe3;
            }

            bf.HanhTrinh = strHanhTrinh;
        }
        protected void FillHanhTrinhInfoData()
        {
            ListItem item;
            string strHanhTrinh = GetHanhTrinh();

            TinhTrangChuyen HanhTrinhInfo = new TinhTrangChuyen();
            HanhTrinhInfo = TinhTrangChuyenDB.GetInfo(strHanhTrinh);

            List<BookingFile> BFList = new List<BookingFile>();
            BFList = BookingFileDB.GetListBookingFileByDate(txtNgayDi.Text.Trim(), strHanhTrinh);

            if (HanhTrinhInfo != null)
            {
                #region  Điền dữ liệu giờ khởi hành - giờ kết thúc
                if (CheckDateNgayDi() == true)
                {
                    DateTime dt = DateTime.Parse(txtNgayDi.Text.Trim());
                    switch (dt.DayOfWeek)
                    {
                        case DayOfWeek.Monday:
                            {
                                if (HanhTrinhInfo.GioKhoiHanh_Thu2 == DateTime.Parse("1/1/1900 12:00:00 AM"))
                                {
                                    lblGioKhoiHanh.Text = "";
                                    ResetRdbSoGhe();
                                }
                                else
                                {
                                    lblGioKhoiHanh.Text = HanhTrinhInfo.GioKhoiHanh_Thu2.ToShortTimeString();
                                }

                                if (HanhTrinhInfo.GioDen_Thu2 == DateTime.Parse("1/1/1900 12:00:00 AM"))
                                {
                                    lblGioDen.Text = "";
                                    ResetRdbSoGhe();
                                    return;
                                }
                                else
                                {
                                    lblGioDen.Text = HanhTrinhInfo.GioDen_Thu2.ToShortTimeString();
                                }
                            }
                            break;
                        case DayOfWeek.Tuesday:
                            {
                                if (HanhTrinhInfo.GioKhoiHanh_Thu3 == DateTime.Parse("1/1/1900 12:00:00 AM"))
                                {
                                    lblGioKhoiHanh.Text = "";
                                    ResetRdbSoGhe();
                                }
                                else
                                {
                                    lblGioKhoiHanh.Text = HanhTrinhInfo.GioKhoiHanh_Thu3.ToShortTimeString();
                                }

                                if (HanhTrinhInfo.GioDen_Thu3 == DateTime.Parse("1/1/1900 12:00:00 AM"))
                                {
                                    lblGioDen.Text = "";
                                    ResetRdbSoGhe();
                                    return;
                                }
                                else
                                {
                                    lblGioDen.Text = HanhTrinhInfo.GioDen_Thu3.ToShortTimeString();
                                }
                            }
                            break;
                        case DayOfWeek.Wednesday:
                            {
                                if (HanhTrinhInfo.GioKhoiHanh_Thu4 == DateTime.Parse("1/1/1900 12:00:00 AM"))
                                {
                                    lblGioKhoiHanh.Text = "";
                                    ResetRdbSoGhe();
                                }
                                else
                                {
                                    lblGioKhoiHanh.Text = HanhTrinhInfo.GioKhoiHanh_Thu4.ToShortTimeString();
                                }

                                if (HanhTrinhInfo.GioDen_Thu4 == DateTime.Parse("1/1/1900 12:00:00 AM"))
                                {
                                    lblGioDen.Text = "";
                                    ResetRdbSoGhe();
                                    return;
                                }
                                else
                                {
                                    lblGioDen.Text = HanhTrinhInfo.GioDen_Thu4.ToShortTimeString();
                                }
                            }
                            break;
                        case DayOfWeek.Thursday:
                            {
                                if (HanhTrinhInfo.GioKhoiHanh_Thu5 == DateTime.Parse("1/1/1900 12:00:00 AM"))
                                {
                                    lblGioKhoiHanh.Text = "";
                                    ResetRdbSoGhe();
                                }
                                else
                                {
                                    lblGioKhoiHanh.Text = HanhTrinhInfo.GioKhoiHanh_Thu5.ToShortTimeString();
                                }

                                if (HanhTrinhInfo.GioDen_Thu5 == DateTime.Parse("1/1/1900 12:00:00 AM"))
                                {
                                    lblGioDen.Text = "";
                                    ResetRdbSoGhe();
                                    return;
                                }
                                else
                                {
                                    lblGioDen.Text = HanhTrinhInfo.GioDen_Thu5.ToShortTimeString();
                                }
                            }
                            break;
                        case DayOfWeek.Friday:
                            {
                                if (HanhTrinhInfo.GioKhoiHanh_Thu6 == DateTime.Parse("1/1/1900 12:00:00 AM"))
                                {
                                    lblGioKhoiHanh.Text = "";
                                    ResetRdbSoGhe();
                                }
                                else
                                {
                                    lblGioKhoiHanh.Text = HanhTrinhInfo.GioKhoiHanh_Thu6.ToShortTimeString();
                                }

                                if (HanhTrinhInfo.GioDen_Thu6 == DateTime.Parse("1/1/1900 12:00:00 AM"))
                                {
                                    lblGioDen.Text = "";
                                    ResetRdbSoGhe();
                                    return;
                                }
                                else
                                {
                                    lblGioDen.Text = HanhTrinhInfo.GioDen_Thu6.ToShortTimeString();
                                }
                            }
                            break;
                        case DayOfWeek.Saturday:
                            {
                                if (HanhTrinhInfo.GioKhoiHanh_Thu7 == DateTime.Parse("1/1/1900 12:00:00 AM"))
                                {
                                    lblGioKhoiHanh.Text = "";
                                    ResetRdbSoGhe();
                                }
                                else
                                {
                                    lblGioKhoiHanh.Text = HanhTrinhInfo.GioKhoiHanh_Thu7.ToShortTimeString();
                                }

                                if (HanhTrinhInfo.GioDen_Thu7 == DateTime.Parse("1/1/1900 12:00:00 AM"))
                                {
                                    lblGioDen.Text = "";
                                    ResetRdbSoGhe();
                                    return;
                                }
                                else
                                {
                                    lblGioDen.Text = HanhTrinhInfo.GioDen_Thu7.ToShortTimeString();
                                }
                            }
                            break;
                        case DayOfWeek.Sunday:
                            {
                                if (HanhTrinhInfo.GioKhoiHanh_ChuNhat == DateTime.Parse("1/1/1900 12:00:00 AM"))
                                {
                                    lblGioKhoiHanh.Text = "";
                                    ResetRdbSoGhe();
                                }
                                else
                                {
                                    lblGioKhoiHanh.Text = HanhTrinhInfo.GioKhoiHanh_ChuNhat.ToShortTimeString();
                                }

                                if (HanhTrinhInfo.GioDen_ChuNhat == DateTime.Parse("1/1/1900 12:00:00 AM"))
                                {
                                    lblGioDen.Text = "";
                                    ResetRdbSoGhe();
                                    return;
                                }
                                else
                                {
                                    lblGioDen.Text = HanhTrinhInfo.GioDen_ChuNhat.ToShortTimeString();
                                }
                            }
                            break;
                        default:
                            break;
                    }
                }
                else
                {
                    ResetRdbSoGhe();
                    lblGioKhoiHanh.Text = "";
                    lblGioDen.Text = "";
                    return;
                }
                #endregion

                #region Điền dữ liệu số lượng vé
                switch (ddlLoaiVe.SelectedValue)
                {
                    case "HangThuong":
                        {
                            int count = 0;
                            int SoLuongVeConLai = 0;
                            lblGiaVe.Text = HanhTrinhInfo.GiaVe1.Trim() + " VNĐ";
                            for (int i = 0; i < BFList.Count; i++)
                            {
                                if (BFList[i].LoaiVe.Equals("Hạng thường") == true)
                                {
                                    count += 1;
                                }
                            }
                            SoLuongVeConLai = Convert.ToInt16(HanhTrinhInfo.SoLuongVe1);
                            SoLuongVeConLai -= count;
                            if (SoLuongVeConLai > 0)
                            {
                                lblSoLuongVe.Text = Convert.ToString(SoLuongVeConLai) + " vé";
                                lblSoLuongVe.ForeColor = Color.Blue;
                            }
                            else
                            {
                                lblSoLuongVe.Text = "Đã hết vé";
                                lblSoLuongVe.ForeColor = Color.Red;
                                return;
                            }
                        }
                        break;
                    case "HangDoanhNhan":
                        {
                            int count = 0;
                            int SoLuongVeConLai = 0;
                            lblGiaVe.Text = HanhTrinhInfo.GiaVe2.Trim() + " VNĐ";
                            for (int i = 0; i < BFList.Count; i++)
                            {
                                if (BFList[i].LoaiVe.Equals("Hạng doanh nhân") == true)
                                {
                                    count += 1;
                                }
                            }
                            SoLuongVeConLai = Convert.ToInt16(HanhTrinhInfo.SoLuongVe2);
                            SoLuongVeConLai -= count;
                            if (SoLuongVeConLai > 0)
                            {
                                lblSoLuongVe.Text = Convert.ToString(SoLuongVeConLai) + " vé";
                                lblSoLuongVe.ForeColor = Color.Blue;
                            }
                            else
                            {
                                lblSoLuongVe.Text = "Đã hết vé";
                                lblSoLuongVe.ForeColor = Color.Red;
                                return;
                            }
                        }
                        break;
                    case "HangVIP":
                        {
                            int count = 0;
                            int SoLuongVeConLai = 0;
                            lblGiaVe.Text = HanhTrinhInfo.GiaVe3.Trim() + " VNĐ";
                            for (int i = 0; i < BFList.Count; i++)
                            {
                                if (BFList[i].LoaiVe.Equals("Hạng VIP") == true)
                                {
                                    count += 1;
                                }
                            }
                            SoLuongVeConLai = Convert.ToInt16(HanhTrinhInfo.SoLuongVe3);
                            SoLuongVeConLai -= count;
                            if (SoLuongVeConLai > 0)
                            {
                                lblSoLuongVe.Text = Convert.ToString(SoLuongVeConLai) + " vé";
                                lblSoLuongVe.ForeColor = Color.Blue;
                            }
                            else
                            {
                                lblSoLuongVe.Text = "Đã hết vé";
                                lblSoLuongVe.ForeColor = Color.Red;
                                return;
                            }
                        }
                        break;
                    default:
                        break;
                }
                #endregion

                #region Điền tất cả các ghế trên chuyến tàu
                int SoGhe = 0;
                SoGhe = Convert.ToInt16(HanhTrinhInfo.SoGhe.Trim());
                for (int i = 1; i <= SoGhe; i++)
                {
                    item = new ListItem();
                    item.Text = Convert.ToString(i);
                    item.Value = Convert.ToString(i);
                    rdbSoGhe.Items.Add(item);
                    item = null;
                }

                //Remove những ghế đã được chọn trong ngày
                int SoGheDaDat = 0;
                for (int i = 1; i <= SoGhe; i++)
                {
                    item = new ListItem();
                    item.Text = Convert.ToString(i);
                    item.Value = Convert.ToString(i);

                    for (int j = 0; j < BFList.Count; j++)
                    {
                        SoGheDaDat = Convert.ToInt16(BFList[j].SoGhe.Trim());
                        if (i == SoGheDaDat)
                        {
                            rdbSoGhe.Items.Remove(item);
                        }
                    }
                    item = null;
                }
                #endregion
            }

            lblMsg.Text = "";
        }
 public static void Update(TinhTrangChuyen obj)
 {
     string[] parameters = new string[] { "@HanhTrinh", "@TinhTrang", "@MaTPDi", "@MaTPDen", "@GiaVe1", "@GiaVe2", "@GiaVe3", "@GiaVe1_TreEm", "@GiaVe2_TreEm", "@GiaVe3_TreEm", "@MaSoTau", "@SoLuongVe1", "@SoLuongVe2", "@SoLuongVe3", "@GioKhoiHanh_Thu2", "@GioKhoiHanh_Thu3", "@GioKhoiHanh_Thu4", "@GioKhoiHanh_Thu5", "@GioKhoiHanh_Thu6", "@GioKhoiHanh_Thu7", "@GioKhoiHanh_ChuNhat", "@GioDen_Thu2", "@GioDen_Thu3", "@GioDen_Thu4", "@GioDen_Thu5", "@GioDen_Thu6", "@GioDen_Thu7", "@GioDen_ChuNhat", "@SoGhe" };
     string[] values = new string[] { obj.HanhTrinh, obj.TinhTrang, obj.MaTPDi, obj.MaTPDen, obj.GiaVe1, obj.GiaVe2, obj.GiaVe3, obj.GiaVe1_TreEm, obj.GiaVe2_TreEm, obj.GiaVe3_TreEm, obj.MaSoTau, obj.SoLuongVe1, obj.SoLuongVe2, obj.SoLuongVe3, obj.GioKhoiHanh_Thu2.ToString(), obj.GioKhoiHanh_Thu3.ToString(), obj.GioKhoiHanh_Thu4.ToString(), obj.GioKhoiHanh_Thu5.ToString(), obj.GioKhoiHanh_Thu6.ToString(), obj.GioKhoiHanh_Thu7.ToString(), obj.GioKhoiHanh_ChuNhat.ToString(), obj.GioDen_Thu2.ToString(), obj.GioDen_Thu3.ToString(), obj.GioDen_Thu4.ToString(), obj.GioDen_Thu5.ToString(), obj.GioDen_Thu6.ToString(), obj.GioDen_Thu7.ToString(), obj.GioDen_ChuNhat.ToString(), obj.SoGhe };
     ExecuteData("spTinhTrangChuyen_UpdateByID", parameters, values);
 }