示例#1
0
        public bool add(NHANVIEN nv, ACCOUNT ac)
        {
            bool check = false;

            using (ContextEntites context = new ContextEntites())
            {
                NHANVIEN kh = new NHANVIEN();
                kh.MANV       = nv.MANV;
                kh.CMT        = nv.CMT;
                kh.NGAYSINH   = nv.NGAYSINH;
                kh.MACV       = nv.MACV;
                kh.PHAI       = nv.PHAI;
                kh.QUEQUAN    = nv.QUEQUAN;
                kh.SDT        = nv.SDT;
                kh.NGAYVAOLAM = nv.NGAYVAOLAM;
                kh.TENNV      = nv.TENNV;
                context.NHANVIENs.Add(kh);
                context.SaveChanges();
                ACCOUNT account = new ACCOUNT();
                account.ID       = kh.MANV;
                account.PASS     = ac.PASS;
                account.USERNAME = ac.USERNAME;
                context.ACCOUNTs.Add(account);
                context.SaveChanges();
                check = true;
            }
            return(check);
        }
示例#2
0
        public bool editHD(HOADON hd)
        {
            bool chek = false;

            using (ContextEntites context = new ContextEntites())
            {
                try
                {
                    var s = context.HOADONs.Single(x => x.MAHD == hd.MAHD);
                    s.MANV   = hd.MANV;
                    s.NGAYHD = hd.NGAYHD;
                    s.TRIGIA = hd.TRIGIA;

                    if (context.SaveChanges() >= 0)
                    {
                        var bc = context.BAOCAOs.Where(x => x.NGAYBAOCAO == hd.NGAYHD.Date);

                        if ((bc.Count() > 0))
                        {
                            Console.WriteLine(bc.First().TONGGIATRI);
                            bc.First().TONGGIATRI += hd.TRIGIA;
                            Console.WriteLine(bc.First().TONGGIATRI);
                        }

                        context.SaveChanges();
                        chek = true;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            return(chek);
        }
示例#3
0
        public bool deleteNV(int maNV)
        {
            bool check = false;

            using (ContextEntites con = new ContextEntites())
            {
                try
                {
                    NHANVIEN kh = con.NHANVIENs.SingleOrDefault(x => x.MANV == maNV);

                    ACCOUNT ac = con.ACCOUNTs.SingleOrDefault(x => x.ID == maNV);
                    if (ac != null)
                    {
                        con.NHANVIENs.Remove(kh);
                        //con.SaveChanges();
                        con.ACCOUNTs.Remove(ac);
                        con.SaveChanges();
                        check = true;
                        return(check);
                    }
                    else
                    {
                        con.NHANVIENs.Remove(kh);
                        con.SaveChanges();
                        check = true;
                        return(check);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            return(check);
        }
示例#4
0
        public bool editac(ACCOUNT kh)
        {
            bool chek = false;

            using (ContextEntites context = new ContextEntites())
            {
                try
                {
                    var s = context.ACCOUNTs.Single(x => x.ID == kh.ID);
                    s.ID       = kh.ID;
                    s.PASS     = kh.PASS;
                    s.USERNAME = kh.USERNAME;

                    if (context.SaveChanges() >= 0)
                    {
                        chek = true;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            return(chek);
            //change
        }
示例#5
0
        public int AddHoaDon(HOADON hd)
        {
            int s = 0;

            using (ContextEntites cn = new ContextEntites())
            {
                try
                {
                    cn.HOADONs.Add(hd);

                    var bc = cn.BAOCAOs.Where(x => (x.NGAYBAOCAO == hd.NGAYHD.Date));
                    Console.WriteLine(bc.Count());
                    if ((bc.Count() == 0))
                    {
                        BAOCAO b = new BAOCAO();
                        b.NGAYBAOCAO = hd.NGAYHD;
                        b.TONGGIATRI = 0;
                        cn.BAOCAOs.Add(b);
                    }

                    s = cn.SaveChanges();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    s = 0;
                }
            }
            return(s);
        }
示例#6
0
        public bool deleteCTPhieuNhap(int maPhieu, int madc)
        {
            bool check = false;

            using (ContextEntites con = new ContextEntites())
            {
                try
                {
                    var lpn = con.CTPHIEUNHAPs.Where(x => (x.MAPHIEU == maPhieu && x.MADC == madc)).ToList();
                    foreach (var pn in lpn)
                    {
                        con.CTPHIEUNHAPs.Remove(pn);
                    }
                    if (con.SaveChanges() > 0)
                    {
                        check = true;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            return(check);
        }
示例#7
0
        public bool deleteCTHD(int mahd)
        {
            bool check = false;

            using (ContextEntites con = new ContextEntites())
            {
                try
                {
                    var cts = con.CTHDs.Where(x => (x.MAHD == mahd));
                    foreach (CTHD ct in cts)
                    {
                        con.CTHDs.Remove(ct);
                    }

                    if (con.SaveChanges() >= 0)
                    {
                        check = true;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            return(check);
        }
示例#8
0
        public bool editNV(NHANVIEN kh)
        {
            bool chek = false;

            using (ContextEntites context = new ContextEntites())
            {
                try
                {
                    var s = context.NHANVIENs.Single(x => x.MANV == kh.MANV);
                    s.TENNV      = kh.TENNV;
                    s.SDT        = kh.SDT;
                    s.PHAI       = kh.PHAI;
                    s.CMT        = kh.CMT;
                    s.MACV       = kh.MACV;
                    s.NGAYVAOLAM = kh.NGAYVAOLAM;
                    s.NGAYSINH   = kh.NGAYSINH;
                    s.QUEQUAN    = kh.QUEQUAN;

                    if (context.SaveChanges() >= 0)
                    {
                        chek = true;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            return(chek);
            //change
        }
示例#9
0
        public bool editDC(DOCHOI dc)
        {
            bool chek = false;

            using (ContextEntites context = new ContextEntites())
            {
                try
                {
                    var s = context.DOCHOIs.Single(x => x.MADC == dc.MADC);
                    s.TENDC  = dc.TENDC;
                    s.SL     = dc.SL;
                    s.NUOCSX = dc.NUOCSX;
                    s.LOAI   = dc.LOAI;
                    s.GIA    = dc.GIA;
                    if (context.SaveChanges() >= 0)
                    {
                        chek = true;
                    }
                }
                catch (Exception ec)
                {
                    Console.WriteLine(ec.ToString());
                }
            }
            return(chek);
        }
示例#10
0
        public int addCTHDs(List <CTHD> cts)
        {
            int s = 0;

            foreach (CTHD ct in cts)
            {
                using (ContextEntites context = new ContextEntites())
                {
                    var a = context.CTHDs.Add(ct);
                    s += context.SaveChanges();
                }
            }
            return(s);
        }
示例#11
0
        public int AddCV(CHUCVU ac)
        {
            int s;

            using (ContextEntites context = new ContextEntites())
            {
                CHUCVU kh = new CHUCVU();
                kh.MACV  = ac.MACV;
                kh.TENCV = ac.TENCV;
                context.CHUCVUs.Add(kh);
                s = context.SaveChanges();
            }
            return(s);
        }
示例#12
0
        public int addCTHD(CTHD ct)
        {
            int  s;
            CTHD add = new CTHD();

            add.MAHD = ct.MAHD;
            add.MADC = ct.MADC;
            add.SL   = ct.SL;
            add.GIA  = ct.GIA;
            using (ContextEntites context = new ContextEntites())
            {
                var a = context.CTHDs.Add(add);
                s = context.SaveChanges();
            }
            return(s);
        }
示例#13
0
        public int AddDoChoi(DOCHOI dc)
        {
            int s = 0;

            using (ContextEntites context = new ContextEntites())
            {
                try
                {
                    context.DOCHOIs.Add(dc);
                    s = context.SaveChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
            }
            return(s);
        }
示例#14
0
        public bool AddAc(ACCOUNT ac)
        {
            bool check = false;

            using (ContextEntites context = new ContextEntites())
            {
                ACCOUNT kh = new ACCOUNT();
                kh.ID       = ac.ID;
                kh.PASS     = ac.PASS;
                kh.USERNAME = ac.USERNAME;
                context.ACCOUNTs.Add(kh);
                if (context.SaveChanges() > 0)
                {
                    check = true;
                }
            }
            return(check);
        }
示例#15
0
        public int AddBAOCAO(BAOCAO bc)
        {
            int s;

            using (ContextEntites cn = new ContextEntites())
            {
                try
                {
                    cn.BAOCAOs.Add(bc);
                    s = cn.SaveChanges();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    s = 0;
                }
            }
            return(s);
        }
示例#16
0
        public int AddCTPhieuNhap(CTPHIEUNHAP ct)
        {
            int s;

            using (ContextEntites cn = new ContextEntites())
            {
                try
                {
                    cn.CTPHIEUNHAPs.Add(ct);
                    s = cn.SaveChanges();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    s = 0;
                }
            }
            return(s);
        }
示例#17
0
        public bool deleteDC(int maDC)
        {
            bool check = false;

            using (ContextEntites con = new ContextEntites())
            {
                try
                {
                    DOCHOI hd = con.DOCHOIs.Single(x => x.MADC == maDC);
                    con.DOCHOIs.Remove(hd);
                    if (con.SaveChanges() >= 0)
                    {
                        check = true;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            return(check);
        }
示例#18
0
        public bool deleteCTHD(int mahd, int madc)
        {
            bool check = false;

            using (ContextEntites con = new ContextEntites())
            {
                try
                {
                    CTHD ct = con.CTHDs.Single(x => (x.MADC == madc && x.MAHD == mahd));
                    con.CTHDs.Remove(ct);
                    if (con.SaveChanges() >= 0)
                    {
                        check = true;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            return(check);
        }
示例#19
0
        public bool addSLDC(int madc, int sl)
        {
            bool chek = false;

            using (ContextEntites context = new ContextEntites())
            {
                try
                {
                    var s = context.DOCHOIs.Single(x => x.MADC == madc);
                    s.SL += sl;
                    if (context.SaveChanges() >= 0)
                    {
                        chek = true;
                    }
                }
                catch (Exception ec)
                {
                    Console.WriteLine(ec.ToString());
                }
            }
            return(chek);
        }
示例#20
0
        public bool deleteac(int AcID)
        {
            bool check = false;

            using (ContextEntites con = new ContextEntites())
            {
                try
                {
                    ACCOUNT kh = con.ACCOUNTs.Single(x => x.ID == AcID);
                    con.ACCOUNTs.Remove(kh);
                    if (con.SaveChanges() >= 0)
                    {
                        check = true;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            return(check);
        }
示例#21
0
        public bool deleteCV(string Macv)
        {
            bool check = false;

            using (ContextEntites con = new ContextEntites())
            {
                try
                {
                    CHUCVU kh = con.CHUCVUs.Single(x => x.MACV == Macv);
                    con.CHUCVUs.Remove(kh);
                    if (con.SaveChanges() >= 0)
                    {
                        check = true;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            return(check);
        }
示例#22
0
        public bool deletePhieuNhap(int maPhieu)
        {
            bool check = false;

            using (ContextEntites con = new ContextEntites())
            {
                try
                {
                    PHIEUNHAP pn = con.PHIEUNHAPs.Single(x => x.MAPHIEU == maPhieu);
                    con.PHIEUNHAPs.Remove(pn);
                    if (con.SaveChanges() >= 0)
                    {
                        check = true;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            return(check);
        }
示例#23
0
        public bool editbc(BAOCAO bc)
        {
            bool chek = false;

            using (ContextEntites context = new ContextEntites())
            {
                try
                {
                    var s = context.BAOCAOs.Single(x => x.NGAYBAOCAO == bc.NGAYBAOCAO);
                    s.NGAYBAOCAO = bc.NGAYBAOCAO;
                    s.TONGGIATRI = bc.TONGGIATRI;
                    if (context.SaveChanges() >= 0)
                    {
                        chek = true;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            return(chek);
        }
示例#24
0
        public bool deleteHD(int maHD)
        {
            bool check = false;

            using (ContextEntites con = new ContextEntites())
            {
                try
                {
                    HOADON hd = con.HOADONs.Single(x => x.MAHD == maHD);
                    con.HOADONs.Remove(hd);


                    if (con.SaveChanges() >= 0)
                    {
                        check = true;
                    }
                }catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            return(check);
        }
示例#25
0
        public bool editCTPhieuNhap(CTPHIEUNHAP ct)
        {
            bool chek = false;

            using (ContextEntites context = new ContextEntites())
            {
                try
                {
                    var s = context.CTPHIEUNHAPs.Single(x => (x.MADC == ct.MADC && x.MAPHIEU == ct.MAPHIEU));
                    s.SL = ct.SL;

                    if (context.SaveChanges() >= 0)
                    {
                        chek = true;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            return(chek);
            //change
        }
示例#26
0
        public bool editCV(CHUCVU kh)
        {
            bool chek = false;

            using (ContextEntites context = new ContextEntites())
            {
                try
                {
                    var s = context.CHUCVUs.Single(x => x.MACV == kh.MACV);
                    s.MACV  = kh.MACV;
                    s.TENCV = kh.TENCV;
                    if (context.SaveChanges() >= 0)
                    {
                        chek = true;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            return(chek);
            //change
        }
示例#27
0
        public bool addNV(NHANVIEN nv)
        {
            bool check = false;

            using (ContextEntites context = new ContextEntites())
            {
                NHANVIEN kh = new NHANVIEN();
                kh.MANV       = nv.MANV;
                kh.CMT        = nv.CMT;
                kh.NGAYSINH   = nv.NGAYSINH;
                kh.MACV       = nv.MACV;
                kh.PHAI       = nv.PHAI;
                kh.QUEQUAN    = nv.QUEQUAN;
                kh.SDT        = nv.SDT;
                kh.NGAYVAOLAM = nv.NGAYVAOLAM;
                kh.TENNV      = nv.TENNV;
                context.NHANVIENs.Add(kh);
                if (context.SaveChanges() > 0)
                {
                    check = true;
                }
            }
            return(check);
        }