Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace bd
- {
- public partial class Form3 : Form
- {
- private SqlDataAdapter adapter = null;
- private DataTable table;
- public Form3(SqlConnection sqlConnection, int id)
- {
- // MessageBox.Show(id.ToString());
- InitializeComponent();
- sqlConnection.Open();
- SqlCommand command = new SqlCommand(
- "SELECT txtAccountTypeName, concat(txtClientSurname, ' ', txtClientName, ' ', txtClientSecondName), datAccountBegin, datAccountEnd, txtAccountNumber, fltAccountSum" +
- " FROM tblClient, tblAccountType, tblAccount WHERE (tblAccountType.intAccountTypeId = tblAccount.intAccountTypeId) AND ( tblClient.intClientId = tblAccount.intClientId) and (tblAccount.intAccountId= " + id + ")", sqlConnection);
- SqlDataReader rd;
- rd = command.ExecuteReader();
- while (rd.Read())
- {
- textBox1.Text = rd[0].ToString();
- textBox2.Text = rd[1].ToString();
- textBox3.Text = DateTime.Parse(rd[2].ToString()).ToShortDateString();
- textBox4.Text = DateTime.Parse(rd[3].ToString()).ToShortDateString();
- textBox5.Text = rd[4].ToString();
- textBox6.Text = rd[5].ToString();
- }
- rd.Close();
- table = new DataTable();
- adapter = new SqlDataAdapter("SELECT tblOperation.datOperation as 'Дата проведения операции', tblOperationType.txtOperationTypeName as 'Наименование типа операции', tblOperation.fltValue as 'Сумма' FROM tblOperation, tblOperationType, tblAccount WHERE (tblAccount.intAccountId = tblOperation.intAccountId) and (tblOperation.intOperationTypeId = tblOperationType.intOperationTypeId) and (tblAccount.intAccountId = '" + id + "')", sqlConnection);
- adapter.Fill(table);
- dataGridView1.DataSource = table;
- dataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
- dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
- dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
- sqlConnection.Close();
- }
- private void Form3_Load(object sender, EventArgs e)
- {
- }
- private void Cancel_Click_1(object sender, EventArgs e)
- {
- this.Hide();
- var form = new Form1();
- form.ShowDialog();
- }
- private void Add_Click(object sender, EventArgs e)
- {
- var form = new Form4(textBox2.Text.ToString(), textBox5.Text.ToString(), textBox1.Text.ToString());
- form.Show();
- }
- private void button_Click(object sender, EventArgs e)
- {
- table.Clear();
- adapter.Fill(table);
- dataGridView1.DataSource = table;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement