diff --git a/Firmendatenbank.sln b/Firmendatenbank.sln new file mode 100644 index 0000000..8df3c60 --- /dev/null +++ b/Firmendatenbank.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.35122.118 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Firmendatenbank", "Firmendatenbank\Firmendatenbank.csproj", "{8D75A6EB-1A3A-486E-8E0E-DE3BF99D4528}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8D75A6EB-1A3A-486E-8E0E-DE3BF99D4528}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8D75A6EB-1A3A-486E-8E0E-DE3BF99D4528}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8D75A6EB-1A3A-486E-8E0E-DE3BF99D4528}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8D75A6EB-1A3A-486E-8E0E-DE3BF99D4528}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {58080282-C549-4218-8D12-FD1BAE26A1AA} + EndGlobalSection +EndGlobal diff --git a/Firmendatenbank/CRMForm.Designer.cs b/Firmendatenbank/CRMForm.Designer.cs new file mode 100644 index 0000000..ffd9841 --- /dev/null +++ b/Firmendatenbank/CRMForm.Designer.cs @@ -0,0 +1,81 @@ +namespace Firmendatenbank +{ + partial class CRMForm + { + private System.ComponentModel.IContainer components = null; + private System.Windows.Forms.DataGridView dataGridViewNotes; + private System.Windows.Forms.TextBox txtNote; + private System.Windows.Forms.Button btnAddNote; + private System.Windows.Forms.Label lblNote; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + private void InitializeComponent() + { + dataGridViewNotes = new DataGridView(); + txtNote = new TextBox(); + btnAddNote = new Button(); + lblNote = new Label(); + ((System.ComponentModel.ISupportInitialize)dataGridViewNotes).BeginInit(); + SuspendLayout(); + // + // dataGridViewNotes + // + dataGridViewNotes.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + dataGridViewNotes.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewNotes.Location = new Point(12, 12); + dataGridViewNotes.Name = "dataGridViewNotes"; + dataGridViewNotes.Size = new Size(500, 200); + dataGridViewNotes.TabIndex = 0; + // + // txtNote + // + txtNote.Location = new Point(12, 230); + txtNote.Multiline = true; + txtNote.Name = "txtNote"; + txtNote.Size = new Size(500, 80); + txtNote.TabIndex = 1; + // + // btnAddNote + // + btnAddNote.Location = new Point(412, 330); + btnAddNote.Name = "btnAddNote"; + btnAddNote.Size = new Size(100, 30); + btnAddNote.TabIndex = 2; + btnAddNote.Text = "Notiz hinzufügen"; + btnAddNote.UseVisualStyleBackColor = true; + btnAddNote.Click += btnAddNote_Click; + // + // lblNote + // + lblNote.AutoSize = true; + lblNote.Location = new Point(12, 210); + lblNote.Name = "lblNote"; + lblNote.Size = new Size(38, 15); + lblNote.TabIndex = 3; + lblNote.Text = "Notiz:"; + // + // CRMForm + // + ClientSize = new Size(524, 380); + Controls.Add(lblNote); + Controls.Add(btnAddNote); + Controls.Add(txtNote); + Controls.Add(dataGridViewNotes); + Name = "CRMForm"; + Text = "CRM - Notizen verwalten"; + Shown += CRMForm_Shown; + KeyDown += CRMForm_KeyDown; + ((System.ComponentModel.ISupportInitialize)dataGridViewNotes).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + } +} diff --git a/Firmendatenbank/CRMForm.cs b/Firmendatenbank/CRMForm.cs new file mode 100644 index 0000000..549eb16 --- /dev/null +++ b/Firmendatenbank/CRMForm.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using MySql.Data.MySqlClient; + +namespace Firmendatenbank +{ + public partial class CRMForm : Form + { + private MySqlConnection connection; + private string domain; + private string connectionString = "Server=192.168.178.201;Database=domainchecker;User ID=root;Password=1td5rugut8;"; + + // Konstruktor + public CRMForm(string domain) + { + InitializeComponent(); + this.domain = domain; + InitializeDatabaseConnection(); + LoadNotes(); + this.KeyPreview = true; // Damit das Formular Tastatureingaben empfangen kann + this.KeyDown += new KeyEventHandler(CRMForm_KeyDown); + } + + private void InitializeDatabaseConnection() + { + //string connectionString = "Server=your_server;Database=your_database;Uid=your_username;Pwd=your_password;"; + connection = new MySqlConnection(connectionString); + } + + private void LoadNotes() + { + DataTable dataTable = new DataTable(); + + try + { + connection.Open(); + string query = "SELECT zeitstempel, notiz FROM crm_notizen WHERE domain = @domain ORDER BY zeitstempel DESC"; + MySqlCommand cmd = new MySqlCommand(query, connection); + cmd.Parameters.AddWithValue("@domain", domain); + MySqlDataAdapter adapter = new MySqlDataAdapter(cmd); + adapter.Fill(dataTable); + connection.Close(); + } + catch (Exception ex) + { + MessageBox.Show("Fehler beim Laden der Notizen: " + ex.Message); + } + finally + { + if (connection.State == System.Data.ConnectionState.Open) + { + connection.Close(); + } + } + + dataGridViewNotes.DataSource = dataTable; + } + + private void btnAddNote_Click(object sender, EventArgs e) + { + try + { + connection.Open(); + string query = "INSERT INTO crm_notizen (domain, notiz) VALUES (@domain, @notiz)"; + MySqlCommand cmd = new MySqlCommand(query, connection); + cmd.Parameters.AddWithValue("@domain", domain); + cmd.Parameters.AddWithValue("@notiz", txtNote.Text); + cmd.ExecuteNonQuery(); + + //MessageBox.Show("Notiz erfolgreich hinzugefügt."); + txtNote.Text = ""; // Textbox leeren + connection.Close(); + LoadNotes(); // Aktualisiere die Liste der Notizen + } + catch (Exception ex) + { + MessageBox.Show("Fehler beim Hinzufügen der Notiz: " + ex.Message); + } + finally + { + if (connection.State == System.Data.ConnectionState.Open) + { + connection.Close(); + } + } + } + + private void CRMForm_Shown(object sender, EventArgs e) + { + txtNote.Focus(); + } + + private void CRMForm_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + this.Close(); // Schließt das Formular, wenn die Escape-Taste gedrückt wird + } + } + } + +} diff --git a/Firmendatenbank/CRMForm.resx b/Firmendatenbank/CRMForm.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/Firmendatenbank/CRMForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Firmendatenbank/Firmendatenbank.csproj b/Firmendatenbank/Firmendatenbank.csproj new file mode 100644 index 0000000..782567f --- /dev/null +++ b/Firmendatenbank/Firmendatenbank.csproj @@ -0,0 +1,16 @@ + + + + WinExe + net8.0-windows + enable + true + enable + + + + + + + + \ No newline at end of file diff --git a/Firmendatenbank/Form1.Designer.cs b/Firmendatenbank/Form1.Designer.cs new file mode 100644 index 0000000..c4f9956 --- /dev/null +++ b/Firmendatenbank/Form1.Designer.cs @@ -0,0 +1,338 @@ +using System.Media; + +namespace Firmendatenbank +{ + partial class Form1 + { + private System.ComponentModel.IContainer components = null; + private System.Windows.Forms.TextBox txtFirmenname; + private System.Windows.Forms.TextBox txtMailadresse; + private System.Windows.Forms.TextBox txtAdresse; + private System.Windows.Forms.TextBox txtPlz; + private System.Windows.Forms.TextBox txtOrt; + private System.Windows.Forms.TextBox txtTelefonnummer; + private System.Windows.Forms.TextBox txtAnsprechpartner; + private System.Windows.Forms.Button btnSave; + private System.Windows.Forms.TextBox txtDomain; + private System.Windows.Forms.Label lblFirmenname; + private System.Windows.Forms.Label lblMailadresse; + private System.Windows.Forms.Label lblAdresse; + private System.Windows.Forms.Label lblPlz; + private System.Windows.Forms.Label lblOrt; + private System.Windows.Forms.Label lblTelefonnummer; + private System.Windows.Forms.Label lblAnsprechpartner; + private System.Windows.Forms.Label lblStatus; + private System.Windows.Forms.Label lblDomain; + private System.Windows.Forms.Button btnCRM; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + private void InitializeComponent() + { + txtFirmenname = new TextBox(); + txtMailadresse = new TextBox(); + txtAdresse = new TextBox(); + txtPlz = new TextBox(); + txtOrt = new TextBox(); + txtTelefonnummer = new TextBox(); + txtAnsprechpartner = new TextBox(); + btnSave = new Button(); + txtDomain = new TextBox(); + lblFirmenname = new Label(); + lblMailadresse = new Label(); + lblAdresse = new Label(); + lblPlz = new Label(); + lblOrt = new Label(); + lblTelefonnummer = new Label(); + lblAnsprechpartner = new Label(); + lblStatus = new Label(); + lblDomain = new Label(); + btnCRM = new Button(); + tableLayoutPanel1 = new TableLayoutPanel(); + txtStatus = new TextBox(); + dataGridViewWpVersionen = new DataGridView(); + tableLayoutPanel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewWpVersionen).BeginInit(); + SuspendLayout(); + // + // txtFirmenname + // + txtFirmenname.Dock = DockStyle.Fill; + txtFirmenname.Location = new Point(126, 368); + txtFirmenname.Margin = new Padding(4, 3, 4, 3); + txtFirmenname.Name = "txtFirmenname"; + txtFirmenname.Size = new Size(269, 23); + txtFirmenname.TabIndex = 1; + // + // txtMailadresse + // + txtMailadresse.Dock = DockStyle.Fill; + txtMailadresse.Location = new Point(126, 398); + txtMailadresse.Margin = new Padding(4, 3, 4, 3); + txtMailadresse.Name = "txtMailadresse"; + txtMailadresse.Size = new Size(269, 23); + txtMailadresse.TabIndex = 2; + // + // txtAdresse + // + txtAdresse.Dock = DockStyle.Fill; + txtAdresse.Location = new Point(126, 428); + txtAdresse.Margin = new Padding(4, 3, 4, 3); + txtAdresse.Name = "txtAdresse"; + txtAdresse.Size = new Size(269, 23); + txtAdresse.TabIndex = 3; + // + // txtPlz + // + txtPlz.Dock = DockStyle.Fill; + txtPlz.Location = new Point(126, 458); + txtPlz.Margin = new Padding(4, 3, 4, 3); + txtPlz.Name = "txtPlz"; + txtPlz.Size = new Size(269, 23); + txtPlz.TabIndex = 4; + // + // txtOrt + // + txtOrt.Dock = DockStyle.Fill; + txtOrt.Location = new Point(126, 488); + txtOrt.Margin = new Padding(4, 3, 4, 3); + txtOrt.Name = "txtOrt"; + txtOrt.Size = new Size(269, 23); + txtOrt.TabIndex = 5; + // + // txtTelefonnummer + // + txtTelefonnummer.Dock = DockStyle.Fill; + txtTelefonnummer.Location = new Point(126, 518); + txtTelefonnummer.Margin = new Padding(4, 3, 4, 3); + txtTelefonnummer.Name = "txtTelefonnummer"; + txtTelefonnummer.Size = new Size(269, 23); + txtTelefonnummer.TabIndex = 6; + // + // txtAnsprechpartner + // + txtAnsprechpartner.Dock = DockStyle.Fill; + txtAnsprechpartner.Location = new Point(126, 548); + txtAnsprechpartner.Margin = new Padding(4, 3, 4, 3); + txtAnsprechpartner.Name = "txtAnsprechpartner"; + txtAnsprechpartner.Size = new Size(269, 23); + txtAnsprechpartner.TabIndex = 7; + // + // btnSave + // + btnSave.Dock = DockStyle.Fill; + btnSave.Location = new Point(403, 578); + btnSave.Margin = new Padding(4, 3, 4, 3); + btnSave.Name = "btnSave"; + btnSave.Size = new Size(118, 24); + btnSave.TabIndex = 9; + btnSave.Text = "Speichern"; + btnSave.UseVisualStyleBackColor = true; + btnSave.Click += btnSave_Click; + // + // txtDomain + // + txtDomain.Dock = DockStyle.Fill; + txtDomain.Location = new Point(126, 608); + txtDomain.Margin = new Padding(4, 3, 4, 3); + txtDomain.Name = "txtDomain"; + txtDomain.ReadOnly = true; + txtDomain.Size = new Size(269, 23); + txtDomain.TabIndex = 10; + // + // lblFirmenname + // + lblFirmenname.AutoSize = true; + lblFirmenname.Location = new Point(4, 365); + lblFirmenname.Margin = new Padding(4, 0, 4, 0); + lblFirmenname.Name = "lblFirmenname"; + lblFirmenname.Size = new Size(77, 15); + lblFirmenname.TabIndex = 11; + lblFirmenname.Text = "Firmenname:"; + // + // lblMailadresse + // + lblMailadresse.AutoSize = true; + lblMailadresse.Location = new Point(4, 395); + lblMailadresse.Margin = new Padding(4, 0, 4, 0); + lblMailadresse.Name = "lblMailadresse"; + lblMailadresse.Size = new Size(72, 15); + lblMailadresse.TabIndex = 12; + lblMailadresse.Text = "Mailadresse:"; + // + // lblAdresse + // + lblAdresse.AutoSize = true; + lblAdresse.Location = new Point(4, 425); + lblAdresse.Margin = new Padding(4, 0, 4, 0); + lblAdresse.Name = "lblAdresse"; + lblAdresse.Size = new Size(51, 15); + lblAdresse.TabIndex = 13; + lblAdresse.Text = "Adresse:"; + // + // lblPlz + // + lblPlz.AutoSize = true; + lblPlz.Location = new Point(4, 455); + lblPlz.Margin = new Padding(4, 0, 4, 0); + lblPlz.Name = "lblPlz"; + lblPlz.Size = new Size(30, 15); + lblPlz.TabIndex = 14; + lblPlz.Text = "PLZ:"; + // + // lblOrt + // + lblOrt.AutoSize = true; + lblOrt.Location = new Point(4, 485); + lblOrt.Margin = new Padding(4, 0, 4, 0); + lblOrt.Name = "lblOrt"; + lblOrt.Size = new Size(27, 15); + lblOrt.TabIndex = 15; + lblOrt.Text = "Ort:"; + // + // lblTelefonnummer + // + lblTelefonnummer.AutoSize = true; + lblTelefonnummer.Location = new Point(4, 515); + lblTelefonnummer.Margin = new Padding(4, 0, 4, 0); + lblTelefonnummer.Name = "lblTelefonnummer"; + lblTelefonnummer.Size = new Size(94, 15); + lblTelefonnummer.TabIndex = 16; + lblTelefonnummer.Text = "Telefonnummer:"; + // + // lblAnsprechpartner + // + lblAnsprechpartner.AutoSize = true; + lblAnsprechpartner.Location = new Point(4, 545); + lblAnsprechpartner.Margin = new Padding(4, 0, 4, 0); + lblAnsprechpartner.Name = "lblAnsprechpartner"; + lblAnsprechpartner.Size = new Size(98, 15); + lblAnsprechpartner.TabIndex = 17; + lblAnsprechpartner.Text = "Ansprechpartner:"; + // + // lblStatus + // + lblStatus.AutoSize = true; + lblStatus.Location = new Point(4, 575); + lblStatus.Margin = new Padding(4, 0, 4, 0); + lblStatus.Name = "lblStatus"; + lblStatus.Size = new Size(42, 15); + lblStatus.TabIndex = 18; + lblStatus.Text = "Status:"; + // + // lblDomain + // + lblDomain.AutoSize = true; + lblDomain.Location = new Point(4, 605); + lblDomain.Margin = new Padding(4, 0, 4, 0); + lblDomain.Name = "lblDomain"; + lblDomain.Size = new Size(52, 15); + lblDomain.TabIndex = 19; + lblDomain.Text = "Domain:"; + lblDomain.Click += lblDomain_Click; + // + // btnCRM + // + btnCRM.Dock = DockStyle.Fill; + btnCRM.Location = new Point(403, 608); + btnCRM.Margin = new Padding(4, 3, 4, 3); + btnCRM.Name = "btnCRM"; + btnCRM.Size = new Size(118, 24); + btnCRM.TabIndex = 20; + btnCRM.Text = "CRM"; + btnCRM.UseVisualStyleBackColor = true; + btnCRM.Click += btnCRM_Click; + // + // tableLayoutPanel1 + // + tableLayoutPanel1.ColumnCount = 4; + tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 122F)); + tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 277F)); + tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 19.5084476F)); + tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 80.4915543F)); + tableLayoutPanel1.Controls.Add(txtStatus, 1, 8); + tableLayoutPanel1.Controls.Add(lblDomain, 0, 9); + tableLayoutPanel1.Controls.Add(lblStatus, 0, 8); + tableLayoutPanel1.Controls.Add(btnCRM, 2, 9); + tableLayoutPanel1.Controls.Add(lblAnsprechpartner, 0, 7); + tableLayoutPanel1.Controls.Add(txtDomain, 1, 9); + tableLayoutPanel1.Controls.Add(lblTelefonnummer, 0, 6); + tableLayoutPanel1.Controls.Add(btnSave, 2, 8); + tableLayoutPanel1.Controls.Add(lblOrt, 0, 5); + tableLayoutPanel1.Controls.Add(lblPlz, 0, 4); + tableLayoutPanel1.Controls.Add(txtAnsprechpartner, 1, 7); + tableLayoutPanel1.Controls.Add(lblAdresse, 0, 3); + tableLayoutPanel1.Controls.Add(txtTelefonnummer, 1, 6); + tableLayoutPanel1.Controls.Add(lblMailadresse, 0, 2); + tableLayoutPanel1.Controls.Add(txtOrt, 1, 5); + tableLayoutPanel1.Controls.Add(lblFirmenname, 0, 1); + tableLayoutPanel1.Controls.Add(txtPlz, 1, 4); + tableLayoutPanel1.Controls.Add(txtFirmenname, 1, 1); + tableLayoutPanel1.Controls.Add(txtMailadresse, 1, 2); + tableLayoutPanel1.Controls.Add(txtAdresse, 1, 3); + tableLayoutPanel1.Controls.Add(dataGridViewWpVersionen, 0, 0); + tableLayoutPanel1.Dock = DockStyle.Fill; + tableLayoutPanel1.Location = new Point(0, 0); + tableLayoutPanel1.Name = "tableLayoutPanel1"; + tableLayoutPanel1.RowCount = 10; + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F)); + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F)); + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F)); + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F)); + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F)); + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F)); + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F)); + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F)); + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F)); + tableLayoutPanel1.Size = new Size(1050, 635); + tableLayoutPanel1.TabIndex = 21; + // + // txtStatus + // + txtStatus.Dock = DockStyle.Fill; + txtStatus.Location = new Point(126, 578); + txtStatus.Margin = new Padding(4, 3, 4, 3); + txtStatus.Name = "txtStatus"; + txtStatus.Size = new Size(269, 23); + txtStatus.TabIndex = 22; + // + // dataGridViewWpVersionen + // + dataGridViewWpVersionen.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + tableLayoutPanel1.SetColumnSpan(dataGridViewWpVersionen, 4); + dataGridViewWpVersionen.Dock = DockStyle.Fill; + dataGridViewWpVersionen.Location = new Point(3, 3); + dataGridViewWpVersionen.Name = "dataGridViewWpVersionen"; + dataGridViewWpVersionen.Size = new Size(1044, 359); + dataGridViewWpVersionen.TabIndex = 24; + dataGridViewWpVersionen.CellClick += dataGridViewWpVersionen_CellClick; + // + // Form1 + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1050, 635); + Controls.Add(tableLayoutPanel1); + Margin = new Padding(4, 3, 4, 3); + Name = "Form1"; + Text = "Firmendaten verwalten"; + WindowState = FormWindowState.Maximized; + tableLayoutPanel1.ResumeLayout(false); + tableLayoutPanel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewWpVersionen).EndInit(); + ResumeLayout(false); + } + + private TableLayoutPanel tableLayoutPanel1; + private TextBox txtStatus; + private DataGridView dataGridViewWpVersionen; + } +} diff --git a/Firmendatenbank/Form1.cs b/Firmendatenbank/Form1.cs new file mode 100644 index 0000000..1420aaf --- /dev/null +++ b/Firmendatenbank/Form1.cs @@ -0,0 +1,170 @@ +using MySql.Data.MySqlClient; +using System.Data; +using System.Diagnostics; +using System.Windows.Forms; + +namespace Firmendatenbank +{ + public partial class Form1 : Form + { + private string connectionString = "Server=192.168.178.201;Database=domainchecker;User ID=root;Password=1td5rugut8;"; + public Form1() + { + InitializeComponent(); + LoadWpVersionen(); + dataGridViewWpVersionen.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + } + private void LoadWpVersionen() + { + string query = @"SELECT wp.domain, wp.version, wp.letzte_pruefung, wp.cms_name, + COALESCE(fd.status, '') AS status + FROM wp_versionen wp + LEFT JOIN firmendaten fd ON wp.domain = fd.domain + ORDER BY wp.version ASC"; + + DataTable dt = new DataTable(); + + using (MySqlConnection connection = new MySqlConnection(connectionString)) + { + MySqlCommand cmd = new MySqlCommand(query, connection); + connection.Open(); + using (MySqlDataReader reader = cmd.ExecuteReader()) + { + dt.Load(reader); + } + } + + dataGridViewWpVersionen.DataSource = dt; + } + + private void dataGridViewWpVersionen_CellClick(object sender, DataGridViewCellEventArgs e) + { + DataGridViewRow row = dataGridViewWpVersionen.Rows[e.RowIndex]; + txtDomain.Text = row.Cells["domain"].Value.ToString(); + txtStatus.Text = row.Cells["status"].Value.ToString(); + + + // Lade bestehende Firmendaten + LoadFirmendaten(txtDomain.Text); + } + + private void LoadFirmendaten(string domain) + { + string query = "SELECT * FROM firmendaten WHERE domain = @domain"; + + using (MySqlConnection connection = new MySqlConnection(connectionString)) + { + MySqlCommand cmd = new MySqlCommand(query, connection); + cmd.Parameters.AddWithValue("@domain", domain); + connection.Open(); + using (MySqlDataReader reader = cmd.ExecuteReader()) + { + if (reader.Read()) + { + txtFirmenname.Text = reader["firmenname"].ToString(); + txtMailadresse.Text = reader["mailadresse"].ToString(); + txtAdresse.Text = reader["adresse"].ToString(); + txtPlz.Text = reader["plz"].ToString(); + txtOrt.Text = reader["ort"].ToString(); + txtTelefonnummer.Text = reader["telefonnummer"].ToString(); + txtAnsprechpartner.Text = reader["ansprechpartner"].ToString(); + txtStatus.Text = reader["status"].ToString(); + } + else + { + // Felder leeren, wenn keine Daten gefunden wurden + txtFirmenname.Clear(); + txtMailadresse.Clear(); + txtAdresse.Clear(); + txtPlz.Clear(); + txtOrt.Clear(); + txtTelefonnummer.Clear(); + txtAnsprechpartner.Clear(); + txtStatus.Clear(); + } + } + } + } + + private void btnSave_Click(object sender, EventArgs e) + { + string domain = txtDomain.Text; + + string selectQuery = "SELECT COUNT(*) FROM firmendaten WHERE domain = @domain"; + string insertQuery = @"INSERT INTO firmendaten (firmenname, domain, mailadresse, adresse, plz, ort, telefonnummer, ansprechpartner, status) + VALUES (@firmenname, @domain, @mailadresse, @adresse, @plz, @ort, @telefonnummer, @ansprechpartner, @status)"; + string updateQuery = @"UPDATE firmendaten SET firmenname=@firmenname, mailadresse=@mailadresse, adresse=@adresse, plz=@plz, ort=@ort, + telefonnummer=@telefonnummer, ansprechpartner=@ansprechpartner, status=@status WHERE domain=@domain"; + + using (MySqlConnection connection = new MySqlConnection(connectionString)) + { + connection.Open(); + MySqlCommand selectCmd = new MySqlCommand(selectQuery, connection); + selectCmd.Parameters.AddWithValue("@domain", domain); + int count = Convert.ToInt32(selectCmd.ExecuteScalar()); + + MySqlCommand cmd; + + if (count > 0) + { + // Update bestehender Daten + cmd = new MySqlCommand(updateQuery, connection); + } + else + { + // Insert neuer Daten + cmd = new MySqlCommand(insertQuery, connection); + } + + cmd.Parameters.AddWithValue("@firmenname", txtFirmenname.Text); + cmd.Parameters.AddWithValue("@domain", domain); + cmd.Parameters.AddWithValue("@mailadresse", txtMailadresse.Text); + cmd.Parameters.AddWithValue("@adresse", txtAdresse.Text); + cmd.Parameters.AddWithValue("@plz", txtPlz.Text); + cmd.Parameters.AddWithValue("@ort", txtOrt.Text); + cmd.Parameters.AddWithValue("@telefonnummer", txtTelefonnummer.Text); + cmd.Parameters.AddWithValue("@ansprechpartner", txtAnsprechpartner.Text); + cmd.Parameters.AddWithValue("@status", txtStatus.Text); + + cmd.ExecuteNonQuery(); + } + + //MessageBox.Show("Daten erfolgreich gespeichert!", "Erfolg", MessageBoxButtons.OK, MessageBoxIcon.Information); + + // Aktualisiere das DataGridView nach dem Speichern + RefreshGridView(); + } + + private void RefreshGridView() + { + dataGridViewWpVersionen.DataSource = null; + LoadWpVersionen(); + } + private void btnCRM_Click(object sender, EventArgs e) + { + if (!string.IsNullOrEmpty(txtDomain.Text)) + { + CRMForm crmForm = new CRMForm(txtDomain.Text); + crmForm.Show(); + } + else + { + MessageBox.Show("Bitte wählen Sie eine Domain aus, bevor Sie das CRM öffnen."); + } + } + + private void lblDomain_Click(object sender, EventArgs e) + { + string url = txtDomain.Text; + string chromePath = @"C:\Program Files\Google\Chrome\Application\chrome.exe"; + + // Öffne die URL mit Google Chrome + Process.Start(new ProcessStartInfo + { + FileName = chromePath, + Arguments = url, + UseShellExecute = false + }); + } + } +} diff --git a/Firmendatenbank/Form1.resx b/Firmendatenbank/Form1.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/Firmendatenbank/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Firmendatenbank/Program.cs b/Firmendatenbank/Program.cs new file mode 100644 index 0000000..4a35522 --- /dev/null +++ b/Firmendatenbank/Program.cs @@ -0,0 +1,17 @@ +namespace Firmendatenbank +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new Form1()); + } + } +} \ No newline at end of file