/// <summary> /// Updates tree view field. /// </summary> /// <param name="dto">The DTO object.</param> /// <exception cref="System.ArgumentException"></exception> /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception> public void UpdateTreeViewField(TreeViewDisplayFieldDto dto) { if (dto == null) throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto")); const string CmdText = @" UPDATE [dbo].[TreeViewStepFields] SET [ReverseCrossRefStepId] = @stepId ,[DisplayFieldName] = @fieldName ,[FullPath] = @fullPath ,[Order] = @order ,[Guid] = @guid WHERE [Id] = @id; "; using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { using (var cmd = new SqlCommand(CmdText, ctx.Connection)) { cmd.Parameters.AddWithValue("@id", dto.Id); cmd.Parameters.AddWithValue("@stepId", dto.StepId); cmd.Parameters.AddWithValue("@fieldName", dto.DisplayName); cmd.Parameters.AddWithValue("@fullPath", dto.FullPath); cmd.Parameters.AddWithValue("@order", dto.Order); cmd.Parameters.AddWithValue("@guid", dto.Guid); cmd.ExecuteNonQuery(); } } }
/// <summary> /// Inserts tree view field. /// </summary> /// <param name="dto">The DTO object.</param> /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception> public void InsertTreeViewField(TreeViewDisplayFieldDto dto) { if (dto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto")); const string CmdText = @" INSERT INTO [dbo].[TreeViewStepFields] ( [ReverseCrossRefStepId] ,[DisplayFieldName] ,[FullPath] ,[Order] ,[Guid] ) VALUES ( @stepId ,@fieldName ,@fullPath ,@order ,@guid ); SELECT [Id] FROM [dbo].[TreeViewStepFields] WHERE [Id] = SCOPE_IDENTITY()"; using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var cn = ctx.Connection; using (var cmd = new SqlCommand(CmdText, cn)) { cmd.Parameters.AddWithValue("@stepId", dto.StepId); cmd.Parameters.AddWithValue("@fieldName", dto.DisplayName); cmd.Parameters.AddWithValue("@fullPath", dto.FullPath); cmd.Parameters.AddWithValue("@order", dto.Order); cmd.Parameters.AddWithValue("@guid", dto.Guid); dto.Id = (int)cmd.ExecuteScalar(); } } }