public void ModifyEntity() { _bdmSvc = new BDMService(); List<EntityDE> entities = _bdmSvc.GetAllEntities(AppConstants.SITE_CODE); var ety = entities.LastOrDefault(); ety.EntityName = "Imran Farooq ..."; ety.EntityTypeCode = EntityTypes.DOC.ToString(); ety.SiteCode = AppConstants.SITE_CODE; AddressDE add = ety.Addresses.FirstOrDefault(); add.AddressLine1 = "St. Ahmad Din Sipahi ..."; add.AddressLine2 = "Moh. Fatu Pura, Gujrat .."; ContactDE contact = ety.Contacts.FirstOrDefault(); contact.Mobile1 = "0333-348343499 ..."; _bdmSvc.ModifyEntity(ety); ety = _bdmSvc.GetEntityById(AppConstants.SITE_CODE, ety.ID); }
public void Entity_CRUD() { EntityDE ety = new EntityDE(); ety.SiteCode = "QST"; ety.EntityTypeCode = "DNR"; ety.EntityName = "Khairaat"; ety.Code = "090"; _bdmSvc = new BDMService(); int id = _bdmSvc.AddEntity(ety); ety.ID = id; ety.EntityName = "Khariraat ..."; bool res = _bdmSvc.ModifyEntity(ety); res = _bdmSvc.DeleteEntity(ety.SiteCode, ety.EntityTypeCode, ety.ID); }
public bool ModifyGiftType(GiftTypeBE mod) { EntityDE ety = new EntityDE(); ety.SiteCode = mod.SiteCode; ety.EntityTypeCode = mod.EntityTypeCode; ety.ID = mod.ID; ety.EntityName = mod.EntityName; ety.Code = mod.Code; ety.IsActive = mod.IsActive; SqlConnection con = new SqlConnection(DBHelper.ConnectionString); try { //mod.ID = GetNextEntityId(mod.SiteCode, mod.EntityTypeCode); StringBuilder sb = new StringBuilder(); using (TransactionScope trans = new TransactionScope()) { _bdmSvc = new BDMService(); if (_bdmSvc.ModifyEntity(ety)) { SqlCommand cmd = new SqlCommand(); #region CommandText & Params sb.Append("UPDATE [dbo].[GiftType] SET "); sb.Append("[GiftTypeID] = @GiftTypeID"); sb.Append(",[IsCondition] = @IsCondition"); sb.Append(",[Price] = @Price"); sb.Append(" WHERE "); sb.Append(" [GiftTypeID] = @GiftTypeID"); cmd.Parameters.AddWithValue("@GiftTypeID", mod.ID); cmd.Parameters.AddWithValue("@IsCondition", mod.IsCondition); cmd.Parameters.AddWithValue("@Price", mod.Price); #endregion cmd.Connection = con; cmd.CommandText = sb.ToString(); con.Open(); cmd.ExecuteNonQuery(); trans.Complete(); } } } catch (Exception ex) { return false; } finally { con.Close(); } return true; }