Advertisement
Guest User

INV

a guest
Jun 9th, 2013
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 10.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Configuration;
  10. using System.IO;
  11. using System.Data.SqlClient;
  12. using MySql.Data.MySqlClient;
  13.  
  14.  
  15. namespace Inventarverwaltung
  16. {
  17.     public partial class Programm : Form
  18.     {
  19.        
  20.        
  21.         String selectQueryStringInventar = null;
  22.         String selectQueryStringVersand = null;
  23.        
  24.         private MySqlCommandBuilder sqlCommandBuilder = null;
  25.         MySqlConnection sqlConnection = new MySqlConnection(dbconnect);
  26.        
  27.         private MySqlDataAdapter sqlDataAdapterInventar = null;
  28.        
  29.         private DataTable dataTableInventar = null;
  30.         private BindingSource bindingSourceInventar = null;
  31.        
  32.         private MySqlDataAdapter sqlDataAdapterVersand = null;
  33.        
  34.         private DataTable dataTableVersand = null;
  35.         private BindingSource bindingSourceVersand = null;
  36.        
  37.        
  38.         //BindingSource bindingSource = null;
  39.         //
  40.        
  41.         /*MySqlDataAdapter sqlDataAdapterInventar = new MySqlDataAdapter(selectQueryStringInventar, sqlConnection);
  42.             MySqlCommandBuilder sqlCommandBuilderInventar = new MySqlCommandBuilder(sqlDataAdapterInventar);*/
  43.        
  44.        
  45.        
  46.        
  47.        
  48.         /*MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
  49.             MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);*/
  50.        
  51.        
  52.  
  53.        
  54.        
  55.         //Deklaration der SQL-Verbindung mit Hilfe des SQL-Connectors
  56.         //http://dev.mysql.com/downloads/connector/net/
  57.         public static string dbconnect = "Server=localhost;Database=Inventar;Uid=root;Pwd=root;Allow User Variables=True";
  58.        
  59.        
  60.         public Programm()
  61.         {
  62.             InitializeComponent();
  63.            
  64.        
  65.            
  66.            
  67.         }
  68.  
  69.        
  70.         private void btnBeenden_Click(object sender, EventArgs e)
  71.         {
  72.             this.Close();
  73.         }
  74.        
  75.        
  76.         public void CbStandortSelectedIndexChanged(object sender, EventArgs e)
  77.         {
  78.            
  79.            
  80.         }
  81.        
  82.        
  83.        
  84.         void ProgrammLoad(object sender, EventArgs e)
  85.         {
  86.            
  87.            
  88.             selectQueryStringInventar = "SELECT * FROM inventar ORDER BY Kostenstelle;";
  89.             sqlConnection.Open();
  90.             MySqlDataAdapter sqlDataAdapterInventar = new MySqlDataAdapter(selectQueryStringInventar, sqlConnection);
  91.             MySqlCommandBuilder sqlCommandBuilderInventar = new MySqlCommandBuilder(sqlDataAdapterInventar);
  92.             BindingSource bindingSourceInventar = new BindingSource();
  93.             DataTable dataTableInventar = new DataTable();
  94.             sqlDataAdapterInventar.Fill(dataTableInventar);
  95.             bindingSourceInventar.DataSource = dataTableInventar;
  96.             dataGridInventar.DataSource = bindingSourceInventar;
  97.             dataGridInventar.Columns[0].Visible = true;
  98.            
  99.            
  100.            
  101.             //Verarbeitung für die Versandliste
  102.             selectQueryStringVersand = "SELECT * FROM versand;";
  103.             MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
  104.             MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);
  105.             BindingSource bindingSourceVersand = new BindingSource();
  106.             DataTable dataTableVersand = new DataTable();
  107.             sqlDataAdapterVersand.Fill(dataTableVersand);
  108.             bindingSourceVersand.DataSource = dataTableVersand;
  109.  
  110.             dataGridVersand.DataSource = bindingSourceVersand;
  111.            
  112.            
  113.             dataGridVersand.Columns[0].Visible = true;
  114.             sqlConnection.Close();
  115.            
  116.            
  117.         }
  118.  
  119.         void GbGeraetelisteEnter(object sender, EventArgs e)
  120.         {
  121.            
  122.         }
  123.        
  124.         void CbKostenstelleMouseDown(object sender, MouseEventArgs e)
  125.         {
  126. //
  127.         }
  128.        
  129.         public void BtnSpeichernClick(object sender, EventArgs e)
  130.         {
  131.             //          sqlConnection.Open();
  132.             //          selectQueryStringInventar = "SELECT * FROM inventar ORDER BY Kostenstelle;";
  133.             //            MySqlDataAdapter sqlDataAdapterInventar = new MySqlDataAdapter(selectQueryStringInventar, sqlConnection);
  134.             //            MySqlCommandBuilder sqlCommandBuilderInventar = new MySqlCommandBuilder(sqlDataAdapterInventar);
  135. //
  136.             //          sqlCommandBuilderInventar.GetUpdateCommand();
  137.             //          sqlCommandBuilderInventar.GetInsertCommand();
  138.             //          sqlCommandBuilderInventar.GetDeleteCommand();
  139. //
  140. //          dataGridInventar.EndEdit();
  141.             //          sqlDataAdapterInventar.Update(dataTableInventar);
  142. //
  143.            
  144.  
  145.             }
  146.        
  147.        
  148.         public void CbKostenstelleKeyDown(object sender, KeyEventArgs e)
  149.         {
  150.            
  151.             if (e.KeyCode == Keys.Enter)
  152.             {
  153.  
  154.                 if (cbKostenstelle.Text =="" && cbKostenstelle.SelectedItem == null)
  155.                 {
  156.                     selectQueryStringVersand = "SELECT * FROM versand;";
  157.  
  158.                     MySqlConnection sqlConnection = new MySqlConnection(dbconnect);
  159.                     sqlConnection.Open();
  160.                     MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
  161.                     MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);
  162.  
  163.                     DataTable dataTableVersand = new DataTable();
  164.                     sqlDataAdapterVersand.Fill(dataTableVersand);
  165.                     BindingSource bindingSourceVersand = new BindingSource();
  166.                     bindingSourceVersand.DataSource = dataTableVersand;
  167.  
  168.                     dataGridVersand.DataSource = bindingSourceVersand;
  169.                    
  170.  
  171.                 }
  172.  
  173.                 else if (cbKostenstelle.Text != null)
  174.                 {
  175.                     selectQueryStringVersand = "SELECT * FROM versand WHERE Kostenstelle ='" + cbKostenstelle.Text + "';";
  176.  
  177.                     MySqlConnection sqlConnection = new MySqlConnection(dbconnect);
  178.                     sqlConnection.Open();
  179.                    
  180.                     MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
  181.                     MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);
  182.  
  183.                     DataTable dataTableVersand = new DataTable();
  184.                     sqlDataAdapterVersand.Fill(dataTableVersand);
  185.                     BindingSource bindingSourceVersand = new BindingSource();
  186.                     bindingSourceVersand.DataSource = dataTableVersand;
  187.  
  188.                     dataGridVersand.DataSource = bindingSourceVersand;
  189.                 }
  190.             }
  191.         }
  192.  
  193.        
  194.        
  195.        
  196.         public void cbRNR_KeyDown(object sender, KeyEventArgs e)
  197.         {
  198.             if (e.KeyCode == Keys.Enter)
  199.             {
  200.  
  201.                 if (cbRNR.Text == "" && cbRNR.SelectedItem == null)
  202.                 {
  203.                     selectQueryStringVersand = "SELECT * FROM versand;";
  204.  
  205.                     MySqlConnection sqlConnection = new MySqlConnection(dbconnect);
  206.                     sqlConnection.Open();
  207.                     MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
  208.                     MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);
  209.  
  210.                     DataTable dataTableVersand = new DataTable();
  211.                     sqlDataAdapterVersand.Fill(dataTableVersand);
  212.                     BindingSource bindingSourceVersand = new BindingSource();
  213.                     bindingSourceVersand.DataSource = dataTableVersand;
  214.  
  215.                     dataGridVersand.DataSource = bindingSourceVersand;
  216.  
  217.                 }
  218.  
  219.                 else if (cbRNR.Text != null)
  220.                 {
  221.                     selectQueryStringVersand = "SELECT * FROM versand WHERE Rechnungsnummer ='" + cbRNR.Text + "';";
  222.  
  223.                     MySqlConnection sqlConnection = new MySqlConnection(dbconnect);
  224.                     sqlConnection.Open();
  225.                     MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
  226.                     MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);
  227.  
  228.                     DataTable dataTableVersand = new DataTable();
  229.                     sqlDataAdapterVersand.Fill(dataTableVersand);
  230.                     BindingSource bindingSourceVersand = new BindingSource();
  231.                     bindingSourceVersand.DataSource = dataTableVersand;
  232.  
  233.                     dataGridVersand.DataSource = bindingSourceVersand;
  234.                 }
  235.             }
  236.         }
  237.  
  238.         public void txtbGerät_KeyDown(object sender, KeyEventArgs e)
  239.         {
  240.             if (e.KeyCode == Keys.Enter)
  241.             {
  242.  
  243.                 if (txtbGerät.Text == "" && txtbGerät.TextLength == 0)
  244.                 {
  245.                     selectQueryStringVersand = "SELECT * FROM versand;";
  246.  
  247.                     MySqlConnection sqlConnection = new MySqlConnection(dbconnect);
  248.                     sqlConnection.Open();
  249.                     MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
  250.                     MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);
  251.  
  252.                     DataTable dataTableVersand = new DataTable();
  253.                     sqlDataAdapterVersand.Fill(dataTableVersand);
  254.                     BindingSource bindingSourceVersand = new BindingSource();
  255.                     bindingSourceVersand.DataSource = dataTableVersand;
  256.  
  257.                     dataGridVersand.DataSource = bindingSourceVersand;
  258.  
  259.                 }
  260.  
  261.                 else if (txtbGerät.Text != null)
  262.                 {
  263.                     selectQueryStringVersand = "SELECT * FROM versand WHERE Gerät ='" + txtbGerät.Text + "';";
  264.  
  265.                     MySqlConnection sqlConnection = new MySqlConnection(dbconnect);
  266.                     sqlConnection.Open();
  267.                     MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
  268.                     MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);
  269.  
  270.                     DataTable dataTableVersand = new DataTable();
  271.                     sqlDataAdapterVersand.Fill(dataTableVersand);
  272.                     BindingSource bindingSourceVersand = new BindingSource();
  273.                     bindingSourceVersand.DataSource = dataTableVersand;
  274.  
  275.                     dataGridVersand.DataSource = bindingSourceVersand;
  276.                 }
  277.             }
  278.         }
  279.  
  280.         public void txtBOXVDATE_KeyDown(object sender, KeyEventArgs e)
  281.         {
  282.             if (e.KeyCode == Keys.Enter)
  283.             {
  284.  
  285.                 if (txtBOXVDATE.Text == "" && txtBOXVDATE.TextLength == 0)
  286.                 {
  287.                     selectQueryStringVersand = "SELECT * FROM versand;";
  288.  
  289.                     MySqlConnection sqlConnection = new MySqlConnection(dbconnect);
  290.                     sqlConnection.Open();
  291.                     MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
  292.                     MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);
  293.  
  294.                     DataTable dataTableVersand = new DataTable();
  295.                     sqlDataAdapterVersand.Fill(dataTableVersand);
  296.                     BindingSource bindingSourceVersand = new BindingSource();
  297.                     bindingSourceVersand.DataSource = dataTableVersand;
  298.  
  299.                     dataGridVersand.DataSource = bindingSourceVersand;
  300.  
  301.                 }
  302.  
  303.                 else if (txtBOXVDATE.Text != null && txtBOXVDATE.TextLength == 4 || txtBOXVDATE.TextLength == 7 || txtBOXVDATE.TextLength == 10)
  304.                 {
  305.                     selectQueryStringVersand = "SELECT * FROM versand WHERE Versanddatum LIKE '%"+ txtBOXVDATE.Text +"';";
  306.  
  307.                    
  308.                     sqlConnection.Open();
  309.                     MySqlDataAdapter sqlDataAdapterVersand = new MySqlDataAdapter(selectQueryStringVersand, sqlConnection);
  310.                     MySqlCommandBuilder sqlCommandBuilderVersand = new MySqlCommandBuilder(sqlDataAdapterVersand);
  311.  
  312.                     DataTable dataTableVersand = new DataTable();
  313.                     sqlDataAdapterVersand.Fill(dataTableVersand);
  314.                     BindingSource bindingSourceVersand = new BindingSource();
  315.                     bindingSourceVersand.DataSource = dataTableVersand;
  316.  
  317.                     dataGridVersand.DataSource = bindingSourceVersand;
  318.                 }
  319.             }
  320.         }
  321.  
  322.  
  323.  
  324.        
  325.        
  326.         void DataGridInventarCellEndEdit(object sender, DataGridViewCellEventArgs e)
  327.         {
  328.            
  329.            
  330.            
  331.            
  332.            
  333.            
  334.         }
  335.        
  336.         void BindingSource1CurrentChanged(object sender, EventArgs e)
  337.         {
  338.            
  339.         }
  340.     }
  341. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement