예제 #1
0
        public GiaPhong getPrice(string roomName)
        {
            ketnoi();
            GiaPhong g   = null;
            string   str = "SELECT tblPhong.LoaiPhong, GiaGioDau, Gia2GioDau,Gia3GioDau,GiaCacGioConLai,GiaQuaDem,GiaTheoNgay,PhuThu FROM tblPhong JOIN tblGia ON tblPhong.LoaiPhong = tblGia.LoaiPhong WHERE SoPhong=@SoPhong";

            cmd = new SqlCommand(str, conn);
            cmd.Parameters.AddWithValue("SoPhong", roomName);
            SqlDataReader r = cmd.ExecuteReader();

            if (r.Read())
            {
                g = new GiaPhong()
                {
                    LoaiPhong       = Convert.ToInt32(r["LoaiPhong"]),
                    GiaGioDau       = Convert.ToSingle(r["GiaGioDau"]),
                    Gia2GioDau      = Convert.ToSingle(r["Gia2GioDau"]),
                    Gia3GioDau      = Convert.ToSingle(r["Gia3GioDau"]),
                    GiaTheoNgay     = Convert.ToSingle(r["GiaTheoNgay"]),
                    GiaCacGioConLai = Convert.ToSingle(r["GiaCacGioConLai"]),
                    GiaQuaDem       = Convert.ToSingle(r["GiaQuaDem"]),
                    PhuThu          = Convert.ToSingle(r["PhuThu"])
                };
            }
            dongketnoi();
            return(g);
        }
예제 #2
0
파일: frmMain.cs 프로젝트: superhenrikey/PT
 private void btnCapNhatGia_Click(object sender, EventArgs e)
 {
     if (btnThayDoi.Text == "Thay đổi giá")
     {
         enableTxt(true);
         btnThayDoi.Text = "Hoàn thành";
         ActiveControl   = txtGiaGioDau;
     }
     else
     {
         GiaPhong gia = new GiaPhong()
         {
             LoaiPhong       = cbbLoaiPhong.SelectedIndex + 1,
             GiaGioDau       = Convert.ToSingle(txtGiaGioDau.Text),
             Gia2GioDau      = Convert.ToSingle(txtGia2GioDau.Text),
             Gia3GioDau      = Convert.ToSingle(txtGia3GioDau.Text),
             GiaCacGioConLai = Convert.ToSingle(txtGiaMoiGioTiepTheo.Text),
             GiaQuaDem       = Convert.ToSingle(txtGiaQuaDem.Text),
             GiaTheoNgay     = Convert.ToSingle(txtGiaTheoNgay.Text),
             PhuThu          = Convert.ToSingle(txtPhuThu.Text)
         };
         data.updatePrice(gia);
         btnThayDoi.Text = "Thay đổi giá";
         enableTxt(false);
         MessageBox.Show("Cập nhật giá thành công!");
     }
 }
예제 #3
0
        public GiaPhong getPriceType(int LoaiPhong)
        {
            ketnoi();
            GiaPhong g   = null;
            string   str = "SELECT * FROM tblGia WHERE LoaiPhong=@LoaiPhong";

            cmd = new SqlCommand(str, conn);
            cmd.Parameters.AddWithValue("LoaiPhong", LoaiPhong);
            SqlDataReader r = cmd.ExecuteReader();

            if (r.Read())
            {
                g = new GiaPhong()
                {
                    LoaiPhong       = Convert.ToInt32(r["LoaiPhong"]),
                    GiaGioDau       = Convert.ToSingle(r["GiaGioDau"]),
                    Gia2GioDau      = Convert.ToSingle(r["Gia2GioDau"]),
                    Gia3GioDau      = Convert.ToSingle(r["Gia3GioDau"]),
                    GiaTheoNgay     = Convert.ToSingle(r["GiaTheoNgay"]),
                    GiaCacGioConLai = Convert.ToSingle(r["GiaCacGioConLai"]),
                    GiaQuaDem       = Convert.ToSingle(r["GiaQuaDem"]),
                    PhuThu          = Convert.ToSingle(r["PhuThu"])
                };
            }
            dongketnoi();
            return(g);
        }
