예제 #1
0
        private bool trovaAnagraficaPerMigrazione(MigrazioneODLDS.USR_PRD_MOVFASIRow odl)
        {
            txtAnagrafica.Text = string.Empty;
            if (odl.IsIDMAGAZZNull())
            {
                return(false);
            }


            string idmagazz = odl.IDMAGAZZ;

            using (MigrazioneODLBusiness bMigrazioneODL = new MigrazioneODLBusiness())
            {
                bool continua = true;
                MigrazioneODLDS.BC_ANAGRAFICA_PRODUZIONERow anagrafica = bMigrazioneODL.GetANAGRAFICA(_ds, idmagazz);

                if (anagrafica != null)
                {
                    txtAnagrafica.Text = (anagrafica == null) ? string.Empty : anagrafica.BC;
                    return(true);
                }
                bMigrazioneODL.FillBC_MIGRAZIONE(_ds);
                MigrazioneODLDS.BC_MIGRAZIONERow riga = _ds.BC_MIGRAZIONE.Where(x => x.IDMAGAZZ == idmagazz).FirstOrDefault();
                if (riga == null)
                {
                    return(false);
                }
                decimal iddiba = riga.DIBA;
                decimal idnodo = riga.IDNODO;
                while (anagrafica == null && continua)
                {
                    riga = _ds.BC_MIGRAZIONE.Where(x => x.IDNODO == idnodo && x.DIBA == iddiba).FirstOrDefault();
                    if (riga == null)
                    {
                        continua = false;
                    }
                    else
                    {
                        if (riga.IDPADRE < 0)
                        {
                            continua = false;
                        }
                        else
                        {
                            MigrazioneODLDS.BC_MIGRAZIONERow rigaPadre = _ds.BC_MIGRAZIONE.Where(x => x.IDNODO == riga.IDPADRE && x.DIBA == iddiba).FirstOrDefault();
                            idmagazz   = rigaPadre.IDMAGAZZ;
                            idnodo     = rigaPadre.IDNODO;
                            anagrafica = bMigrazioneODL.GetANAGRAFICA(_ds, idmagazz);
                        }
                    }
                }

                txtPRODOTTOFINITO.Text = riga.PRODOTTOFINALE;
                txtAnagrafica.Text     = (anagrafica == null) ? string.Empty : anagrafica.BC;

                return(anagrafica != null);
            }
        }
예제 #2
0
        private void btnSCaricaNodi_Click(object sender, EventArgs e)
        {
            txtMessaggi.Text = string.Empty;
            StringBuilder sb = new StringBuilder();

            _ds = new MigrazioneODLDS();
            using (MigrazioneODLBusiness bMigrazioneODL = new MigrazioneODLBusiness())
            {
                bMigrazioneODL.FillBC_MIGRAZIONE(_ds);
                foreach (MigrazioneODLDS.BC_MIGRAZIONERow r in _ds.BC_MIGRAZIONE)
                {
                    r.Delete();
                }

                bMigrazioneODL.UpdateTable(_ds.BC_MIGRAZIONE.TableName, _ds);
                _ds.AcceptChanges();
                bMigrazioneODL.GetPRODOTTIFINITI(_ds);
            }
            int idDiba = 0;
            EstraiProdottoFinito form = new EstraiProdottoFinito();

            foreach (MigrazioneODLDS.BC_ANAGRAFICA_PRODUZIONERow prodottoFinito in _ds.BC_ANAGRAFICA_PRODUZIONE)
            {
                try
                {
                    _ds.BC_MIGRAZIONE.Clear();
                    List <Nodo> Nodi = form.CreaListaNodi(prodottoFinito.MODELLO, false);
                    if (Nodi == null)
                    {
                        sb.AppendLine(string.Format("Articolo {0} distinta non trovata", prodottoFinito.MODELLO));
                    }
                    else
                    {
                        idDiba++;
                        Nodi.ForEach(x => caricaNodo(x, idDiba, prodottoFinito.MODELLO));

                        using (MigrazioneODLBusiness bMigrazioneODL = new MigrazioneODLBusiness())
                        {
                            bMigrazioneODL.UpdateTable(_ds.BC_MIGRAZIONE.TableName, _ds);
                        }
                    }
                }
                catch (Exception ex)
                {
                    sb.AppendLine(string.Format("Articolo {0} ECCEZIONE in CREA LISTA", prodottoFinito));
                    sb.AppendLine(ex.Message);
                }
            }
            form.Close();
            form.Dispose();
            form             = null;
            txtMessaggi.Text = sb.ToString();
        }
