public static DeletedConstantManaged GetFromRow(DataGridViewRow iRow) { var control = new DeletedConstantManaged(); var viewRow = (DeletedConstantView)iRow.DataBoundItem; control.ConstantName = viewRow.Object.ConstantName; control.ProjectVersion = viewRow.Object.ProjectVersion; control.TransfertConstantName = viewRow.TransfertConstantName; return(control); }
public static DeletedConstantView ConvertTo(DeletedConstantManaged iObj) { if (iObj == null) { return(null); } var newView = new DeletedConstantView(); newView.Object = iObj; newView.ConstantName = iObj.ConstantName; newView.ProjectVersion = iObj.ProjectVersion; newView.TransfertConstantName = iObj.TransfertConstantName; return(newView); }
private static List <DeletedConstantManaged> GetDeletedConstantList(this Project iProject) { var result = new List <DeletedConstantManaged>(); var projectTable = iProject.DataTables.SingleOrDefault(x => x.DisplayName == PROJECTDELETEDCONSTANTDATATABLENAME); if (projectTable == null) { throw new Exception("La table de projet : " + PROJECTDELETEDCONSTANTDATATABLENAME + " est inexistante"); } var projectTableDataArray = projectTable.GetCachedTableData(); //Bouclage sur les lignes, mais ne tient pas compte de la première qui est l'entete for (int rowIndex = 1; rowIndex <= projectTableDataArray.GetLength(0) - 1; rowIndex++) { var newDeletedConstant = new DeletedConstantManaged(); var constantName = projectTableDataArray[rowIndex, 0]; newDeletedConstant.ConstantName = constantName?.ToString(); if (newDeletedConstant.ConstantName.IsNullOrEmpty()) { throw new Exception("Dans la table de projet '{0}', ligne '{1}' le nom du control est invalide".FormatString(PROJECTDELETEDCONSTANTDATATABLENAME, rowIndex + 1)); } var projectVersion = projectTableDataArray[rowIndex, 1]; newDeletedConstant.ProjectVersion = (projectVersion != null) ? ((projectVersion.ToString() != "") ? Convert.ToDecimal(projectVersion.ToString()) : 0) : 0; if (newDeletedConstant.ProjectVersion <= 1) { throw new Exception("Dans la table de projet '{0}', ligne '{1}' la version majeure de projet est invalide".FormatString(PROJECTDELETEDCONSTANTDATATABLENAME, rowIndex + 1)); } var transfertConstantName = projectTableDataArray[rowIndex, 2]; newDeletedConstant.TransfertConstantName = transfertConstantName?.ToString(); result.Add(newDeletedConstant); } return(result); }