Ejemplo n.º 1
0
        public static int AddOrUpdateBiTich(BiTich biTich)
        {
            int _idGiaoDan = 0;

            using (QLGIAOXU db = new QLGIAOXU())
            {
                BiTich tmp = db.BiTich.Where(u => u.IDGiaoDan == biTich.IDGiaoDan).FirstOrDefault();
                if (tmp != null)
                {
                    tmp.NgayRLLD     = biTich.NgayRLLD;
                    tmp.NgayRuaToi   = biTich.NgayRuaToi;
                    tmp.NgayThemSuc  = biTich.NgayThemSuc;
                    tmp.NguoiDoDauRT = biTich.NguoiDoDauRT;
                    tmp.NguoiDoDauTS = biTich.NguoiDoDauTS;
                    tmp.NguoiRuaToi  = biTich.NguoiRuaToi;
                    tmp.NguoiThemSuc = biTich.NguoiThemSuc;
                    tmp.SoRLLD       = biTich.SoRLLD;
                    tmp.SoRuaToi     = biTich.SoRuaToi;
                    tmp.SoThemSuc    = biTich.SoThemSuc;
                    tmp.NoiRLLD      = biTich.NoiRLLD;
                    tmp.NoiRuaToi    = biTich.NoiRuaToi;
                    tmp.NoiThemSuc   = biTich.NoiThemSuc;
                }
                else
                {
                    db.BiTich.Add(biTich);
                }
                int x = db.SaveChanges();
                if (x > 0)
                {
                    _idGiaoDan = x;
                }
            }
            return(_idGiaoDan);
        }
Ejemplo n.º 2
0
        public static BiTichEntity GetBiTich(int?idGiaoDan)
        {
            BiTich       _tmp    = null;
            BiTichEntity _bitich = new BiTichEntity();

            using (QLGIAOXU db = new QLGIAOXU())
            {
                if (idGiaoDan != 0)
                {
                    _tmp = (from u in db.BiTich where (u.IDGiaoDan == idGiaoDan) select u).FirstOrDefault();
                }
                if (_tmp != null)
                {
                    _bitich.NgayRLLD     = _tmp.NgayRLLD;
                    _bitich.NgayRuaToi   = _tmp.NgayRuaToi;
                    _bitich.NgayThemSuc  = _tmp.NgayThemSuc;
                    _bitich.NguoiDoDauRT = _tmp.NguoiDoDauRT;
                    _bitich.NguoiDoDauTS = _tmp.NguoiDoDauTS;
                    _bitich.NguoiRuaToi  = _tmp.NguoiRuaToi;
                    _bitich.NguoiThemSuc = _tmp.NguoiThemSuc;
                    _bitich.NoiRLLD      = _tmp.NoiRLLD;
                    _bitich.NoiRuaToi    = _tmp.NoiRuaToi;
                    _bitich.NoiThemSuc   = _tmp.NoiThemSuc;
                    _bitich.SoRLLD       = _tmp.SoRLLD;
                    _bitich.SoRuaToi     = _tmp.SoRuaToi;
                    _bitich.SoThemSuc    = _tmp.SoThemSuc;
                }
            }
            return(_bitich);
        }
Ejemplo n.º 3
0
        public static List <string> GetListGiaoHo()
        {
            List <string> _listgiaoho = null;

            using (QLGIAOXU db = new QLGIAOXU())
            {
                _listgiaoho = (from u in db.GiaoHo select u.TenGiaoHo).Distinct().ToList();
            }
            return(_listgiaoho);
        }
        public static List <GiaoDan> GetAllActiveGiaoDanByName(string tenGiaodan)
        {
            List <GiaoDan> _Giaodan = null;

            using (QLGIAOXU db = new QLGIAOXU())
            {
                _Giaodan = (from u in db.GiaoDan where (u.HoTen.Contains(tenGiaodan) && u.Status == true) select u).ToList();
            }
            return(_Giaodan);
        }
        public static GiaoDan GetActiveGiaoDanByID(int IDGiaoDan)
        {
            GiaoDan _Giaodan = null;

            using (QLGIAOXU db = new QLGIAOXU())
            {
                _Giaodan = (from u in db.GiaoDan where (u.ID == IDGiaoDan && u.Status == true) select u).FirstOrDefault();
            }
            return(_Giaodan);
        }
