Exemplo n.º 1
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (idphongconguoi == 0)
            {
                MessageBox.Show("Bạn chưa chọn phòng");
                return;
            }

            try
            {
                datphong.capNhatTrangThaiPhong(idphongconguoi, "Trống");
                loadPhongCoNguoi();
                loadPhongTrong();
                giora = DateTime.Now;
                int      idhoadon     = datphong.layIDHoaDon(idphongconguoi);
                string   str          = datphong.layGioVaoTheoHD(idhoadon);
                DateTime timevao      = DateTime.Parse(str);
                TimeSpan timeofdayvao = timevao.TimeOfDay;

                DateTime timera      = DateTime.Now;
                TimeSpan timeofdayra = timera.TimeOfDay;


                int hourvao = timeofdayvao.Hours;
                int hourra  = timeofdayra.Hours;
                int minvao  = timevao.Minute;
                int minra   = timera.Minute;

                int hour = 0;
                int min  = 0;
                if (minra >= minvao)
                {
                    hour = hourra - hourvao;
                    min  = minra - minvao;
                }
                else
                {
                    hour = hourra - hourvao - 1;
                    min  = 60 - minvao + minra;
                }
                float  giaphong  = datphong.layGiaPhong(idphongconguoi);
                double tienphong = 0;
                tienphong = Math.Round((giaphong / 60.0) * (hour * 60 + min), 0);
                double tongtien = tienphong + float.Parse(txtTienDV.Text.ToString());
                datphong.capNhatHoaDon(idhoadon, giora, hour + " giờ " + min + " phút", float.Parse(tienphong.ToString()), float.Parse(tongtien.ToString()));
                MessageBox.Show("Thanh toán thành công");
                loadCTHD(0);
                loadCboPhongTrong();
                frm_HoaDon frm = new frm_HoaDon(idhoadon);
                frm.Show();
            }
            catch
            {
                MessageBox.Show("Bạn chưa chọn phòng");
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            int idhoadon = datphong.layIDHoaDon(idphongconguoi);
            //string str = datphong.layGioVaoTheoHD(idhoadon);
            //DateTime timevao = DateTime.Parse(str);
            //TimeSpan timeofdayvao = timevao.TimeOfDay;

            //DateTime timera = DateTime.Now;
            //TimeSpan timeofdayra = timera.TimeOfDay;


            //int hourvao = timeofdayvao.Hours;
            //int hourra = timeofdayra.Hours;
            //int minvao = timevao.Minute;
            //int minra = timera.Minute;

            //int hour=0;
            //int min=0;
            //if(minra>=minvao)
            //{
            //    hour = hourra - hourvao;
            //    min = minra - minvao;

            //}
            //else
            //{
            //    hour = hourra - hourvao - 1;
            //    min = 60 - minvao + minra;
            //}
            //float giaphong = datphong.layGiaPhong(idphongconguoi);
            //double tienphong = 0;
            //tienphong =Math.Round( (giaphong / 60.0) * (hour * 60 + min),0);
            //double tongtien = tienphong + float.Parse(txtTienDV.Text.ToString());
            //MessageBox.Show(tongtien+"");
            frm_HoaDon frm = new frm_HoaDon(idhoadon);

            frm.Show();
        }