public bool getsetClientes(ClassClientes cli, string id)
{
Dictionary<string, string> parametros = new Dictionary<string, string>();
parametros.Add("@p1", id);
DataRow registo = this.GetRow("SELECT * FROM clientes WHERE id_cliente = @p1", parametros);
if (this.isEmptyRow(registo))
{
cli.id = "";
cli.nome = "";
cli.dt_nasc = "";
cli.sexo = "";
cli.morada = "";
cli.telefone = "";
cli.contacto_emergencia = "";
cli.parentesco = "";
return false;
}
else
{
cli.id = registo[0].ToString();
cli.nome = registo[1].ToString();
cli.dt_nasc = registo[2].ToString();
cli.sexo = registo[3].ToString();
cli.morada = registo[4].ToString();
cli.telefone = registo[5].ToString();
cli.contacto_emergencia = registo[6].ToString();
cli.parentesco = registo[7].ToString();
return true;
}
public class ClassClientes
{
//Variaveis
string _id;
string _nome;
string _dt_nasc;
string _sexo;
string _morada;
string _telefone;
string _contacto_emergencia;
string _parentesco;
//Constructores
public ClassClientes()
{
_id = "";
_nome = "";
_dt_nasc = "";
_sexo = "";
_morada = "";
_telefone = "";
_contacto_emergencia = "";
_parentesco = "";
}
public ClassClientes(string i, string n, string d, string s, string m, string t, string c,string p)
{
_id = i;
_nome = n;
_dt_nasc = d;
_sexo = s;
_morada = m;
_telefone = t;
_contacto_emergencia = c;
_parentesco = p;
}
//Propriedades
public string id { get { return _id; } set { _id = value; } }
public string nome { get { return _nome; } set { _nome = value; } }
public string dt_nasc { get { return _dt_nasc; } set { _dt_nasc = value; } }
public string sexo { get { return _sexo; } set { _sexo = value; } }
public string morada { get { return _morada; } set { _morada = value; } }
public string telefone { get { return _telefone; } set { _telefone = value; } }
public string contacto_emergencia { get { return _contacto_emergencia; } set { _contacto_emergencia = value; } }
public string parentesco { get { return _parentesco; } set { _parentesco = value; } }
//Metodos
public bool VerificaCampos(string crud, TextBox[] tbs)
{
string erros = "";
int a;
if (crud == "CREATE")
{
if (tbs[1].Text == "") erros += "Inserir Nome!";
if (tbs[2].Text == "") erros += "Inserir Data de Nascimento!";
if (tbs[3].Text == "") erros += "Inserir Sexo!";
if (tbs[4].Text == "") erros += "Inserir Morada!";
if (tbs[5].Text == "") erros += "Inserir Telefone!";
if (tbs[6].Text == "") erros += "Inserir Contacto de Emergencia";
if (tbs[7].Text == "") erros += "Inserir Contacto de Parentesco do contacto de Emergencia";
else if (tbs[3].Text.Length != 1) erros += "Inserir M ou F no Sexo!";
else if (tbs[5].Text.Length != 9) erros += "Inserir Telefone com 9 digitos!";
else if (tbs[6].Text.Length != 9) erros += "Inserir Contacto de Emergencia com 9 digitos!";
}
else if (crud == "READ")
{
if (tbs[0].Text == "") erros += "O id nao pode ser vazio!";
else if (!int.TryParse(tbs[0].Text, out a)) erros += "O id tem que ser numerico!";
}
else if (crud == "UPDATE")
{
if (tbs[1].Text == "") erros += "Inserir Nome!";
if (tbs[2].Text == "") erros += "Inserir Data de Nascimento!";
if (tbs[3].Text == "") erros += "Inserir Sexo!";
if (tbs[4].Text == "") erros += "Inserir Morada!";
if (tbs[5].Text == "") erros += "Inserir Telefone!";
if (tbs[6].Text == "") erros += "Inserir Contacto de Emergencia";
if (tbs[7].Text == "") erros += "Inserir Contacto de Parentesco do contacto de Emergencia";
else if (tbs[3].Text.Length != 1) erros += "Inserir M ou F no Sexo!";
else if (tbs[5].Text.Length != 9) erros += "Inserir Telefone com 9 digitos!";
else if (tbs[6].Text.Length != 9) erros += "Inserir Contacto de Emergencia com 9 digitos!";
}
else if (crud == "DELETE")
{
if (tbs[0].Text == "") erros += "O id nao pode ser vazio!";
else if (!int.TryParse(tbs[0].Text, out a)) erros += "O id tem que ser numerico!";
}
if (erros == "")
{
return true;
}
else
{
MessageBox.Show(erros);
return false;
}
}
public void preencherCampos(ClassClientes cli, TextBox[] tbs)
{
tbs[0].Text = cli.id.ToString();
tbs[1].Text = cli.nome.ToString();
tbs[2].Text = cli.dt_nasc.ToString();
tbs[3].Text = cli.sexo.ToString();
tbs[4].Text = cli.morada.ToString();
tbs[5].Text = cli.telefone.ToString();
tbs[6].Text = cli.contacto_emergencia.ToString();
tbs[7].Text = cli.parentesco.ToString();
}
public void limpar(TextBox[] tbs)
{
_id = "";
_nome = "";
_dt_nasc = "";
_sexo = "";
_morada = "";
_telefone = "";
_contacto_emergencia = "";
_parentesco = "";
foreach (TextBox tb in tbs)
{
tb.Text = "";
}
}
}
有較少acessible,ClassClientes
都在那裏;我有所有類public
。不一致的可訪問性;參數類型比方法
錯誤消息:
錯誤1可訪問性不一致:參數類型 'WindowsFormsApplication1.ClassClientes' 比方法 'AAR_CLASSES.aar_mysql.getsetClientes(WindowsFormsApplication1.ClassClientes,字符串)' 不易接近C:\用戶\ JOAO \桌面\ PAP \ WindowsFormsApplication1 \ WindowsFormsApplication1 \ AAR_mysql.cs 469 21 WindowsFormsApplication1
你確定'ClassClients'類設置爲'public'嗎? – MarcinJuraszek
是的,那將是我要檢查的第一件事。 –
是的,我在這裏尋找解決方案,這是我做的第一件事 – user3221369