Ejemplo n.º 6
0
        public static List <BiTich> GetAllBiTich()
        {
            List <BiTich> _listbitich = null;

            using (QLGIAOXU db = new QLGIAOXU())
            {
                _listbitich = (from u in db.BiTich select u).ToList();
            }
            return(_listbitich);
        }
        public static List <GiaoDan> GetAllActiveGiaoDan()
        {
            List <GiaoDan> _Giaodan = null;

            using (QLGIAOXU db = new QLGIAOXU())
            {
                _Giaodan = (from u in db.GiaoDan
                            where (u.Status == true)
                            select u).ToList();
            }
            return(_Giaodan);
        }
        public static QuaDoi GetInfoDeath(int?idGiaoDan)
        {
            QuaDoi _quadoi = null;

            using (QLGIAOXU db = new QLGIAOXU())
            {
                _quadoi = (from u in db.QuaDoi
                           where u.IDGiaoDan == idGiaoDan
                           select u).FirstOrDefault();
            }
            return(_quadoi);
        }
        public static ChuyenXu GetInfoLeaving(int?idGiaoDan)
        {
            ChuyenXu _chuyenxu = null;

            using (QLGIAOXU db = new QLGIAOXU())
            {
                _chuyenxu = (from u in db.ChuyenXu
                             where u.IDGiaoDan == idGiaoDan
                             select u).FirstOrDefault();
            }
            return(_chuyenxu);
        }
Ejemplo n.º 10
0
        public static GiaoDan GetGiaoDanByID(int?idGiaoDan)
        {
            GiaoDan _Giaodan = null;

            using (QLGIAOXU db = new QLGIAOXU())
            {
                _Giaodan = (from u in db.GiaoDan
                            where u.ID == idGiaoDan
                            select u).FirstOrDefault();
            }
            return(_Giaodan);
        }
Ejemplo n.º 11
0
        public static bool DeleteGiaoDan(int idGiaoDan)
        {
            bool isDel = false;

            using (QLGIAOXU db = new QLGIAOXU())
            {
                GiaoDan tmp = db.GiaoDan.Where(u => u.ID == idGiaoDan && u.Status == true).FirstOrDefault();
                if (tmp != null)
                {
                    tmp.Status = false;
                    db.SaveChanges();
                    isDel = true;
                }
            }
            return(isDel);
        }
Ejemplo n.º 12
0
        public static int AddOrUpdateGiaoDan(GiaoDan giaodan)
        {
            int idgiaodan = 0;

            using (QLGIAOXU db = new QLGIAOXU())
            {
                if (giaodan.ID > 0)
                {
                    GiaoDan _giaodan = db.GiaoDan.Where(u => u.ID == giaodan.ID).FirstOrDefault();
                    if (_giaodan != null)
                    {
                        _giaodan.TenThanh    = giaodan.TenThanh;
                        _giaodan.HoTen       = giaodan.HoTen;
                        _giaodan.NgaySinh    = giaodan.NgaySinh;
                        _giaodan.ThangSinh   = giaodan.ThangSinh;
                        _giaodan.NamSinh     = giaodan.NamSinh;
                        _giaodan.NoiSinh     = giaodan.NoiSinh;
                        _giaodan.GioiTinh    = giaodan.GioiTinh;
                        _giaodan.Gioi        = giaodan.Gioi;
                        _giaodan.GiaoHo      = giaodan.GiaoHo;
                        _giaodan.TenCha      = giaodan.TenCha;
                        _giaodan.TenMe       = giaodan.TenMe;
                        _giaodan.AnhDaiDien  = giaodan.AnhDaiDien;
                        _giaodan.NgheNghiep  = giaodan.NgheNghiep;
                        _giaodan.SoDienThoai = giaodan.SoDienThoai;
                        _giaodan.Status      = giaodan.Status;
                    }
                }
                else
                {
                    db.GiaoDan.Add(giaodan);
                }
                int x = db.SaveChanges();
                if (x > 0) // The number of objects written to the underlying database, if x==0 that means update objects
                {
                    idgiaodan = giaodan.ID;
                }
            }
            return(idgiaodan);
        }
Ejemplo n.º 13
0
        public static GiaoDanEntityShort GetNameGiaoDanByID(int?idGiaoDan)
        {
            GiaoDanEntityShort _Giaodan = new GiaoDanEntityShort();

            using (QLGIAOXU db = new QLGIAOXU())
            {
                GiaoDanEntityShort _tmpgiaodan = (from u in db.GiaoDan
                                                  where u.ID == idGiaoDan
                                                  select new GiaoDanEntityShort
                {
                    anhdaidien = u.AnhDaiDien,
                    hoten = u.HoTen,
                    tenthanh = u.TenThanh
                }
                                                  ).FirstOrDefault();
                if (_tmpgiaodan != null)
                {
                    _Giaodan = _tmpgiaodan;
                }
            }
            return(_Giaodan);
        }