Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button3_Click(object sender, EventArgs e)
- {
- string ConnectionString = @"Data Source=192.168.112.103;Initial Catalog=db22204;User ID=User032;Password=User032%$27;Integrated Security=False;MultipleActiveResultSets=True;";
- sqlConnection = new SqlConnection(ConnectionString);
- sqlConnection.Open();
- StreamWriter file = new StreamWriter("report2.html");
- file.WriteLine("<h1 style='text-align: center;'> Закрытые счета </h1>");
- file.WriteLine("<hr></hr>");
- SqlCommand command1 = new SqlCommand("SELECT txtAccountTypeName, txtAccountNumber, " +
- "datAccountBegin, datAccountEnd, " +
- "concat(txtClientSurname, ' ', txtClientName, ' ', txtClientSecondName), txtClientAddress " +
- "FROM tblClient, tblAccount, tblAccountType " +
- "WHERE (tblAccount.intAccountTypeId = tblAccountType.intAccountTypeId) " +
- "AND (tblAccount.intClientId = tblClient.intClientId) " +
- "AND (tblAccount.datAccountEnd < CURRENT_TIMESTAMP) ORDER BY txtAccountTypeName", sqlConnection);
- var reader1 = command1.ExecuteReader();
- var count = 0;
- var totalCount = 0;
- int c1 = 0; int c2 = 0; int c3 = 0; int c4 = 0; int c5 = 0;
- while (reader1.Read())
- {
- var type = reader1[0].ToString();
- if (type == "Дебетовый") c1++;
- if (type == "Кредитный") c2++;
- if (type == "Депозитный") c3++;
- if (type == "Лицевой") c4++;
- if (type == "Расчётный") c5++;
- totalCount++;
- var name1 = reader1[4].ToString();
- var client = name1.Split(' ');
- string open = reader1[2].ToString();
- string[] openDate = open.Split(' ');
- var date = openDate[0];
- string close = reader1[3].ToString();
- string[] closeDate = close.Split(' ');
- var date1 = closeDate[0];
- var number = reader1[1].ToString();
- file.WriteLine("<p><strong>Наименование типа счета:</strong> " + type + "</p>");
- file.WriteLine("<p><strong>Номер счета:</strong> " + number + " </p>");
- file.WriteLine("<p><strong>Дата открытия счета: </strong>" + date + "</p>");
- file.WriteLine("<p><strong>Дата закрытия счета: </strong>" + date1 + "</p>");
- file.WriteLine("<p><strong>ФИО клиента:</strong> " + name1 + "</p>");
- file.WriteLine("<p><strong>Адрес: </strong>" + reader1[5].ToString() + " </p>");
- file.WriteLine("<p style='text-align: center;'>Список операций </p>");
- file.WriteLine("<table align='center' border='1'> " +
- " <tr>" +
- " <th>Дата проведения</th> " +
- " <th>Тип операции</th> " +
- " <th>Сумма операции</th>" +
- " </tr>");
- SqlCommand command = new SqlCommand(
- "SELECT datOperation, txtOperationTypeName, fltValue FROM tblOperation, tblOperationType, tblAccount " +
- "WHERE (tblOperationType.intOperationTypeId = tblOperation.intOperationTypeId)" +
- " AND (tblOperation.intAccountId = tblAccount.intAccountId)" +
- " AND (txtAccountNumber = @number1) ORDER BY datOperation DESC", sqlConnection);
- command.Parameters.AddWithValue("number1", number);
- SqlDataReader reader = command.ExecuteReader();
- while (reader.Read())
- {
- count++;
- string str1 = reader.GetDateTime(0).ToString("dd.MM.yyyy");
- string str2 = reader.GetString(1);
- var str3 = reader.GetDecimal(2);
- file.WriteLine("<tr><td> " + str1 + "</td>" +
- "<td> " + str2 + "</td>" +
- "<td> " + str3 + "</td> " +
- "</tr>");
- }
- reader.Close();
- file.WriteLine("</table>");
- file.WriteLine("<p><strong>Количество операций:</strong> " + count + " </p>");
- file.WriteLine("<hr></hr>");
- count = 0;
- }
- reader1.Close();
- file.WriteLine("<p><strong>Количество закрытых дебетовых счетов:</strong> " + c1 + " </p>");
- file.WriteLine("<p><strong>Количество закрытых кредитных счетов:</strong> " + c2 + " </p>");
- file.WriteLine("<p><strong>Количество закрытых депозитных счетов:</strong> " + c3 + " </p>");
- file.WriteLine("<p><strong>Количество закрытых лицевых счетов:</strong> " + c4 + " </p>");
- file.WriteLine("<p><strong>Количество закрытых расчётных счетов:</strong> " + c5 + " </p>");
- file.WriteLine("<p><strong>ОБЩЕЕ КОЛИЧЕСТВО ЗАКРЫТЫХ СЧЕТОВ:</strong> " + totalCount + " </p>");
- file.Close();
- Process.Start(@"report2.html");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement