private async void InsertInvoiceCustomerInfo(DataRowView rowView)
        {
            try
            {
                CustomerInfoAddress.Text        = "";
                CustomerInfoFirstname.Text      = "";
                CustomerInfoLastname.Text       = "";
                CustomerInfoID.Text             = "";
                CustomerInfoNeededServices.Text = "";
                CustomerInfoMail.Text           = "";
                CustomerInfoMobile.Text         = "";
                CustomerInfoHome.Text           = "";
                CustomerInfoServicesGotten.Text = "";

                var query = $"SELECT * FROM `customers` WHERE `Customer_ID` = {rowView.Row.ItemArray[1].ToString()}";

                customerExists = await AsyncMySqlHelper.CheckDataFromDatabase(query, "ConnString");

                var userData = await AsyncMySqlHelper.GetDataFromDatabase <Customer>(query, "ConnString");

                foreach (Customer row in userData)
                {
                    CustomerInfoAddress.Text        = row.Customer_ADDRESS;                    // 1
                    CustomerInfoFirstname.Text      = row.Customer_FIRSTNAME;                  // 2
                    CustomerInfoLastname.Text       = row.Customer_LASTNAME;                   // 3
                    CustomerInfoID.Text             = row.Customer_ID.ToString();              // 4
                    CustomerInfoNeededServices.Text = row.Customer_SERVICES_NEEDED.ToString(); // 5
                    CustomerInfoMail.Text           = row.Customer_EMAIL;                      // 6
                    CustomerInfoMobile.Text         = row.Customer_PHONE_MOBILE;               // 7
                    CustomerInfoHome.Text           = row.Customer_PHONE_HOME;                 // 8
                }

                query = $"SELECT * FROM `services` WHERE `Customer_ID` = {rowView.Row.ItemArray[1].ToString()} AND `Service_YEAR` = {DateTime.Now.Year}";

                var serviceData = await AsyncMySqlHelper.GetDataFromDatabase <Service>(query, "ConnString");

                CustomerInfoServicesGotten.Text = serviceData.Count.ToString();
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Unexpected Error");
            }
        }
Esempio n. 2
0
        /// <summary>  Verifies the license to check if the license has expired or don't exist.</summary>
        private void CheckLicense()
        {
            try
            {
                Log.Information("Checking License");

                const string getList  = "SELECT * FROM licenses";
                var          licenses = AsyncMySqlHelper.ReturnStringList(getList, "LicenseConnString").Result.ToList();

#if DEBUG
                var localLicense = PropertiesExtension.Get <string>("License");
#else
                var localLicense = RegHelper.Readvalue(@"Software\", "GiroZilla", "License");
#endif

                switch (!string.IsNullOrWhiteSpace(localLicense))
                {
                case true:
                {
                    Log.Information("Local license found");

                    var count = 1;

                    foreach (var s in licenses)
                    {
                        switch (!IsLicenseVerified)
                        {
                        case true:
                        {
                            _isCorrect = Hashing.Confirm(s, localLicense);

                            switch (_isCorrect)
                            {
                            case true:
                            {
                                var searchLicenseId = $"SELECT `License_VALUE` FROM `licenses` WHERE `License_ID`='{count}'";

                                var license    = AsyncMySqlHelper.GetString(searchLicenseId, "LicenseConnString").Result;
                                var query      = $"SELECT * FROM `licenses` WHERE `License_VALUE`='{license}' AND `License_USED` > 0";
                                var canConnect = AsyncMySqlHelper.CheckDataFromDatabase(query, "LicenseConnString").Result;

                                switch (canConnect)
                                {
                                case true:
                                {
                                    _connectionStatus = 1;
                                    break;
                                }

                                case false:
                                {
                                    _connectionStatus = 0;
                                    break;
                                }
                                }

                                switch (_connectionStatus)
                                {
                                case 1:
                                {
                                    LicenseDialog.IsOpen = false;
                                    IsLicenseVerified    = true;
                                    Log.Information(@"GiroZilla v" + FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion + " loaded");
                                    break;
                                }

                                case 0:
                                {
                                    LicenseDialog.IsOpen = true;
                                    IsLicenseVerified    = false;

                                    switch (!string.IsNullOrWhiteSpace(localLicense))
                                    {
                                    case true:
                                    {
                                        Log.Warning("This license is invalid and wil be reset");

                                        ErrorText.Text = "Din nuværende licens er ugyldig & vil blive nulstillet";

#if DEBUG
                                        PropertiesExtension.Set("License", "");
#else
                                        RegHelper.SetRegValue(@"Software\GiroZilla", "License", "", RegistryValueKind.String);
#endif
                                        break;
                                    }
                                    }

                                    break;
                                }

                                default:
                                {
                                    LicenseDialog.IsOpen = true;
                                    IsLicenseVerified    = false;

                                    switch (!string.IsNullOrWhiteSpace(localLicense))
                                    {
                                    case true:
                                    {
                                        Log.Warning("Something went wrong validating this license");

                                        ErrorText.Text = "Kunne ikke validere din licens prøv igen senere";
                                        break;
                                    }

                                    default:
                                    {
                                        Log.Warning("Something went wrong validating this license (String empty or null)");

                                        ErrorText.Text = "Kunne ikke validere din licens";
                                        break;
                                    }
                                    }
                                    break;
                                }
                                }
                                break;
                            }

                            case false:
                            {
                                count++;
                                break;
                            }
                            }
                            break;
                        }
                        }
                    }
                    break;
                }

                default:
                {
                    LicenseDialog.IsOpen = true;
                    IsLicenseVerified    = false;

                    Log.Warning("The license was not found");

                    ErrorText.Text = "Licensen blev ikke fundet";
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                _connectionStatus = 2;

                Log.Error(ex, "Unexpected Error");
            }
        }