using (SqlConnection con =подключение к бд))
{
con.Open();
SqlCommand comm = new SqlCommand
(
"Use sysCases SELECT cases.id, cases.titlenumber, cases.date, cases.list, cases.description, cases.other, cases.status, cases.junge_id, users.id, users.fathername, plaintiff.name, plaintiff.adress, plaintiff.birhday, defendant.name, defendant.adress, defendant.birhday FROM cases INNER JOIN users ON users.id = cases.junge_id INNER JOIN plaintiff ON plaintiff.cases_id = cases.id INNER JOIN defendant ON defendant.cases_id = cases.id"
, con
);
SqlDataReader reader = comm.ExecuteReader();
while (reader.Read())
{
string des = " ", lis = " ", oth = " ", ad = " ";
string painadd = " ";
if (reader.GetString(4) != null)
des = reader.GetString(4);
if (reader.GetString(3) != null)
lis = reader.GetString(3);
if (reader.GetString(5) != null)
oth = reader.GetString(5);
if (reader.GetString(11) != null)
painadd = reader.GetString(11);
if (reader.GetString(14) != null)
ad = reader.GetString(14);
casesList.Add(new ClassCasesAll
{
id_cases = reader.GetInt32(0),
titlenumber = reader.GetInt32(1),
date = reader.GetDateTime(2),
list = lis,
description = des,
other = oth,
status = reader.GetBoolean(6),
junge_id = reader.GetInt32(7),
id_users = reader.GetInt32(8),
fathername = reader.GetString(9),
name_plaintiff = reader.GetString(10),
adress_plaintiff = painadd,
birthday_plaintiff = reader.GetDateTime(12),
name_defendant = reader.GetString(13),
adress_defendant = ad,
birthday_defendant = reader.GetDateTime(15),
}); ;
}
reader.Close();
}