예제 #4
0
        public void updatePrice(GiaPhong g)
        {
            ketnoi();
            string query = "UPDATE tblGia SET GiaGioDau=@GiaGioDau,Gia2GioDau=@Gia2GioDau,Gia3GioDau=@Gia3GioDau,GiaCacGioConLai=@GiaCacGioConLai,GiaQuaDem=@GiaQuaDem,GiaTheoNgay=@GiaTheoNgay,PhuThu=@PhuThu WHERE LoaiPhong=@LoaiPhong";

            cmd = new SqlCommand(query, conn);
            cmd.Parameters.AddWithValue("GiaGioDau", g.GiaGioDau);
            cmd.Parameters.AddWithValue("Gia2GioDau", g.Gia2GioDau);
            cmd.Parameters.AddWithValue("Gia3GioDau", g.Gia3GioDau);
            cmd.Parameters.AddWithValue("GiaCacGioConLai", g.GiaCacGioConLai);
            cmd.Parameters.AddWithValue("GiaQuaDem", g.GiaQuaDem);
            cmd.Parameters.AddWithValue("GiaTheoNgay", g.GiaTheoNgay);
            cmd.Parameters.AddWithValue("PhuThu", g.PhuThu);
            cmd.Parameters.AddWithValue("LoaiPhong", g.LoaiPhong);
            cmd.ExecuteNonQuery();
            dongketnoi();
        }
예제 #5
0
파일: frmMain.cs 프로젝트: superhenrikey/PT
 private void cbbLoaiPhong_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cbbLoaiPhong.SelectedIndex == 0)
     {
         g = data.getPriceType(1);
     }
     else
     {
         g = data.getPriceType(2);
     }
     if (g != null)
     {
         txtGiaGioDau.Text         = g.GiaGioDau.ToString();
         txtGia2GioDau.Text        = g.Gia2GioDau.ToString();
         txtGia3GioDau.Text        = g.Gia3GioDau.ToString();
         txtGiaMoiGioTiepTheo.Text = g.GiaCacGioConLai.ToString();
         txtGiaTheoNgay.Text       = g.GiaTheoNgay.ToString();
         txtGiaQuaDem.Text         = g.GiaQuaDem.ToString();
         txtPhuThu.Text            = g.PhuThu.ToString();
     }
 }
예제 #6
0
 private void FrmGiaPhong_Load(object sender, EventArgs e)
 {
     if (SoPhong != null)
     {
         GiaPhong g = data.getPrice(SoPhong);
         if (g.LoaiPhong == 1)
         {
             lblSoPhong.Text = "Phòng " + SoPhong + ", Phòng đơn";
         }
         if (g.LoaiPhong == 2)
         {
             lblSoPhong.Text = "Phòng " + SoPhong + ", Phòng đôi";
         }
         lblGioDau.Text         = "Giá giờ đầu: " + g.GiaGioDau + " VND";
         lbl2GioDau.Text        = "Giá 2 giờ đầu: " + g.Gia2GioDau + " VND";
         lbl3GioDau.Text        = "Giá 3 giờ đầu: " + g.Gia3GioDau + " VND";
         lblCacGioTiepTheo.Text = "Giá giờ tiếp theo: " + g.GiaCacGioConLai + " VND";
         lblGiaQuaDem.Text      = "Giá qua đêm: " + g.GiaQuaDem + " VND";
         lblGiaTheoNgay.Text    = "Giá theo ngày: " + g.GiaTheoNgay + " VND";
         lblPhuThu.Text         = "Phụ thu: " + g.PhuThu + " VND";
     }
 }
