using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Data.SqlClient; namespace Bestand { /// /// Zusammenfassung für Form1. /// public class Home : System.Windows.Forms.Form { private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button1; private System.Windows.Forms.Label label3; private System.Windows.Forms.ComboBox comboBox1; private System.Windows.Forms.Label label2; private System.Windows.Forms.TabPage NS; private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.TextBox Seriennummer; private System.Windows.Forms.Label label4; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TabPage edit; private System.Windows.Forms.Button button4; private System.Windows.Forms.TabPage Model; private System.Windows.Forms.ComboBox comboBox3; private System.Data.SqlClient.SqlConnection sqlConnection1; private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem menuItem2; private System.Data.SqlClient.SqlDataAdapter sqlDAHardwaretyp; private System.Data.SqlClient.SqlDataAdapter sqlDAHardware; private System.Windows.Forms.Button delete; private System.Data.SqlClient.SqlDataAdapter sqlHersteller; private WindowsApplication1.dsHersteller dsHersteller1; private System.Windows.Forms.Button button5; private System.Data.SqlClient.SqlCommand sqlSelectCommand2; private System.Data.SqlClient.SqlCommand sqlInsertCommand2; private WindowsApplication1.dsHardware dsHardware1; private System.Data.SqlClient.SqlCommand sqlSelectCommand1; private System.Data.SqlClient.SqlCommand sqlInsertCommand1; private System.Data.SqlClient.SqlCommand sqlUpdateCommand2; private System.Data.SqlClient.SqlCommand sqlDeleteCommand2; private System.Data.SqlClient.SqlCommand sqlSelectCommand3; private System.Data.SqlClient.SqlCommand sqlInsertCommand3; private System.Data.SqlClient.SqlCommand sqlUpdateCommand1; private System.Data.SqlClient.SqlCommand sqlDeleteCommand1; private WindowsApplication1.DataSet1 dsHardwaretyp; private System.Windows.Forms.Label label8; private System.Windows.Forms.TextBox textBox3; private System.Windows.Forms.Label label7; private System.Windows.Forms.Label label6; private System.Windows.Forms.ListBox listBox1; private System.Windows.Forms.Button button6; private System.Windows.Forms.Button suchen; private System.Windows.Forms.TextBox textBox2; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.TextBox textBox4; private System.Windows.Forms.TabPage suche; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.TextBox textBox5; private System.Windows.Forms.GroupBox groupBox3; private System.Windows.Forms.GroupBox groupBox4; private System.Windows.Forms.Label label1; private System.Windows.Forms.ListBox listBox2; private System.Windows.Forms.Button button8; private System.Windows.Forms.GroupBox groupBox5; private System.Windows.Forms.Button testbutton; private System.Windows.Forms.ComboBox comboBox2; private System.Windows.Forms.TextBox suchfeld; private System.Windows.Forms.TabPage Zuordnung; private System.Windows.Forms.ComboBox comboBox4; private System.Windows.Forms.Label label5; private System.Windows.Forms.ListBox listBox3; private System.Windows.Forms.Button button10; private System.Windows.Forms.GroupBox groupBox6; private System.Windows.Forms.TextBox suchfeld2; private System.Windows.Forms.TextBox textBox6; private System.Windows.Forms.Label label9; private System.Windows.Forms.Label label10; private System.Windows.Forms.Button button11; private System.Windows.Forms.Button button12; private System.Windows.Forms.TabPage test; private System.Windows.Forms.DataGrid dataGrid1; private System.Windows.Forms.Button button13; /// /// Erforderliche Designervariable. /// private System.ComponentModel.Container components = null; public Home() { // // Erforderlich für die Windows Form-Designerunterstützung // InitializeComponent(); // Füllt das Dataset mit Daten beim Inizialisieren des Forms, wird // für die Bereitstellung der Daten in den Drop Down Elementen benötigt try { sqlConnection1.Open(); sqlDAHardwaretyp.Fill(dsHardwaretyp); sqlHersteller.Fill(dsHersteller1); sqlConnection1.Close(); } catch(Exception ex) { MessageBox.Show("Fehler " + ex.Message, "Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error); } } /// /// Die verwendeten Ressourcen bereinigen. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Vom Windows Form-Designer generierter Code /// /// Erforderliche Methode für die Designerunterstützung. /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. /// private void InitializeComponent() { this.Model = new System.Windows.Forms.TabPage(); this.button5 = new System.Windows.Forms.Button(); this.delete = new System.Windows.Forms.Button(); this.comboBox3 = new System.Windows.Forms.ComboBox(); this.dsHardwaretyp = new WindowsApplication1.DataSet1(); this.button4 = new System.Windows.Forms.Button(); this.textBox1 = new System.Windows.Forms.TextBox(); this.Seriennummer = new System.Windows.Forms.TextBox(); this.label4 = new System.Windows.Forms.Label(); this.button3 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); this.label3 = new System.Windows.Forms.Label(); this.comboBox1 = new System.Windows.Forms.ComboBox(); this.dsHersteller1 = new WindowsApplication1.dsHersteller(); this.label2 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.groupBox4 = new System.Windows.Forms.GroupBox(); this.NS = new System.Windows.Forms.TabPage(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.suche = new System.Windows.Forms.TabPage(); this.textBox5 = new System.Windows.Forms.TextBox(); this.label8 = new System.Windows.Forms.Label(); this.textBox3 = new System.Windows.Forms.TextBox(); this.label7 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.listBox1 = new System.Windows.Forms.ListBox(); this.button6 = new System.Windows.Forms.Button(); this.suchen = new System.Windows.Forms.Button(); this.textBox2 = new System.Windows.Forms.TextBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.label10 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label(); this.textBox6 = new System.Windows.Forms.TextBox(); this.textBox4 = new System.Windows.Forms.TextBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.edit = new System.Windows.Forms.TabPage(); this.Zuordnung = new System.Windows.Forms.TabPage(); this.button12 = new System.Windows.Forms.Button(); this.button11 = new System.Windows.Forms.Button(); this.comboBox4 = new System.Windows.Forms.ComboBox(); this.label5 = new System.Windows.Forms.Label(); this.listBox3 = new System.Windows.Forms.ListBox(); this.button10 = new System.Windows.Forms.Button(); this.suchfeld2 = new System.Windows.Forms.TextBox(); this.groupBox6 = new System.Windows.Forms.GroupBox(); this.comboBox2 = new System.Windows.Forms.ComboBox(); this.testbutton = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.listBox2 = new System.Windows.Forms.ListBox(); this.button8 = new System.Windows.Forms.Button(); this.suchfeld = new System.Windows.Forms.TextBox(); this.groupBox5 = new System.Windows.Forms.GroupBox(); this.test = new System.Windows.Forms.TabPage(); this.button13 = new System.Windows.Forms.Button(); this.dataGrid1 = new System.Windows.Forms.DataGrid(); this.sqlConnection1 = new System.Data.SqlClient.SqlConnection(); this.mainMenu1 = new System.Windows.Forms.MainMenu(); this.menuItem1 = new System.Windows.Forms.MenuItem(); this.menuItem2 = new System.Windows.Forms.MenuItem(); this.sqlDAHardwaretyp = new System.Data.SqlClient.SqlDataAdapter(); this.sqlDeleteCommand2 = new System.Data.SqlClient.SqlCommand(); this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlUpdateCommand2 = new System.Data.SqlClient.SqlCommand(); this.sqlDAHardware = new System.Data.SqlClient.SqlDataAdapter(); this.sqlInsertCommand2 = new System.Data.SqlClient.SqlCommand(); this.sqlSelectCommand2 = new System.Data.SqlClient.SqlCommand(); this.sqlHersteller = new System.Data.SqlClient.SqlDataAdapter(); this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlInsertCommand3 = new System.Data.SqlClient.SqlCommand(); this.sqlSelectCommand3 = new System.Data.SqlClient.SqlCommand(); this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand(); this.dsHardware1 = new WindowsApplication1.dsHardware(); this.Model.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dsHardwaretyp)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dsHersteller1)).BeginInit(); this.tabControl1.SuspendLayout(); this.suche.SuspendLayout(); this.groupBox1.SuspendLayout(); this.Zuordnung.SuspendLayout(); this.test.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dsHardware1)).BeginInit(); this.SuspendLayout(); // // Model // this.Model.Controls.Add(this.button5); this.Model.Controls.Add(this.delete); this.Model.Controls.Add(this.comboBox3); this.Model.Controls.Add(this.button4); this.Model.Controls.Add(this.textBox1); this.Model.Controls.Add(this.Seriennummer); this.Model.Controls.Add(this.label4); this.Model.Controls.Add(this.button3); this.Model.Controls.Add(this.button2); this.Model.Controls.Add(this.button1); this.Model.Controls.Add(this.label3); this.Model.Controls.Add(this.comboBox1); this.Model.Controls.Add(this.label2); this.Model.Controls.Add(this.groupBox3); this.Model.Controls.Add(this.groupBox4); this.Model.Cursor = System.Windows.Forms.Cursors.Default; this.Model.Font = new System.Drawing.Font("Microsoft Sans Serif", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.Model.Location = new System.Drawing.Point(4, 22); this.Model.Name = "Model"; this.Model.Size = new System.Drawing.Size(968, 574); this.Model.TabIndex = 0; this.Model.Text = "Neue Hardware"; this.Model.ToolTipText = "Neue Hardware"; this.Model.Click += new System.EventHandler(this.NH_Click); // // button5 // this.button5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.button5.Location = new System.Drawing.Point(16, 192); this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(72, 23); this.button5.TabIndex = 20; this.button5.Text = "Löschen"; this.button5.Click += new System.EventHandler(this.button5_Click); // // delete // this.delete.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.delete.Location = new System.Drawing.Point(16, 96); this.delete.Name = "delete"; this.delete.Size = new System.Drawing.Size(72, 23); this.delete.TabIndex = 19; this.delete.Text = "Löschen"; this.delete.Click += new System.EventHandler(this.delete_Click); // // comboBox3 // this.comboBox3.DataSource = this.dsHardwaretyp; this.comboBox3.DisplayMember = "hardtyp.hardWareTyp"; this.comboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.comboBox3.ItemHeight = 13; this.comboBox3.Location = new System.Drawing.Point(16, 64); this.comboBox3.Name = "comboBox3"; this.comboBox3.Size = new System.Drawing.Size(128, 21); this.comboBox3.TabIndex = 16; this.comboBox3.Tag = ""; this.comboBox3.ValueMember = "hardtyp.HWID"; this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged); // // dsHardwaretyp // this.dsHardwaretyp.DataSetName = "DataSet1"; this.dsHardwaretyp.Locale = new System.Globalization.CultureInfo("de-DE"); // // button4 // this.button4.Enabled = false; this.button4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.button4.Location = new System.Drawing.Point(360, 264); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(64, 24); this.button4.TabIndex = 11; this.button4.Text = "OK"; this.button4.Click += new System.EventHandler(this.button4_Click); // // textBox1 // this.textBox1.AcceptsReturn = true; this.textBox1.AutoSize = false; this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.textBox1.Location = new System.Drawing.Point(264, 40); this.textBox1.Multiline = true; this.textBox1.Name = "textBox1"; this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.textBox1.Size = new System.Drawing.Size(232, 200); this.textBox1.TabIndex = 10; this.textBox1.Text = ""; this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); // // Seriennummer // this.Seriennummer.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.Seriennummer.Location = new System.Drawing.Point(16, 256); this.Seriennummer.Name = "Seriennummer"; this.Seriennummer.Size = new System.Drawing.Size(208, 20); this.Seriennummer.TabIndex = 8; this.Seriennummer.Text = ""; this.Seriennummer.TextChanged += new System.EventHandler(this.Seriennummer_TextChanged); // // label4 // this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label4.Location = new System.Drawing.Point(16, 232); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(136, 24); this.label4.TabIndex = 9; this.label4.Text = "Seriennummer"; this.label4.Click += new System.EventHandler(this.label4_Click); // // button3 // this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.button3.Location = new System.Drawing.Point(152, 160); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(72, 24); this.button3.TabIndex = 7; this.button3.Text = "Neu"; this.button3.Click += new System.EventHandler(this.button3_Click); // // button2 // this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.button2.Location = new System.Drawing.Point(152, 64); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(72, 24); this.button2.TabIndex = 6; this.button2.Text = "Neu"; this.button2.Click += new System.EventHandler(this.button2_Click); // // button1 // this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.button1.Location = new System.Drawing.Point(432, 264); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(64, 24); this.button1.TabIndex = 5; this.button1.Text = "Exit"; this.button1.Click += new System.EventHandler(this.button1_Click); // // label3 // this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label3.Location = new System.Drawing.Point(16, 136); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(136, 24); this.label3.TabIndex = 4; this.label3.Text = "Hersteller"; // // comboBox1 // this.comboBox1.DataSource = this.dsHersteller1; this.comboBox1.DisplayMember = "hersteller.Hersteller"; this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.comboBox1.ItemHeight = 13; this.comboBox1.Location = new System.Drawing.Point(16, 160); this.comboBox1.Name = "comboBox1"; this.comboBox1.Size = new System.Drawing.Size(128, 21); this.comboBox1.TabIndex = 3; this.comboBox1.ValueMember = "hersteller.ID"; this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged_1); // // dsHersteller1 // this.dsHersteller1.DataSetName = "dsHersteller"; this.dsHersteller1.Locale = new System.Globalization.CultureInfo("de-DE"); // // label2 // this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label2.Location = new System.Drawing.Point(16, 40); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(136, 24); this.label2.TabIndex = 2; this.label2.Text = "Hardware Typ"; this.label2.Click += new System.EventHandler(this.label2_Click); // // groupBox3 // this.groupBox3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.groupBox3.Location = new System.Drawing.Point(256, 16); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(256, 232); this.groupBox3.TabIndex = 22; this.groupBox3.TabStop = false; this.groupBox3.Text = "Bemerkungen"; // // groupBox4 // this.groupBox4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.groupBox4.Location = new System.Drawing.Point(8, 16); this.groupBox4.Name = "groupBox4"; this.groupBox4.Size = new System.Drawing.Size(240, 277); this.groupBox4.TabIndex = 23; this.groupBox4.TabStop = false; this.groupBox4.Text = "Neue Hardware"; // // NS // this.NS.Cursor = System.Windows.Forms.Cursors.Hand; this.NS.Location = new System.Drawing.Point(4, 22); this.NS.Name = "NS"; this.NS.Size = new System.Drawing.Size(968, 574); this.NS.TabIndex = 1; this.NS.Text = "Neue Software"; this.NS.ToolTipText = "Neue Software"; this.NS.Click += new System.EventHandler(this.NS_Click); // // tabControl1 // this.tabControl1.Controls.Add(this.Model); this.tabControl1.Controls.Add(this.NS); this.tabControl1.Controls.Add(this.suche); this.tabControl1.Controls.Add(this.edit); this.tabControl1.Controls.Add(this.Zuordnung); this.tabControl1.Controls.Add(this.test); this.tabControl1.Cursor = System.Windows.Forms.Cursors.Default; this.tabControl1.ImeMode = System.Windows.Forms.ImeMode.NoControl; this.tabControl1.ItemSize = new System.Drawing.Size(42, 18); this.tabControl1.Location = new System.Drawing.Point(8, 0); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; this.tabControl1.Size = new System.Drawing.Size(976, 600); this.tabControl1.TabIndex = 0; this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged_1); // // suche // this.suche.Controls.Add(this.textBox5); this.suche.Controls.Add(this.label8); this.suche.Controls.Add(this.textBox3); this.suche.Controls.Add(this.label7); this.suche.Controls.Add(this.label6); this.suche.Controls.Add(this.listBox1); this.suche.Controls.Add(this.button6); this.suche.Controls.Add(this.suchen); this.suche.Controls.Add(this.textBox2); this.suche.Controls.Add(this.groupBox1); this.suche.Controls.Add(this.groupBox2); this.suche.Cursor = System.Windows.Forms.Cursors.Default; this.suche.Location = new System.Drawing.Point(4, 22); this.suche.Name = "suche"; this.suche.Size = new System.Drawing.Size(968, 574); this.suche.TabIndex = 3; this.suche.Text = "Suche"; this.suche.ToolTipText = "Suche in den Datensätzen"; this.suche.Click += new System.EventHandler(this.suche_Click); // // textBox5 // this.textBox5.Location = new System.Drawing.Point(256, 136); this.textBox5.Multiline = true; this.textBox5.Name = "textBox5"; this.textBox5.ReadOnly = true; this.textBox5.Size = new System.Drawing.Size(248, 144); this.textBox5.TabIndex = 14; this.textBox5.Text = ""; this.textBox5.TextChanged += new System.EventHandler(this.textBox5_TextChanged); // // label8 // this.label8.Location = new System.Drawing.Point(16, 24); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(100, 16); this.label8.TabIndex = 12; this.label8.Text = "Seriennummer"; // // textBox3 // this.textBox3.Location = new System.Drawing.Point(256, 40); this.textBox3.Name = "textBox3"; this.textBox3.ReadOnly = true; this.textBox3.Size = new System.Drawing.Size(248, 20); this.textBox3.TabIndex = 11; this.textBox3.Text = ""; this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged); // // label7 // this.label7.Location = new System.Drawing.Point(256, 72); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(100, 16); this.label7.TabIndex = 9; this.label7.Text = "Typ"; // // label6 // this.label6.Location = new System.Drawing.Point(256, 24); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(100, 16); this.label6.TabIndex = 7; this.label6.Text = "Hersteller"; // // listBox1 // this.listBox1.Location = new System.Drawing.Point(16, 104); this.listBox1.Name = "listBox1"; this.listBox1.Size = new System.Drawing.Size(192, 82); this.listBox1.TabIndex = 5; this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged_1); // // button6 // this.button6.Location = new System.Drawing.Point(96, 72); this.button6.Name = "button6"; this.button6.TabIndex = 4; this.button6.Text = "Daten holen"; this.button6.Click += new System.EventHandler(this.button6_Click); // // suchen // this.suchen.Location = new System.Drawing.Point(16, 72); this.suchen.Name = "suchen"; this.suchen.TabIndex = 1; this.suchen.Text = "Suchen"; this.suchen.Click += new System.EventHandler(this.suchen_Click); // // textBox2 // this.textBox2.Location = new System.Drawing.Point(16, 40); this.textBox2.Name = "textBox2"; this.textBox2.Size = new System.Drawing.Size(192, 20); this.textBox2.TabIndex = 0; this.textBox2.Text = ""; this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged); // // groupBox1 // this.groupBox1.Controls.Add(this.label10); this.groupBox1.Controls.Add(this.label9); this.groupBox1.Controls.Add(this.textBox6); this.groupBox1.Controls.Add(this.textBox4); this.groupBox1.Location = new System.Drawing.Point(240, 8); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(544, 424); this.groupBox1.TabIndex = 10; this.groupBox1.TabStop = false; this.groupBox1.Text = "Info"; // // label10 // this.label10.Location = new System.Drawing.Point(16, 280); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(100, 16); this.label10.TabIndex = 14; this.label10.Text = "Zugeordnet auf"; // // label9 // this.label9.Location = new System.Drawing.Point(16, 112); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(100, 16); this.label9.TabIndex = 13; this.label9.Text = "Bemerkungen"; // // textBox6 // this.textBox6.Location = new System.Drawing.Point(16, 296); this.textBox6.Name = "textBox6"; this.textBox6.ReadOnly = true; this.textBox6.Size = new System.Drawing.Size(248, 20); this.textBox6.TabIndex = 12; this.textBox6.Text = ""; // // textBox4 // this.textBox4.Location = new System.Drawing.Point(16, 80); this.textBox4.Name = "textBox4"; this.textBox4.ReadOnly = true; this.textBox4.Size = new System.Drawing.Size(248, 20); this.textBox4.TabIndex = 0; this.textBox4.Text = ""; // // groupBox2 // this.groupBox2.Location = new System.Drawing.Point(8, 8); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(216, 192); this.groupBox2.TabIndex = 13; this.groupBox2.TabStop = false; this.groupBox2.Text = "Suche"; // // edit // this.edit.Location = new System.Drawing.Point(4, 22); this.edit.Name = "edit"; this.edit.Size = new System.Drawing.Size(968, 574); this.edit.TabIndex = 2; this.edit.Text = "Editieren"; this.edit.ToolTipText = "Editieren vorhandener Datensätze"; // // Zuordnung // this.Zuordnung.Controls.Add(this.button12); this.Zuordnung.Controls.Add(this.button11); this.Zuordnung.Controls.Add(this.comboBox4); this.Zuordnung.Controls.Add(this.label5); this.Zuordnung.Controls.Add(this.listBox3); this.Zuordnung.Controls.Add(this.button10); this.Zuordnung.Controls.Add(this.suchfeld2); this.Zuordnung.Controls.Add(this.groupBox6); this.Zuordnung.Controls.Add(this.comboBox2); this.Zuordnung.Controls.Add(this.testbutton); this.Zuordnung.Controls.Add(this.label1); this.Zuordnung.Controls.Add(this.listBox2); this.Zuordnung.Controls.Add(this.button8); this.Zuordnung.Controls.Add(this.suchfeld); this.Zuordnung.Controls.Add(this.groupBox5); this.Zuordnung.Location = new System.Drawing.Point(4, 22); this.Zuordnung.Name = "Zuordnung"; this.Zuordnung.Size = new System.Drawing.Size(968, 574); this.Zuordnung.TabIndex = 4; this.Zuordnung.Text = "Zuordnung"; this.Zuordnung.Click += new System.EventHandler(this.Benutzerverwaltung_Click); // // button12 // this.button12.Location = new System.Drawing.Point(344, 144); this.button12.Name = "button12"; this.button12.Size = new System.Drawing.Size(96, 23); this.button12.TabIndex = 32; this.button12.Text = "Neuer Standort"; // // button11 // this.button11.Location = new System.Drawing.Point(344, 176); this.button11.Name = "button11"; this.button11.Size = new System.Drawing.Size(96, 23); this.button11.TabIndex = 31; this.button11.Text = "Neuer Bearbeiter"; this.button11.Click += new System.EventHandler(this.button11_Click); // // comboBox4 // this.comboBox4.Items.AddRange(new object[] { "Nachname", "Arbeitsplatz", "Software", "Hardware"}); this.comboBox4.Location = new System.Drawing.Point(472, 40); this.comboBox4.Name = "comboBox4"; this.comboBox4.Size = new System.Drawing.Size(192, 21); this.comboBox4.TabIndex = 29; this.comboBox4.Tag = ""; this.comboBox4.Text = "Bitte Wählen..."; // // label5 // this.label5.Location = new System.Drawing.Point(472, 72); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(100, 16); this.label5.TabIndex = 27; this.label5.Text = "Suche"; // // listBox3 // this.listBox3.Location = new System.Drawing.Point(472, 152); this.listBox3.Name = "listBox3"; this.listBox3.Size = new System.Drawing.Size(192, 238); this.listBox3.TabIndex = 26; this.listBox3.SelectedIndexChanged += new System.EventHandler(this.listBox3_SelectedIndexChanged); // // button10 // this.button10.Location = new System.Drawing.Point(472, 120); this.button10.Name = "button10"; this.button10.TabIndex = 24; this.button10.Text = "Suchen"; this.button10.Click += new System.EventHandler(this.button10_Click); // // suchfeld2 // this.suchfeld2.Location = new System.Drawing.Point(472, 88); this.suchfeld2.Name = "suchfeld2"; this.suchfeld2.Size = new System.Drawing.Size(192, 20); this.suchfeld2.TabIndex = 23; this.suchfeld2.Text = ""; // // groupBox6 // this.groupBox6.Location = new System.Drawing.Point(464, 16); this.groupBox6.Name = "groupBox6"; this.groupBox6.Size = new System.Drawing.Size(216, 392); this.groupBox6.TabIndex = 28; this.groupBox6.TabStop = false; this.groupBox6.Text = "Zuordnung B"; // // comboBox2 // this.comboBox2.Items.AddRange(new object[] { "Hardware", "Software"}); this.comboBox2.Location = new System.Drawing.Point(112, 40); this.comboBox2.Name = "comboBox2"; this.comboBox2.Size = new System.Drawing.Size(192, 21); this.comboBox2.TabIndex = 21; this.comboBox2.Tag = ""; this.comboBox2.Text = "Bitte Wählen..."; // // testbutton // this.testbutton.Location = new System.Drawing.Point(344, 208); this.testbutton.Name = "testbutton"; this.testbutton.Size = new System.Drawing.Size(96, 23); this.testbutton.TabIndex = 20; this.testbutton.Text = "<-- Zuordnen -->"; this.testbutton.Click += new System.EventHandler(this.testbutton_Click); // // label1 // this.label1.Location = new System.Drawing.Point(112, 72); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(100, 16); this.label1.TabIndex = 18; this.label1.Text = "Suche"; // // listBox2 // this.listBox2.Location = new System.Drawing.Point(112, 152); this.listBox2.Name = "listBox2"; this.listBox2.Size = new System.Drawing.Size(192, 238); this.listBox2.TabIndex = 17; // // button8 // this.button8.Location = new System.Drawing.Point(112, 120); this.button8.Name = "button8"; this.button8.TabIndex = 15; this.button8.Text = "Suchen"; this.button8.Click += new System.EventHandler(this.button8_Click); // // suchfeld // this.suchfeld.Location = new System.Drawing.Point(112, 88); this.suchfeld.Name = "suchfeld"; this.suchfeld.Size = new System.Drawing.Size(192, 20); this.suchfeld.TabIndex = 14; this.suchfeld.Text = ""; // // groupBox5 // this.groupBox5.Location = new System.Drawing.Point(104, 16); this.groupBox5.Name = "groupBox5"; this.groupBox5.Size = new System.Drawing.Size(216, 392); this.groupBox5.TabIndex = 19; this.groupBox5.TabStop = false; this.groupBox5.Text = "Zuordnung A"; // // test // this.test.Controls.Add(this.button13); this.test.Controls.Add(this.dataGrid1); this.test.Location = new System.Drawing.Point(4, 22); this.test.Name = "test"; this.test.Size = new System.Drawing.Size(968, 574); this.test.TabIndex = 5; this.test.Text = "test"; // // button13 // this.button13.Location = new System.Drawing.Point(40, 336); this.button13.Name = "button13"; this.button13.TabIndex = 1; this.button13.Text = "Einlesen"; this.button13.Click += new System.EventHandler(this.button13_Click_1); // // dataGrid1 // this.dataGrid1.DataMember = ""; this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.dataGrid1.Location = new System.Drawing.Point(40, 32); this.dataGrid1.Name = "dataGrid1"; this.dataGrid1.Size = new System.Drawing.Size(696, 288); this.dataGrid1.TabIndex = 0; // // sqlConnection1 // this.sqlConnection1.ConnectionString = "workstation id=KATZENCLO;packet size=4096;integrated security=SSPI;data source=KA" + "TZENCLO;persist security info=False;initial catalog=Bestand"; this.sqlConnection1.InfoMessage += new System.Data.SqlClient.SqlInfoMessageEventHandler(this.sqlConnection1_InfoMessage); // // mainMenu1 // this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem1}); // // menuItem1 // this.menuItem1.Index = 0; this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem2}); this.menuItem1.RadioCheck = true; this.menuItem1.Shortcut = System.Windows.Forms.Shortcut.CtrlD; this.menuItem1.ShowShortcut = false; this.menuItem1.Text = "Datei"; // // menuItem2 // this.menuItem2.Index = 0; this.menuItem2.Shortcut = System.Windows.Forms.Shortcut.CtrlB; this.menuItem2.Text = "Beenden"; this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click); // // sqlDAHardwaretyp // this.sqlDAHardwaretyp.DeleteCommand = this.sqlDeleteCommand2; this.sqlDAHardwaretyp.InsertCommand = this.sqlInsertCommand1; this.sqlDAHardwaretyp.SelectCommand = this.sqlSelectCommand1; this.sqlDAHardwaretyp.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] { new System.Data.Common.DataTableMapping("Table", "hardtyp", new System.Data.Common.DataColumnMapping[] { new System.Data.Common.DataColumnMapping("hardWareTyp", "hardWareTyp"), new System.Data.Common.DataColumnMapping("HWID", "HWID")})}); this.sqlDAHardwaretyp.UpdateCommand = this.sqlUpdateCommand2; this.sqlDAHardwaretyp.RowUpdated += new System.Data.SqlClient.SqlRowUpdatedEventHandler(this.sqlDataAdapter1_RowUpdated); // // sqlDeleteCommand2 // this.sqlDeleteCommand2.CommandText = "DELETE FROM hardtyp WHERE (HWID = @Original_HWID) AND (hardWareTyp = @Original_ha" + "rdWareTyp OR @Original_hardWareTyp IS NULL AND hardWareTyp IS NULL)"; this.sqlDeleteCommand2.Connection = this.sqlConnection1; this.sqlDeleteCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_HWID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "HWID", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_hardWareTyp", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "hardWareTyp", System.Data.DataRowVersion.Original, null)); // // sqlInsertCommand1 // this.sqlInsertCommand1.CommandText = "INSERT INTO hardtyp(hardWareTyp) VALUES (@hardWareTyp); SELECT hardWareTyp, HWID " + "FROM hardtyp WHERE (HWID = @@IDENTITY)"; this.sqlInsertCommand1.Connection = this.sqlConnection1; this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@hardWareTyp", System.Data.SqlDbType.VarChar, 30, "hardWareTyp")); // // sqlSelectCommand1 // this.sqlSelectCommand1.CommandText = "SELECT hardWareTyp, HWID FROM hardtyp"; this.sqlSelectCommand1.Connection = this.sqlConnection1; // // sqlUpdateCommand2 // this.sqlUpdateCommand2.CommandText = "UPDATE hardtyp SET hardWareTyp = @hardWareTyp WHERE (HWID = @Original_HWID) AND (" + "hardWareTyp = @Original_hardWareTyp OR @Original_hardWareTyp IS NULL AND hardWar" + "eTyp IS NULL); SELECT hardWareTyp, HWID FROM hardtyp WHERE (HWID = @HWID)"; this.sqlUpdateCommand2.Connection = this.sqlConnection1; this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@hardWareTyp", System.Data.SqlDbType.VarChar, 30, "hardWareTyp")); this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_HWID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "HWID", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_hardWareTyp", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "hardWareTyp", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@HWID", System.Data.SqlDbType.Int, 4, "HWID")); // // sqlDAHardware // this.sqlDAHardware.InsertCommand = this.sqlInsertCommand2; this.sqlDAHardware.SelectCommand = this.sqlSelectCommand2; this.sqlDAHardware.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] { new System.Data.Common.DataTableMapping("Table", "hardware", new System.Data.Common.DataColumnMapping[] { new System.Data.Common.DataColumnMapping("Hardware ID", "Hardware ID"), new System.Data.Common.DataColumnMapping("Seriennummer", "Seriennummer"), new System.Data.Common.DataColumnMapping("Bemerkungen", "Bemerkungen"), new System.Data.Common.DataColumnMapping("TypID", "TypID"), new System.Data.Common.DataColumnMapping("HerstellerID", "HerstellerID")})}); // // sqlInsertCommand2 // this.sqlInsertCommand2.CommandText = "INSERT INTO hardware(Seriennummer, Bemerkungen, TypID, HerstellerID) VALUES (@Ser" + "iennummer, @Bemerkungen, @TypID, @HerstellerID); SELECT [Hardware ID], Seriennum" + "mer, Bemerkungen, TypID, HerstellerID FROM hardware"; this.sqlInsertCommand2.Connection = this.sqlConnection1; this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Seriennummer", System.Data.SqlDbType.VarChar, 30, "Seriennummer")); this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Bemerkungen", System.Data.SqlDbType.VarChar, 160, "Bemerkungen")); this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@TypID", System.Data.SqlDbType.Int, 4, "TypID")); this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@HerstellerID", System.Data.SqlDbType.Int, 4, "HerstellerID")); // // sqlSelectCommand2 // this.sqlSelectCommand2.CommandText = "SELECT [Hardware ID], Seriennummer, Bemerkungen, TypID, HerstellerID FROM hardwar" + "e"; this.sqlSelectCommand2.Connection = this.sqlConnection1; // // sqlHersteller // this.sqlHersteller.DeleteCommand = this.sqlDeleteCommand1; this.sqlHersteller.InsertCommand = this.sqlInsertCommand3; this.sqlHersteller.SelectCommand = this.sqlSelectCommand3; this.sqlHersteller.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] { new System.Data.Common.DataTableMapping("Table", "hersteller", new System.Data.Common.DataColumnMapping[] { new System.Data.Common.DataColumnMapping("Hersteller", "Hersteller"), new System.Data.Common.DataColumnMapping("ID", "ID")})}); this.sqlHersteller.UpdateCommand = this.sqlUpdateCommand1; // // sqlDeleteCommand1 // this.sqlDeleteCommand1.CommandText = "DELETE FROM hersteller WHERE (ID = @Original_ID) AND (Hersteller = @Original_Hers" + "teller OR @Original_Hersteller IS NULL AND Hersteller IS NULL)"; this.sqlDeleteCommand1.Connection = this.sqlConnection1; this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ID", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Hersteller", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Hersteller", System.Data.DataRowVersion.Original, null)); // // sqlInsertCommand3 // this.sqlInsertCommand3.CommandText = "INSERT INTO hersteller(Hersteller) VALUES (@Hersteller); SELECT Hersteller, ID FR" + "OM hersteller WHERE (ID = @@IDENTITY)"; this.sqlInsertCommand3.Connection = this.sqlConnection1; this.sqlInsertCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Hersteller", System.Data.SqlDbType.VarChar, 30, "Hersteller")); // // sqlSelectCommand3 // this.sqlSelectCommand3.CommandText = "SELECT Hersteller, ID FROM hersteller"; this.sqlSelectCommand3.Connection = this.sqlConnection1; // // sqlUpdateCommand1 // this.sqlUpdateCommand1.CommandText = "UPDATE hersteller SET Hersteller = @Hersteller WHERE (ID = @Original_ID) AND (Her" + "steller = @Original_Hersteller OR @Original_Hersteller IS NULL AND Hersteller IS" + " NULL); SELECT Hersteller, ID FROM hersteller WHERE (ID = @ID)"; this.sqlUpdateCommand1.Connection = this.sqlConnection1; this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Hersteller", System.Data.SqlDbType.VarChar, 30, "Hersteller")); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ID", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Hersteller", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Hersteller", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ID", System.Data.SqlDbType.Int, 4, "ID")); // // dsHardware1 // this.dsHardware1.DataSetName = "dsHardware"; this.dsHardware1.EnforceConstraints = false; this.dsHardware1.Locale = new System.Globalization.CultureInfo("de-DE"); // // Home // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(806, 487); this.Controls.Add(this.tabControl1); this.Cursor = System.Windows.Forms.Cursors.Default; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; this.Menu = this.mainMenu1; this.Name = "Home"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "BestandDB"; this.Load += new System.EventHandler(this.Form1_Load); this.Model.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dsHardwaretyp)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dsHersteller1)).EndInit(); this.tabControl1.ResumeLayout(false); this.suche.ResumeLayout(false); this.groupBox1.ResumeLayout(false); this.Zuordnung.ResumeLayout(false); this.test.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dsHardware1)).EndInit(); this.ResumeLayout(false); } #endregion /// /// Der Haupteinstiegspunkt für die Anwendung. /// [STAThread] static void Main() { Application.Run(new Home()); } private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e) { } private void tabControl1_SelectedIndexChanged_1(object sender, System.EventArgs e) { } private void label1_Click(object sender, System.EventArgs e) { } private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e) { } private void label2_Click(object sender, System.EventArgs e) { } private void NH_Click(object sender, System.EventArgs e) { } private void NS_Click(object sender, System.EventArgs e) { } private void button1_Click(object sender, System.EventArgs e) { Bestand.Home.ActiveForm.Close(); } private void button2_Click(object sender, System.EventArgs e) { neueht FormNeu = new neueht(); FormNeu.ShowDialog(); //Löscht die Daten im Dataset und füllt sie neu //Wird benötigt um die Drop Down Buttons zu aktualisieren dsHardwaretyp.Clear(); try { sqlConnection1.Open(); sqlDAHardwaretyp.Fill(dsHardwaretyp); sqlConnection1.Close(); } catch (Exception ex) { MessageBox.Show("Fehler " + ex.Message, "Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error); } } private void menuItem3_Click(object sender, System.EventArgs e) { } private void label4_Click(object sender, System.EventArgs e) { } private void button4_Click(object sender, System.EventArgs e) { int id2 = 0; //Datenbank schreiben try { sqlConnection1.Open(); sqlDAHardware.Fill(dsHardware1, "hardware"); DataRow objZeile; objZeile = dsHardware1.hardware.NewRow(); // Dataset Spalte Hardware ID schreibschutz aufheben objZeile.Table.Columns["Hardware ID"].ReadOnly = false; // Zeile ausfüllen objZeile["Seriennummer"] = Seriennummer.Text; objZeile["Bemerkungen"] = textBox1.Text; objZeile["TypID"] = comboBox3.SelectedValue.ToString(); objZeile["HerstellerID"] = comboBox1.SelectedValue.ToString(); dsHardware1.Tables["hardware"].Rows.Add(objZeile); // ID Wert holen sqlDAHardware.RowUpdated += new SqlRowUpdatedEventHandler(OnRowUpdated); sqlDAHardware.Update(dsHardware1, "hardware"); sqlConnection1.Close(); // Rückgegebene ID int id = (int)objZeile[ "Hardware ID" ]; MessageBox.Show("Es wurde Erfolgreich eine neue Hardware mit der ID: " + id.ToString()+ " erfasst"); id2 = id; } catch (Exception ex) { MessageBox.Show("Fehler " + ex.Message, "Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error); } //Form auf standard zurücksetzen comboBox3.SelectedIndex = -1; comboBox1.SelectedIndex = -1; Seriennummer.Text = ""; textBox1.Text = ""; // Zuordnung A an neu eingegebene Hardware binden SqlDataAdapter da2 = new SqlDataAdapter("SELECT * FROM hardware WHERE [Hardware ID] LIKE @HWID", sqlConnection1); da2.SelectCommand.Parameters.Add("@HWID", SqlDbType.Int,4).Value = id2; DataSet ds2 = new DataSet(); try { ds2.Clear(); sqlConnection1.Open(); da2.Fill(ds2, "hardware"); sqlConnection1.Close(); } catch (Exception ex) { MessageBox.Show("Fehler " + ex.Message, "Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error); } listBox2.DataSource = ds2; listBox2.DisplayMember = "hardware.Seriennummer"; listBox2.ValueMember = "hardware.Hardware ID"; // Tab wechseln comboBox2.SelectedIndex = 0; tabControl1.SelectedTab = Zuordnung; } private void OnRowUpdated(object sender, SqlRowUpdatedEventArgs args) { if (args.StatementType == StatementType.Insert && args.Status == UpdateStatus.Continue ) { SqlCommand idCMD = new SqlCommand("SELECT @@IDENTITY", sqlConnection1); object id = idCMD.ExecuteScalar(); args.Row["Hardware ID"] = (Decimal)id; // if( id != null ) // { // // args.Row["Hardware ID"] = (Decimal)id; // System.Diagnostics.Debug.WriteLine( "ID: " + id.ToString() + " Type: " + id.GetType().ToString() ); // // } } } private void Seriennummer_TextChanged(object sender, System.EventArgs e) { if (Seriennummer.Text != "" && textBox1.Text != "") { button4.Enabled = true; } else if (Seriennummer.Text == "" || textBox1.Text == "") { button4.Enabled = false; } } private void textBox1_TextChanged(object sender, System.EventArgs e) { if (textBox1.Text != "" && Seriennummer.Text != "") { button4.Enabled = true; } else if (textBox1.Text == "" || Seriennummer.Text == "") { button4.Enabled = false; } } private void comboBox3_SelectedIndexChanged(object sender, System.EventArgs e) { } private void Form1_Load(object sender, System.EventArgs e) { } private void menuItem2_Click(object sender, System.EventArgs e) { Bestand.Home.ActiveForm.Close(); } private void Benutzer_CheckedChanged(object sender, System.EventArgs e) { } private void Arbeitsplatz_CheckedChanged(object sender, System.EventArgs e) { } private void sqlDataAdapter1_RowUpdated(object sender, System.Data.SqlClient.SqlRowUpdatedEventArgs e) { } private void delete_Click(object sender, System.EventArgs e) { int arg; arg = comboBox3.SelectedIndex; dsHardwaretyp.Tables["hardtyp"].Rows[arg].Delete(); MessageBox.Show("Wollen sie wirklich die auswahl löschen ?","Frage", MessageBoxButtons.OKCancel,MessageBoxIcon.Question); try { sqlConnection1.Open(); sqlDAHardwaretyp.Update(dsHardwaretyp, "hardtyp"); sqlConnection1.Close(); } catch (Exception ex) { MessageBox.Show("Fehler " + ex.Message, "Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error); dsHardwaretyp.RejectChanges(); } } private void button3_Click(object sender, System.EventArgs e) { //Löscht die Daten im Dataset und füllt sie neu //Wird benötigt um die Drop Down Buttons zu aktualisieren NeuHersteller FormNeu = new NeuHersteller(); FormNeu.ShowDialog(); dsHersteller1.Clear(); try { sqlConnection1.Open(); sqlHersteller.Fill(dsHersteller1); sqlConnection1.Close(); } catch (Exception ex) { MessageBox.Show("Fehler " + ex.Message, "Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error); } } private void button5_Click(object sender, System.EventArgs e) { int arg; arg = comboBox1.SelectedIndex; dsHersteller1.Tables[0].Rows[arg].Delete(); MessageBox.Show("Wollen sie wirklich die auswahl löschen ?", "Frage", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); try { sqlConnection1.Open(); sqlHersteller.Update(dsHersteller1, "hersteller"); sqlConnection1.Close(); } catch (Exception ex) { MessageBox.Show("Fehler " + ex.Message, "Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error); dsHardwaretyp.RejectChanges(); } } private void debug_Click(object sender, System.EventArgs e) { } private void textBox2_TextChanged(object sender, System.EventArgs e) { } private void suchen_Click(object sender, System.EventArgs e) { // Sucht die Seriennummern in der Datenbank SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM hardware WHERE Seriennummer LIKE @Seriennummer", sqlConnection1); da.SelectCommand.Parameters.Add("@Seriennummer", SqlDbType.VarChar,30).Value = '%' + textBox2.Text + '%'; DataSet ds = new DataSet(); ds.Clear(); try { ds.Clear(); sqlConnection1.Open(); da.Fill(ds, "hardware"); sqlConnection1.Close(); } catch (Exception ex) { MessageBox.Show("Fehler " + ex.Message, "Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error); } listBox1.DataSource = ds; listBox1.DisplayMember = "hardware.Seriennummer"; listBox1.ValueMember = "hardware.Hardware ID"; } private void button6_Click(object sender, System.EventArgs e) { // Variabeln string strMitarbeiter = ""; string strMitarbeiterVorname = ""; // Ausgewählte Hardware ID in Variable zähler laden string zaehler = listBox1.SelectedValue.ToString(); // HardwareID laden und die dazugehörigen TypID und HerstellerID holen SqlDataAdapter da = new SqlDataAdapter("SELECT [Hardware ID], Seriennummer, Bemerkungen, Hersteller, hardWareTyp FROM hardware INNER JOIN hersteller ON (hardware.HerstellerID = hersteller.ID )INNER JOIN hardtyp ON (hardware.TypID = hardtyp.HWID) WHERE [Hardware ID] = @ID", sqlConnection1); da.SelectCommand.Parameters.Add("@ID", SqlDbType.Int,4).Value = zaehler; DataSet ds = new DataSet(); try { ds.Clear(); sqlConnection1.Open(); da.Fill(ds, "test"); sqlConnection1.Close(); } catch (Exception ex) { MessageBox.Show("Fehler " + ex.Message, "Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error); } if( ds.Tables["test"].Rows.Count == 0 ) { textBox5.Text = "leer"; textBox4.Text = "leer"; textBox3.Text = "leer"; } else { textBox5.Text = ds.Tables["test"].Rows[0]["Bemerkungen"].ToString(); textBox4.Text = ds.Tables["test"].Rows[0]["hardWareTyp"].ToString(); textBox3.Text = ds.Tables["test"].Rows[0]["Hersteller"].ToString(); } // Zuordnung laden SqlDataAdapter dazuHardUser = new SqlDataAdapter("SELECT * FROM zuHardUser WHERE ID = @ID", sqlConnection1); dazuHardUser.SelectCommand.Parameters.Add("@ID", SqlDbType.Int,4).Value = zaehler; DataSet dszuHardUser = new DataSet(); try { dszuHardUser.Clear(); sqlConnection1.Open(); dazuHardUser.Fill(dszuHardUser, "zuHardUser"); sqlConnection1.Close(); } catch (Exception ex) { MessageBox.Show("Fehler " + ex.Message, "Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error); } if( dszuHardUser.Tables["zuHardUser"].Rows.Count == 0 ) { textBox6.Text = "nicht Zugeordnet"; } else { DataTable dtzuHardUser = dszuHardUser.Tables["zuHardUser"]; DataRow aRowzuHardUser = dtzuHardUser.Rows[0]; string strzuHardUSer = aRowzuHardUser["zuID"].ToString(); // ID in Mitarbeiter umwandeln SqlDataAdapter dazuMitarbeiter = new SqlDataAdapter("SELECT * FROM mitarbeiter WHERE ID = @ID", sqlConnection1); dazuMitarbeiter.SelectCommand.Parameters.Add("@ID", SqlDbType.Int,4).Value = strzuHardUSer; DataSet dszuMitarbeiter = new DataSet(); try { dszuMitarbeiter.Clear(); sqlConnection1.Open(); dazuMitarbeiter.Fill(dszuMitarbeiter, "mitarbeiter"); sqlConnection1.Close(); } catch (Exception ex) { MessageBox.Show("Fehler " + ex.Message, "Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error); } DataTable dtzuMitarbeiter = dszuMitarbeiter.Tables["mitarbeiter"]; DataRow aRowzuMitarbeiter = dtzuMitarbeiter.Rows[0]; strMitarbeiter = aRowzuMitarbeiter["Nachname"].ToString(); strMitarbeiterVorname = aRowzuMitarbeiter["Vorname"].ToString(); // Füllen der Textfelder textBox6.Text = strMitarbeiter + ", " + strMitarbeiterVorname; } } private void listBox1_SelectedIndexChanged_1(object sender, System.EventArgs e) { } private void textBox3_TextChanged(object sender, System.EventArgs e) { } private void suche_Click(object sender, System.EventArgs e) { } private void textBox5_TextChanged(object sender, System.EventArgs e) { } private void comboBox1_SelectedIndexChanged_1(object sender, System.EventArgs e) { } private void Benutzerverwaltung_Click(object sender, System.EventArgs e) { } private void button8_Click(object sender, System.EventArgs e) { if (comboBox2.Text == "Hardware") { SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM hardware WHERE Seriennummer LIKE @Seriennummer", sqlConnection1); da.SelectCommand.Parameters.Add("@Seriennummer", SqlDbType.VarChar,30).Value = '%' + suchfeld.Text + '%'; DataSet ds = new DataSet(); try { sqlConnection1.Open(); da.Fill(ds, "hardware"); sqlConnection1.Close(); } catch (Exception ex) { MessageBox.Show("Fehler " + ex.Message, "Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error); } listBox2.DataSource = ds; listBox2.DisplayMember = "hardware.Seriennummer"; listBox2.ValueMember = "hardware.Hardware ID"; } else { MessageBox.Show("Nix ausgewählt"); } } private void debug_Click_1(object sender, System.EventArgs e) { string test1 = listBox2.SelectedValue.ToString(); MessageBox.Show("ID "+test1+" ausgewählt"); } private void testbutton_Click(object sender, System.EventArgs e) { if (comboBox2.Text == "Software"& comboBox4.Text == "Software") { MessageBox.Show("Fehler in der Zuordnung! Eine Software kann keiner andern Software zugeordnet werden!","Fehler",MessageBoxButtons.OK,MessageBoxIcon.Error); } else if (comboBox2.Text == "Hardware" & comboBox4.Text == "Nachname") { try { sqlConnection1.Open(); SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM zuHardUser", sqlConnection1); SqlCommandBuilder cmdB = new SqlCommandBuilder(da); DataSet ds = new DataSet(); da.Fill(ds, "zuHardUser"); DataTable dt = ds.Tables["zuHardUser"]; DataRow objZeile = dt.NewRow(); objZeile["ID"] = listBox2.SelectedValue.ToString(); objZeile["zuID"] = listBox3.SelectedValue.ToString(); ds.Tables["zuHardUser"].Rows.Add(objZeile); da.Update(ds, "zuHardUser"); MessageBox.Show("Die Hardware wurde erfolgreich einem Mitarbeiter zugeordnet", "Info", MessageBoxButtons.OK,MessageBoxIcon.Information); } catch //(Exception ex) { MessageBox.Show("Fehler, Harware wurde schon einem Mitarbeiter zugeordnet! " , "Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error); } sqlConnection1.Close(); } else { MessageBox.Show("Noch nicht unterstütztes Feature ;o)", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Information); } } private void button10_Click(object sender, System.EventArgs e) { if (comboBox4.Text == "Hardware") { SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM hardware WHERE Seriennummer LIKE @Seriennummer", sqlConnection1); da.SelectCommand.Parameters.Add("@Seriennummer", SqlDbType.VarChar,30).Value = '%' + suchfeld.Text + '%'; DataSet ds = new DataSet(); DataSet dsmitarbeiter = new DataSet(); try { sqlConnection1.Open(); da.Fill(ds, "hardware"); sqlConnection1.Close(); } catch (Exception ex) { MessageBox.Show("Fehler " + ex.Message, "Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error); } listBox2.DataSource = ds; listBox2.DisplayMember = "hardware.Seriennummer"; listBox2.ValueMember = "hardware.Hardware ID"; } else if (comboBox4.Text == "Nachname") { SqlDataAdapter da = new SqlDataAdapter("SELECT ID, Nachname + Vorname as ganzername FROM mitarbeiter WHERE Nachname LIKE @Nachname", sqlConnection1); da.SelectCommand.Parameters.Add("@Nachname", SqlDbType.VarChar,30).Value = '%' + suchfeld2.Text + '%'; DataSet ds = new DataSet(); DataSet dsmitarbeiter = new DataSet(); try { sqlConnection1.Open(); da.Fill(ds, "mitarbeiter"); sqlConnection1.Close(); } catch (Exception ex) { MessageBox.Show("Fehler " + ex.Message, "Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error); } listBox3.DataSource = ds; listBox3.DisplayMember = "mitarbeiter.ganzername"; listBox3.ValueMember = "mitarbeiter.ID"; } else { MessageBox.Show("Nix ausgewählt"); } } private void listBox3_SelectedIndexChanged(object sender, System.EventArgs e) { } private void debug2_Click(object sender, System.EventArgs e) { string test1 = listBox3.SelectedValue.ToString(); MessageBox.Show("ID "+test1+" ausgewählt"); } private void button11_Click(object sender, System.EventArgs e) { Bearbeiter NewForm = new Bearbeiter(); NewForm.ShowDialog(); } private void sqlConnection1_InfoMessage(object sender, System.Data.SqlClient.SqlInfoMessageEventArgs e) { } private void button13_Click(object sender, System.EventArgs e) { } private void button13_Click_1(object sender, System.EventArgs e) { SqlDataAdapter da = new SqlDataAdapter("SELECT TypID, hardWareTyp FROM hardware INNER JOIN hardtyp ON (hardware.TypID = hardtyp.HWID)", sqlConnection1); DataSet ds = new DataSet(); try { Cursor.Current = Cursors.WaitCursor; sqlConnection1.Open(); da.Fill(ds, "test"); sqlConnection1.Close(); } catch (Exception ex) { MessageBox.Show("Fehler " + ex.Message, "Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error); } dataGrid1.DataSource = ds.Tables["test"].DefaultView; } } }