예제 #3
0
        private MigrazioneODLDS.USR_PRD_MOVFASIRow estraiDatiODLAuto(string ordine)
        {
            using (MigrazioneODLBusiness bMigrazioneODLAuto = new MigrazioneODLBusiness())
            {
                bMigrazioneODLAuto.GetUSR_PRD_MOVFASI(_ds, ordine);


                MigrazioneODLDS.USR_PRD_MOVFASIRow odls = _ds.USR_PRD_MOVFASI.Where(x => x.BARCODE == ordine).FirstOrDefault();
                if (odls != null)
                {
                    bMigrazioneODLAuto.GetCLIFO(_ds, odls.CODICECLIFO);
                    MigrazioneODLDS.CLIFORow reparto = _ds.CLIFO.Where(x => x.CODICE == odls.CODICECLIFO).FirstOrDefault();

                    bMigrazioneODLAuto.GetTABFAS(_ds, odls.IDTABFAS);
                    MigrazioneODLDS.TABFASRow fase = _ds.TABFAS.Where(x => x.IDTABFAS == odls.IDTABFAS).FirstOrDefault();

                    bMigrazioneODLAuto.GetMAGAZZ(_ds, odls.IDMAGAZZ);
                    MigrazioneODLDS.MAGAZZRow articolo = _ds.MAGAZZ.Where(x => x.IDMAGAZZ == odls.IDMAGAZZ).FirstOrDefault();

                    txtIDPRDMOVFASE.Text = odls.IDPRDMOVFASE;
                    txtAZIENDA.Text      = odls.AZIENDA;
                    txtREPARTO.Text      = reparto.RAGIONESOC.Trim();
                    txtFASE.Text         = fase.CODICEFASE.Trim();
                    txtIDMAGAZZ.Text     = articolo.IDMAGAZZ.Trim();
                    txtArticolo.Text     = articolo.MODELLO.Trim();
                    txtQuantita.Text     = odls.QTA.ToString();
                    txtQtaDaTer.Text     = odls.QTADATER.ToString();
                    txtMetodoDiba.Text   = odls.IDDIBAMETHOD;
                    txtVersioneDiba.Text = odls.VERSION.ToString();
                    txtDescVersione.Text = odls.DESVERSION.Trim();
                    txtDescVersione.Text = odls.NUMMOVFASE;
                    txtNumOdl.Text       = odls.NUMMOVFASE;
                }
                return(odls);
            }
        }
