public static List <CaratteristicaItem> EstraiListaCaratteristiche(string anagrafica) { List <CaratteristicaItem> caratteristiche = new List <CaratteristicaItem>(); ArticoliDS ds = new ArticoliDS(); using (ArticoliBusiness bArticolo = new ArticoliBusiness()) { bArticolo.FillCARATTERISTICHE_ANAGRAFICA(ds, anagrafica); } foreach (string caratteristica in codiciCaratteristiche) { ArticoliDS.CARATTERISTICHE_ANAGRAFICARow c = ds.CARATTERISTICHE_ANAGRAFICA.Where(x => x.CARATTERISTICA == caratteristica).FirstOrDefault(); if (c != null) { caratteristiche.Add(new CaratteristicaItem(c.DESCARATTERISTICA, c.CARATTERISTICA, c.DESVALORE, c.VALORE)); } } return(caratteristiche); }
public static string CreaDistinta(int idArticolo, int idTipoDistinta, int versione, string descrizione, bool standard, string account, out int idDiba) { idDiba = ElementiVuoti.DistintaBase; Articolo articolo = Articolo.EstraiArticolo(idArticolo); if (articolo == null) { return("Articolo non valido"); } TipoDistinta tipoDistinta = TipoDistinta.EstraiTipoDistinta(idTipoDistinta); if (tipoDistinta == null) { return("Tipo distinta non valido"); } ArticoliDS ds = new ArticoliDS(); using (ArticoliBusiness bArticolo = new ArticoliBusiness()) { ArticoliDS.DIBARow dibaNuova = ds.DIBA.NewDIBARow(); dibaNuova.IDARTICOLO = idArticolo; dibaNuova.IDTIPODIBA = idTipoDistinta; dibaNuova.DESCRIZIONE = descrizione; dibaNuova.VERSIONE = versione; dibaNuova.STANDARD = standard; dibaNuova.CANCELLATO = false; dibaNuova.DATAMODIFICA = DateTime.Now; dibaNuova.UTENTEMODIFICA = account; ds.DIBA.AddDIBARow(dibaNuova); bArticolo.UpdateDistintaBaseTable(ds); idDiba = dibaNuova.IDDIBA; } return("Distinta creata correttamente"); }
public static void SalvaListaFaseCiclo(List <FaseCiclo> fasiCiclo, string utente, int idDiba, int idComponente, ArticoliDS ds) { // if (fasiCiclo.Count() == 0) return; // int idComponente = fasiCiclo[0].IdComponente; // int idDiba = fasiCiclo[0].IdDiba; using (ArticoliBusiness bArticolo = new ArticoliBusiness()) { List <int> idFasiCicloAttive = fasiCiclo.Select(x => x.IdFaseCiclo).ToList(); List <int> idFasiCicloDaCancellare = ds.FASICICLO.Where(x => !idFasiCicloAttive.Contains(x.IDFASECICLO) && x.IDCOMPONENTE == idComponente).Select(x => x.IDFASECICLO).ToList(); foreach (int idFaseCicloDaCancellare in idFasiCicloDaCancellare) { ArticoliDS.FASICICLORow faseCicloDaCancellare = ds.FASICICLO.Where(x => x.RowState != System.Data.DataRowState.Deleted && x.IDFASECICLO == idFaseCicloDaCancellare).FirstOrDefault(); faseCicloDaCancellare.CANCELLATO = true; faseCicloDaCancellare.UTENTEMODIFICA = utente; faseCicloDaCancellare.DATAMODIFICA = DateTime.Now; } foreach (FaseCiclo faseCiclo in fasiCiclo) { SalvaFaseCiclo(faseCiclo, utente, ds); } } }
public static void SalvaListaComponenti(List <Componente> componenti, string utente) { if (componenti.Count() == 0) { return; } int idDiba = componenti[0].IdDiba; ArticoliDS ds = new ArticoliDS(); using (ArticoliBusiness bArticolo = new ArticoliBusiness()) { bArticolo.GetCOMPONENTI(ds, idDiba, true); bArticolo.GetFASICICLO(ds, idDiba, true); List <int> idComponentiAttivi = componenti.Select(x => x.IdComponente).ToList(); List <int> idComponentiDaCancellare = ds.COMPONENTI.Where(x => !idComponentiAttivi.Contains(x.IDCOMPONENTE)).Select(x => x.IDCOMPONENTE).ToList(); foreach (int idComponenteDaCancellare in idComponentiDaCancellare) { ArticoliDS.COMPONENTIRow componenteDaCancellare = ds.COMPONENTI.Where(x => x.RowState != System.Data.DataRowState.Deleted && x.IDCOMPONENTE == idComponenteDaCancellare).FirstOrDefault(); componenteDaCancellare.CANCELLATO = true; componenteDaCancellare.UTENTEMODIFICA = utente; componenteDaCancellare.DATAMODIFICA = DateTime.Now; } //Componente radice = componenti.Where(x => x.IdPadre == 0).FirstOrDefault(); //if (radice == null) return; //salvaComponentiRicorsivo(radice, ds, componenti, utente); foreach (Componente componente in componenti.OrderByDescending(x => x.IdPadre)) { // preparaSalvataggio(componente, ds, utente); ArticoliDS.COMPONENTIRow rigaComponente = ds.COMPONENTI.Where(x => x.RowState != System.Data.DataRowState.Deleted && x.IDCOMPONENTE == componente.IdComponente).FirstOrDefault(); if (rigaComponente == null || componente.IdComponente < 0) { rigaComponente = ds.COMPONENTI.NewCOMPONENTIRow(); rigaComponente.IDCOMPONENTE = componente.IdComponente; if (componente.IdPadre != 0) { rigaComponente.IDPADRE = componente.IdPadre; } rigaComponente.IDDIBA = componente.IdDiba; rigaComponente.DESCRIZIONE = componente.Descrizione.ToUpper(); rigaComponente.ANAGRAFICA = (string.IsNullOrEmpty(componente.Anagrafica)) ? string.Empty : componente.Anagrafica.ToUpper(); rigaComponente.COLLEGAMENTODIBA = (string.IsNullOrEmpty(componente.CollegamentoDiBa)) ? string.Empty : componente.CollegamentoDiBa.ToUpper(); rigaComponente.QUANTITA = componente.Quantita; rigaComponente.UMQUANTITA = (string.IsNullOrEmpty(componente.UMQuantita)) ? string.Empty : componente.UMQuantita.ToUpper(); rigaComponente.CANCELLATO = false; rigaComponente.DATAMODIFICA = DateTime.Now; rigaComponente.UTENTEMODIFICA = utente; ds.COMPONENTI.AddCOMPONENTIRow(rigaComponente); } else { if (componente.IdPadre != 0) { rigaComponente.IDPADRE = componente.IdPadre; } rigaComponente.DESCRIZIONE = componente.Descrizione.ToUpper(); rigaComponente.ANAGRAFICA = (string.IsNullOrEmpty(componente.Anagrafica)) ? string.Empty : componente.Anagrafica.ToUpper(); rigaComponente.COLLEGAMENTODIBA = (string.IsNullOrEmpty(componente.CollegamentoDiBa)) ? string.Empty : componente.CollegamentoDiBa.ToUpper(); rigaComponente.QUANTITA = componente.Quantita; rigaComponente.UMQUANTITA = (string.IsNullOrEmpty(componente.UMQuantita)) ? string.Empty : componente.UMQuantita.ToUpper(); rigaComponente.CANCELLATO = false; rigaComponente.DATAMODIFICA = DateTime.Now; rigaComponente.UTENTEMODIFICA = utente; } FaseCiclo.SalvaListaFaseCiclo(componente.FasiCiclo, utente, componente.IdDiba, componente.IdComponente, ds); } DataRow[] root = ds.COMPONENTI.Where(x => x.IsIDPADRENull()).ToArray(); // DataRow[] altriNodi = ds.COMPONENTI.Where(x => !x.IsIDPADRENull()).OrderByDescending(x => x.IDPADRE).ToArray(); salvaComponentiRicorsivo(root, ds, bArticolo); //bArticolo.UpdateComponentiTable(ds.COMPONENTI.TableName, root); //bArticolo.UpdateComponentiTable(ds.COMPONENTI.TableName, altriNodi); bArticolo.UpdateTable(ds.FASICICLO.TableName, ds); } }
public static bool Salva(List <TaskArea> tasks, string utente) { bool esito = true; foreach (TaskArea t in tasks) { if (string.IsNullOrEmpty(t.Task)) { esito = false; } if (string.IsNullOrEmpty(t.AreaProduzione)) { esito = false; } if (t.Periodo <= 0) { esito = false; } if (t.PezziPeriodo <= 0) { esito = false; } } if (!esito) { return(false); } ArticoliDS ds = new ArticoliDS(); using (ArticoliBusiness bArticolo = new ArticoliBusiness()) { bArticolo.FillTaskArea(ds, true); List <int> ids = tasks.Select(x => x.IdTaskArea).ToList(); foreach (ArticoliDS.TASKAREARow rigaDaCancellare in ds.TASKAREA.Where(x => !ids.Contains(x.IDTASKAREA))) { rigaDaCancellare.CANCELLATO = true; rigaDaCancellare.DATAMODIFICA = DateTime.Now; rigaDaCancellare.UTENTEMODIFICA = utente; } List <int> idBC = ds.TASKAREA.Select(x => x.IDTASKAREA).ToList(); foreach (TaskArea t in tasks) { ArticoliDS.TASKAREARow riga = ds.TASKAREA.Where(x => x.IDTASKAREA == t.IdTaskArea).FirstOrDefault(); if (riga == null) { riga = ds.TASKAREA.NewTASKAREARow(); // riga.IDTASKAREA = t.IdTaskArea; riga.AREAPRODUZIONE = t.AreaProduzione; riga.TASK = t.Task; riga.PEZZIPERIODO = t.PezziPeriodo; riga.PERIODO = t.Periodo; riga.DATAMODIFICA = DateTime.Now; riga.UTENTEMODIFICA = utente; riga.CANCELLATO = false; ds.TASKAREA.AddTASKAREARow(riga); } else { if (riga.AREAPRODUZIONE == t.AreaProduzione && riga.TASK == t.Task && riga.PEZZIPERIODO == t.PezziPeriodo && riga.PERIODO == t.Periodo) { continue; } riga.AREAPRODUZIONE = t.AreaProduzione; riga.TASK = t.Task; riga.PEZZIPERIODO = t.PezziPeriodo; riga.PERIODO = t.Periodo; riga.DATAMODIFICA = DateTime.Now; riga.UTENTEMODIFICA = utente; } } bArticolo.UpdateTable(ds.TASKAREA.TableName, ds); } return(true); }