public Kedvezmenyezettek(SqlConnection SqlConn, int Pnr_id, object Szulo) { InitializeComponent(); this.sconn = SqlConn; if (sconn.State == ConnectionState.Closed) { sconn.Open(); } this.tagPnr = Pnr_id; txPnrid.Text = tagPnr.ToString(); // adattábla dt = new DataTable(); tsUpdate.Enabled = true; tsNew.Enabled = true; tsDelete.Enabled = true; tsFind.Enabled = false; tsSearch.Enabled = false; tsSave.Enabled = false; if (Szulo.GetType() == typeof(Okiratok)) { this.okir = (Okiratok)Szulo; scommand = new SqlCommand("select count(*) from kedvezmenyezettek where pnr_id=" + tagPnr.ToString(), sconn); int van = (int)scommand.ExecuteScalar(); if (van > 0) { scommand = new SqlCommand("spKedvezmenyezettek", sconn); scommand.CommandType = CommandType.StoredProcedure; scommand.Parameters.Add(new SqlParameter("@pnr_id", SqlDbType.Int)).Value = tagPnr; lastScommand = scommand; da = new SqlDataAdapter(scommand); Frissit(); this.dgvKedvezmenyezettek.DataSource = dt; rejtId(); decimal sum = 0; for (int i = 0; i < dgvKedvezmenyezettek.RowCount; i++) { sum += decimal.Parse(dgvKedvezmenyezettek.Rows[i].Cells[3].Value.ToString()); } txKedvOssz.Value = dgvKedvezmenyezettek.RowCount; txReszOssz.Text = sum.ToString() + " %"; } createNew(); } else if (Szulo.GetType() == typeof(OkiratokModositas)) { this.om = (OkiratokModositas)Szulo; scommand = new SqlCommand("select count(*) from kedvezmenyezettek where pnr_id=" + tagPnr.ToString(), sconn); int van = (int)scommand.ExecuteScalar(); if (van > 0) { scommand = new SqlCommand("spKedvezmenyezettek", sconn); scommand.CommandType = CommandType.StoredProcedure; scommand.Parameters.Add(new SqlParameter("@pnr_id", SqlDbType.Int)).Value = tagPnr; lastScommand = scommand; da = new SqlDataAdapter(scommand); Frissit(); this.dgvKedvezmenyezettek.DataSource = dt; rejtId(); decimal sum = 0; for (int i = 0; i < dgvKedvezmenyezettek.RowCount; i++) { sum += decimal.Parse(dgvKedvezmenyezettek.Rows[i].Cells[3].Value.ToString()); } txKedvOssz.Value = dgvKedvezmenyezettek.RowCount; txReszOssz.Text = sum.ToString() + " %"; txAdoazon.ReadOnly = true; txAdoszam.ReadOnly = true; txAnyjaNeve.ReadOnly = true; txBankszla.ReadOnly = true; txCim.ReadOnly = true; txHelyseg.ReadOnly = true; txIrszam.ReadOnly = true; txNev.ReadOnly = true; txPnrid.ReadOnly = true; txSzulHely.ReadOnly = true; txSzulNev.ReadOnly = true; txTelefon.ReadOnly = true; chTerm.Enabled = false; numReszesedes.ReadOnly = true; dtSzulIdo.Enabled = false; dgvKedvezmenyezettek.Focus(); } } }
private void tagságiOkiratokToolStripMenuItem_Click(object sender, EventArgs e) { OkiratokModositas updateContract = new OkiratokModositas(sconn); updateContract.Show(); }