예제 #1
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 += @"HoTen=N'" + _set[0] + "',";
            _value += @"SoCMND=N'" + _set[1] + "',";
            _value += @"NgayVaoLam=convert(date, '" + _set[2] + "',105),";
            _value += @"NgaySinh=convert(date, '" + _set[3] + "',105),";
            _value += @"email='" + _set[4] + "'";
            _value += @"SoDienThoai='" + _set[5] + "'";
            _value += @"Username='******'";
            _value += @"PassWord='******'";
            _value += @"LoaiTaiKhoan='" + _set[8] + "'";
            _value += @"GioiTinh='" + _set[9] + "'";
            _value += @"Deleted='" + _set[10] + "'";
            _value += @"Active='" + _set[11] + "'";
            DTBill.update(_value, _where);
            return(-1);
        }
예제 #2
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;
            }
        }
예제 #3
0
        public static int update(string[] _set, string _where)
        {
            string _value = "";

            //"NgayLap", "TongGia", "NhanVien", "Phong", "MaPhieuThue"
            for (int i = 0; i < _set.Length; i++)
            {
                if (String.IsNullOrWhiteSpace(_set[i]))
                {
                    return(i);
                }
            }
            _value += @"NgayLap=N'" + _set[0] + "',";
            _value += @"TongGia=N'" + _set[1] + "',";
            _value += @"NhanVien=N'" + _set[2] + "',";
            _value += @"Phong='" + _set[3] + "',";
            _value += @"MaPhieuThue='" + _set[4] + "'";


            DTBill.update(_value, _where);
            return(-1);
        }
예제 #4
0
        private void btnThemDV_Click(object sender, EventArgs e)
        {
            string maDV = txtDichVuSelect.Text;

            if (String.IsNullOrEmpty(maDV))
            {
                MessageBox.Show("Bạn phải chọn 1 dịch vụ khi thêm!");
            }
            else
            {
                string[] values = { txtSoBill.Text, maDV, DateTime.Now.ToString("yyyy-MM-dd"), txtSoPhong.Tag.ToString() };
                if (DTBillDetail.create(values))
                {
                    //
                    //DataRow dr = new DataRow(txtSoBill.Text, maDV, DateTime.Now.ToString("yyyy-MM-dd"), txtSoPhong.Tag.ToString());
                    DataTable dtCTHD = DTBillDetail.getAllWhere("CHITIETHOADON", "MAHD = " + txtSoBill.Text + " AND Phong = " + txtSoPhong.Tag.ToString());
                    if (dtCTHD.Rows.Count != 0)
                    {
                        string[] arrayDV = new string[dtCTHD.Rows.Count];
                        for (int i = 0; i < dtCTHD.Rows.Count; i++)
                        {
                            arrayDV[i] = dtCTHD.Rows[i]["MaDichVu"].ToString();
                        }
                        dtDVSD = DTService.getAllWhere("DICHVU", "MaDichVu in (" + String.Join(",", arrayDV) + ")");
                        DataColumn[] keysDVSD = new DataColumn[1];
                        keysDVSD[0]       = dtDVSD.Columns[0];
                        dtDVSD.PrimaryKey = keysDVSD;
                        gridControlDVSuDung.DataSource = dtDVSD;

                        decimal giaDVselected = 0;
                        foreach (DataRow item in dtDVSD.Rows)
                        {
                            if (item["MaDichVu"].ToString() == maDV)
                            {
                                giaDVselected = Decimal.Parse(item["Gia"].ToString());
                            }
                        }

                        DataTable dtHD = DTBill.getAllWhere("HOADON", "MaHoaDon = " + dtCTHD.Rows[0]["MaHD"].ToString());

                        if (DTBill.update("TongGia = " + (Decimal.Parse(dtHD.Rows[0]["TongGia"].ToString()) + giaDVselected), "MaHoaDon = " + dtCTHD.Rows[0]["MaHD"].ToString()))
                        {
                            //HD
                            loadHoaDon();
                        }
                        else
                        {
                            MessageBox.Show("Lỗi Khi cập nhật hóa đơn!");
                        }
                    }
                    else
                    {
                        dtDVSD = new DataTable();
                        gridControlDVSuDung.DataSource = dtDVSD;
                    }
                }
                else
                {
                    MessageBox.Show("Lỗi không thêm được dịch vụ!");
                }
            }
        }