예제 #4
0
        private void _bgwMigraODL_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            string           numord = txtBarcodeODL.Text;

            ODLDTO dto = (ODLDTO)e.Argument;

            int progress = 1;

            foreach (string nummovfase in dto.odls)
            {
                decimal perc = progress;

                string distintaBC = string.Empty;
                worker.ReportProgress((int)perc);
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }
                try
                {
                    MigrazioneODLDS ds = new MigrazioneODLDS();

                    if (string.IsNullOrEmpty(nummovfase))
                    {
                        continue;
                    }
                    //string anagraficaBC = string.Empty;
                    MigrazioneODLDS.USR_PRD_MOVFASIRow odl      = null;
                    MigrazioneODLDS.MAGAZZRow          articolo = null;
                    string desvcrizione2odl       = string.Empty;
                    string descrizioneVersioneODV = string.Empty;
                    string repartoRagSoc          = string.Empty;
                    string faseCodice             = string.Empty;

                    using (MigrazioneODLBusiness bMigrazioneODL = new MigrazioneODLBusiness())
                    {
                        bMigrazioneODL.InsertODL2ODPlog(nummovfase, "8 Migrazione iniziata", dto.esecuzione, dto.company);

                        bMigrazioneODL.GetUSR_PRD_MOVFASIByNumdoc(ds, nummovfase);
                        odl = ds.USR_PRD_MOVFASI.Where(x => x.NUMMOVFASE == nummovfase).FirstOrDefault();

                        if (odl == null)
                        {
                            bMigrazioneODL.InsertODL2ODPlog(nummovfase, "1 ODL NON TROVATO", dto.esecuzione, dto.company);
                            continue;
                        }

                        bMigrazioneODL.GetCLIFO(ds, odl.CODICECLIFO);
                        MigrazioneODLDS.CLIFORow reparto = ds.CLIFO.Where(x => x.CODICE == odl.CODICECLIFO).FirstOrDefault();
                        repartoRagSoc = reparto.CODICE;

                        if (reparto.CODICE.Substring(0, 1) == "0")
                        {
                            bMigrazioneODL.InsertODL2ODPlog(nummovfase, "7 REPARTO TERZISTA", dto.esecuzione, dto.company);
                            continue;
                        }

                        if (worker.CancellationPending)
                        {
                            e.Cancel = true;
                            return;
                        }

                        bMigrazioneODL.GetTABFAS(ds, odl.IDTABFAS);
                        MigrazioneODLDS.TABFASRow fase = ds.TABFAS.Where(x => x.IDTABFAS == odl.IDTABFAS).FirstOrDefault();
                        faseCodice = fase.CODICEFASE;

                        if (worker.CancellationPending)
                        {
                            e.Cancel = true;
                            return;
                        }

                        bMigrazioneODL.GetMAGAZZ(ds, odl.IDMAGAZZ);
                        articolo = ds.MAGAZZ.Where(x => x.IDMAGAZZ == odl.IDMAGAZZ).FirstOrDefault();

                        bool continua = true;
                        if (worker.CancellationPending)
                        {
                            e.Cancel = true;
                            return;
                        }
                        MigrazioneODLDS.BC_ANAGRAFICA_PRODUZIONERow anagrafica = bMigrazioneODL.GetANAGRAFICA(ds, odl.IDMAGAZZ);

                        MigrazioneODLDS.USR_PRD_FASIRow prdFase = bMigrazioneODL.GetUSR_PRD_FASI(ds, odl.IsIDPRDFASENull() ? string.Empty : odl.IDPRDFASE, odl.AZIENDA);
                        if (prdFase == null && anagrafica == null)
                        {
                            string str = string.Format("2 USR PRD FASE non trovata ");
                            bMigrazioneODL.InsertODL2ODPlog(nummovfase, str, dto.esecuzione, dto.company);
                            continue;
                        }
                        while (anagrafica == null && continua)
                        {
                            if (prdFase.IsIDPRDFASEPADRENull() || string.IsNullOrEmpty(prdFase.IDPRDFASEPADRE))
                            {
                                string str = string.Format("9 impossibile trovare una anagrafica di trasferimento idmagazz {0} odl {1}", odl.IDMAGAZZ, odl.IDPRDMOVFASE);
                                bMigrazioneODL.InsertODL2ODPlog(nummovfase, str, dto.esecuzione, dto.company);
                                continua = false;
                                continue;
                            }
                            prdFase = bMigrazioneODL.GetUSR_PRD_FASI(ds, prdFase.IDPRDFASEPADRE, prdFase.AZIENDA);
                            if (prdFase != null)
                            {
                                anagrafica = bMigrazioneODL.GetANAGRAFICA(ds, prdFase.IDMAGAZZ);
                            }
                            else
                            {
                                string str = string.Format("3 fase padre non trovata ");
                                bMigrazioneODL.InsertODL2ODPlog(nummovfase, str, dto.esecuzione, dto.company);
                                continua = false;
                            }
                        }

                        if (anagrafica == null)
                        {
                            string str = string.Format("4 Anagrafica non trovata ");
                            bMigrazioneODL.InsertODL2ODPlog(nummovfase, str, dto.esecuzione, dto.company);
                            continue;
                        }

                        distintaBC = anagrafica.BC;

                        descrizioneVersioneODV = string.Format("{0} {1}", odl.NUMMOVFASE, odl.DATAMOVFASE.ToShortDateString());
                        desvcrizione2odl       = string.Format("{0} - {1}", reparto.CODICE.Trim(), fase.CODICEFASE.Trim());
                    }

                    if (odl == null)
                    {
                        continue;
                    }
                    if (articolo == null)
                    {
                        continue;
                    }

                    string  IDPRDMOVFASE = odl.IDPRDMOVFASE;
                    string  azienda      = odl.AZIENDA;
                    string  idmagazz     = articolo.IDMAGAZZ.Trim();
                    string  modello      = articolo.MODELLO.Trim();
                    decimal quantita     = odl.QTA;
                    decimal qtadater     = odl.QTADATER;


                    using (MigrazioneODLSQLBusiness bMigrazioneODLSQL = new MigrazioneODLSQLBusiness())
                    {
                        bMigrazioneODLSQL.GetDistinteBCDettaglio(ds, distintaBC);
                    }
                    using (MigrazioneODLBusiness bMigrazioneODL = new MigrazioneODLBusiness())
                    {
                        if (worker.CancellationPending)
                        {
                            e.Cancel = true;
                            return;
                        }

                        MPIntranet.WS.BCServices bc = new MPIntranet.WS.BCServices();
                        bc.CreaConnessione(dto.company);

                        bMigrazioneODL.GetODL2ODP(ds, nummovfase);
                        bMigrazioneODL.GetODL2ODPCOMPONENTI(ds, nummovfase);

                        List <MigrazioneODLDS.ODL2ODPRow> odls = ds.ODL2ODP.Where(x => x.NUMMOVFASE == nummovfase && x.COMPANY == dto.company).ToList();
                        if (odls.Count > 0)
                        {
                            MigrazioneODLDS.ODL2ODPRow odp = odls[0];
                            string msg = String.Format("5 ODL già migrato nell'ordine di produzione {0} per la company {1}", odp.ODV, dto.company);
                            bMigrazioneODL.InsertODL2ODPlog(nummovfase, msg, dto.esecuzione, dto.company);
                            continue;
                        }

                        List <MigrazioneODLDS.ODL2ODPCOMPONENTIRow> odlsComp = ds.ODL2ODPCOMPONENTI.Where(x => x.NUMMOVFASE == nummovfase && x.COMPANY == dto.company).ToList();
                        if (odlsComp.Count > 0)
                        {
                            string msg = String.Format("6 Componenti dell'ODL {0} già a sistema per la company {1}", txtNumOdl.Text, dto.company);
                            bMigrazioneODL.InsertODL2ODPlog(nummovfase, msg, dto.esecuzione, dto.company);
                            continue;
                        }
                        if (worker.CancellationPending)
                        {
                            e.Cancel = true;
                            return;
                        }

                        if (dto.soloRVL)
                        {
                            bMigrazioneODL.InsertODL2ODPlog(nummovfase, "0 Migrazione completata correttamente SOLO RVL", dto.esecuzione, dto.company);
                            continue;
                        }
                        string codiceODP = bc.CreaOdDPConfermato(distintaBC, DateTime.Now, quantita, ubicazione, descrizioneVersioneODV, desvcrizione2odl);
                        bMigrazioneODL.InsertODL2ODP(azienda, odl.IDPRDMOVFASE, nummovfase, repartoRagSoc.Trim(), faseCodice, idmagazz, distintaBC, quantita, codiceODP, descrizioneVersioneODV, desvcrizione2odl, dto.company);

                        int             linenumber = 0;
                        List <RegMesWS> magazzino  = bc.EstraiRegMag();
                        if (magazzino.Count > 0)
                        {
                            linenumber = magazzino.Where(x => x.Journal_Batch_Name == "REGWS").Max(x => x.Line_No);
                        }

                        foreach (MigrazioneODLDS.DistinteBCDettaglioRow dettaglio in ds.DistinteBCDettaglio.Where(x => x.Production_BOM_No_ == distintaBC))
                        {
                            decimal quantitaComponente = quantita * dettaglio.Quantity;
                            linenumber += 1000;
                            bc.CreaRegistrazioneMagazzino(ubicazione, collocazione, linenumber, nummovfase, quantitaComponente, dettaglio.No_);
                            bMigrazioneODL.InsertODL2ODPComponenti(azienda, nummovfase, repartoRagSoc.Trim(), faseCodice, distintaBC, dettaglio.No_, quantitaComponente, quantita, codiceODP, ubicazione, collocazione, dto.company);
                        }
                        if (dto.ChBoxRegMag)
                        {
                            bc.PostingRegMag();
                        }

                        bMigrazioneODL.InsertODL2ODPlog(nummovfase, "0 Migrazione completata correttamente", dto.esecuzione, dto.company);
                    }
                }
                catch (Exception ex)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("ECCEZIONE ");
                    while (ex != null)
                    {
                        sb.AppendLine(ex.Message);
                        sb.AppendLine(ex.Source);
                        ex = ex.InnerException;
                        sb.AppendLine("**");
                    }
                    using (MigrazioneODLBusiness bMigrazioneODL = new MigrazioneODLBusiness())
                    {
                        bMigrazioneODL.InsertODL2ODPlog(nummovfase, sb.ToString(), dto.esecuzione, dto.company);
                    }
                }
                finally
                {
                    progress++;
                }
            }
        }
