private void textBoxTipProdus_TextChanged(object sender, EventArgs e) { string sql = "SELECT * FROM Produse WHERE Nume = '" + textBoxTipProdus.Text + "' "; SqlCommand cmd = new SqlCommand(sql, con); SqlDataReader NrReader; try { con.Open(); NrReader = cmd.ExecuteReader(); while (NrReader.Read()) { string sCod_produs = NrReader.GetString(3).ToString(); string sLot = NrReader.GetString(4).ToString(); string sData = NrReader.GetString(5).ToString(); string sNatura = NrReader.GetString(2).ToString(); textBoxProdus.Text = sNatura; textBoxCodP.Text = sCod_produs; textBoxLot.Text = sLot; textBoxDataExp.Text = sData; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } }
private void Bonform_Load(object sender, EventArgs e) { string sql = "SELECT Bonuri_printate FROM Bonuri "; // SqlConnection con = new SqlConnection(); SqlCommand cmd = new SqlCommand(sql, con); // DataTable dt = new DataTable(); // SqlDataAdapter adapter = new SqlDataAdapter(); SqlDataReader NrReader; try { con.Open(); NrReader = cmd.ExecuteReader(); while (NrReader.Read()) { string sBonuri_printate = NrReader.GetDecimal(0).ToString(); labelBonuriPrintate.Text = sBonuri_printate; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } }
private void textBoxClient_TextChanged(object sender, EventArgs e) { string sql = "SELECT * FROM Clienti WHERE Nume = '" + textBoxClient.Text + "' "; SqlCommand cmd = new SqlCommand(sql, con); SqlDataReader NrReader; try { con.Open(); NrReader = cmd.ExecuteReader(); while (NrReader.Read()) { string sAdresa = NrReader.GetString(2).ToString(); string sCod_fiscal = NrReader.GetString(3).ToString(); textBoxAdresaC.Text = sAdresa; textBoxCifC.Text = sCod_fiscal; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } }
private void InfoMetrologic_Load(object sender, EventArgs e) { string sql = "SELECT * FROM Metrologie"; SqlCommand cmd = new SqlCommand(sql, con); SqlDataReader NrReader; try { con.Open(); NrReader = cmd.ExecuteReader(); // while (NrReader.Read()) { NrReader.Read(); string sNrCantar = NrReader.GetString(0).ToString(); string sSerie_indicator = NrReader.GetString(1).ToString(); string sBuletin_metrologic = NrReader.GetString(2).ToString(); string sClasa_precizie = NrReader.GetString(3).ToString(); string sTip_cantarire = NrReader.GetString(4).ToString(); string sTip_cantar = NrReader.GetString(6).ToString(); // textBoxNrCantar.Text = sNrCantar; textBoxSerieIndicator.Text = sSerie_indicator; textBoxBuletin.Text = sBuletin_metrologic; textBoxClasaPrecizie.Text = sClasa_precizie; textBoxTipCantarire.Text = sTip_cantarire; comboBox1.Text = sTip_cantar; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } }
private void dataGridViewIstoric_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { int RowIndex = e.RowIndex; raportId = int.Parse(dataGridViewIstoric.Rows[RowIndex].Cells[0].Value.ToString()); DataTable dt = rdal.CustomSelect(con, raportId); textBoxCodP = dt.Rows[0].ItemArray[1].ToString(); textBoxCodC = dt.Rows[0].ItemArray[2].ToString(); textBoxCodF = dt.Rows[0].ItemArray[3].ToString(); file.GreutateNeta = dt.Rows[0].ItemArray[4].ToString(); file.DataTichet = dt.Rows[0].ItemArray[5].ToString(); file.NrTichet = dt.Rows[0].ItemArray[6].ToString(); //initializare campuri necompletate file.GreutateBrut = "-"; file.GreutateTara = "-"; //autocomplete produss #region Repopulare produse { string sql = "SELECT * FROM Produse WHERE ID_produs = '" + textBoxCodP + "' "; SqlCommand cmd = new SqlCommand(sql, con); SqlDataReader NrReader; try { con.Open(); NrReader = cmd.ExecuteReader(); { NrReader.Read(); file.DenumireProdus = NrReader.GetString(1).ToString(); file.NaturaProdus = NrReader.GetString(2).ToString(); file.CodProdus = NrReader.GetString(3).ToString(); file.LotProdus = NrReader.GetString(4).ToString(); file.DataExpirariiProdus = NrReader.GetString(5).ToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } } #endregion //autocomplete furnizori #region Repopulare furnizori { string sql = "SELECT * FROM Furnizori WHERE ID_furnizor = '" + textBoxCodF + "' "; SqlCommand cmd = new SqlCommand(sql, con); SqlDataReader NrReader; try { con.Open(); NrReader = cmd.ExecuteReader(); { NrReader.Read(); file.DenumireFurnizor = NrReader.GetString(1).ToString(); file.AdresaFurnizor = NrReader.GetString(2).ToString(); file.CifFurnizor = NrReader.GetString(3).ToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } } #endregion //autocomplete clienti #region Repopulare Clienti { string sql = "SELECT * FROM Clienti WHERE ID_client = '" + textBoxCodC + "' "; SqlCommand cmd = new SqlCommand(sql, con); SqlDataReader NrReader; try { con.Open(); NrReader = cmd.ExecuteReader(); { NrReader.Read(); file.DenumireClient = NrReader.GetString(1).ToString(); file.AdresaClient = NrReader.GetString(2).ToString(); file.CifClient = NrReader.GetString(3).ToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } } #endregion }