Exemplo n.º 1
0
        public void Cancella()
        {
            ArticoliDS ds = new ArticoliDS();

            using (ArticoliBusiness bArticolo = new ArticoliBusiness())
            {
                bArticolo.GetArticolo(ds, IdArticolo);
                ArticoliDS.ARTICOLIRow articoloDs = ds.ARTICOLI.Where(x => x.IDARTICOLO == IdArticolo).FirstOrDefault();
                if (articoloDs != null)
                {
                    this.Cancellato       = true;
                    articoloDs.CANCELLATO = true;
                    bArticolo.UpdateTable(ds.ARTICOLI.TableName, ds);
                }
            }
        }
Exemplo n.º 2
0
        public void Cancella(string utente)
        {
            ArticoliDS ds = new ArticoliDS();

            using (ArticoliBusiness bArticolo = new ArticoliBusiness())
            {
                bArticolo.GetDistintaBase(ds, IdDiba);
                ArticoliDS.DIBARow riga = ds.DIBA.Where(x => x.IDDIBA == IdDiba).FirstOrDefault();
                if (riga != null)
                {
                    riga.CANCELLATO     = true;
                    riga.UTENTEMODIFICA = utente;
                    riga.DATAMODIFICA   = DateTime.Now;
                }
                bArticolo.UpdateTable(ds.DIBA.TableName, ds);
            }
        }
Exemplo n.º 3
0
        public static string CreaArticolo(int idBrand, string anagrafica, string descrizione, string codiceCliente, string codiceColore, string account)
        {
            Brand brand = Brand.EstraiBrand(idBrand);

            if (brand == null)
            {
                return("Brand non valido");
            }

            Articolo articolo = Articolo.EstraiArticolo(anagrafica);

            if (articolo != null)
            {
                return("Esiste già un articolo con questa anagrafica");
            }

            ArticoliDS ds = new ArticoliDS();

            using (ArticoliBusiness bArticolo = new ArticoliBusiness())
            {
                ArticoliDS.ARTICOLIRow articolonuovo = ds.ARTICOLI.NewARTICOLIRow();
                articolonuovo.IDBRAND        = idBrand;
                articolonuovo.DESCRIZIONE    = descrizione;
                articolonuovo.CANCELLATO     = false;
                articolonuovo.DATAMODIFICA   = DateTime.Now;
                articolonuovo.UTENTEMODIFICA = account;

                if (!string.IsNullOrEmpty(anagrafica))
                {
                    articolonuovo.ANAGRAFICA = anagrafica;
                }
                if (!string.IsNullOrEmpty(codiceCliente))
                {
                    articolonuovo.CODICECLIENTE = codiceCliente;
                }
                if (!string.IsNullOrEmpty(codiceColore))
                {
                    articolonuovo.COLORE = codiceColore;
                }

                ds.ARTICOLI.AddARTICOLIRow(articolonuovo);
                bArticolo.UpdateTable(ds.ARTICOLI.TableName, ds);
            }
            return("Articolo creato correttamente");
        }
Exemplo n.º 4
0
        public void Salva(string utente)
        {
            ArticoliDS ds = new ArticoliDS();

            using (ArticoliBusiness bArticolo = new ArticoliBusiness())
            {
                bArticolo.GetDistintaBase(ds, IdDiba);
                ArticoliDS.DIBARow diba = ds.DIBA.Where(x => x.IDDIBA == IdDiba).FirstOrDefault();
                if (diba != null)
                {
                    diba.DESCRIZIONE = Descrizione;
                    bArticolo.UpdateTable(ds.DIBA.TableName, ds);
                }
            }

            if (Componenti.Count() == 0)
            {
                return;
            }

            Componente.SalvaListaComponenti(Componenti, utente);
        }
        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);
            }
        }
Exemplo n.º 6
0
        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);
        }