Ejemplo n.º 1
0
        public void sistemsRelations(int systemID)
        {
            // Insert relation of auto and system
            string qry_insAutoSystem = "INSERT INTO rel_autos_sist (autos_ID, sistema_ID) VALUES ";

            qry_insAutoSystem += "(";
            string qry_insAutoSystemMod;
            string ID_currentCB;

            // insert code for relation of system
            foreach (CheckBox cb in stackAutos.Children)
            {
                // we get the id of the name of each cb, combobox,
                // of course we have to know if cb was checked
                if (cb.IsChecked.HasValue && cb.IsChecked.Value == true)
                {
                    ID_currentCB = cb.Name.ToString();
                    ID_currentCB = ID_currentCB.Trim(new char[] { '_' });
                    // we append to the list of IDS of checked comboboxes
                    // could not append several insert values so we do one insert at a time
                    qry_insAutoSystemMod = qry_insAutoSystem + ID_currentCB + ", " + systemID + ")";
                    MessageBox.Show("QRY: " + qry_insAutoSystemMod);
                    using (db.setComm(qry_insAutoSystemMod))
                    {
                        affectedRows = db.getComm().ExecuteNonQuery();
                    }
                    if (affectedRows == 0)
                    {
                        db.sendMBandCloseConn("No se pudo crear las relaciones pertinentes de sistemas y autos.");
                        return;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void autosRelations(int carID)
        {
            // GET ALL EVENTS SO WE CREATE A
            List <int> eventos_IDs      = new List <int>();
            string     qry_getAllEvents = "SELECT ID FROM evento";

            using (db.setComm(qry_getAllEvents))
            {
                db.setReader();
                while (db.getReader().Read())
                {
                    eventos_IDs.Add(Convert.ToInt32(db.getReader()["ID"]));
                }
            }

            //EDIT_CAMPOS_FUNCTION REGISTER IN THE TABLE
            // SEPARATE IN A FUNCTION
            // Insert relation of auto and systems
            string qry_insAutoSystem = "INSERT INTO rel_autos_sist (autos_ID, sistema_ID) VALUES ";

            qry_insAutoSystem += "(" + carID + ", ";

            string qry_insAutoSystemMod;
            string ID_currentCB;

            // insert code for relation of system

            string qry_editcampos = "INSERT INTO edit_campos_funktion ";

            qry_editcampos += "(funktion_ID, evento_ID, auto_ID) VALUES (";
            string qry_getSysFunktions = "SELECT";

            foreach (CheckBox cb in stackSystems.Children)
            {
                // we get the id of the name of each cb, combobox,
                // of course we have to know if cb was checked
                if (cb.IsChecked.HasValue && cb.IsChecked.Value == true)
                {
                    // ID OF CURRENT SYSTEM
                    ID_currentCB = cb.Name.ToString();
                    ID_currentCB = ID_currentCB.Trim(new char[] { '_' });
                    // we append to the list of IDS of checked comboboxes
                    // could not append several insert values so we do one insert each
                    qry_insAutoSystemMod = qry_insAutoSystem + ID_currentCB + ")";

                    using (db.setComm(qry_insAutoSystemMod))
                    {
                        affectedRows = db.getComm().ExecuteNonQuery();
                    }
                    if (affectedRows == 0)
                    {
                        db.sendMBandCloseConn("No se pudo crear las relaciones pertinentes de auto y sistemas.");
                        return;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void deletePermanent(object sender, RoutedEventArgs e)
        {
            if (RestoreStack.Children.Count < 1)
            {
                return;
            }
            if (whichItem != 1)
            {
                MessageBox.Show("Solo puedes eliminar de manera permanente autos");
                return;
            }

            MessageBoxResult result = MessageBox.Show(
                "Estás seguro de eliminar este(os) auto(s) de maner definitiva? Esta accion no se puede revertir.",
                "Eliminar Auto Permanente",
                MessageBoxButton.YesNoCancel
                );

            switch (result)
            {
            case MessageBoxResult.Yes:
                string ID_currentCB;
                foreach (CheckBox cb in RestoreStack.Children)
                {
                    // we get the id of the name of each cb, combobox,
                    // of course we have to know if cb was checked
                    if (cb.IsChecked.HasValue && cb.IsChecked.Value == true)
                    {
                        // ID OF CURRENT ITEM
                        ID_currentCB = cb.Name.ToString();
                        ID_currentCB = ID_currentCB.Trim(new char[] { '_' });
                        deleteOnceNForAll(ID_currentCB);
                    }
                }
                break;

            case MessageBoxResult.No:
                MessageBox.Show("Auto(s) no eliminado(s).", "Eliminar Auto Permanente");
                break;

            case MessageBoxResult.Cancel:
                MessageBox.Show("Auto(s) no eliminado(s).", "Eliminar Auto Permanente");
                break;
            }
            fillItems2Edit(qry_getAutos, whichItem);
        }
Ejemplo n.º 4
0
        private void Restore(object sender, RoutedEventArgs e)
        {
            if (RestoreStack.Children.Count < 1)
            {
                return;
            }
            string ID_currentCB;

            foreach (CheckBox cb in RestoreStack.Children)
            {
                // we get the id of the name of each cb, combobox,
                // of course we have to know if cb was checked
                if (cb.IsChecked.HasValue && cb.IsChecked.Value == true)
                {
                    // ID OF CURRENT ITEM
                    ID_currentCB = cb.Name.ToString();
                    ID_currentCB = ID_currentCB.Trim(new char[] { '_' });
                    updateOrDelete(1, ID_currentCB);
                }
            }

            switch (whichItem)
            {
            case 1:
                fillItems2Edit(qry_getAutos, whichItem);
                break;

            case 2:
                fillItems2Edit(qry_getFunciones, whichItem);
                break;

            case 3:
                fillItems2Edit(qry_getSistemas, whichItem);
                break;
            }
        }