Exemplo n.º 1
0
        public bool ThemChu(bool HoSoChinhThuc, string MaHoSo, string DanhXung, string HoTen, string NamSinh, string DiaChi, string DinhDanh, string SoDinhDanh, string NoiCap, string NgayCap, string QuocTich)
        {
            try
            {
                if (HoSoChinhThuc)
                {
                    tblChu chumoi = new tblChu();

                    chumoi.DanhXung = DanhXung;
                    chumoi.HoTen = HoTen;
                    chumoi.NamSinh = NamSinh;
                    chumoi.DiaChi = DiaChi;
                    chumoi.DinhDanh = DinhDanh;
                    chumoi.SoDinhDanh = SoDinhDanh;
                    chumoi.NoiCap = NoiCap;
                    chumoi.NgayCap = Convert.ToDateTime(NgayCap);
                    chumoi.QuocTich = QuocTich;

                    db.tblChus.Add(chumoi);
                    db.SaveChanges();

                    tblChuDangKyBienDong chuhoso = new tblChuDangKyBienDong();
                    chuhoso.MaChu = chumoi.MaChu;
                    chuhoso.MaDangKyBienDong = Convert.ToInt32(MaHoSo);
                    db.tblChuDangKyBienDongs.Add(chuhoso);
                    db.SaveChanges();
                }
                else
                {
                    tblChuDuBi chumoi = new tblChuDuBi();
                    chumoi.DanhXung = DanhXung;
                    chumoi.HoTen = HoTen;
                    chumoi.NamSinh = NamSinh;
                    chumoi.DiaChi = DiaChi;
                    chumoi.DinhDanh = DinhDanh;
                    chumoi.SoDinhDanh = SoDinhDanh;
                    chumoi.NoiCap = NoiCap;
                    if(NgayCap!="")
                    chumoi.NgayCap = Convert.ToDateTime(NgayCap);
                    chumoi.QuocTich = QuocTich;
                    db.tblChuDuBis.Add(chumoi);
                    db.SaveChanges();

                    tblChuDangKyBienDongDuBi chuhoso = new tblChuDangKyBienDongDuBi();
                    chuhoso.MaChu = chumoi.MaChu;
                    chuhoso.MaDangKyBienDong = Convert.ToInt32(MaHoSo);
                    db.tblChuDangKyBienDongDuBis.Add(chuhoso);
                    db.SaveChanges();

                }

                return true;
            }
            catch (Exception ex)
            {

                return false;
            }
        }
Exemplo n.º 2
0
        public bool ThemChu(bool HoSoChinhThuc, string MaHoSo, string Machu)
        {
            try
            {
                long _maDangKyBienDong = long.Parse(MaHoSo);
                long _maChu = long.Parse(Machu);
                if (HoSoChinhThuc)
                {
                    tblChu chu = db.tblChus.SingleOrDefault(n => n.MaChu == _maChu);
                    if(chu != null)
                    {
                        tblChuDangKyBienDong chuhoso = new tblChuDangKyBienDong();
                        chuhoso.MaChu = _maChu;
                        chuhoso.MaDangKyBienDong = _maDangKyBienDong;
                        db.tblChuDangKyBienDongs.Add(chuhoso);
                        db.SaveChanges();
                    }
                }
                else
                {
                    tblChuDuBi chu = db.tblChuDuBis.SingleOrDefault(n => n.MaChu == _maChu);
                    if (chu != null)
                    {
                        tblChuDangKyBienDongDuBi chuhoso = new tblChuDangKyBienDongDuBi();
                        chuhoso.MaChu = _maChu;
                        chuhoso.MaDangKyBienDong = _maDangKyBienDong;
                        db.tblChuDangKyBienDongDuBis.Add(chuhoso);
                        db.SaveChanges();
                    }
                }
                return true;
            }
            catch (Exception)
            {

                return false;
            }
        }