예제 #7
0
        private void calcNumDay()
        {
            GiaPhong g           = data.getPrice(h.SoPhong);
            DateTime dateIn      = DateTime.Parse(h.NgayVao);
            DateTime dateOut     = DateTime.Parse(h.NgayRa);
            DateTime currentDate = DateTime.Now;

            switch (h.DonVi)
            {
            case "Ngày":
                if ((Convert.ToInt32(parseTime(currentDate)[3]) <= 12 && currentDate.CompareTo(dateIn) < 0) || currentDate.CompareTo(dateIn) < 0)
                {
                    lblThoiGianThue.Text = h.ThoiGianThue + " ngày";
                }
                else
                {
                    h.ThoiGianThue       = h.ThoiGianThue + 1;
                    lblThoiGianThue.Text = h.ThoiGianThue + " ngày";
                }
                lblTienPhong.Text     = (g.GiaTheoNgay * h.ThoiGianThue).ToString();
                c.TienPhong           = (g.GiaTheoNgay * h.ThoiGianThue + h.PhuThu);
                lblTongTienPhong.Text = c.TienPhong.ToString();
                lblPhuThu.Text        = h.PhuThu.ToString();
                break;

            case "Giờ":
                int y = Convert.ToInt32(parseTime(currentDate)[3]) - Convert.ToInt32(parseTime(dateOut)[3]);
                if (y == 0 && Convert.ToInt32(parseTime(currentDate)[3]) > 30)
                {
                    h.ThoiGianThue = h.ThoiGianThue + 1;
                }
                if (y > 0)
                {
                    h.ThoiGianThue = h.ThoiGianThue + y;
                }

                if (h.ThoiGianThue == 1)
                {
                    lblThoiGianThue.Text  = "1 giờ";
                    lblTienPhong.Text     = g.GiaGioDau.ToString();
                    c.TienPhong           = g.GiaGioDau;
                    lblTongTienPhong.Text = c.TienPhong.ToString();
                }
                else if (h.ThoiGianThue == 2)
                {
                    lblThoiGianThue.Text  = "2 giờ";
                    lblTienPhong.Text     = g.Gia2GioDau.ToString();
                    c.TienPhong           = g.Gia2GioDau;
                    lblTongTienPhong.Text = c.TienPhong.ToString();
                }
                else if (h.ThoiGianThue == 3)
                {
                    lblThoiGianThue.Text  = "3 giờ";
                    lblTienPhong.Text     = g.Gia3GioDau.ToString();
                    c.TienPhong           = g.Gia3GioDau;
                    lblTongTienPhong.Text = c.TienPhong.ToString();
                }
                else if (h.ThoiGianThue <= 8)
                {
                    lblThoiGianThue.Text  = h.ThoiGianThue.ToString();
                    lblTienPhong.Text     = (g.Gia3GioDau + (h.ThoiGianThue - 3) * g.GiaCacGioConLai).ToString();
                    c.TienPhong           = g.Gia3GioDau + (h.ThoiGianThue - 3) * g.GiaCacGioConLai;
                    lblTongTienPhong.Text = c.TienPhong.ToString();
                }
                else
                {
                    lblThoiGianThue.Text  = "1 ngày";
                    lblTienPhong.Text     = g.GiaTheoNgay.ToString();
                    c.TienPhong           = g.GiaTheoNgay;
                    lblTongTienPhong.Text = g.GiaTheoNgay.ToString();
                    h.ThoiGianThue        = 1;
                    h.DonVi = "Ngày";
                }
                break;

            case "Đêm":
                int z = Convert.ToInt32(parseTime(currentDate)[3]) - 12;
                if (Convert.ToInt32(parseTime(currentDate)[2]) == Convert.ToInt32(parseTime(dateOut)[2]) && z >= 0)
                {
                    h.PhuThu              = h.PhuThu + g.PhuThu + z * g.PhuThu;
                    lblPhuThu.Text        = h.PhuThu.ToString();
                    lblThoiGianThue.Text  = "1 đêm";
                    lblTienPhong.Text     = g.GiaQuaDem.ToString();
                    lblTongTienPhong.Text = (h.PhuThu + g.GiaQuaDem).ToString();
                    c.TienPhong           = h.PhuThu + g.GiaQuaDem;
                }
                else
                {
                    lblPhuThu.Text        = h.PhuThu.ToString();
                    lblThoiGianThue.Text  = "1 đêm";
                    lblTienPhong.Text     = g.GiaQuaDem.ToString();
                    lblTongTienPhong.Text = (h.PhuThu + g.GiaQuaDem).ToString();
                    c.TienPhong           = h.PhuThu + g.GiaQuaDem;
                }
                break;
            }
        }