예제 #1
0
        //protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        //{
        //    //todo da collegare
        //    this._context.Dispose();
        //}

        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            Competenza competenza = competenzaDataGrid.SelectedItem as Competenza;

            _context.Competenze.Remove(competenza);
            _context.SaveChanges();
        }
예제 #2
0
        public bool SalvaCompetenza(Competenza c)
        {
            try
            {
                var repos = ServiceLocator.Current.GetInstance <IRepository <Competenza> >();
                var uow   = ServiceLocator.Current.GetInstance <IUnitOfWork>();

                if (c.Id == 0)
                {
                    repos.Add(c);
                }
                else
                {
                    repos.Attach(c);

                    /*var competenza = context.Competenze.Find(CompetenzaSelezionata.Id);
                     * competenza.Titolo = CompetenzaSelezionata.Titolo;
                     * competenza.Descrizione = CompetenzaSelezionata.Descrizione;
                     * competenza.TipologiaCompetenzaId = CompetenzaSelezionata.TipologiaCompetenza.Id;*/
                }

                uow.Commit();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
예제 #3
0
        private Competenza InitComp(string tipo, int livello)
        {
            Competenza c = new Competenza {
                Titolo  = tipo,
                Livello = livello
            };

            return(c);
        }
예제 #4
0
        private void AggiungiCompetenza()
        {
            var comp = new Competenza()
            {
                Titolo = "Nuova"
            };

            CompetenzeLista.Add(comp);
            CompetenzaSelezionata = comp;
        }
예제 #5
0
        public ActionResult AddComp(string tipo, string livello)
        {
            Competenza comp = new Competenza();
            Profilo    p    = Session["profile"] as Profilo; //ATTENZIONE DA RIVEDERE QUANDO CI SARA' LA PROFILATURA

            comp.Titolo  = tipo;
            comp.Livello = int.Parse(livello);
            dm.AddCompetenze(p.Matricola, comp);
            return(View($"MyPage"));
        }
예제 #6
0
        public ActionResult ModificaCompetenza(string tipo, int livello)
        {
            Competenza c = new Competenza();

            c = InitComp(tipo, livello);
            Competenza daMod = Session["competenza"] as Competenza;
            string     matr  = (Session["profile"] as Profilo).Matricola;       //ATTENZIONE DA RIVEDERE QUANDO CI SARA' LA PROFILATURA

            dm.ModComp(daMod, c, matr);
            ViewBag.Comp = c;
            return(View("MyPage"));
        }
예제 #7
0
        public Competenza TransfInCompetenza(SqlDataReader data)
        {
            Competenza output = null;

            if (data.Read())
            {
                output = new Competenza {
                    Livello = data.GetValue(0) == DBNull.Value ? 0 : data.GetInt32(0),
                    Titolo  = data.GetValue(1) == DBNull.Value ? "" : data.GetString(1)
                };
            }
            return(output);
        }
예제 #8
0
 public void AddCompetenze(string MatrCv, Competenza comp)
 {
     try{
         SqlParameter[] param =
         {
             new SqlParameter("@Tipo",    comp.Titolo),
             new SqlParameter("@Livello", comp.Livello),
             new SqlParameter("@MatrCv",  MatrCv)
         };
         int output = DB.ExecNonQProcedure("dbo.AddCompetenze", param, "GeCV");
         if (output == 0)
         {
             throw new Exception("Nessuna competenza aggiunta!");
         }
     } catch (SqlException e) {
         throw new Exception(e.Message);
     } catch (Exception e) {
         throw e;
     }
 }
예제 #9
0
 private CV InitCV(string nome, string cognome, string eta,
                   string email, string residenza, string telefono, string annoinizio, string annofine,
                   string titolo, string descrizione, string annoinizioesp, string annofinesp, string qualifica,
                   string descrizionesp, string tipo, string livello)
 {
     try{
         CV cv = new CV {
             Nome      = nome,
             Cognome   = cognome,
             Eta       = int.Parse(eta),
             Email     = email,
             Residenza = residenza,
             Telefono  = telefono,
             Matricola = "BBBB"
         };
         EspLav esp = new EspLav {
             AnnoInizio  = int.Parse(annoinizioesp),
             AnnoFine    = int.Parse(annofinesp),
             Qualifica   = qualifica,
             Descrizione = descrizionesp
         };
         cv.Esperienze.Add(esp);
         PerStud percorso = new PerStud {
             AnnoInizio  = int.Parse(annoinizio),
             AnnoFine    = int.Parse(annofine),
             Titolo      = titolo,
             Descrizione = descrizione
         };
         cv.Percorsostudi.Add(percorso);
         Competenza comp = new Competenza {
             Titolo  = tipo,
             Livello = int.Parse(livello)
         };
         cv.Competenze.Add(comp);
         return(cv);
     } catch (Exception e) {
         throw e;
     }
 }
예제 #10
0
 //GeCv
 public void ModComp(string matricola, Competenza daMod, Competenza Mod)
 {
     try{
         SqlParameter[] parameters =
         {
             new SqlParameter("@matricola",   matricola),
             new SqlParameter("@titoloDaMod", daMod.Titolo),
             new SqlParameter("@livdaMod",    daMod.Livello),
             new SqlParameter("@titoloMod",   Mod.Titolo),
             new SqlParameter("@livMod",      Mod.Livello)
         };
         int output = DB.ExecNonQProcedure("ModComp", parameters, "GeCV");
         if (output == 0)
         {
             throw new Exception("Nessuna modifica fatta!");
         }
     } catch (SqlException e) {
         throw new Exception(e.Message);
     } catch (Exception e) {
         throw e;
     }
 }
예제 #11
0
 public void AddCompetenze(string MatrCv, Competenza comp)
 {
     dao.AddCompetenze(MatrCv, comp);
 }
예제 #12
0
 public void ModComp(Competenza daMod, Competenza Mod, string matricola)
 {
     dao.ModComp(matricola, daMod, Mod);
 }
예제 #13
0
        public bool CaricaSurvey(string title, Stream stream)
        {
            //string filepath = "D:\\survey1.xlsx";
            using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open(stream, false))
            {
                IEnumerable <Sheet> sheets = spreadsheetDocument.WorkbookPart.Workbook.Descendants <Sheet>().Where(s => s.Name == "Eterovalutazione");
                if (sheets.Count() == 0)
                {
                    throw new Exception("File non valido");
                }

                WorksheetPart worksheetPart = (WorksheetPart)spreadsheetDocument.WorkbookPart.GetPartById(sheets.First().Id);
                Worksheet     worksheet     = worksheetPart.Worksheet;
                WorkbookPart  wbPart        = spreadsheetDocument.WorkbookPart;

                //Creazione di una nuova survey
                Survey survey = new Survey();

                uint curRow = 4;
                bool eof    = false;
                do
                {
                    //Prendo la domanda
                    string questionStr = GetCellValue(worksheet, wbPart, "B" + curRow);

                    if (!string.IsNullOrEmpty(questionStr))
                    {
                        //Creo la question e gli associo il testo della domanda
                        Question question = new Question();
                        question.Testo = questionStr;

                        //Ricerco la competenza associata
                        Competenza competenza = reposCompetenze.Get(c => c.Titolo.ToUpper() == questionStr.ToUpper());
                        if (competenza != null)
                        {
                            question.CompetenzaId = competenza.Id;
                        }
                        else
                        {
                            throw new Exception("Non trovata competenza " + questionStr);
                        }

                        //Aggiungo quella nulla
                        question.Children.Add(new SubQuestion
                        {
                            Testo = "La padronanza della competenza non è valutabile",
                            LivelloConoscenzaId = 1
                        });


                        AddSubQuestion(worksheet, wbPart, "E" + curRow, 2, question);
                        AddSubQuestion(worksheet, wbPart, "G" + curRow, 3, question);
                        AddSubQuestion(worksheet, wbPart, "I" + curRow, 4, question);
                        AddSubQuestion(worksheet, wbPart, "K" + curRow, 5, question);

                        //Leggo il valore atteso
                        string s_valAtteso = GetCellValue(worksheet, wbPart, "M" + curRow);
                        //Livello nullo ha id 1
                        question.ValoreAttesoId = Convert.ToInt32(s_valAtteso) + 1;

                        survey.Questions.Add(question);

                        curRow++;
                    }
                    else
                    {
                        eof = true;
                    }
                }while (!eof);

                survey.Name   = title;
                survey.Active = true;
                reposSurvey.Add(survey);
                unitOfWork.Commit();
            }

            return(true);
        }