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.Windows.Forms;
- using System.Configuration;
- using System.IO;
- using System.Data.SqlClient;
- using MySql.Data.MySqlClient;
- namespace Inventarverwaltung
- {
- public partial class Programm : Form
- {
- String selectQueryStringInventar = null;
- String selectQueryStringVersand = null;
- private MySqlCommandBuilder sqlCommandBuilder = null;
- MySqlConnection sqlConnection = new MySqlConnection(dbconnect);
- private MySqlDataAdapter sqlDataAdapterInventar = null;
- private DataTable dataTableInventar = null;
- private BindingSource bindingSourceInventar = null;
- private MySqlDataAdapter sqlDataAdapterVersand = null;
- private DataTable dataTableVersand = null;
- private BindingSource bindingSourceVersand = null;
- //BindingSource bindingSource = null;
- //
- /*MySqlDataAdapter sqlDataAdapterInventar = new MySqlDataAdapter(selectQueryStringInventar, sqlConnection);
- MySqlCommandBuilder sqlCommandBuilderInventar = new MySqlCommandBuilder(sqlDataAdapterInventar);*/
- /*MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
- MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);*/
- //Deklaration der SQL-Verbindung mit Hilfe des SQL-Connectors
- //http://dev.mysql.com/downloads/connector/net/
- public static string dbconnect = "Server=localhost;Database=Inventar;Uid=root;Pwd=root;Allow User Variables=True";
- public Programm()
- {
- InitializeComponent();
- }
- private void btnBeenden_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- public void CbStandortSelectedIndexChanged(object sender, EventArgs e)
- {
- }
- void ProgrammLoad(object sender, EventArgs e)
- {
- selectQueryStringInventar = "SELECT * FROM inventar ORDER BY Kostenstelle;";
- sqlConnection.Open();
- MySqlDataAdapter sqlDataAdapterInventar = new MySqlDataAdapter(selectQueryStringInventar, sqlConnection);
- MySqlCommandBuilder sqlCommandBuilderInventar = new MySqlCommandBuilder(sqlDataAdapterInventar);
- BindingSource bindingSourceInventar = new BindingSource();
- DataTable dataTableInventar = new DataTable();
- sqlDataAdapterInventar.Fill(dataTableInventar);
- bindingSourceInventar.DataSource = dataTableInventar;
- dataGridInventar.DataSource = bindingSourceInventar;
- dataGridInventar.Columns[0].Visible = true;
- //Verarbeitung für die Versandliste
- selectQueryStringVersand = "SELECT * FROM versand;";
- MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
- MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);
- BindingSource bindingSourceVersand = new BindingSource();
- DataTable dataTableVersand = new DataTable();
- sqlDataAdapterVersand.Fill(dataTableVersand);
- bindingSourceVersand.DataSource = dataTableVersand;
- dataGridVersand.DataSource = bindingSourceVersand;
- dataGridVersand.Columns[0].Visible = true;
- sqlConnection.Close();
- }
- void GbGeraetelisteEnter(object sender, EventArgs e)
- {
- }
- void CbKostenstelleMouseDown(object sender, MouseEventArgs e)
- {
- //
- }
- public void BtnSpeichernClick(object sender, EventArgs e)
- {
- // sqlConnection.Open();
- // selectQueryStringInventar = "SELECT * FROM inventar ORDER BY Kostenstelle;";
- // MySqlDataAdapter sqlDataAdapterInventar = new MySqlDataAdapter(selectQueryStringInventar, sqlConnection);
- // MySqlCommandBuilder sqlCommandBuilderInventar = new MySqlCommandBuilder(sqlDataAdapterInventar);
- //
- // sqlCommandBuilderInventar.GetUpdateCommand();
- // sqlCommandBuilderInventar.GetInsertCommand();
- // sqlCommandBuilderInventar.GetDeleteCommand();
- //
- // dataGridInventar.EndEdit();
- // sqlDataAdapterInventar.Update(dataTableInventar);
- //
- }
- public void CbKostenstelleKeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (cbKostenstelle.Text =="" && cbKostenstelle.SelectedItem == null)
- {
- selectQueryStringVersand = "SELECT * FROM versand;";
- MySqlConnection sqlConnection = new MySqlConnection(dbconnect);
- sqlConnection.Open();
- MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
- MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);
- DataTable dataTableVersand = new DataTable();
- sqlDataAdapterVersand.Fill(dataTableVersand);
- BindingSource bindingSourceVersand = new BindingSource();
- bindingSourceVersand.DataSource = dataTableVersand;
- dataGridVersand.DataSource = bindingSourceVersand;
- }
- else if (cbKostenstelle.Text != null)
- {
- selectQueryStringVersand = "SELECT * FROM versand WHERE Kostenstelle ='" + cbKostenstelle.Text + "';";
- MySqlConnection sqlConnection = new MySqlConnection(dbconnect);
- sqlConnection.Open();
- MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
- MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);
- DataTable dataTableVersand = new DataTable();
- sqlDataAdapterVersand.Fill(dataTableVersand);
- BindingSource bindingSourceVersand = new BindingSource();
- bindingSourceVersand.DataSource = dataTableVersand;
- dataGridVersand.DataSource = bindingSourceVersand;
- }
- }
- }
- public void cbRNR_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (cbRNR.Text == "" && cbRNR.SelectedItem == null)
- {
- selectQueryStringVersand = "SELECT * FROM versand;";
- MySqlConnection sqlConnection = new MySqlConnection(dbconnect);
- sqlConnection.Open();
- MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
- MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);
- DataTable dataTableVersand = new DataTable();
- sqlDataAdapterVersand.Fill(dataTableVersand);
- BindingSource bindingSourceVersand = new BindingSource();
- bindingSourceVersand.DataSource = dataTableVersand;
- dataGridVersand.DataSource = bindingSourceVersand;
- }
- else if (cbRNR.Text != null)
- {
- selectQueryStringVersand = "SELECT * FROM versand WHERE Rechnungsnummer ='" + cbRNR.Text + "';";
- MySqlConnection sqlConnection = new MySqlConnection(dbconnect);
- sqlConnection.Open();
- MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
- MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);
- DataTable dataTableVersand = new DataTable();
- sqlDataAdapterVersand.Fill(dataTableVersand);
- BindingSource bindingSourceVersand = new BindingSource();
- bindingSourceVersand.DataSource = dataTableVersand;
- dataGridVersand.DataSource = bindingSourceVersand;
- }
- }
- }
- public void txtbGerät_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (txtbGerät.Text == "" && txtbGerät.TextLength == 0)
- {
- selectQueryStringVersand = "SELECT * FROM versand;";
- MySqlConnection sqlConnection = new MySqlConnection(dbconnect);
- sqlConnection.Open();
- MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
- MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);
- DataTable dataTableVersand = new DataTable();
- sqlDataAdapterVersand.Fill(dataTableVersand);
- BindingSource bindingSourceVersand = new BindingSource();
- bindingSourceVersand.DataSource = dataTableVersand;
- dataGridVersand.DataSource = bindingSourceVersand;
- }
- else if (txtbGerät.Text != null)
- {
- selectQueryStringVersand = "SELECT * FROM versand WHERE Gerät ='" + txtbGerät.Text + "';";
- MySqlConnection sqlConnection = new MySqlConnection(dbconnect);
- sqlConnection.Open();
- MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
- MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);
- DataTable dataTableVersand = new DataTable();
- sqlDataAdapterVersand.Fill(dataTableVersand);
- BindingSource bindingSourceVersand = new BindingSource();
- bindingSourceVersand.DataSource = dataTableVersand;
- dataGridVersand.DataSource = bindingSourceVersand;
- }
- }
- }
- public void txtBOXVDATE_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (txtBOXVDATE.Text == "" && txtBOXVDATE.TextLength == 0)
- {
- selectQueryStringVersand = "SELECT * FROM versand;";
- MySqlConnection sqlConnection = new MySqlConnection(dbconnect);
- sqlConnection.Open();
- MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
- MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);
- DataTable dataTableVersand = new DataTable();
- sqlDataAdapterVersand.Fill(dataTableVersand);
- BindingSource bindingSourceVersand = new BindingSource();
- bindingSourceVersand.DataSource = dataTableVersand;
- dataGridVersand.DataSource = bindingSourceVersand;
- }
- else if (txtBOXVDATE.Text != null && txtBOXVDATE.TextLength == 4 || txtBOXVDATE.TextLength == 7 || txtBOXVDATE.TextLength == 10)
- {
- selectQueryStringVersand = "SELECT * FROM versand WHERE Versanddatum LIKE '%"+ txtBOXVDATE.Text +"';";
- sqlConnection.Open();
- MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
- MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);
- DataTable dataTableVersand = new DataTable();
- sqlDataAdapterVersand.Fill(dataTableVersand);
- BindingSource bindingSourceVersand = new BindingSource();
- bindingSourceVersand.DataSource = dataTableVersand;
- dataGridVersand.DataSource = bindingSourceVersand;
- }
- }
- }
- void DataGridInventarCellEndEdit(object sender, DataGridViewCellEventArgs e)
- {
- }
- void BindingSource1CurrentChanged(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement