Example #1
0
        private static SPMaster CreaMaster(SchedeProcessoDS.SPMASTERSRow riga, SchedeProcessoDS ds)
        {
            if (riga == null)
            {
                return(null);
            }
            SPMaster master = new SPMaster();

            master.IdSPMaster           = riga.IDSPMASTER;
            master.Codice               = riga.CODICE;
            master.Descrizione          = riga.DESCRIZIONE;
            master.AreaProduzione       = riga.AREAPRODUZIONE;
            master.Task                 = riga.TASK;
            master.IdSchedaObbligatoria = riga.IDSCHEDAOBBLIGATORIA;

            master.Cancellato     = riga.CANCELLATO;
            master.DataModifica   = riga.DATAMODIFICA;
            master.Descrizione    = riga.DESCRIZIONE;
            master.UtenteModifica = riga.UTENTEMODIFICA;

            master.Elementi            = SPElemento.EstraiListaSPElementi(riga.IDSPMASTER, true, ds);
            master.ElementiObbligatori = SPElemento.EstraiListaSPElementiObbligatori(riga.IDSCHEDAOBBLIGATORIA, true);

            return(master);
        }
        private static SPElemento CreaElementoObbligatorio(SchedeProcessoDS.SPELEMENTIOBBLIGATORIRow riga)
        {
            if (riga == null)
            {
                return(null);
            }
            SPElemento elemento = new SPElemento();

            elemento.IdSPElemento  = riga.IDSPELEMENTOOBBLIGATORIO;
            elemento.IdSPControllo = riga.IsIDSPCONTROLLONull() ? -1 : riga.IDSPCONTROLLO;
            elemento.IdSPMaster    = -1;
            elemento.Testo         = riga.IsTESTONull() ? string.Empty : riga.TESTO;
            elemento.Tipo          = riga.TIPOELEMENTO;
            elemento.Sequenza      = riga.SEQUENZA;
            elemento.Obbligatorio  = riga.IsOBBLIGATORIONull() ? false : riga.OBBLIGATORIO;
            elemento.ElementoObbligatorioMaster = true;
            elemento.Cancellato     = riga.CANCELLATO;
            elemento.DataModifica   = riga.DATAMODIFICA;
            elemento.UtenteModifica = riga.UTENTEMODIFICA;

            if (elemento.Tipo == TipoSPElemento.CONTROLLO)
            {
                elemento.Controllo = SPControllo.EstraiSPControllo(elemento.IdSPControllo);
            }

            return(elemento);
        }
        public static List <SPElemento> EstraiListaSPElementi(int IdSPMaster, bool soloNonCancellati, SchedeProcessoDS ds)
        {
            using (SchedeProcessoBusiness bScheda = new SchedeProcessoBusiness())
            {
                ds.SPELEMENTI.Clear();
                bScheda.FillElementi(ds, IdSPMaster, soloNonCancellati);
            }

            List <SPElemento> controlli = new List <SPElemento>();

            foreach (SchedeProcessoDS.SPELEMENTIRow riga in ds.SPELEMENTI)
            {
                SPElemento elemento = CreaElemento(riga);
                controlli.Add(elemento);
            }
            return(controlli);
        }
        public static List <SPElemento> EstraiListaSPElementiObbligatori(int idSchedaObbligatoria, bool soloNonCancellati)
        {
            SchedeProcessoDS ds = new SchedeProcessoDS();

            using (SchedeProcessoBusiness bScheda = new SchedeProcessoBusiness())
            {
                ds.SPELEMENTIOBBLIGATORI.Clear();
                bScheda.FillElementiObbligatori(ds, idSchedaObbligatoria, soloNonCancellati);
            }

            List <SPElemento> controlli = new List <SPElemento>();

            foreach (SchedeProcessoDS.SPELEMENTIOBBLIGATORIRow riga in ds.SPELEMENTIOBBLIGATORI)
            {
                SPElemento elemento = CreaElementoObbligatorio(riga);
                controlli.Add(elemento);
            }
            return(controlli);
        }
Example #5
0
        public static string SalvaMaster(int idMaster, string codice, string descrizione, string areaProduzione, string task, ElementoMaster[] elementiLista, string account)
        {
            SchedeProcessoDS ds = new SchedeProcessoDS();

            using (SchedeProcessoBusiness bScheda = new SchedeProcessoBusiness())
            {
                bScheda.GetSPMaster(ds, idMaster);
                bScheda.FillElementi(ds, idMaster, true);

                SchedeProcessoDS.SPMASTERSRow riga = ds.SPMASTERS.Where(x => x.IDSPMASTER == idMaster).FirstOrDefault();

                if (string.IsNullOrEmpty(codice))
                {
                    int maxIDSPMasyer = bScheda.GetMaxIDSPMaster() + 1;
                    codice = "MA" + maxIDSPMasyer.ToString().PadLeft(ds.SPMASTERS.CODICEColumn.MaxLength - 2, '0');
                }

                if (riga != null)
                {
                    riga.CODICE         = codice.ToUpper();
                    riga.DESCRIZIONE    = descrizione.ToUpper();
                    riga.AREAPRODUZIONE = areaProduzione.ToUpper();
                    riga.TASK           = task.ToUpper();
                    riga.DATAMODIFICA   = DateTime.Now;
                    riga.UTENTEMODIFICA = account;
                }
                else
                {
                    riga                = ds.SPMASTERS.NewSPMASTERSRow();
                    riga.CODICE         = codice.ToUpper();
                    riga.DESCRIZIONE    = descrizione.ToUpper();
                    riga.AREAPRODUZIONE = areaProduzione.ToUpper();
                    riga.TASK           = task.ToUpper();
                    riga.CANCELLATO     = false;
                    riga.DATAMODIFICA   = DateTime.Now;
                    riga.UTENTEMODIFICA = account.ToUpper();
                    ds.SPMASTERS.AddSPMASTERSRow(riga);
                }


                if (idMaster > 0)
                {
                    List <int> listaIdElementi = elementiLista.Where(x => x.IDElemento > 0).Select(x => x.IDElemento).Distinct().ToList();
                    foreach (SchedeProcessoDS.SPELEMENTIRow elemento in ds.SPELEMENTI)
                    {
                        if (!listaIdElementi.Contains(elemento.IDSPELEMENTO))
                        {
                            elemento.CANCELLATO     = true;
                            elemento.DATAMODIFICA   = DateTime.Now;
                            elemento.UTENTEMODIFICA = account;
                        }
                    }
                }

                List <int> idControlliObbligatori = SPElemento.EstraiListaSPElementiObbligatori(1, true).Select(x => x.IdSPControllo).Distinct().ToList();
                int        sequenza = 0;
                foreach (ElementoMaster elemento in elementiLista)
                {
                    if (!idControlliObbligatori.Contains(elemento.IDControllo))
                    {
                        sequenza++;
                        SPElemento.SalvaElemento(elemento.IDElemento, elemento.IDControllo, riga.IDSPMASTER, elemento.Testo, elemento.Tipo, elemento.Obbligatorio, sequenza, account, ds);
                    }
                }
                bScheda.UpdateTableSPMaster(ds);
                bScheda.UpdateTable(ds.SPELEMENTI.TableName, ds);
            }
            return("Master creato correttamente");
        }