2
I created a WFA project that will serve as a basis for the others, follows the description:
I created a Formbase that has public control variables, such as operator name, date and time of access to the systems;
I created a Formbasemain, which instance Formbase, putting in this a menu, status bar, toolbar;
I created a Formbasequery, which instance Formbase, in this I put a toolbar, a Datagridview , I installed a DAL class that I created to connect to the database (postgres, at first).
So far everything works legal.
My difficulty is in the Formbasequery class that I have a method to get the SQL string as follows:
public virtual string getSCriptConsulta()
{
sScriprtSQL = "";
return sScriprtSQL;
}
In the Formcomestados class, which instance Formbasequery has a class that defines SQL:
public override string getSCriptConsulta()
{
return "select ufcodigo as codigo, " +
" ufsigla as uf, " +
" ufnome as estado " +
"from cadastros.tbestados " +
"order by ufnome ";
}
Everything is working well, bringing the list of states, but I want to change some properties of the columns, for this I created a class as follows:
namespace wfaPraticandoHeranca
{
class EntidadeGridColumns
{
private string sFieldName = null;
private string sHeaderText = null;
private int iMinimumWidth = 0;
private string sToolTipText = null;
private int iWidth = 0;
private bool bFroze = false;
public string FieldName
{
get { return sFieldName; }
set { sFieldName = value; }
}
public string HeaderText
{
get { return sHeaderText; }
set { sHeaderText = value; }
}
public int MinimumWidth
{
get { return iMinimumWidth; }
set { iMinimumWidth = value; }
}
public string ToolTipText
{
get { return sToolTipText; }
set { sToolTipText = value; }
}
public int Width
{
get { return iWidth; }
set { iWidth = value; }
}
public bool Frozen
{
get { return bFroze; }
set { bFroze = value; }
}
}
}
In Formbasequery I created a class as follows:
public virtual EntidadeGridColumns getGridColumnsProperties()
{
EntidadeGridColumns colProperties = new EntidadeGridColumns[0];
return colProperties;
}
This class is reporting me the error (with getGridColumnsProperties()
underlined in blue):
Error 3 Inconsistent Accessibility: Return type 'wfaPraticandoHeranca.Entidadegridcolumns' is Less accessible than method 'wfaPraticandoHeranca.frmModeloConsultas.getGridColumnsProperties()'
In Formconstados I overwrote the class:
public override EntidadeGridColumns setColumnsProperties()
{
EntidadeGridColumns colProperties = new EntidadeGridColumns[3];
colProperties[0] = new EntidadeGridColumns();
colProperties[0].FieldName = "codigo";
colProperties[0].HeaderText = "Código";
colProperties[0].MinimumWidth = 75;
colProperties[0].Width = 75;
colProperties[0].ToolTipText = "Código do cadastro do Estado...";
colProperties[0].Frozen = true;
colProperties[1] = new EntidadeGridColumns();
colProperties[1].FieldName = "sigla";
colProperties[1].HeaderText = "Sigla";
colProperties[1].MinimumWidth = 60;
colProperties[1].Width = 60;
colProperties[1].ToolTipText = "UF do Estado...";
colProperties[1].Frozen = false;
colProperties[2] = new EntidadeGridColumns();
colProperties[2].FieldName = "estado";
colProperties[2].HeaderText = "Estado";
colProperties[2].MinimumWidth = 250;
colProperties[2].Width = 25;
colProperties[2].ToolTipText = "Nme do Estado...";
colProperties[2].Frozen = false;
return colProperties;
}
This class is reporting me the error (with "getGridColumnsProperties()" underlined in blue):
Error 2 Inconsistent Accessibility: Return type 'wfaPraticandoHeranca.Entidadegridcolumns' is Less accessible than method 'wfaPraticandoHeranca.frmConState.setColumnsProperties()'
Finally, these are the mistakes I’m having, if you can help me I’ll be grateful, because I have no idea how to fix this!
When I see the class EntidadeGridColumns
cannot be used as a return of the method and I do not know how to do in C#.
Note: - Another error that is happening, since these are errors 2 and 3, the design of the Formconestados no longer opens reporting the error:
> Connection string argument missing! Parameter name: Host
Mas executando tudo funciona devidamente; já excluí as pastas BIN e OBJ mas não deu certo. Já verifiquei no "Npgsql" este parâmetro "Host" e não encontre nada, apenas "Server".
Forgive me, I don’t even know how to define the title for this situation.
Alter
class EntidadeGridColumns
forpublic class EntidadeGridColumns
– ramaral