private void btnUpdate_Click(object sender, RoutedEventArgs e) { try { bool Checkerle = false; if (chkDongle.IsChecked.Value == true) { Checkerle = true; } con = new SqlDbConnect(); con.SqlQuery("UPDATE Licenses SET License='" + txtLicense.Text + "', Software='" + cmbSoft.Text + "', Version='" + txtVersion.Text + "', SType='" + cmbSType.Text + "', Dongle='" + Checkerle + "', PDate='" + dPick.Text + "', Customer='" + txtCustomer.Text + "', Seller='" + cmbSeller.Text + "', Notes='" + txtNotes.Text + "' WHERE ID ='" + txtID.Text + "'"); con.QueryEx(); DataTable dt = con.QueryEx(); dataGrid.ItemsSource = dt.DefaultView; string y = ""; y = theDate + "UPDATE Licenses SET License='" + txtLicense.Text + "', Software='" + cmbSoft.Text + "', Version='" + txtVersion.Text + "', SType='" + cmbSType.Text + "', Dongle='" + Checkerle + "', PDate='" + dPick.Text + "', Customer='" + txtCustomer.Text + "', Seller='" + cmbSeller.Text + "', Notes='" + txtNotes.Text + "' WHERE ID ='" + txtID.Text + "'"; System.Windows.MessageBox.Show("The data has been updated successfully", "Success", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information); chkDongle.IsChecked = !chkDongle.IsChecked; if (y != "") { System.Windows.MessageBox.Show(y); } } catch (System.Exception excep) { System.Windows.MessageBox.Show(excep.Message, "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } }
public MainWindow() { InitializeComponent(); txtLicense.Text = ""; cmbSoft.Text = ""; txtVersion.Text = ""; cmbSType.Text = ""; txtCustomer.Text = ""; cmbSeller.Text = ""; txtNotes.Text = ""; try { con = new SqlDbConnect(); con.SqlQuery("SELECT * FROM LICENSES"); con.QueryEx(); DataTable dt = con.QueryEx(); dataGrid.ItemsSource = dt.DefaultView; } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString(), "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } }
private void btnSearchDate_Click(object sender, EventArgs e) { con = new SqlDbConnect(); con.SqlQuery("SELECT ID, License, Software, Version, SType, Dongle, PDate, Customer, Seller, Notes From Licenses where PDate between'" + dPickStart.Text + "'and'" + dPickEnd.Text + "'"); con.QueryEx(); DataTable dt = con.QueryEx(); dataGrid.ItemsSource = dt.DefaultView; }
private void btnDelete_Click(object sender, EventArgs e) { try { con = new SqlDbConnect(); con.SqlQuery("Delete From Licenses where ID = " + txtID.Text); con.QueryEx(); System.Windows.MessageBox.Show("The data has been deleted successfully", "Success", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information); } catch (System.Exception excep) { MessageBox.Show(excep.Message, "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } }
private void btnView_Click(object sender, RoutedEventArgs e) { try { con = new SqlDbConnect(); con.SqlQuery("SELECT * FROM Licenses"); con.QueryEx(); DataTable dt = con.QueryEx(); dataGrid.ItemsSource = dt.DefaultView; } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString(), "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } }
private void btnSearch_Click(object sender, RoutedEventArgs e) { // if (cmbSBox.Text == "License") { con = new SqlDbConnect(); con.SqlQuery("SELECT ID, License, Software, Version, SType, Dongle, PDate, Customer, Seller, Notes From Licenses where License like '%" + txtSearch.Text + "%'"); con.QueryEx(); DataTable dt = con.QueryEx(); dataGrid.ItemsSource = dt.DefaultView; } if (cmbSearch.Text == "Software") { con = new SqlDbConnect(); con.SqlQuery("SELECT ID, License, Software, Version, SType, Dongle, PDate, Customer, Seller, Notes From Licenses where Software like '%" + txtSearch.Text + "%'"); con.QueryEx(); DataTable dt = con.QueryEx(); dataGrid.ItemsSource = dt.DefaultView; } if (cmbSearch.Text == "Version") { con = new SqlDbConnect(); con.SqlQuery("SELECT ID, License, Software, Version, SType, Dongle, PDate, Customer, Seller, Notes From Licenses where Version like '%" + txtSearch.Text + "%'"); con.QueryEx(); DataTable dt = con.QueryEx(); dataGrid.ItemsSource = dt.DefaultView; } if (cmbSearch.Text == "Software Type") { con = new SqlDbConnect(); con.SqlQuery("SELECT ID, License, Software, Version, SType, Dongle, PDate, Customer, Seller, Notes From Licenses where SType like '" + txtSearch.Text + "%'"); con.QueryEx(); DataTable dt = con.QueryEx(); dataGrid.ItemsSource = dt.DefaultView; } }