コード例 #1
0
        protected void grvTTHonNhan_DeleteCommand(object sender, GridCommandEventArgs e)
        {
            var iDTTHonNhan     = (e.Item as GridDataItem).GetDataKeyValue("IDTinhTrangHonNhan").ToString();
            int id              = Convert.ToInt32(iDTTHonNhan);
            TinhTrangHonNhan tt = _entities.TinhTrangHonNhans.Where(d => d.IDTinhTrangHonNhan == id).First();

            _entities.TinhTrangHonNhans.DeleteObject(tt);
            _entities.SaveChanges();
        }
コード例 #2
0
        protected void grvTTHonNhan_UpdateCommand(object sender, GridCommandEventArgs e)
        {
            GridEditableItem item = e.Item as GridEditableItem;
            int id = Convert.ToInt32(item.GetDataKeyValue("IDTinhTrangHonNhan").ToString());
            TinhTrangHonNhan tt = _entities.TinhTrangHonNhans.Where(d => d.IDTinhTrangHonNhan == id).First();

            tt.NgayCapNhat  = DateTime.Now;
            tt.NguoiCapNhat = idNhanVien;
            item.UpdateValues(tt);
            _entities.SaveChanges();
        }
コード例 #3
0
        protected void grvTTHonNhan_InsertCommand(object sender, GridCommandEventArgs e)
        {
            GridEditableItem item   = e.Item as GridEditableItem;
            Hashtable        values = new Hashtable();

            item.ExtractValues(values);
            TinhTrangHonNhan tt = new TinhTrangHonNhan();

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