예제 #1
0
        private void btnThanhToan_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(DTRent.getAllWhere("PHIEUTHUE", "MaPhieuThue = " + txtMaPhieuThue.Text.ToString()).Rows[0]["NgayKetThuc"].ToString()))
                {
                    DTRent.update("NgayKetThuc = '" + DateTime.ParseExact(dtNgayTra.Text, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture).ToString("yyyy-MM-dd HH:mm:ss") + "'", "MaPhieuThue = " + txtMaPhieuThue.Text.ToString());
                }
                loadHoaDon();

                DTBill.update("TinhTrang = 2", "MaHoaDon = " + txtSoBill.Text);
                Phong.update("PHONG", "TinhTrangPhong = -1", "MaPhong = " + txtSoPhong.Tag.ToString());
                DTRent.update("TinhTrangPhieuThue = 2", "MaPhieuThue = " + txtMaPhieuThue.Text.ToString());
                //load lại danh sách phòng
                dt = QLThuePhong.getAll();
                galleryControl1.Gallery.Groups[0].Items.Clear();
                Bitmap image;

                foreach (DataRow dr in dt.Rows)
                {
                    int tinhTrang = Int32.Parse(dr["TinhTrangPhong"].ToString());
                    if (tinhTrang == 1)
                    {
                        image = new Bitmap(Properties.Resources.close);
                    }
                    else if (tinhTrang == 0)
                    {
                        image = new Bitmap(Properties.Resources.checkInRom);
                    }
                    else
                    {
                        image = new Bitmap(Properties.Resources.open);
                    }

                    GalleryItem item = new GalleryItem(image, dr["TenPhong"].ToString(), dr["MoTaPhong"].ToString() == "" ? "Ghi Chú" : dr["MoTaPhong"].ToString());
                    item.Tag = dr["MaPhong"].ToString() + "_" + dr["TinhTrangPhong"].ToString().Trim();
                    galleryControl1.Gallery.Groups[0].Items.Add(item);
                }
                MessageBox.Show("Thanh Toán Thành Công!");
            }
            catch (Exception)
            {
                MessageBox.Show("Lỗi Trong Quá trình thanh toán");
                throw;
            }
        }
예제 #2
0
        public static int update(string[] _set, string _where)
        {
            string _value = "";

            for (int i = 0; i < _set.Length; i++)
            {
                if (String.IsNullOrWhiteSpace(_set[i]))
                {
                    return(i);
                }
            }
            _value += @"TenPhieuThue=N'" + _set[0] + "',";
            _value += @"TinhTrangPhieuThue=N'" + _set[1] + "',";
            _value += @"MaPhong=N'" + _set[2] + "',";
            _value += @"NgayLap='" + _set[3] + "',";
            _value += @"NgayBatDau='" + _set[4] + "',";
            _value += @"NgayKetThuc='" + _set[5] + "',";
            _value += @"MaKH='" + _set[6] + "'";

            DTRent.update("PHIEUTHUE", _value, _where);
            return(-1);
        }