예제 #5
0
        private void btnMigraOrdineProduzione_Click(object sender, EventArgs e)
        {
            try
            {
                MigrazioneODLDS ds = new MigrazioneODLDS();
                Cursor.Current = Cursors.WaitCursor;
                txtBarcodeODL.Focus();
                txtMessaggi.Text = string.Empty;
                txtODP.Text      = string.Empty;

                if (string.IsNullOrEmpty(txtNumOdl.Text))
                {
                    txtMessaggi.Text = "Prima selezionare in ODL";
                    return;
                }

                if (string.IsNullOrEmpty(txtAnagrafica.Text))
                {
                    txtMessaggi.Text = "Impossibile inserire un'anagrafica vuota";
                    return;
                }

                if (string.IsNullOrEmpty(txtQtaDaTer.Text))
                {
                    txtMessaggi.Text = "Quantità da terminare indefinita";
                    return;
                }

                string company = ConfigurationManager.AppSettings["Azienda"];

                decimal quantita = 0;
                if (!decimal.TryParse(txtQuantita.Text, out quantita))
                {
                    txtMessaggi.Text = "Impossibile convertire quantità da terminare";
                    return;
                }

                MPIntranet.WS.BCServices bc = new MPIntranet.WS.BCServices();
                bc.CreaConnessione(company);
                using (MigrazioneODLBusiness bMigrazioneODL = new MigrazioneODLBusiness())
                {
                    bMigrazioneODL.GetODL2ODP(ds, txtNumOdl.Text);
                    bMigrazioneODL.GetODL2ODPCOMPONENTI(ds, txtNumOdl.Text);

                    List <MigrazioneODLDS.ODL2ODPRow> odls = ds.ODL2ODP.Where(x => x.NUMMOVFASE == txtNumOdl.Text && x.COMPANY == company).ToList();
                    if (odls.Count > 0)
                    {
                        MigrazioneODLDS.ODL2ODPRow odp = odls[0];
                        txtMessaggi.Text = String.Format("ODL già migrato nell'ordine di produzione {0} per la company {1}", odp.ODV, company);
                        return;
                    }

                    List <MigrazioneODLDS.ODL2ODPCOMPONENTIRow> odlsComp = ds.ODL2ODPCOMPONENTI.Where(x => x.NUMMOVFASE == txtNumOdl.Text && x.COMPANY == company).ToList();
                    if (odlsComp.Count > 0)
                    {
                        txtMessaggi.Text = String.Format("Componenti dell'ODL {0} già a sistema per la company {1}", txtNumOdl.Text, company);
                        return;
                    }

                    string codiceODP = bc.CreaOdDPConfermato(txtAnagrafica.Text, DateTime.Now, quantita, ubicazione, txtDescrizioneODV.Text, txtDescrizione2ODV.Text);
                    bMigrazioneODL.InsertODL2ODP(txtAZIENDA.Text, txtIDPRDMOVFASE.Text, txtNumOdl.Text, txtREPARTO.Text, txtFASE.Text, txtIDMAGAZZ.Text, txtAnagrafica.Text, quantita, codiceODP, txtDescrizioneODV.Text, txtDescrizione2ODV.Text, company);

                    txtODP.Text = codiceODP;
                    int             linenumber = 0;
                    List <RegMesWS> magazzino  = bc.EstraiRegMag();
                    if (magazzino.Count > 0)
                    {
                        linenumber = magazzino.Where(x => x.Journal_Batch_Name == "REGWS").Max(x => x.Line_No);
                    }

                    foreach (MigrazioneODLDS.DistinteBCDettaglioRow dettaglio in _ds.DistinteBCDettaglio.Where(x => x.Production_BOM_No_ == txtAnagrafica.Text))
                    {
                        decimal quantitaComponente = quantita * dettaglio.Quantity;
                        linenumber += 1000;
                        bc.CreaRegistrazioneMagazzino(ubicazione, collocazione, linenumber, txtNumOdl.Text, quantitaComponente, dettaglio.No_);
                        bMigrazioneODL.InsertODL2ODPComponenti(txtAZIENDA.Text, txtNumOdl.Text, txtREPARTO.Text, txtFASE.Text, txtAnagrafica.Text, dettaglio.No_, quantitaComponente, quantita, codiceODP, ubicazione, collocazione, company);

                        txtMessaggi.Text = "Ordine Migrato Correttamente";
                    }
                    if (ChBoxRegMag.Checked)
                    {
                        bc.PostingRegMag();
                    }
                }
            }
            catch (Exception ex)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("ERRORE IRREVERSIBILE");
                while (ex != null)
                {
                    sb.AppendLine(ex.Message);
                    ex = ex.InnerException;
                }
                txtMessaggi.Text = sb.ToString();
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }