Example #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);
        }
Example #2
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);
            }
        }