Example #1
0
        protected void grvChucDanhCongViec_DeleteCommand(object sender, GridCommandEventArgs e)
        {
            var iD = (e.Item as GridDataItem).GetDataKeyValue("IDChucDanhCongViec").ToString();
            int id = Convert.ToInt32(iD);
            ChucDanhCongViec obj = _entities.ChucDanhCongViecs.Where(o => o.IDChucDanhCongViec == id).First();

            _entities.ChucDanhCongViecs.DeleteObject(obj);
            _entities.SaveChanges();
        }
Example #2
0
        protected void grvChucDanhCongViec_UpdateCommand(object sender, GridCommandEventArgs e)
        {
            GridEditableItem item = e.Item as GridEditableItem;
            var iD = Convert.ToInt32(item.GetDataKeyValue("IDChucDanhCongViec").ToString());
            ChucDanhCongViec obj = _entities.ChucDanhCongViecs.Where(o => o.IDChucDanhCongViec == iD).First();

            obj.NgayCapNhat  = DateTime.Now;
            obj.NguoiCapNhat = idNhanVien;
            item.UpdateValues(obj);
            _entities.SaveChanges();
        }
Example #3
0
        protected void grvChucDanhCongViec_InsertCommand(object sender, GridCommandEventArgs e)
        {
            GridEditableItem item   = e.Item as GridEditableItem;
            Hashtable        values = new Hashtable();

            item.ExtractValues(values);
            ChucDanhCongViec obj = new ChucDanhCongViec();

            obj.NgayTao  = obj.NgayCapNhat = DateTime.Now;
            obj.NguoiTao = obj.NguoiCapNhat = idNhanVien;
            item.UpdateValues(obj);
            _entities.AddToChucDanhCongViecs(obj);
            _entities.SaveChanges();
        }