private static PCData setPCData()
        {
            PCData pd = new PCData();

            try
            {
                System.Management.SelectQuery query = new System.Management.SelectQuery(@"Select * from Win32_ComputerSystem");
                using (System.Management.ManagementObjectSearcher searcher1 = new System.Management.ManagementObjectSearcher(query))
                {
                    foreach (System.Management.ManagementObject process in searcher1.Get())
                    {
                        process.Get();

                        pd.vendorPC = "" + process["Manufacturer"];
                        pd.modelPC  = "" + process["Model"];
                    }
                }
                ManagementObjectSearcher MOS = new ManagementObjectSearcher("Select * From Win32_BIOS");

                foreach (ManagementObject getserial in MOS.Get())
                {
                    pd.serialNumberPC = getserial["SerialNumber"].ToString();
                }

                pd.systemName = System.Environment.MachineName;
                pd.version    = GetOSFriendlyName();
                pd.domain     = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName;
                pd.assetName  = pd.vendorPC + " " + pd.modelPC;

                Database d = new Database();
                if (!d.verifyPC(pd.serialNumberPC))
                {
                    d.insertPC(pd);
                }
            }
            catch (Exception t)
            {
                Console.WriteLine(t.Message);
            }

            return(pd);
        }
 public void insertPC(PCData data)
 {
     try
     {
         sqlConnection.Open();
         SqlCommand sqlCommand = new SqlCommand("INSERT INTO PC(pcSerial,pcVendor,pcModel,pcWindowsVersion,pcName,domain,assetName) " +
                                                "VALUES('" + data.serialNumberPC + "','" + data.vendorPC + "','" + data.modelPC + "','" + data.version + "','" + data.systemName + "','" + data.domain +
                                                "','" + data.assetName + "')"
                                                , sqlConnection);
         sqlCommand.ExecuteNonQuery();
     }
     catch (SqlException e)
     {
         SqlCommand sqlCommand = new SqlCommand("INSERT INTO Monitor(monitorModel, monitorSerial, monitorVendor) " +
                                                "VALUES('" + "Generic Model" + "','" + "Generic Serial" + "','" + "Generic Vendor" + "')"
                                                , sqlConnection);
         sqlCommand.ExecuteNonQuery();
         Console.WriteLine("Sql error from insertPC method" + e.Message);
     }
     finally
     {
         sqlConnection.Close();
     }
 }