public bool ThemNhaO(string MaHoSo, string LoaiNhaO, string DienTichXayDung, string DienTichSan, string KetCau, string SoTang, string SoHuuChung, string SoHuuRieng, string CoHanChe, string HanChe)
        {
            try
            {
                bool _cohanche = false;
                if (CoHanChe.ToLower() == "true")
                    _cohanche = true;
                else
                    _cohanche = false;

                tblThongTinNhaO nhaNew = new tblThongTinNhaO();
                nhaNew.MaHoSo = Convert.ToInt32(MaHoSo);
                nhaNew.LoaiNhaO = LoaiNhaO;
                nhaNew.DienTichXayDung = DienTichXayDung;
                nhaNew.DienTichSan = DienTichSan;
                nhaNew.KetCau = KetCau;
                nhaNew.SoTang = SoTang;
                nhaNew.SoHuuChung = SoHuuChung;
                nhaNew.SoHuuRieng = SoHuuRieng;
                nhaNew.CoHanCheThoiHanSoHuu = _cohanche;
                nhaNew.ThoiHanSoHuu = HanChe;

                db.tblThongTinNhaOs.Add(nhaNew);
                db.SaveChanges();

                return true;
            }
            catch (Exception ex)
            {

                return false;
            }
        }
        public bool ChapNhanHoSo(string MaHoSoKeKhai)
        {
            try
            {
                long _maHS = long.Parse(MaHoSoKeKhai);
                tblHoSoKeKhaiDuBi HS = db.tblHoSoKeKhaiDuBis.Single(h => h.MaHoSoKeKhai == _maHS);

                //-- tao ho so moi
                tblHoSo HoSoMoi = new tblHoSo();
                db.tblHoSoes.Add(HoSoMoi);

                //-- them vao bang ho so

                tblHoSoKeKhai HSKK = new tblHoSoKeKhai();
                HSKK.KinhGuiCoQuanChucNang = HS.KinhGuiCoQuanChucNang;
                HSKK.NgayNhanHoSo = HS.NgayNhanHoSo;
                HSKK.NguoiNhanHoSo = HS.NguoiNhanHoSo;
                HSKK.SoTiepNhan = HS.SoTiepNhan;
                HSKK.Quyen = HS.Quyen;
                HSKK.NguoiVietDon = HS.NguoiVietDon;
                HSKK.DonViHanhChinh = HS.DonViHanhChinh;
                HSKK.GiayToKemTheo = HS.GiayToKemTheo;
                HSKK.NghiaVuTaiChinh = HS.NghiaVuTaiChinh;
                HSKK.DeNghiKhac = HS.DeNghiKhac;
                HSKK.SoDienThoaiLienHe = HS.SoDienThoaiLienHe;
                HSKK.DiaChiMail = HS.DiaChiMail;
                HSKK.MaLoaiDeNghi = HS.MaLoaiDeNghi;

                HSKK.MaHoSo =_maHS;
                db.tblHoSoKeKhais.Add(HSKK);

                //-- insert vao bang hosokekhaiduocchapnhan

                tblHoSoKeKhaiDuocChapNhan HSKKDCN = new tblHoSoKeKhaiDuocChapNhan();
                HSKKDCN.MaHoSoKeKhai = HSKK.MaHoSoKeKhai;
                HSKKDCN.MaHoSoKeKhaiDuBi = HS.MaHoSoKeKhai;
                HSKKDCN.NgayThucHien = DateTime.Today;

                db.tblHoSoKeKhaiDuocChapNhans.Add(HSKKDCN);

                //-- insert vao bang hoso

                HoSoMoi.LoaiDoiTuong = HS.MaLoaiDoiTuong;
                HoSoMoi.DonViHanhChinh = HS.DonViHanhChinh;
                HoSoMoi.TrangThaiHoSoCapGCN = "1";
                //HoSoMoi.TongSoThua se cap nhat o phan thua dat...

                //-- insert vao bang thuadat
                List<tblThuaDatDuBi> dsThuaDat = (from td in db.tblThuaDatDuBis
                                                  where td.MaHoSoKeKhai == HS.MaHoSoKeKhai
                                                  select td).ToList<tblThuaDatDuBi>();

                if (dsThuaDat.Count > 0)
                {
                    HoSoMoi.TongSoThua = dsThuaDat.Count;
                    for (int i = 0; i < dsThuaDat.Count; i++)
                    {
                        tblThuaDat ThuaDaMoi = new tblThuaDat();

                        ThuaDaMoi.MaHoSo = dsThuaDat[i].MaHoSoKeKhai;
                        ThuaDaMoi.ToBanDo = dsThuaDat[i].ToBanDo;
                        ThuaDaMoi.SoThua = dsThuaDat[i].SoThua;
                        ThuaDaMoi.DiaChi = dsThuaDat[i].DiaChi;
                        ThuaDaMoi.DienTich = dsThuaDat[i].DienTich;
                        ThuaDaMoi.SuDungChung = dsThuaDat[i].SuDungChung;
                        ThuaDaMoi.SuDungRieng = dsThuaDat[i].SuDungRieng;
                        ThuaDaMoi.MucDichSuDung = dsThuaDat[i].MucDichSuDung;
                        ThuaDaMoi.ThoiHanSuDung = dsThuaDat[i].ThoiHanSuDung;
                        ThuaDaMoi.NgayBatDauSuDung = dsThuaDat[i].NgayBatDauSuDung;
                        ThuaDaMoi.LoaiNguonGocSuDung = dsThuaDat[i].LoaiNguonGocSuDung;
                        ThuaDaMoi.CoHanCheSuDung = dsThuaDat[i].CoHanCheSuDung.ToString();
                        ThuaDaMoi.NoiDungHanCheSuDung = dsThuaDat[i].NoiDungHanCheSuDung;

                        db.tblThuaDats.Add(ThuaDaMoi);

                    }
                }
                //-- insert vao bang nhao
                List<tblThongTinNhaODuBi> dsNhaO = (from n in db.tblThongTinNhaODuBis
                                                    where n.MaHoSoKeKhai == _maHS
                                                    select n).ToList<tblThongTinNhaODuBi>();
                if (dsNhaO.Count > 0)
                {
                    for (int i = 0; i < dsNhaO.Count; i++)
                    {
                        tblThongTinNhaO NhaMoi = new tblThongTinNhaO();
                        NhaMoi.MaHoSo = dsNhaO[i].MaHoSoKeKhai;
                        NhaMoi.LoaiNhaO = dsNhaO[i].LoaiNhaO;
                        NhaMoi.DienTichXayDung = dsNhaO[i].DienTichXayDung;
                        NhaMoi.DienTichSan = dsNhaO[i].DienTichSan;
                        NhaMoi.SoHuuChung = dsNhaO[i].SoHuuChung;
                        NhaMoi.SoHuuRieng = dsNhaO[i].SoHuuRieng;
                        NhaMoi.KetCau = dsNhaO[i].KetCau;
                        NhaMoi.SoTang = dsNhaO[i].SoTang;
                        NhaMoi.CoHanCheThoiHanSoHuu = dsNhaO[i].CoHanCheThoiHanSoHuu;
                        NhaMoi.ThoiHanSoHuu = dsNhaO[i].ThoiHanSoHuu;

                        db.tblThongTinNhaOs.Add(NhaMoi);

                    }
                }
                //-- insert vao bang chuhoso va bang chu
                List<tblChuHoSoDuBi> dsChuHS = (from chs in db.tblChuHoSoDuBis
                                                where chs.MaHoSoKeKhai == _maHS
                                                select chs).ToList<tblChuHoSoDuBi>();

                if (dsChuHS.Count > 0)
                {
                    for (int i = 0; i < dsChuHS.Count; i++)
                    {
                        tblChuHoSo ChuHS = new tblChuHoSo();
                        ChuHS.MaChu = dsChuHS[i].MaChu;
                        ChuHS.MaHoSo = _maHS;

                        db.tblChuHoSoes.Add(ChuHS);

                        long ma =(long)dsChuHS[i].MaChu;
                        tblChuDuBi chudubi = db.tblChuDuBis.Single(c => c.MaChu == ma);
                        tblChu Chu = new tblChu();
                        Chu.DanhXung = chudubi.DanhXung;
                        Chu.HoTen = chudubi.HoTen;
                        Chu.NamSinh = chudubi.NamSinh;
                        Chu.DiaChi = chudubi.DiaChi;
                        Chu.DinhDanh = chudubi.DinhDanh;
                        Chu.SoDinhDanh = chudubi.SoDinhDanh;
                        Chu.NoiCap = chudubi.NoiCap;
                        Chu.NgayCap = chudubi.NgayCap;
                        Chu.QuocTich = chudubi.QuocTich;

                        db.tblChus.Add(Chu);
                    }
                }

                //LƯU LẠI LẦN 1
                db.SaveChanges();

                return true;
            }
            catch (Exception ex)
            {

                return false;
            }
        }