//Create a new Licenseinventory
 public LicenseInventory CreateLicenseInventory(int customerNumber)
 {
     currentLicenseInventory = new LicenseInventory(customerNumber, list_licenseInventories.Count);
     list_licenseInventories.Add(currentLicenseInventory);
     db.SaveLicenseInventory(currentLicenseInventory);
     return(currentLicenseInventory);
 }
        public ArrayList GetLicenseInventories()
        {
            ArrayList list_licenseinventories = new ArrayList();

            try
            {
                connection = new SQLiteConnection("Data Source=" + dbpath + ";Version=3;MultipleActiveResultSets=True; foreign keys=true;");
                connection.Open();
                command             = new SQLiteCommand(connection);
                command.CommandText = "SELECT * FROM licenseinventory;";
                SQLiteDataReader r = command.ExecuteReader();
                while (r.Read())
                {
                    LicenseInventory currentLicensInvnetory = new LicenseInventory(r.GetInt32(1), r.GetInt32(0));
                    //Get Licenses of the inventory
                    SQLiteCommand command2 = new SQLiteCommand(connection);
                    command2.CommandText = "SELECT * FROM containslicense WHERE licenseInventoryNumber=@licenseInventoryNumber;";
                    command2.Parameters.AddWithValue("@licenseInventoryNumber", currentLicensInvnetory.LicenseInventoryNumber);
                    SQLiteDataReader r_inner = command2.ExecuteReader();
                    while (r_inner.Read())
                    {
                        currentLicensInvnetory.AddLicenseToInventory(r_inner.GetInt32(1), r_inner.GetInt32(2));
                    }
                    list_licenseinventories.Add(currentLicensInvnetory);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error SQL Reading LicenseInventory", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log.WriteLog(e.Message);
            }
            return(list_licenseinventories);
        }
 public override void SelectedCustomerChanged(Object customer)
 {
     base.SelectedCustomerChanged(customer);
     currentLicenseInventory = null;
     currentNetworkInventory = null;
     Log.WriteLog(string.Format("Customer changed successfully: New Customer: {0}", currentCustomer.Name));
     //Get Licenseinventory of the customer
     foreach (LicenseInventory li in list_licenseInventories)
     {
         if (li.Customernumber == currentCustomer.Cnumber)
         {
             currentLicenseInventory = li;
             Log.WriteLog(string.Format("Licenseinventory for customer {0} found", currentCustomer.Name));
         }
     }
     if (currentLicenseInventory == null)
     {
         MessageBox.Show("Kein Lizenzinventar für diesen Kunden gefunden.", "Kein Lizenzinventar gefunden", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     //Get Networkinventory of the customer
     foreach (NetworkInventory ni in list_networkInventories)
     {
         if (ni.Customernumber == currentCustomer.Cnumber)
         {
             currentNetworkInventory = ni;
             Log.WriteLog(string.Format("Networkinventory for customer {0} found", currentCustomer.Name));
         }
     }
     if (currentNetworkInventory == null)
     {
         MessageBox.Show("Kein Netzwerkinventar für diesen Kunden gefunden.", "Kein Netzwerkinventar gefunden", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     UpdateView(false);
 }
Beispiel #4
0
 //constructor
 public ControllerAudit(ControllerParent calling, FormAudit view, ArrayList list_customers, ArrayList list_licenseinventories, ArrayList list_systeminventories, ArrayList list_audits, ArrayList list_licenses) : base(calling, list_customers)
 {
     //connect controller to its view
     this.view = view;
     this.list_licenseInventories   = list_licenseinventories;
     this.list_systemInventories    = list_systeminventories;
     this.list_audits               = list_audits;
     this.list_allAvailableLicenses = list_licenses;
     currentAudit            = null;
     currentLicenseInventory = null;
     currentSystemInventory  = null;
 }
        public override void SelectedCustomerChanged(Object customer)
        {
            base.SelectedCustomerChanged(customer);
            Log.WriteLog(string.Format("Customer changed successfully: New Customer: {0}", currentCustomer.Name));

            //Get Networkinventory of the customer
            currentNetworkInventory = null;
            foreach (NetworkInventory n in list_networkInventories)
            {
                if (n.Customernumber == currentCustomer.Cnumber)
                {
                    currentNetworkInventory = n;
                    Log.WriteLog(string.Format("NetworkInventory for customer {0} found", currentCustomer.Name));
                }
            }

            //Get LicenseInventory of the customer
            currentLicenseInventory = null;
            foreach (LicenseInventory li in list_licenseInventories)
            {
                if (li.Customernumber == currentCustomer.Cnumber)
                {
                    currentLicenseInventory = li;
                    Log.WriteLog(string.Format("LicenseInventory for customer {0} found", currentCustomer.Name));
                }
            }

            //Get latest SystemInventory of the customer
            currentSystemInventory = null;
            foreach (SystemInventory si in list_systemInventories)
            {
                if (si.Customernumber == currentCustomer.Cnumber)
                {
                    currentSystemInventory = si;
                    Log.WriteLog(string.Format("SystemInventory for customer {0} found", currentCustomer.Name));
                }
            }

            //Get latest Audit of the customer
            currentAudit = null;
            foreach (Audit a in list_Audits)
            {
                if (a.CustomerNumber == currentCustomer.Cnumber)
                {
                    currentAudit = a;
                    Log.WriteLog(string.Format("Audit for customer {0} found", currentCustomer.Name));
                }
            }
            UpdateView(false);
        }
 public void SaveLicenseInventory(LicenseInventory li)
 {
     try
     {
         connection = new SQLiteConnection("Data Source=" + dbpath + ";Version=3; foreign keys=true;");
         connection.Open();
         command             = new SQLiteCommand(connection);
         command.CommandText = "INSERT INTO licenseinventory (licenseInventoryNumber, customerNumber) VALUES(@licenseInventoryNumber, @customerNumber);";
         command.Parameters.AddWithValue("@licenseInventoryNumber", li.LicenseInventoryNumber);
         command.Parameters.AddWithValue("@customerNumber", li.Customernumber);
         command.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         MessageBox.Show("Error SQL Update LicenseInventory", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Log.WriteLog(e.Message);
     }
     connection.Close();
 }
        public void UpdateLicenseInventory(LicenseInventory li, License l, int count)
        {
            bool update = false;

            try
            {
                connection = new SQLiteConnection("Data Source=" + dbpath + ";Version=3; foreign keys=true;");
                connection.Open();
                command = new SQLiteCommand(connection);
                try
                {
                    command.CommandText = "INSERT INTO containsLicense (licenseInventoryNumber, licenseNumber, count) VALUES(@licenseInventoryNumber, @licenseNumber, @count);";
                    command.Parameters.AddWithValue("@licenseInventoryNumber", li.LicenseInventoryNumber);
                    command.Parameters.AddWithValue("@licenseNumber", l.LicenseNumber);
                    command.Parameters.AddWithValue("@count", count);
                    command.ExecuteNonQuery();
                    Log.WriteLog("Lizenz war noch nicht im Inventory");
                }
                catch (SQLiteException e)
                {
                    //Tuple alreeady in table
                    update = true;
                    Log.WriteLog("License already in invnetory, update it");
                }
                if (update)
                {
                    command.CommandText = "UPDATE containsLicense SET count=@count WHERE licenseInventoryNumber=@licenseInventoryNumber AND  licenseNumber=@licenseNumber ;";
                    command.Parameters.AddWithValue("@licenseInventoryNumber", li.LicenseInventoryNumber);
                    command.Parameters.AddWithValue("@licenseNumber", l.LicenseNumber);
                    command.Parameters.AddWithValue("@count", count);
                    command.ExecuteNonQuery();
                    Log.WriteLog("Lizenz aktualisiert");
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error SQL Update LicenseInventory", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log.WriteLog(e.Message);
            }
            connection.Close();
        }
 //Called if Customer in DropDown Menu is changed, check if a NetworkInventory exist, get it or create a new one and update the view
 public override void SelectedCustomerChanged(Object customer)
 {
     base.SelectedCustomerChanged(customer);
     currentLicenseInventory = null;
     Log.WriteLog(string.Format("Customer changed successfully: New Customer: {0}", currentCustomer.Name));
     //Get Licenseinventory of the customer or create a new one
     foreach (LicenseInventory li in list_licenseInventories)
     {
         if (li.Customernumber == currentCustomer.Cnumber)
         {
             currentLicenseInventory = li;
             Log.WriteLog(string.Format("Licenseinventory for customer {0} found", currentCustomer.Name));
         }
     }
     if (currentLicenseInventory == null)
     {
         currentLicenseInventory = CreateLicenseInventory(currentCustomer.Cnumber);
         Log.WriteLog("new inventory created");
     }
     UpdateView(false);
 }
Beispiel #9
0
 public override void SelectedCustomerChanged(Object customer)
 {
     base.SelectedCustomerChanged(customer);
     currentLicenseInventory = null;
     currentSystemInventory  = null;
     currentAudit            = null;
     Log.WriteLog(string.Format("Customer changed successfully: New Customer: {0}", currentCustomer.Name));
     //Get Licenseinventory of the customer or Display Message
     foreach (LicenseInventory li in list_licenseInventories)
     {
         if (li.Customernumber == currentCustomer.Cnumber)
         {
             currentLicenseInventory = li;
             Log.WriteLog(string.Format("Licenseinventory for customer {0} found", currentCustomer.Name));
             view.EnableAudit();
         }
     }
     if (currentLicenseInventory == null)
     {
         MessageBox.Show("Kein Lizenzinventar für diesen Kunden gefunden. Bitte erstellen Sie zuerst ein Lizenzinventar.", "Kein Lizenzinventar gefunden", MessageBoxButtons.OK, MessageBoxIcon.Error);
         view.DisableAudit();
     }
     //Get latest Audit
     foreach (Audit a in list_audits)
     {
         if (a.CustomerNumber == currentCustomer.Cnumber)
         {
             if (currentAudit == null)
             {
                 currentAudit = a;
                 Log.WriteLog(string.Format("Audit for customer {0} found", currentCustomer.Name));
             }
             else if (DateTime.Compare(a.Date, currentAudit.Date) > 0)
             {
                 currentAudit = a;
                 Log.WriteLog(string.Format("Newer Audit for customer {0} found", currentCustomer.Name));
             }
         }
     }
     if (currentAudit != null)
     {
         //Get belonging SystemInventory of the current Audit
         foreach (SystemInventory si in list_systemInventories)
         {
             if (si.SystemInventoryNumber == currentAudit.SystemInventoryNumber)
             {
                 currentSystemInventory = si;
                 Log.WriteLog("Belonging Systeminventory for current Audit found.");
                 view.EnableAudit();
                 MessageBox.Show(String.Format("Audit für diesen Kunden gefunden. Audit vom {0} für Systeminventar vom {1} wird dargestellt.\nBitte beachten Sie, dass sich das Lizenzinventar des Kunden seitdem geändert haben kann und das aktuell dargestellte Lizenzinventar nicht mit dem Ergebnis des Audits in Verbindung steht.",
                                               currentAudit.Date, currentSystemInventory.Date), "Audit vorhanden", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 break;
             }
         }
     }
     //Get Systeminventory of the customer or Display Message in case no audit with belonging systeminventory was found
     if (currentSystemInventory == null)
     {
         foreach (SystemInventory si in list_systemInventories)
         {
             if (si.Customernumber == currentCustomer.Cnumber)
             {
                 currentSystemInventory = si;
                 Log.WriteLog(string.Format("Systeminventory for customer {0} found", currentCustomer.Name));
                 view.EnableAudit();
             }
         }
         if (currentSystemInventory == null)
         {
             MessageBox.Show("Kein Systeminventar für diesen Kunden gefunden. Bitte führen Sie zuerst ein Netzwerkinventarisierung durch.", "Kein Systeminventar gefunden", MessageBoxButtons.OK, MessageBoxIcon.Error);
             view.DisableAudit();
         }
     }
     UpdateView(false);
 }