/// <summary> /// /// </summary> /// <param name="db"></param> private void GestioneMeseElaborato() { //Svuoto l'attuale oggetto. _mae.Clear(); //Prelevo tutte le righe dei 5 anni precedenti e ordinate in modo descrescente per ordine d'inserimento. var AllMae = _db.MESEANNOELABORAZIONE.Where(a => a.ANNO >= (DateTime.Now.Year - 5)) .OrderByDescending(a => a.IDMESEANNOELAB) .ToList(); //Se sono presenti nel DB già delle righe if (AllMae?.Any() ?? false) { foreach (var mae in AllMae) { MeseAnnoElaborazioneModel maem = new MeseAnnoElaborazioneModel() { idMeseAnnoElab = mae.IDMESEANNOELAB, anno = (int)mae.ANNO, mese = (int)mae.MESE, chiuso = mae.CHIUSO }; _mae.Add(maem); } } //Se non ci sono ancora righe vuol dire che è la prima volta che si procede con l'elaborazione. else { int anno = DateTime.Now.Year; int mese = DateTime.Now.Month; MESEANNOELABORAZIONE mae = new MESEANNOELABORAZIONE() { ANNO = anno, MESE = mese, CHIUSO = false }; _db.MESEANNOELABORAZIONE.Add(mae); int i = _db.SaveChanges(); if (i <= 0) { throw new Exception("Errore nell'inserimento del nuovo mese di elaborazione."); } MeseAnnoElaborazioneModel maem = new MeseAnnoElaborazioneModel() { idMeseAnnoElab = mae.IDMESEANNOELAB, anno = (int)mae.ANNO, mese = (int)mae.MESE, chiuso = mae.CHIUSO }; _mae.Add(maem); } }
public void NewMeseDaElaborare() { //Prelevo tutte le righe dei 5 anni precedenti e ordinate in modo descrescente per ordine d'inserimento. var AllMae = _db.MESEANNOELABORAZIONE.Where(a => a.ANNO >= (DateTime.Now.Year - 5)) .OrderByDescending(a => a.IDMESEANNOELAB) .ToList(); //Prelevo l'ultima riga inserita. var lastMae = AllMae.First(); //Se l'ultima riga inserita risulta elaborata incremento di un mese, inserisco una nuova riga e carico tutte le righe sulla proprietà. if (lastMae.CHIUSO == true) { var mese = 0; var anno = 0; if (lastMae.MESE < 12) { mese = (int)lastMae.MESE + 1; anno = (int)lastMae.ANNO; } else { mese = 1; anno = (int)lastMae.ANNO + 1; } MESEANNOELABORAZIONE newMae = new MESEANNOELABORAZIONE() { ANNO = anno, MESE = mese, CHIUSO = false }; _db.MESEANNOELABORAZIONE.Add(newMae); int i = _db.SaveChanges(); if (i <= 0) { throw new Exception("Errore nell'inserimento del nuovo mese di elaborazione."); } this.GestioneMeseElaborato(); } //Altrimenti se l'ultima riga non risulta elaborata leggo tutte le righe. else { this.GestioneMeseElaborato(); } }
public int MeseAnnoDaElaborare() { int annoMese = 0; using (ModelDBISE db = new ModelDBISE()) { MESEANNOELABORAZIONE meseAnnoElab = db.MESEANNOELABORAZIONE.OrderBy(a => a.ANNO).ThenBy(a => a.MESE).ToList().Last(a => a.CHIUSO == false); if (meseAnnoElab.ANNO > 0) { annoMese = Convert.ToInt32(meseAnnoElab.ANNO.ToString() + meseAnnoElab.MESE.ToString()); } } return(annoMese); }
public IList <RptRiepiloghiIseMensileModel> GetRiepiloghiIseMensile(decimal idElabIni, decimal idElabFin, decimal MeseDa, decimal AnnoDa, decimal MeseA, decimal AnnoA, ModelDBISE db) { List <RptRiepiloghiIseMensileModel> rim = new List <RptRiepiloghiIseMensileModel>(); List <TRASFERIMENTO> lt = new List <TRASFERIMENTO>(); string strMeseDa = MeseDa.ToString().PadLeft(2, Convert.ToChar("0")); string strMeseA = MeseA.ToString().PadLeft(2, Convert.ToChar("0")); DateTime dtIni = Convert.ToDateTime("01/" + strMeseDa + "/" + AnnoDa.ToString()); DateTime dtFin = Utility.GetDtFineMese(Convert.ToDateTime("01/" + strMeseA + "/" + AnnoA.ToString())); lt = db.TRASFERIMENTO .Where(a => a.IDSTATOTRASFERIMENTO != (decimal)EnumStatoTraferimento.Annullato && a.IDSTATOTRASFERIMENTO != (decimal)EnumStatoTraferimento.Da_Attivare && a.DATARIENTRO >= dtIni && a.DATAPARTENZA <= dtFin) .ToList(); foreach (var t in lt) { var d = t.DIPENDENTI; var uf = t.UFFICI; #region elenco livelli x trasferimento var llivdip = t.INDENNITA.LIVELLIDIPENDENTI .Where(a => a.ANNULLATO == false && a.DATAFINEVALIDITA >= dtIni && a.DATAINIZIOVALIDITA <= dtFin) .ToList(); #endregion #region ciclo livelli foreach (var livdip in llivdip) { var annoMeseInizio = Convert.ToDecimal(AnnoDa.ToString() + MeseDa.ToString().PadLeft(2, (char)'0')); var annoMeseFine = Convert.ToDecimal(AnnoA.ToString() + MeseA.ToString().PadLeft(2, (char)'0')); #region lista teorici per livello (tutte le indennita interessate) var lteorici = t.TEORICI.Where(a => a.ANNULLATO == false && a.ELABORATO == true && a.INSERIMENTOMANUALE == false && ( a.IDVOCI == (decimal)EnumVociContabili.Ind_Prima_Sist_IPS || a.IDVOCI == (decimal)EnumVociContabili.Ind_Sede_Estera || a.IDVOCI == (decimal)EnumVociContabili.Ind_Richiamo_IRI ) && a.VOCI.IDTIPOLIQUIDAZIONE == (decimal)EnumTipoLiquidazione.Contabilità && Convert.ToDecimal((a.ANNORIFERIMENTO.ToString() + a.MESERIFERIMENTO.ToString().PadLeft(2, (char)'0'))) >= annoMeseInizio && Convert.ToDecimal((a.ANNORIFERIMENTO.ToString() + a.MESERIFERIMENTO.ToString().PadLeft(2, (char)'0'))) <= annoMeseFine) .GroupBy(a => new { a.ANNORIFERIMENTO, a.MESERIFERIMENTO }) .ToList(); #endregion #region cicla i gruppi di anno/mese rif teorici foreach (var teorici in lteorici) { decimal prima_sistemazione_anticipo = 0; decimal prima_sistemazione_saldo = 0; decimal prima_sistemazione_unica_sol = 0; decimal indennita = 0; decimal richiamo = 0; MESEANNOELABORAZIONE meseannoElab = new MESEANNOELABORAZIONE(); string strMeseAnnoElab = ""; string strMeseAnnoRif = ""; decimal numMeseRiferimento = 0; decimal numMeseElaborazione = 0; #region cicla le singole righe di teorici foreach (var teorici_row in teorici) { if (teorici_row.IDVOCI == (decimal)EnumVociContabili.Ind_Prima_Sist_IPS && teorici_row.ELABINDSISTEMAZIONE?.IDLIVELLO == livdip.IDLIVELLO && teorici_row.ELABINDSISTEMAZIONE.ANTICIPO) { prima_sistemazione_anticipo = teorici_row.IMPORTO; } if (teorici_row.IDVOCI == (decimal)EnumVociContabili.Ind_Prima_Sist_IPS && teorici_row.ELABINDSISTEMAZIONE?.IDLIVELLO == livdip.IDLIVELLO && (teorici_row.ELABINDSISTEMAZIONE.SALDO || teorici_row.ELABINDSISTEMAZIONE.CONGUAGLIO)) { prima_sistemazione_saldo = teorici_row.IMPORTO; } if (teorici_row.IDVOCI == (decimal)EnumVociContabili.Ind_Prima_Sist_IPS && teorici_row.ELABINDSISTEMAZIONE?.IDLIVELLO == livdip.IDLIVELLO && teorici_row.ELABINDSISTEMAZIONE.UNICASOLUZIONE) { prima_sistemazione_unica_sol = teorici_row.IMPORTO; } if (teorici_row.IDVOCI == (decimal)EnumVociContabili.Ind_Sede_Estera && teorici_row.DIRETTO == false && teorici_row.ELABINDENNITA.Any(b => b.IDLIVELLO == livdip.IDLIVELLO)) { indennita = teorici_row.IMPORTO; } if (teorici_row.IDVOCI == (decimal)EnumVociContabili.Ind_Richiamo_IRI && teorici_row.ELABINDRICHIAMO?.IDLIVELLO == livdip.IDLIVELLO) { richiamo = teorici_row.IMPORTO; } meseannoElab = db.MESEANNOELABORAZIONE.Find(teorici_row.IDMESEANNOELAB); using (dtElaborazioni dte = new dtElaborazioni()) { strMeseAnnoElab = CalcoloMeseAnnoElaborazione.NomeMese((EnumDescrizioneMesi)meseannoElab.MESE) + " " + meseannoElab.ANNO.ToString(); strMeseAnnoRif = CalcoloMeseAnnoElaborazione.NomeMese((EnumDescrizioneMesi)teorici_row.MESERIFERIMENTO) + " " + teorici_row.ANNORIFERIMENTO.ToString(); } numMeseRiferimento = Convert.ToDecimal(teorici_row.ANNORIFERIMENTO.ToString() + teorici_row.MESERIFERIMENTO.ToString().ToString().PadLeft(2, (char)'0')); numMeseElaborazione = Convert.ToDecimal(meseannoElab.ANNO.ToString() + meseannoElab.MESE.ToString().PadLeft(2, (char)'0')); } RptRiepiloghiIseMensileModel rptisem = new RptRiepiloghiIseMensileModel() { nominativo = d.COGNOME + " " + d.NOME + " (" + d.MATRICOLA + ")", qualifica = livdip.LIVELLI.LIVELLO, ufficio = uf.DESCRIZIONEUFFICIO, riferimento = strMeseAnnoRif, elaborazione = strMeseAnnoElab, prima_sistemazione_anticipo = prima_sistemazione_anticipo, prima_sistemazione_saldo = prima_sistemazione_saldo, prima_sistemazione_unica_soluz = prima_sistemazione_unica_sol, richiamo = richiamo, indennita_personale = indennita, numannomeseelab = numMeseElaborazione, numannomeserif = numMeseRiferimento }; rim.Add(rptisem); #endregion } #endregion } #endregion } return(rim); }
public ActionResult RptRiepilogoVoci(decimal idTrasferimento, List <decimal> Teorici) { List <RiepilogoVociModel> lrvm = new List <RiepilogoVociModel>(); List <RptRiepilogoVociModel> rpt = new List <RptRiepilogoVociModel>(); try { using (ModelDBISE db = new ModelDBISE()) { using (dtTrasferimento dtt = new dtTrasferimento()) { var tm = dtt.GetTrasferimentoById(idTrasferimento); string Nominativo = tm.Dipendente.Nominativo; using (dtRiepilogoVoci dtrv = new dtRiepilogoVoci()) { //lrvm = dtrv.GetRiepilogoVoci(idTrasferimento).ToList(); lrvm = dtrv.PrelevaRiepilogoVoci(Teorici).ToList(); } MESEANNOELABORAZIONE MeseAnnoElaborato = new MESEANNOELABORAZIONE(); if (lrvm?.Any() ?? false) { foreach (var lm in lrvm) { RptRiepilogoVociModel rptds = new RptRiepilogoVociModel() { dataOperazione = lm.dataOperazione, descrizione = lm.descrizione, Voce = lm.Voci.codiceVoce, movimento = lm.TipoMovimento.DescMovimento, Inserimento = lm.TipoVoce.descrizione, Liquidazione = lm.TipoLiquidazione.descrizione, meseAnnoRiferimento = lm.MeseAnnoRiferimento, Importo = lm.Importo, idMeseAnnoElaborato = lm.idMeseAnnoElaborato, meseAnnoElaborazione = lm.MeseAnnoElaborato, giornoMeseAnnoElaborazione = lm.GiornoMeseAnnoElaborato }; MeseAnnoElaborato = db.MESEANNOELABORAZIONE.Find(rptds.idMeseAnnoElaborato); rpt.Add(rptds); } } decimal annoMeseElaborato = Convert.ToDecimal(MeseAnnoElaborato.ANNO.ToString() + MeseAnnoElaborato.MESE.ToString().PadLeft(2, Convert.ToChar("0"))); ReportViewer reportViewer = new ReportViewer(); reportViewer.ProcessingMode = ProcessingMode.Local; reportViewer.SizeToReportContent = true; reportViewer.Width = Unit.Percentage(100); reportViewer.Height = Unit.Percentage(100); var datasource = new ReportDataSource("DtRiepilogoVoci"); reportViewer.Visible = true; reportViewer.ProcessingMode = ProcessingMode.Local; reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"/Report/RptRiepilogoVoci.rdlc"; reportViewer.LocalReport.DataSources.Clear(); reportViewer.LocalReport.DataSources.Add(datasource); reportViewer.LocalReport.DataSources.Add(new ReportDataSource("DtRiepilogoVoci", rpt)); reportViewer.LocalReport.Refresh(); ReportParameter[] parameterValues = new ReportParameter[] { new ReportParameter("Nominativo", Nominativo), new ReportParameter("parAnnoMeseElab", Convert.ToString(annoMeseElaborato)) }; reportViewer.LocalReport.SetParameters(parameterValues); ViewBag.ReportViewer = reportViewer; } } } catch (Exception ex) { return(PartialView("ErrorPartial", new MsgErr() { msg = ex.Message })); } return(PartialView("RptRiepilogoVoci")); }