Exemple #1
0
        public bool SuaMonAn(MonAnObj monAn)
        {
            db = new DataClasses_QLMADataContext();
            MonAn temp = db.MonAns.Where(x => x.maMonAn == monAn.MaMonAn).FirstOrDefault();

            if (temp != null)
            {
                temp.maMonAn   = monAn.MaMonAn;
                temp.tenMonAn  = monAn.TenMonAn;
                temp.donViTinh = monAn.DonviTinh;
                temp.maNhom    = (int)monAn.MaNhom;
                temp.donGia    = (decimal)monAn.DonGia;
                temp.ghiChu    = monAn.GhiChu;
                db.MonAns.InsertOnSubmit(temp);
                db.SubmitChanges();
            }
            return(true);
        }
Exemple #2
0
        public List <MonAnObj> GetTheoNhom(int maNhom)
        {
            List <MonAnObj> lst = new List <MonAnObj>();

            db = new DataClasses_QLMADataContext();
            foreach (var item in db.MonAns.Where(x => x.maNhom == maNhom))
            {
                MonAnObj monAn = new MonAnObj();
                monAn.MaMonAn   = item.maMonAn;
                monAn.TenMonAn  = item.tenMonAn;
                monAn.DonviTinh = item.donViTinh;
                monAn.MaNhom    = (int)item.maNhom;
                monAn.DonGia    = (decimal)item.donGia;
                monAn.GhiChu    = item.ghiChu;
                lst.Add(monAn);
            }
            return(lst);
        }
Exemple #3
0
        public List <NhomObj> GetNhomMon()
        {
            db = new DataClasses_QLMADataContext();
            List <NhomObj>   lst     = new List <NhomObj>();
            List <NhomMonAn> templst = db.NhomMonAns.ToList();

            if (templst.Count > 0)
            {
                foreach (var item in templst)
                {
                    NhomObj tempnhomObj = new NhomObj();
                    tempnhomObj.MaNhom  = item.maNhom;
                    tempnhomObj.TenNhom = item.tenNhom;
                    lst.Add(tempnhomObj);
                }
            }
            return(lst);
        }
Exemple #4
0
        public bool AddNhom(NhomObj nhomObj)
        {
            db = new DataClasses_QLMADataContext();
            NhomMonAn nhomMon = db.NhomMonAns.Where(x => x.maNhom == nhomObj.MaNhom).FirstOrDefault();

            if (nhomMon != null)
            {
                throw new Exception("Nhom da co");
            }
            else
            {
                NhomMonAn tempnhomMon = new NhomMonAn();
                tempnhomMon.maNhom  = nhomObj.MaNhom;
                tempnhomMon.tenNhom = nhomObj.TenNhom;

                db.NhomMonAns.InsertOnSubmit(tempnhomMon);
                db.SubmitChanges();
                return(true);
            }
        }
Exemple #5
0
 public MonAn_Data()
 {
     db = new DataClasses_QLMADataContext();
 }