using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using SteamWare; using GMW_data; namespace GMW_Term.WebUserControls { public partial class mod_makeMov : System.Web.UI.UserControl { protected int logLevel; /// /// wrapper traduzione termini /// /// /// public string traduci(string lemma) { return user_std.UtSn.Traduci(lemma); } /// /// chiamata principale /// /// /// protected void Page_Load(object sender, EventArgs e) { logLevel = memLayer.ML.confReadInt("_logLevel"); updateMakeMov(); } /// /// aggiorna lo stato dell'operazione di movimentazione /// public void updateMakeMov() { if (logLevel > 6) { logger.lg.scriviLog("chiamata updateMakeMov"); } // recupero barcode e controllo sia valido string _UDC = memLayer.ML.StringSessionObj("UDC_sel"); string _AL = memLayer.ML.StringSessionObj("AL_sel"); // se ho AL --> uso quello... int _idxCella = memLayer.ML.IntSessionObj("IdxCella_sel"); string _codCella = memLayer.ML.StringSessionObj("codCella_sel"); if (logLevel > 6) { logger.lg.scriviLog(string.Format("Valori letti: UDC {0}, IdxCella {1}, codCella {2}", _UDC, _idxCella, _codCella), tipoLog.INFO); } // aggiorno labels standard lblCella.Text = traduci("lblCella"); //2018.07.04 secondo AL/UDC mostro uno o altro... // se AL in sessione if (_AL != "") { lblUDC.Text = traduci("lblAL"); lblCodUDC.Text = _AL; } else { lblUDC.Text = traduci("lblUDC"); lblCodUDC.Text = _UDC; } btnConferma.Text = traduci("btnConferma"); btnAnnulla.Text = traduci("btnAnnulla"); // aggiorno labels valori lblCodCella.Text = _codCella; // controllo se ci siano [UDC/AL] + Cella validi if (_codCella != "") { // se si tratta di UDC... if (_UDC != "") { // SE cella vuota procedo! if (!MagClass.magazzino.cellaPiena(memLayer.ML.confReadString("codCS"), _idxCella)) { if (logLevel > 6) { logger.lg.scriviLog("Cella vuota, procedo a spostamento UDC"); } spostaUdc(_UDC, _idxCella, _codCella); } else { if (logLevel > 6) { logger.lg.scriviLog("Cella piena, chiedo conferma"); } // se cella piena chiedo conferma btnConferma.Visible = true; btnAnnulla.Visible = true; } } // se si tratta di AL... else if (_AL != "") { // SE cella vuota procedo! if (!MagClass.magazzino.cellaPiena(memLayer.ML.confReadString("codCS"), _idxCella)) { if (logLevel > 6) { logger.lg.scriviLog("Cella vuota, procedo a spostamento AL"); } // recupero elenco UDC da AL... var tabUDC = MagClass.magazzino.taAL2UDC.getByAL(_AL); foreach (var item in tabUDC) { spostaUdc(item.UDC, _idxCella, _codCella); } } else { if (logLevel > 6) { logger.lg.scriviLog("Cella piena, chiedo conferma"); } // se cella piena chiedo conferma btnConferma.Visible = true; btnAnnulla.Visible = true; } } else { if (logLevel > 6) { logger.lg.scriviLog("Mancano UDC o AL"); } btnConferma.Visible = false; btnAnnulla.Visible = false; } } else { if (logLevel > 6) { logger.lg.scriviLog("Manca Cella"); } btnConferma.Visible = false; btnAnnulla.Visible = false; } } /// /// effettua spostamento UDC sparato da barcode /// /// /// /// private void spostaUdc(string _UDC, int _idxCella, string _codCella) { if (logLevel > 6) { logger.lg.scriviLog("Spostamento UDC: step 1"); } // controllo UDC sia spostabile (ovvero NON in RLP bloccata) if (MagClass.magazzino.checkUDC_mov(_UDC)) { // calcolo posizione udc int idxPos = 0; try { idxPos = MagClass.magazzino.IdxPosizioneUdc(_UDC); } catch { logger.lg.scriviLog("Errore in calcolo idxposizione udc", tipoLog.EXCEPTION); } // verifico UDC NON sia consumato if (idxPos > 0) { // verifico UDC NON sia in posizione 200-999 = spedito if (!(idxPos >= 200 && idxPos <= 999)) { if (logLevel > 6) { logger.lg.scriviLog("Spostamento UDC: step 2"); } bool fatto = false; fatto = MagClass.magazzino.spostaUDC(memLayer.ML.confReadString("codCS"), _UDC, _idxCella, memLayer.ML.confReadBool("spostaUdcResettaLdp"), Request.UserHostName); btnConferma.Visible = false; btnAnnulla.Visible = false; if (fatto) { lblEsito.Text = string.Format("{0} {1} --> {2} ", traduci("ConfermaSpostatoUDC"), _UDC, _codCella); } else { lblEsito.Text = string.Format("{0} {1} --> {2} ", traduci("ERR-UDC-MOV-01"), _UDC, _codCella); } if (logLevel > 6) { logger.lg.scriviLog("Spostamento UDC: step 3"); } } else { // segnalo errore UDC con idxPosizione 200-999 = spedito ... lblEsito.Text = string.Format("{0} {1}", traduci("ERR-UDC-POS-002"), _UDC); } } else { // segnalo errore UDC con idxPosizione < 0... lblEsito.Text = string.Format("{0} {1}", traduci("ERR-UDC-POS-001"), _UDC); } } else { lblEsito.Text = string.Format("{0} {1}", traduci("UdcNonSpostabile"), _UDC); } resetAndUpdate(); } /// /// CONFERMA associazione UDC/CELLA /// /// /// protected void btnConferma_Click(object sender, EventArgs e) { // calcolo valori string _UDC = memLayer.ML.StringSessionObj("UDC_sel"); int _idxCella = memLayer.ML.IntSessionObj("IdxCella_sel"); string _codCella = memLayer.ML.StringSessionObj("codCella_sel"); if (logLevel > 6) { logger.lg.scriviLog("Conferma Spostamento UDC: step 1"); } // controllo UDC sia spostabile (ovvero NON in RLP bloccata) if (MagClass.magazzino.checkUDC_mov(_UDC)) { if (logLevel > 6) { logger.lg.scriviLog("Conferma Spostamento UDC: step 2"); } // sposto UDC precedente in posizione preimpostata da web.config string codCellaErroriAnime = memLayer.ML.confReadString("codCellaErroriAnime"); int idxCellaTo = MagClass.magazzino.taCelle.getByCodCella(codCellaErroriAnime)[0].IdxCella; string udc2move = MagClass.magazzino.udcInCella(memLayer.ML.confReadString("codCS"), _idxCella); // 2015.01.29 procedo SOLO SE c'è un UDC da spostare if (udc2move != "") { // sposto udc in posizione "errori anime"... if (logLevel > 6) { logger.lg.scriviLog("Conferma Spostamento UDC: step 3"); } MagClass.magazzino.spostaUDC(memLayer.ML.confReadString("codCS"), udc2move, idxCellaTo, memLayer.ML.confReadBool("spostaUdcResettaLdp"), Request.UserHostName); lblEsito.Text = string.Format("{0} {1} --> {2} ", traduci("ConfermaSpostatoUDC"), _UDC, _codCella); } // sposto "vero" UDC if (logLevel > 6) { logger.lg.scriviLog("Conferma Spostamento UDC: step 4"); } spostaUdc(_UDC, _idxCella, _codCella); } else { lblEsito.Text = string.Format("{0} {1}", traduci("UdcNonSpostabile"), _UDC); } resetAndUpdate(); if (logLevel > 6) { logger.lg.scriviLog("Conferma Spostamento UDC: step 5"); } } /// /// aggiorna visualizzazioni e resetta /// private void resetAndUpdate() { //memLayer.ML.emptySessionVal("UDC_sel"); //memLayer.ML.emptySessionVal("IdxCella_sel"); //memLayer.ML.emptySessionVal("codCella_sel"); GMW_data.TermClass.Ter.resetScanBarcode(true, true, false); // aggiorno visualizzazione updateMakeMov(); lblErrore.Visible = false; } /// /// annulla associazione UDC / CELLA /// /// /// protected void btnAnnulla_Click(object sender, EventArgs e) { resetAndUpdate(); } } }