From cb09d9abe1048beb9edebbc161065241affe3d33 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 26 Jul 2017 19:41:53 +0200 Subject: [PATCH] Fix classi gestione Datamatrix.mgr x evitare singleton che si pianta... --- GMW/WebUserControls/mod_LiqDtAnom.ascx.cs | 1974 ++--- GMW/WebUserControls/mod_PostFin_DT.ascx.cs | 26 +- GMW/WebUserControls/mod_PostLiq_DT.ascx.cs | 2284 +++--- GMW/WebUserControls/mod_PostRX_DT.ascx.cs | 8 +- GMW/WebUserControls/mod_PostTT_Pre_DT.ascx.cs | 704 +- GMW/WebUserControls/mod_PostTT_Pre_NT.ascx.cs | 834 ++- GMW/WebUserControls/mod_SearchProvDtx.ascx.cs | 108 +- .../mod_anagFormatiDtx.ascx.cs | 348 +- .../mod_elencoListePrelievo.ascx.cs | 2616 +++---- .../mod_postRX_DT_LIST.ascx.cs | 1764 ++--- GMW/WebUserControls/mod_post_B48.ascx.cs | 2153 +++--- .../mod_recAttributiDtx.ascx.cs | 394 +- GMW/WebUserControls/mod_setAttrDtx.ascx.cs | 615 +- GMW/WebUserControls/mod_specDmtx.ascx.cs | 308 +- .../mod_spostaDataMatrix.ascx.cs | 642 +- GMW/WebUserControls/mod_trascPn2Part.ascx.cs | 372 +- GMW/WebUserControls/mod_verificaDmtx.ascx.cs | 292 +- GMW_data/DataMatrix.cs | 306 +- GMW_data/MagClass.cs | 6642 ++++++++--------- GMW_data/Odette.cs | 892 +-- GMW_data/UserControlBCodeMan.cs | 13 +- 21 files changed, 11682 insertions(+), 11613 deletions(-) diff --git a/GMW/WebUserControls/mod_LiqDtAnom.ascx.cs b/GMW/WebUserControls/mod_LiqDtAnom.ascx.cs index 887b4d31..0da59edd 100644 --- a/GMW/WebUserControls/mod_LiqDtAnom.ascx.cs +++ b/GMW/WebUserControls/mod_LiqDtAnom.ascx.cs @@ -5,991 +5,995 @@ using System.Web.UI; namespace GMW.WebUserControls { - public partial class mod_LiqDtAnom : GMW_data.UserControl + public partial class mod_LiqDtAnom : GMW_data.UserControl + { + /// + /// Oggetto locale gestione classe datamatrix... + /// + protected DataMatrix DataMatrix_mgr = new DataMatrix(); + /// + /// flusso associato (hard coded) a LI (finiti) + /// + protected string flusso = "FI"; + /// + /// flusso associato (hard coded) ad ancestor TT (Trattati) + /// + protected string flussoAnc = "TT"; + /// + /// flusso associato (hard coded) a temporaneo TL (Trattati/Liquidi) + /// + protected string flussoTemp = "TL"; + /// + /// flusso associato (hard coded) a temporaneo TL (Trattati/Liquidi) + /// + protected string flussoRX = "RX"; + /// + /// stato associato (hard coded) a UDC in OUT: Finito + /// + protected string statoUdcOut = "Fin"; + /// + /// stato associato (hard coded) a UDC in IN: Trattato da travaso AL + /// + protected string statoUdcIn = "Tratt"; + /// + /// codice evento dell'UDC definitivo (OUT) che si crea + /// + protected string codEventoUdcOut = "UDC_TL_DT"; + /// + /// codice evento dell'UDC temporaneo (IN) che si crea + /// + protected string codEventoUdcIn = "UDC_TRATT"; + protected string cssOk = "stileComandoOk"; + protected string cssErr = "stileComandoKo"; + protected string cssWait = "stileComandoND"; + protected string cssAtt = "stileAttesa"; + protected string cssWarn = "stileComandoWarn"; + protected string cssAdd = "stileComandoAdd"; + public event EventHandler eh_reqUpdate; + /// + /// ultimo valore barcode letto (x confronto conferme doppio input...) + /// + protected string lastBarcodeIn { - /// - /// flusso associato (hard coded) a LI (finiti) - /// - protected string flusso = "FI"; - /// - /// flusso associato (hard coded) ad ancestor TT (Trattati) - /// - protected string flussoAnc = "TT"; - /// - /// flusso associato (hard coded) a temporaneo TL (Trattati/Liquidi) - /// - protected string flussoTemp = "TL"; - /// - /// flusso associato (hard coded) a temporaneo TL (Trattati/Liquidi) - /// - protected string flussoRX = "RX"; - /// - /// stato associato (hard coded) a UDC in OUT: Finito - /// - protected string statoUdcOut = "Fin"; - /// - /// stato associato (hard coded) a UDC in IN: Trattato da travaso AL - /// - protected string statoUdcIn = "Tratt"; - /// - /// codice evento dell'UDC definitivo (OUT) che si crea - /// - protected string codEventoUdcOut = "UDC_TL_DT"; - /// - /// codice evento dell'UDC temporaneo (IN) che si crea - /// - protected string codEventoUdcIn = "UDC_TRATT"; - protected string cssOk = "stileComandoOk"; - protected string cssErr = "stileComandoKo"; - protected string cssWait = "stileComandoND"; - protected string cssAtt = "stileAttesa"; - protected string cssWarn = "stileComandoWarn"; - protected string cssAdd = "stileComandoAdd"; - public event EventHandler eh_reqUpdate; - /// - /// ultimo valore barcode letto (x confronto conferme doppio input...) - /// - protected string lastBarcodeIn - { - get - { - return memLayer.ML.StringSessionObj(string.Format("lastBCode_{0}", uid)); - } - set - { - memLayer.ML.setSessionVal(string.Format("lastBCode_{0}", uid), value, false); - } - } - /// - /// Codice AL della cella corrente - /// - protected string destAL - { - get - { - return lblDestAL.Text.Trim(); - } - set - { - lblDestAL.Text = value; - } - } - /// - /// Codice AL associato alla cella corrente... - /// - protected string AlByCella - { - get - { - string answ = ""; - try - { - answ = string.Format("ALF00{0}", Postazione.currCodCella); - // controllo se esista AL sennò lo creo... - if (MagClass.magazzino.taEA.getByAL(answ).Rows.Count == 0) - { - MagClass.magazzino.taEA.Insert(answ, true, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, "", ""); - } - } - catch - { } - return answ; - } - } - /// - /// indica il codice articolo correntemente selezionato - /// - protected string currParticolare - { - get - { - return memLayer.ML.StringSessionObj(string.Format("currParticolare_{0}", uid)); - } - set - { - memLayer.ML.setSessionVal(string.Format("currParticolare_{0}", uid), value, memLayer.ML.confReadBool("keepParticolareSel")); - } - } - /// - /// indica UDC correntemente selezionato - /// - protected string currUDC - { - get - { - return memLayer.ML.StringSessionObj(string.Format("UDC_{0}", uid)); - } - set - { - memLayer.ML.setSessionVal(string.Format("UDC_{0}", uid), value, memLayer.ML.confReadBool("keepParticolareSel")); - } - } - /// - /// num pezzi dell'ultimo UDC di uguale particolare e stato fatto... - /// - public int pezziUdc - { - get - { - int answ = 0; - try - { - answ = (int)MagClass.magazzino.taCartellini.getLastByParticolareStatoConImb(memLayer.ML.StringSessionObj("CodCS"), currParticolare, statoUdcOut)[0].Qta; - } - catch - { - answ = memLayer.ML.cdvi("QtaImballoFiniti"); - } - return answ; - } - } - /// - /// cod imballo dell'ultimo UDC del particolare generato - /// - public string lastCodImb - { - get - { - string answ = ""; - try - { - answ = MagClass.magazzino.taCartellini.getLastByParticolareStatoConImb(memLayer.ML.StringSessionObj("CodCS"), currParticolare, statoUdcOut)[0].CodImballo; - } - catch - { } - return answ; - } - } - /// - /// qta pezzi x UDC - /// - public int qta - { - get - { - int qta = 0; - try - { - qta = Convert.ToInt32(txtQta.Text.Trim()); - } - catch - { } - return qta; - } - set - { - txtQta.Text = value.ToString(); - } - } - /// - /// valore barcode - /// - public string barcodeIn - { - get - { - return txtBarcode.Text.Trim(); - } - set - { - txtBarcode.Text = value; - } - } - /// - /// definisce se mostrare controlli x ri-assegnazione storia al Dtx - /// - public bool showForceUdcTratt - { - get - { - return memLayer.ML.BoolSessionObj(string.Format("showForceUdcTratt_{0}", uid)); - } - set - { - memLayer.ML.setSessionVal(string.Format("showForceUdcTratt_{0}", uid), value, memLayer.ML.confReadBool("keepParticolareSel")); - } - } - /// - /// caricamento pagina - /// - /// - /// - protected void Page_Load(object sender, EventArgs e) - { - if (!Page.IsPostBack) - { - Postazione.messaggiText = ""; - Postazione.warningText = ""; - qta = 0; - currUDC = ""; - txtNumTT.Text = string.Format("{0:yy}000000", DateTime.Now); - calcolaUdcTT(); - string AL = string.Format("ALT{0:yy}000000000", DateTime.Now); - MagClass.magazzino.taET.checkEmptyYear(memLayer.ML.cdv("CodCS"), AL, lblUDC.Text, txtNumTT.Text); - showForceUdcTratt = false; - setDefaultVal(); - } - setVisibility(); - checkBarcode(); - } - /// - /// imposta i valori di default ad avvio - /// - private void setDefaultVal() - { - destAL = AlByCella; - } - /// - /// sistema modalità input - /// - private void setVisibility() - { - bool showBtn = false; - // ora controllo btn quantità - if (grViewDest.SelectedIndex >= 0) - { - showBtn = true; - } - divQta.Visible = showBtn; - divImballi.Visible = showBtn; - if (showBtn) - { - selezionaImballo(); - } - // definisce se mostrare controlli x forzare trattamento / UDC di riferimento 0000 oppure uno vero... - divForceUdcTratt.Visible = showForceUdcTratt; - } - /// - /// reset maschera... - /// - protected void doReset() - { - // resetta - lastBarcodeIn = ""; - Postazione.messaggiText = ""; - Postazione.warningText = ""; - Postazione.CssClass = cssAtt; - doUpdate(); - } - /// - /// Verifica l'AL se sia ok x procedere: - /// - Attivo - /// - /// - /// T/L - /// - protected bool checkAL(string AL, string tipo) - { - bool answ = false; - try - { - answ = MagClass.magazzino.taEA.getByAL_TipoAttivo(AL, tipo).Rows.Count > 0; - } - catch - { } - if (answ) - { - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoOk"; - } - else - { - Postazione.warningText = traduci("ErroreAlNonTtAttivo"); - Postazione.CssClass = "stileComandoKo"; - } - - return answ; - } - /// - /// Verifica l'AL se abbia datamatrix - /// - /// - /// - protected bool checkDtxAL(string AL) - { - bool answ = false; - try - { - answ = DataMatrix.mgr.taDtx2UDC.getByAL(AL).Rows.Count > 0; - } - catch - { } - if (!answ) - { - Postazione.warningText = traduci("ErroreAlNonDtx"); - Postazione.CssClass = "stileComandoKo"; - } - else - { - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoOk"; - } - return answ; - } - /// - /// controlla se ci sia un barcode e cosa farne... - /// - private void checkBarcode() - { - if (barcodeIn != "") - { - Postazione.messaggiText = string.Format("{0}: {1}", traduci("BCodeIns"), barcodeIn); - switch (MagClass.tipoBCode_L5(barcodeIn)) - { - case tipoCodiceBarcode.Imballo: - // cerco di selezionare! - try - { - ddlImballi.SelectedValue = barcodeIn; - } - catch - { - Postazione.warningText = traduci("ERR-IMB-001"); - Postazione.CssClass = "stileComandoKo"; - } - break; - case tipoCodiceBarcode.Comando: - // se è reset cancello tutto! - if (barcodeIn == memLayer.ML.cdv("cmdReset")) - { - doReset(); - } - break; - case tipoCodiceBarcode.UDC: - // controllo di avere destAL valido, sennò ricarico pagina... - if (destAL.Length > 5) - { - // controllo se sia un UDC valido... - if (MagClass.magazzino.checkUDC(barcodeIn)) - { - // controllo se sia un UDC di finiti LIQ in posizione 4... - DS_magazzino.ElencoCartelliniRow cartUDC = MagClass.magazzino.taCartellini.getByUdc(barcodeIn)[0]; - if (cartUDC.CodStato == statoUdcOut && cartUDC.IdxPosizione == memLayer.ML.cdvi("IdxPosizioneFiniti")) - { - // controllo NON ci sia già un UDC di pari particolare caricato nella postazione corrente (non posso avere 2 UDC a pari particolare da riempire...) - if (MagClass.magazzino.taCartellini.getByParticolareAL(cartUDC.Particolare, destAL).Rows.Count == 0) - { - // controllo NON sia UDC in LDP e già PRELEVATO - if (MagClass.magazzino.taRigheListePrelievo.getByUdc(barcodeIn).Select("Prelevato = 1").Length == 0) - { - // controllo NON abbia blocco x FinDtx... - if (MagClass.magazzino.udcHasAttr(barcodeIn, "BL")) - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-LIQ-006"); - Postazione.CssClass = cssErr; - } - else - { - // se è ok RICARICO UDC in posizione corrente... - bool fatto = MagClass.magazzino.liquidiRiprendiInCaricoUDC(barcodeIn, MagClass.magazzino.CodSoggCurrUser, destAL, Postazione.currIdxCella); - if (fatto) - { - Postazione.messaggiText = traduci("RiCaricatoUdcLiq"); - Postazione.warningText = ""; - Postazione.CssClass = cssOk; - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-LIQ-001"); - Postazione.CssClass = cssErr; - } - } - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-LIQ-005"); - Postazione.CssClass = cssErr; - } - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-LIQ-004"); - Postazione.CssClass = cssErr; - } - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-LIQ-002"); - Postazione.CssClass = cssErr; - } - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-LIQ-003"); - Postazione.CssClass = cssErr; - } - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-ALF-001"); - Postazione.CssClass = cssErr; - } - break; - case tipoCodiceBarcode.DataMatrixTrovato: - string NewUDC = ""; - string udcRX = ""; - bool dtxBloccato = false; - bool dtxInUdcDest = false; - DateTime adesso = DateTime.Now; - - /*--------------------------------------------------- - * verifico DTX: per procedere deve !!! NON ESSERE associato ad un UDC spedito / in lista di prelievo !!! - * ed avere almeno una di queste condizioni - * - essere tra i Missing In Action (con o senza TT) - * - essere nuovo (mai associato ad UDC) - * - * abbiamo i seguenti casi - * 1) il datamatrix HA un UDC collegato con un trattamento (TT) --> la sua storia viene tenuta - * 2) il datamatrix NON HA alcun UDC collegato (nemmeno RX) - * 3) il datamatrix HA un UDC collegato SOLO RX (SENZA un trattamento) - * - * nei casi (2) e (3) NON HA un trattamento, a questo abbiamo 2 opzioni x ricostruire la sua storia - * a) copiandola da quella di un UDC esistente - * b) copiandola da un UDC/trattamento fittizio (0000 dell'anno) - * - ---------------------------------------------------*/ - - // recupero record DataMatrix (se presenti) - DS_DataMatrix.Dtx2UDCDataTable tabDtx2Udc = DataMatrix.mgr.taDtx2UDC.getByDtx(barcodeIn); - // se ho storia - if (tabDtx2Udc.Rows.Count > 0) - { - // cerco NON sia stato spedito o in LDP - if (DataMatrix.mgr.taDtxBlocked.GetData(barcodeIn).Rows.Count > 0) - { - dtxBloccato = true; - } - } - // controllo datamatrix sia OK - bool isOk = false; - try - { - isOk = DataMatrix.mgr.taVerifica.GetData(barcodeIn)[0].StatoDtx == "OK"; - } - catch - { } - - // IN PRIMIS verifico NON SIA KO... - if (!isOk) - { - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("ERR-DTX-012"); - Postazione.CssClass = cssErr; - } - // POI verifico Dtx NON sia spedito / LDP - else if (dtxBloccato) - { - // mostro errore poiché spedito / in LDP... - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-DTX-009"); - Postazione.CssClass = cssErr; - } - else - { - // calcolo UDC di destinazione x particolare del Dtx letto - NewUDC = getUdcDest(tabDtx2Udc); - udcRX = currUdcTT.Replace(flussoAnc, flussoRX); - // verifico se posso procedere: in caso NON ci fosse UDC di destinazione - if (NewUDC == "") - { - // richiedo di caricare un UDC valido per il particolare richiesto... - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-DTX-007"); - Postazione.CssClass = cssErr; - } - else // mentre se ho un UDC di destinazione cui legare il Dtx... - { - - // verifico che il DataMatrix NON SIA già nell'UDC di destinazione... - dtxInUdcDest = DataMatrix.mgr.taDtx2UDC.getByDtx(barcodeIn).Select(string.Format("UDC = '{0}'", NewUDC)).Length > 0; - if (dtxInUdcDest) - { - // errore: già spostato! - Postazione.warningText = ""; - Postazione.messaggiText = traduci("ERR-DTX-006"); - Postazione.CssClass = cssOk; - } - else - { - // se zero record = niente storia... - if (tabDtx2Udc.Rows.Count == 0) - { - // verifico se sono GIA' in modo forzatura UdcTratt: con 2 letture è verifica che si VUOLE ri-assegnare la storia dell'UDC/trattamento indicato al datamatrix letto - if (showForceUdcTratt) - { - // assegno datamatrix a Udc Destinazione, TT ed RX - assignDtx2UDC(barcodeIn, NewUDC, currUdcTT, udcRX); - // tolgo modalità forza trattamento - showForceUdcTratt = false; - Postazione.warningText = ""; - Postazione.messaggiText = traduci("DatamatrixSpostato"); - Postazione.CssClass = cssOk; - } - else - { - // non ha storia! mostro opzione x forzare un certo codice UDC da un datamatrix "buono" con relativo TT oppure usare un trattamento fittizio(di default 0000 dell'anno) - showForceUdcTratt = true; - Postazione.warningText = traduci("ConfermareTrattamento"); - Postazione.CssClass = cssAdd; - } - } - else - { - // verifico se il datamatrix ha UDC con TT - if (tabDtx2Udc.Select("CodStato = 'Tratt'").Length != 0) - { - // se ce l'ha sposto Dtx in UDC finale e associo UDC TT ad UDC FI - assignDtx2UDC(barcodeIn, NewUDC); - } - else - { - // verifico se sono GIA' in modo forzatura UdcTratt: con 2 letture è verifica che si VUOLE ri-assegnare la storia dell'UDC/trattamento indicato al datamatrix letto - if (showForceUdcTratt) - { - // se avevo già RX NON lo cambio... - if (tabDtx2Udc.Select("CodStato = 'ContrRx'").Length != 0) - { - udcRX = ""; - } - // assegno datamatrix a Udc Destinazione, TT ed RX - assignDtx2UDC(barcodeIn, NewUDC, currUdcTT, udcRX); - // tolgo modalità forza trattamento - showForceUdcTratt = false; - Postazione.warningText = ""; - Postazione.messaggiText = traduci("DatamatrixSpostato"); - Postazione.CssClass = cssOk; - } - else - { - // non ha storia! mostro opzione x forzare un certo codice UDC da un datamatrix "buono" con relativo TT oppure usare un trattamento fittizio(di default 0000 dell'anno) - showForceUdcTratt = true; - Postazione.warningText = traduci("ConfermareTrattamento"); - Postazione.CssClass = cssAdd; - } - } - } - } - } - } - break; - default: - Postazione.warningText = traduci("ERR-BCD-001"); - Postazione.CssClass = cssErr; - break; - } - barcodeIn = ""; - } - doUpdate(); - } - /// - /// calcolo/ricavo UDC di destinazione (se presente) - /// - /// - /// - private string getUdcDest(DS_DataMatrix.Dtx2UDCDataTable tabDtx2Udc) - { - string NewUDC = ""; - // verifico di avere un UDC destinazione x il particolare del datamatrix letto... altrimenti NON possiamo procedere... - try - { - currParticolare = tabDtx2Udc[0].Particolare; - } - catch - { - currParticolare = ""; - } - // se non ho particolare PROVO a decodificare da codice datamatrix - if (currParticolare == "") - { - try - { - // vers 2.9 modifica per multi-datamatrix - currParticolare = DataMatrix.mgr.taDtxAcquisiti.getByKey(barcodeIn)[0].Particolare; - // vers vecchia - //currParticolare = DataMatrix.mgr.taDecode.GetData(barcodeIn, "")[0].Particolare; - } - catch - { } - } - if (currParticolare != "") - { - try - { - NewUDC = MagClass.magazzino.taCartellini.getByParticolareAL(currParticolare, destAL)[0].UDC; - } - catch - { - NewUDC = ""; - } - } - else - { - // datamatrix NON riconosciuto - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-DTX-008"); - Postazione.CssClass = cssErr; - } - return NewUDC; - } - /// - /// rappresenta il codice UDC del corrente TT per resettare history pezzo DataMatrix - /// - private string currUdcTT - { - get - { - // ricalcolo - calcolaUdcTT(); - // default: cartellino TT "nullo" - string UdcTT = ""; - // cerco di recuperare valore UDC in caso sia stato inserito nel textBox - try - { - UdcTT = lblUDC.Text; - } - catch - { - UdcTT = ""; - } - // restituisco risposta - return UdcTT; - } - } - /// - /// evento cambio num TT - /// - /// - /// - protected void txtNumTT_TextChanged(object sender, EventArgs e) - { - // se non inizia per anno aggiunge anno e formatta anno + 6 cifre... - if (!txtNumTT.Text.Trim().StartsWith(string.Format("{0:yy}", DateTime.Now))) - { - // aggiungo anno e formatto numero 6 cifre... - try - { - int numTT = Convert.ToInt32(txtNumTT.Text.Trim()); - txtNumTT.Text = txtNumTT.Text = string.Format("{0:yy}{1:000000}", DateTime.Now, numTT); - } - catch - { - txtNumTT.Text = ""; - } - } - calcolaUdcTT(); - } - /// - /// ricalcolo UDC da num TT - /// - private void calcolaUdcTT() - { - string UdcTT = ""; - try - { - // cerco UDC da num tratt... - UdcTT = MagClass.magazzino.taCartellini.getByParticolareTT(currParticolare, txtNumTT.Text.Trim())[0].UDC; - } - catch - { - UdcTT = ""; - } - if (UdcTT == "") - { - // se non lo trovo uso UDC e trattamento "undef" a 0000, eventualmente creando UDC annuale - UdcTT = string.Format("U{0}{1}{2:yy}000000", memLayer.ML.cdv("CodCS"), flussoAnc, DateTime.Now); - } - lblUDC.Text = UdcTT; - } - /// - /// assegno un Dtx ad un codice UDC fin con eventuale reset storia (e copia da udcTratt) - /// - /// Codice DataMatrix da processare - /// UDC finiti di destinazione - /// UDC dei trattamenti da cui ricavare la stodia da associare, anche "fasullo"/0000 (se VUOTO NON riassocia) - /// UDC Rx da riassociare (se vuoto NON riassocia) - /// - private bool assignDtx2UDC(string codDtx, string UDCFin) - { - // assegno datamatrix a Udc Destinazione e associo UDC TT ad UDC FI - bool spostaDtx = false; - // se lo trovo chiamo procedura di spostamento Dtx tra UDC sorgente --> dest - DataMatrix.mgr.taDtx2UDC.UpdateUDC(UDCFin, barcodeIn, statoUdcOut, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, true, true); - return spostaDtx; - } - /// - /// assegno un Dtx ad un codice UDC fin con eventuale reset storia (e copia da udcTratt) - /// - /// Codice DataMatrix da processare - /// UDC finiti di destinazione - /// UDC dei trattamenti da cui ricavare la stodia da associare, anche "fasullo"/0000 (se VUOTO NON riassocia) - /// UDC Rx da riassociare (se vuoto NON riassocia) - /// - private bool assignDtx2UDC(string codDtx, string UDCFin, string UDCTratt, string UDCRx) - { - // assegno datamatrix a Udc Destinazione e associo UDC TT ad UDC FI - bool spostaDtx = false; - // se ho UdcRX lo cambio... - if (UDCRx != "") - { - DataMatrix.mgr.taDtx2UDC.UpdateUDC(UDCRx, barcodeIn, "ContrRx", DateTime.Now, MagClass.magazzino.CodSoggCurrUser, true, true); - } - // sostituisco UDC TT e Fin.. - DataMatrix.mgr.taDtx2UDC.UpdateUDC(UDCTratt, barcodeIn, statoUdcIn, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, true, true); - DataMatrix.mgr.taDtx2UDC.UpdateUDC(UDCFin, barcodeIn, statoUdcOut, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, true, true); - return spostaDtx; - } - /// - /// aggiorna tabella + focus a barcode - /// - public void doUpdate() - { - setDefaultVal(); - setVisibility(); - grViewDest.DataBind(); - // raise dell'evento - if (eh_reqUpdate != null) - { - eh_reqUpdate(this, new EventArgs()); - } - verificaBtnStampa(); - txtBarcode.Focus(); - } - /// - /// evento selezione grView destinazione: ricarico dati! - /// - /// - /// - protected void grViewDest_SelectedIndexChanged(object sender, EventArgs e) - { - // ricarico dati dell'UDC come particolare e quantità... - currUDC = grViewDest.SelectedDataKey["UDC"].ToString(); - int qtaDtx = 0; - if (MagClass.magazzino.checkUDC(currUDC)) - { - currParticolare = DataProxy.obj.taCartellini.stp_getByUdc(currUDC)[0].Particolare; - qta = Convert.ToInt32(DataProxy.obj.taCartellini.stp_getByUdc(currUDC)[0].Qta); - qtaDtx = Convert.ToInt32(MagClass.magazzino.taA2U2D.getByUDC(currUDC)[0].QtaDtx); - // imposto particolare... - lblPart.Text = currParticolare; - ddlImballi.DataBind(); - } - Postazione.messaggiText = traduci("partSelected"); - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoOk"; - setVisibility(); - doUpdate(); - // fisso focus su note! - txtNote.Focus(); - } - /// - /// Verifica se Assieme sia vuoto (no DTX negli UDC) - /// - /// Codice AL - /// - protected bool assiemeIsEmpty(string AL) - { - bool answ = false; - try - { - answ = DataMatrix.mgr.taDtx2UDC.getByAL(AL).Rows.Count == 0; - } - catch { } - return answ; - } - /// - /// reset della selezione - /// - /// - /// - protected void btnReset_Click(object sender, EventArgs e) - { - grViewDest.SelectedIndex = -1; - qta = 0; - currUDC = ""; - setVisibility(); - doUpdate(); - } - /// - /// update Qty x UDC selezionato... - /// - /// - /// - protected void lbtUpdQty_Click(object sender, EventArgs e) - { - MagClass.magazzino.taCartellini.updateQty(currUDC, MagClass.magazzino.CodSoggCurrUser, "U", codEventoUdcOut, qta); - // fix tablet - currUDC = ""; - currParticolare = ""; - grViewDest.SelectedIndex = -1; - doUpdate(); - } - /// - /// richiesta (ri)stampa UDC - /// - /// - /// - public void ristampa() - { - bool fatto = false; - fatto = MagClass.magazzino.ristampaUdc(udcReq, Postazione.printer, Request.UserHostName); - // registro ri-stampa UDC - if (fatto) MagClass.magazzino.taSAO.insertQuery(DateTime.Now, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, udcReq, "", "stampaUDC", string.Format("Ri-Stampato UDC Dtx {0} su linea anomalie {1}", currUDC, Postazione.currCodLinea)); - } - /// - /// verifica visibilità btn stampa UDC - /// - private void verificaBtnStampa() - { - bool showBtnStampa = false; - // se ho selezionato udc... - if (currUDC != "") - { - DS_magazzino.v_A2U2DRow riga; - int qtaUDC = 0; - int qtaDtx = 0; - try - { - riga = MagClass.magazzino.taA2U2D.getByUDC(currUDC)[0]; - qtaUDC = Convert.ToInt32(riga.Qta); - qtaDtx = riga.QtaDtx; - } - catch - { } - if (qtaUDC > 0) - { - // se le qta voluta e dtx sono uguali... - if (qtaUDC == qtaDtx) - { - showBtnStampa = true; - } - } - } - divNote.Visible = showBtnStampa; - } - /// - /// fornisce in output la corretta classe css x icona - /// - /// - /// - /// - public string cssGlyphByQty(object _qta, object _qtaDtx) - { - string answ = "glyphicon glyphicon-pencil btn-lg"; - int qtaUDC = 0; - int qtaDtx = -1; - try - { - qtaUDC = Convert.ToInt32(_qta); - } - catch { } - try - { - qtaDtx = Convert.ToInt32(_qtaDtx); - } - catch { } - if (qtaUDC == qtaDtx) - { - answ = "glyphicon glyphicon-print btn-lg"; - } - return answ; - } - /// - /// effettua processo di sistemazione UDC e stampa - /// - /// - /// - protected void lbtStampaUDC_Click(object sender, EventArgs e) - { - // verifico postazione sia valida... - if (Postazione.name != "" && Postazione.IP != "" && Postazione.currCodCella != "") - { - // in base ad AL sorgente e destinazione, fa le operazioni di update x UDC e poi lo stampa - bool fatto = false; - string noteTrim = txtNote.Text.Trim(); - try - { - // update UDC! - fatto = MagClass.magazzino.liquidiFullUpdate("", flussoAnc, currUDC, ddlImballi.SelectedValue, noteTrim, MagClass.magazzino.CodSoggCurrUser); - } - catch - { } - if (fatto) - { - // lancio stampa - MagClass.magazzino.stampaUdc(currUDC, Postazione.printer, tipoCartellino.cartFinitiSP, Request.UserHostName); - // registro creazione AL - MagClass.magazzino.taSAO.insertQuery(DateTime.Now, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, currUDC, currParticolare, "stampaUDC", string.Format("Stampato UDC Dtx {0} su linea anomalie {1}, note: {2} ", currUDC, Postazione.currCodLinea, noteTrim)); - Postazione.CssClass = cssAtt; - Postazione.warningText = ""; - Postazione.messaggiText = traduci("cartUDCStampato"); - // calcolo particolare completo di descrizione - DS_Applicazione.ElencoCartelliniRow riga = DataProxy.obj.taCartellini.stp_getByUdc(currUDC)[0]; - string particolare = string.Format("{0} - {1}", riga.Particolare, riga.DescParticolare); - // resetto... - grViewDest.SelectedIndex = -1; - qta = 0; - currUDC = ""; - } - doUpdate(); - } - else - { - // ricarico che mi manca postazione! - Postazione.CssClass = cssAtt; - Postazione.warningText = traduci("ERR-POS-001"); - Postazione.messaggiText = ""; - Response.Redirect(user_std.pagCorrente); - } - } - /// - /// udc da stampare - /// - protected string udcReq - { - get - { - return memLayer.ML.StringSessionObj("udcSelSAO"); - } - } - /// - /// preseleziono (se possibile) imballo... - /// - /// - /// - protected void ddlImballi_DataBound(object sender, EventArgs e) - { - selezionaImballo(); - } - /// - /// seleziona imballo corretto - /// - private void selezionaImballo() - { - string codImb = ""; - // cerco se c'è un imballo x particolare corrente... - if (currParticolare != "") - { - codImb = lastCodImb; - } - else - { - codImb = memLayer.ML.cdv("CodImballoFiniti"); - } - try - { - // preseleziono - ddlImballi.SelectedValue = codImb; - } - catch - { } - } - + get + { + return memLayer.ML.StringSessionObj(string.Format("lastBCode_{0}", uid)); + } + set + { + memLayer.ML.setSessionVal(string.Format("lastBCode_{0}", uid), value, false); + } } + /// + /// Codice AL della cella corrente + /// + protected string destAL + { + get + { + return lblDestAL.Text.Trim(); + } + set + { + lblDestAL.Text = value; + } + } + /// + /// Codice AL associato alla cella corrente... + /// + protected string AlByCella + { + get + { + string answ = ""; + try + { + answ = string.Format("ALF00{0}", Postazione.currCodCella); + // controllo se esista AL sennò lo creo... + if (MagClass.magazzino.taEA.getByAL(answ).Rows.Count == 0) + { + MagClass.magazzino.taEA.Insert(answ, true, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, "", ""); + } + } + catch + { } + return answ; + } + } + /// + /// indica il codice articolo correntemente selezionato + /// + protected string currParticolare + { + get + { + return memLayer.ML.StringSessionObj(string.Format("currParticolare_{0}", uid)); + } + set + { + memLayer.ML.setSessionVal(string.Format("currParticolare_{0}", uid), value, memLayer.ML.confReadBool("keepParticolareSel")); + } + } + /// + /// indica UDC correntemente selezionato + /// + protected string currUDC + { + get + { + return memLayer.ML.StringSessionObj(string.Format("UDC_{0}", uid)); + } + set + { + memLayer.ML.setSessionVal(string.Format("UDC_{0}", uid), value, memLayer.ML.confReadBool("keepParticolareSel")); + } + } + /// + /// num pezzi dell'ultimo UDC di uguale particolare e stato fatto... + /// + public int pezziUdc + { + get + { + int answ = 0; + try + { + answ = (int)MagClass.magazzino.taCartellini.getLastByParticolareStatoConImb(memLayer.ML.StringSessionObj("CodCS"), currParticolare, statoUdcOut)[0].Qta; + } + catch + { + answ = memLayer.ML.cdvi("QtaImballoFiniti"); + } + return answ; + } + } + /// + /// cod imballo dell'ultimo UDC del particolare generato + /// + public string lastCodImb + { + get + { + string answ = ""; + try + { + answ = MagClass.magazzino.taCartellini.getLastByParticolareStatoConImb(memLayer.ML.StringSessionObj("CodCS"), currParticolare, statoUdcOut)[0].CodImballo; + } + catch + { } + return answ; + } + } + /// + /// qta pezzi x UDC + /// + public int qta + { + get + { + int qta = 0; + try + { + qta = Convert.ToInt32(txtQta.Text.Trim()); + } + catch + { } + return qta; + } + set + { + txtQta.Text = value.ToString(); + } + } + /// + /// valore barcode + /// + public string barcodeIn + { + get + { + return txtBarcode.Text.Trim(); + } + set + { + txtBarcode.Text = value; + } + } + /// + /// definisce se mostrare controlli x ri-assegnazione storia al Dtx + /// + public bool showForceUdcTratt + { + get + { + return memLayer.ML.BoolSessionObj(string.Format("showForceUdcTratt_{0}", uid)); + } + set + { + memLayer.ML.setSessionVal(string.Format("showForceUdcTratt_{0}", uid), value, memLayer.ML.confReadBool("keepParticolareSel")); + } + } + /// + /// caricamento pagina + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + Postazione.messaggiText = ""; + Postazione.warningText = ""; + qta = 0; + currUDC = ""; + txtNumTT.Text = string.Format("{0:yy}000000", DateTime.Now); + calcolaUdcTT(); + string AL = string.Format("ALT{0:yy}000000000", DateTime.Now); + MagClass.magazzino.taET.checkEmptyYear(memLayer.ML.cdv("CodCS"), AL, lblUDC.Text, txtNumTT.Text); + showForceUdcTratt = false; + setDefaultVal(); + } + setVisibility(); + checkBarcode(); + } + /// + /// imposta i valori di default ad avvio + /// + private void setDefaultVal() + { + destAL = AlByCella; + } + /// + /// sistema modalità input + /// + private void setVisibility() + { + bool showBtn = false; + // ora controllo btn quantità + if (grViewDest.SelectedIndex >= 0) + { + showBtn = true; + } + divQta.Visible = showBtn; + divImballi.Visible = showBtn; + if (showBtn) + { + selezionaImballo(); + } + // definisce se mostrare controlli x forzare trattamento / UDC di riferimento 0000 oppure uno vero... + divForceUdcTratt.Visible = showForceUdcTratt; + } + /// + /// reset maschera... + /// + protected void doReset() + { + // resetta + lastBarcodeIn = ""; + Postazione.messaggiText = ""; + Postazione.warningText = ""; + Postazione.CssClass = cssAtt; + doUpdate(); + } + /// + /// Verifica l'AL se sia ok x procedere: + /// - Attivo + /// + /// + /// T/L + /// + protected bool checkAL(string AL, string tipo) + { + bool answ = false; + try + { + answ = MagClass.magazzino.taEA.getByAL_TipoAttivo(AL, tipo).Rows.Count > 0; + } + catch + { } + if (answ) + { + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoOk"; + } + else + { + Postazione.warningText = traduci("ErroreAlNonTtAttivo"); + Postazione.CssClass = "stileComandoKo"; + } + + return answ; + } + /// + /// Verifica l'AL se abbia datamatrix + /// + /// + /// + protected bool checkDtxAL(string AL) + { + bool answ = false; + try + { + answ = DataMatrix_mgr.taDtx2UDC.getByAL(AL).Rows.Count > 0; + } + catch + { } + if (!answ) + { + Postazione.warningText = traduci("ErroreAlNonDtx"); + Postazione.CssClass = "stileComandoKo"; + } + else + { + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoOk"; + } + return answ; + } + /// + /// controlla se ci sia un barcode e cosa farne... + /// + private void checkBarcode() + { + if (barcodeIn != "") + { + Postazione.messaggiText = string.Format("{0}: {1}", traduci("BCodeIns"), barcodeIn); + switch (MagClass.tipoBCode_L5(barcodeIn)) + { + case tipoCodiceBarcode.Imballo: + // cerco di selezionare! + try + { + ddlImballi.SelectedValue = barcodeIn; + } + catch + { + Postazione.warningText = traduci("ERR-IMB-001"); + Postazione.CssClass = "stileComandoKo"; + } + break; + case tipoCodiceBarcode.Comando: + // se è reset cancello tutto! + if (barcodeIn == memLayer.ML.cdv("cmdReset")) + { + doReset(); + } + break; + case tipoCodiceBarcode.UDC: + // controllo di avere destAL valido, sennò ricarico pagina... + if (destAL.Length > 5) + { + // controllo se sia un UDC valido... + if (MagClass.magazzino.checkUDC(barcodeIn)) + { + // controllo se sia un UDC di finiti LIQ in posizione 4... + DS_magazzino.ElencoCartelliniRow cartUDC = MagClass.magazzino.taCartellini.getByUdc(barcodeIn)[0]; + if (cartUDC.CodStato == statoUdcOut && cartUDC.IdxPosizione == memLayer.ML.cdvi("IdxPosizioneFiniti")) + { + // controllo NON ci sia già un UDC di pari particolare caricato nella postazione corrente (non posso avere 2 UDC a pari particolare da riempire...) + if (MagClass.magazzino.taCartellini.getByParticolareAL(cartUDC.Particolare, destAL).Rows.Count == 0) + { + // controllo NON sia UDC in LDP e già PRELEVATO + if (MagClass.magazzino.taRigheListePrelievo.getByUdc(barcodeIn).Select("Prelevato = 1").Length == 0) + { + // controllo NON abbia blocco x FinDtx... + if (MagClass.magazzino.udcHasAttr(barcodeIn, "BL")) + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-LIQ-006"); + Postazione.CssClass = cssErr; + } + else + { + // se è ok RICARICO UDC in posizione corrente... + bool fatto = MagClass.magazzino.liquidiRiprendiInCaricoUDC(barcodeIn, MagClass.magazzino.CodSoggCurrUser, destAL, Postazione.currIdxCella); + if (fatto) + { + Postazione.messaggiText = traduci("RiCaricatoUdcLiq"); + Postazione.warningText = ""; + Postazione.CssClass = cssOk; + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-LIQ-001"); + Postazione.CssClass = cssErr; + } + } + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-LIQ-005"); + Postazione.CssClass = cssErr; + } + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-LIQ-004"); + Postazione.CssClass = cssErr; + } + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-LIQ-002"); + Postazione.CssClass = cssErr; + } + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-LIQ-003"); + Postazione.CssClass = cssErr; + } + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-ALF-001"); + Postazione.CssClass = cssErr; + } + break; + case tipoCodiceBarcode.DataMatrixTrovato: + string NewUDC = ""; + string udcRX = ""; + bool dtxBloccato = false; + bool dtxInUdcDest = false; + DateTime adesso = DateTime.Now; + + /*--------------------------------------------------- + * verifico DTX: per procedere deve !!! NON ESSERE associato ad un UDC spedito / in lista di prelievo !!! + * ed avere almeno una di queste condizioni + * - essere tra i Missing In Action (con o senza TT) + * - essere nuovo (mai associato ad UDC) + * + * abbiamo i seguenti casi + * 1) il datamatrix HA un UDC collegato con un trattamento (TT) --> la sua storia viene tenuta + * 2) il datamatrix NON HA alcun UDC collegato (nemmeno RX) + * 3) il datamatrix HA un UDC collegato SOLO RX (SENZA un trattamento) + * + * nei casi (2) e (3) NON HA un trattamento, a questo abbiamo 2 opzioni x ricostruire la sua storia + * a) copiandola da quella di un UDC esistente + * b) copiandola da un UDC/trattamento fittizio (0000 dell'anno) + * + ---------------------------------------------------*/ + + // recupero record DataMatrix (se presenti) + DS_DataMatrix.Dtx2UDCDataTable tabDtx2Udc = DataMatrix_mgr.taDtx2UDC.getByDtx(barcodeIn); + // se ho storia + if (tabDtx2Udc.Rows.Count > 0) + { + // cerco NON sia stato spedito o in LDP + if (DataMatrix_mgr.taDtxBlocked.GetData(barcodeIn).Rows.Count > 0) + { + dtxBloccato = true; + } + } + // controllo datamatrix sia OK + bool isOk = false; + try + { + isOk = DataMatrix_mgr.taVerifica.GetData(barcodeIn)[0].StatoDtx == "OK"; + } + catch + { } + + // IN PRIMIS verifico NON SIA KO... + if (!isOk) + { + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("ERR-DTX-012"); + Postazione.CssClass = cssErr; + } + // POI verifico Dtx NON sia spedito / LDP + else if (dtxBloccato) + { + // mostro errore poiché spedito / in LDP... + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-DTX-009"); + Postazione.CssClass = cssErr; + } + else + { + // calcolo UDC di destinazione x particolare del Dtx letto + NewUDC = getUdcDest(tabDtx2Udc); + udcRX = currUdcTT.Replace(flussoAnc, flussoRX); + // verifico se posso procedere: in caso NON ci fosse UDC di destinazione + if (NewUDC == "") + { + // richiedo di caricare un UDC valido per il particolare richiesto... + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-DTX-007"); + Postazione.CssClass = cssErr; + } + else // mentre se ho un UDC di destinazione cui legare il Dtx... + { + + // verifico che il DataMatrix NON SIA già nell'UDC di destinazione... + dtxInUdcDest = DataMatrix_mgr.taDtx2UDC.getByDtx(barcodeIn).Select(string.Format("UDC = '{0}'", NewUDC)).Length > 0; + if (dtxInUdcDest) + { + // errore: già spostato! + Postazione.warningText = ""; + Postazione.messaggiText = traduci("ERR-DTX-006"); + Postazione.CssClass = cssOk; + } + else + { + // se zero record = niente storia... + if (tabDtx2Udc.Rows.Count == 0) + { + // verifico se sono GIA' in modo forzatura UdcTratt: con 2 letture è verifica che si VUOLE ri-assegnare la storia dell'UDC/trattamento indicato al datamatrix letto + if (showForceUdcTratt) + { + // assegno datamatrix a Udc Destinazione, TT ed RX + assignDtx2UDC(barcodeIn, NewUDC, currUdcTT, udcRX); + // tolgo modalità forza trattamento + showForceUdcTratt = false; + Postazione.warningText = ""; + Postazione.messaggiText = traduci("DatamatrixSpostato"); + Postazione.CssClass = cssOk; + } + else + { + // non ha storia! mostro opzione x forzare un certo codice UDC da un datamatrix "buono" con relativo TT oppure usare un trattamento fittizio(di default 0000 dell'anno) + showForceUdcTratt = true; + Postazione.warningText = traduci("ConfermareTrattamento"); + Postazione.CssClass = cssAdd; + } + } + else + { + // verifico se il datamatrix ha UDC con TT + if (tabDtx2Udc.Select("CodStato = 'Tratt'").Length != 0) + { + // se ce l'ha sposto Dtx in UDC finale e associo UDC TT ad UDC FI + assignDtx2UDC(barcodeIn, NewUDC); + } + else + { + // verifico se sono GIA' in modo forzatura UdcTratt: con 2 letture è verifica che si VUOLE ri-assegnare la storia dell'UDC/trattamento indicato al datamatrix letto + if (showForceUdcTratt) + { + // se avevo già RX NON lo cambio... + if (tabDtx2Udc.Select("CodStato = 'ContrRx'").Length != 0) + { + udcRX = ""; + } + // assegno datamatrix a Udc Destinazione, TT ed RX + assignDtx2UDC(barcodeIn, NewUDC, currUdcTT, udcRX); + // tolgo modalità forza trattamento + showForceUdcTratt = false; + Postazione.warningText = ""; + Postazione.messaggiText = traduci("DatamatrixSpostato"); + Postazione.CssClass = cssOk; + } + else + { + // non ha storia! mostro opzione x forzare un certo codice UDC da un datamatrix "buono" con relativo TT oppure usare un trattamento fittizio(di default 0000 dell'anno) + showForceUdcTratt = true; + Postazione.warningText = traduci("ConfermareTrattamento"); + Postazione.CssClass = cssAdd; + } + } + } + } + } + } + break; + default: + Postazione.warningText = traduci("ERR-BCD-001"); + Postazione.CssClass = cssErr; + break; + } + barcodeIn = ""; + } + doUpdate(); + } + /// + /// calcolo/ricavo UDC di destinazione (se presente) + /// + /// + /// + private string getUdcDest(DS_DataMatrix.Dtx2UDCDataTable tabDtx2Udc) + { + string NewUDC = ""; + // verifico di avere un UDC destinazione x il particolare del datamatrix letto... altrimenti NON possiamo procedere... + try + { + currParticolare = tabDtx2Udc[0].Particolare; + } + catch + { + currParticolare = ""; + } + // se non ho particolare PROVO a decodificare da codice datamatrix + if (currParticolare == "") + { + try + { + // vers 2.9 modifica per multi-datamatrix + currParticolare = DataMatrix_mgr.taDtxAcquisiti.getByKey(barcodeIn)[0].Particolare; + // vers vecchia + //currParticolare = DataMatrix_mgr.taDecode.GetData(barcodeIn, "")[0].Particolare; + } + catch + { } + } + if (currParticolare != "") + { + try + { + NewUDC = MagClass.magazzino.taCartellini.getByParticolareAL(currParticolare, destAL)[0].UDC; + } + catch + { + NewUDC = ""; + } + } + else + { + // datamatrix NON riconosciuto + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-DTX-008"); + Postazione.CssClass = cssErr; + } + return NewUDC; + } + /// + /// rappresenta il codice UDC del corrente TT per resettare history pezzo DataMatrix + /// + private string currUdcTT + { + get + { + // ricalcolo + calcolaUdcTT(); + // default: cartellino TT "nullo" + string UdcTT = ""; + // cerco di recuperare valore UDC in caso sia stato inserito nel textBox + try + { + UdcTT = lblUDC.Text; + } + catch + { + UdcTT = ""; + } + // restituisco risposta + return UdcTT; + } + } + /// + /// evento cambio num TT + /// + /// + /// + protected void txtNumTT_TextChanged(object sender, EventArgs e) + { + // se non inizia per anno aggiunge anno e formatta anno + 6 cifre... + if (!txtNumTT.Text.Trim().StartsWith(string.Format("{0:yy}", DateTime.Now))) + { + // aggiungo anno e formatto numero 6 cifre... + try + { + int numTT = Convert.ToInt32(txtNumTT.Text.Trim()); + txtNumTT.Text = txtNumTT.Text = string.Format("{0:yy}{1:000000}", DateTime.Now, numTT); + } + catch + { + txtNumTT.Text = ""; + } + } + calcolaUdcTT(); + } + /// + /// ricalcolo UDC da num TT + /// + private void calcolaUdcTT() + { + string UdcTT = ""; + try + { + // cerco UDC da num tratt... + UdcTT = MagClass.magazzino.taCartellini.getByParticolareTT(currParticolare, txtNumTT.Text.Trim())[0].UDC; + } + catch + { + UdcTT = ""; + } + if (UdcTT == "") + { + // se non lo trovo uso UDC e trattamento "undef" a 0000, eventualmente creando UDC annuale + UdcTT = string.Format("U{0}{1}{2:yy}000000", memLayer.ML.cdv("CodCS"), flussoAnc, DateTime.Now); + } + lblUDC.Text = UdcTT; + } + /// + /// assegno un Dtx ad un codice UDC fin con eventuale reset storia (e copia da udcTratt) + /// + /// Codice DataMatrix da processare + /// UDC finiti di destinazione + /// UDC dei trattamenti da cui ricavare la stodia da associare, anche "fasullo"/0000 (se VUOTO NON riassocia) + /// UDC Rx da riassociare (se vuoto NON riassocia) + /// + private bool assignDtx2UDC(string codDtx, string UDCFin) + { + // assegno datamatrix a Udc Destinazione e associo UDC TT ad UDC FI + bool spostaDtx = false; + // se lo trovo chiamo procedura di spostamento Dtx tra UDC sorgente --> dest + DataMatrix_mgr.taDtx2UDC.UpdateUDC(UDCFin, barcodeIn, statoUdcOut, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, true, true); + return spostaDtx; + } + /// + /// assegno un Dtx ad un codice UDC fin con eventuale reset storia (e copia da udcTratt) + /// + /// Codice DataMatrix da processare + /// UDC finiti di destinazione + /// UDC dei trattamenti da cui ricavare la stodia da associare, anche "fasullo"/0000 (se VUOTO NON riassocia) + /// UDC Rx da riassociare (se vuoto NON riassocia) + /// + private bool assignDtx2UDC(string codDtx, string UDCFin, string UDCTratt, string UDCRx) + { + // assegno datamatrix a Udc Destinazione e associo UDC TT ad UDC FI + bool spostaDtx = false; + // se ho UdcRX lo cambio... + if (UDCRx != "") + { + DataMatrix_mgr.taDtx2UDC.UpdateUDC(UDCRx, barcodeIn, "ContrRx", DateTime.Now, MagClass.magazzino.CodSoggCurrUser, true, true); + } + // sostituisco UDC TT e Fin.. + DataMatrix_mgr.taDtx2UDC.UpdateUDC(UDCTratt, barcodeIn, statoUdcIn, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, true, true); + DataMatrix_mgr.taDtx2UDC.UpdateUDC(UDCFin, barcodeIn, statoUdcOut, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, true, true); + return spostaDtx; + } + /// + /// aggiorna tabella + focus a barcode + /// + public void doUpdate() + { + setDefaultVal(); + setVisibility(); + grViewDest.DataBind(); + // raise dell'evento + if (eh_reqUpdate != null) + { + eh_reqUpdate(this, new EventArgs()); + } + verificaBtnStampa(); + txtBarcode.Focus(); + } + /// + /// evento selezione grView destinazione: ricarico dati! + /// + /// + /// + protected void grViewDest_SelectedIndexChanged(object sender, EventArgs e) + { + // ricarico dati dell'UDC come particolare e quantità... + currUDC = grViewDest.SelectedDataKey["UDC"].ToString(); + int qtaDtx = 0; + if (MagClass.magazzino.checkUDC(currUDC)) + { + currParticolare = DataProxy.obj.taCartellini.stp_getByUdc(currUDC)[0].Particolare; + qta = Convert.ToInt32(DataProxy.obj.taCartellini.stp_getByUdc(currUDC)[0].Qta); + qtaDtx = Convert.ToInt32(MagClass.magazzino.taA2U2D.getByUDC(currUDC)[0].QtaDtx); + // imposto particolare... + lblPart.Text = currParticolare; + ddlImballi.DataBind(); + } + Postazione.messaggiText = traduci("partSelected"); + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoOk"; + setVisibility(); + doUpdate(); + // fisso focus su note! + txtNote.Focus(); + } + /// + /// Verifica se Assieme sia vuoto (no DTX negli UDC) + /// + /// Codice AL + /// + protected bool assiemeIsEmpty(string AL) + { + bool answ = false; + try + { + answ = DataMatrix_mgr.taDtx2UDC.getByAL(AL).Rows.Count == 0; + } + catch { } + return answ; + } + /// + /// reset della selezione + /// + /// + /// + protected void btnReset_Click(object sender, EventArgs e) + { + grViewDest.SelectedIndex = -1; + qta = 0; + currUDC = ""; + setVisibility(); + doUpdate(); + } + /// + /// update Qty x UDC selezionato... + /// + /// + /// + protected void lbtUpdQty_Click(object sender, EventArgs e) + { + MagClass.magazzino.taCartellini.updateQty(currUDC, MagClass.magazzino.CodSoggCurrUser, "U", codEventoUdcOut, qta); + // fix tablet + currUDC = ""; + currParticolare = ""; + grViewDest.SelectedIndex = -1; + doUpdate(); + } + /// + /// richiesta (ri)stampa UDC + /// + /// + /// + public void ristampa() + { + bool fatto = false; + fatto = MagClass.magazzino.ristampaUdc(udcReq, Postazione.printer, Request.UserHostName); + // registro ri-stampa UDC + if (fatto) MagClass.magazzino.taSAO.insertQuery(DateTime.Now, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, udcReq, "", "stampaUDC", string.Format("Ri-Stampato UDC Dtx {0} su linea anomalie {1}", currUDC, Postazione.currCodLinea)); + } + /// + /// verifica visibilità btn stampa UDC + /// + private void verificaBtnStampa() + { + bool showBtnStampa = false; + // se ho selezionato udc... + if (currUDC != "") + { + DS_magazzino.v_A2U2DRow riga; + int qtaUDC = 0; + int qtaDtx = 0; + try + { + riga = MagClass.magazzino.taA2U2D.getByUDC(currUDC)[0]; + qtaUDC = Convert.ToInt32(riga.Qta); + qtaDtx = riga.QtaDtx; + } + catch + { } + if (qtaUDC > 0) + { + // se le qta voluta e dtx sono uguali... + if (qtaUDC == qtaDtx) + { + showBtnStampa = true; + } + } + } + divNote.Visible = showBtnStampa; + } + /// + /// fornisce in output la corretta classe css x icona + /// + /// + /// + /// + public string cssGlyphByQty(object _qta, object _qtaDtx) + { + string answ = "glyphicon glyphicon-pencil btn-lg"; + int qtaUDC = 0; + int qtaDtx = -1; + try + { + qtaUDC = Convert.ToInt32(_qta); + } + catch { } + try + { + qtaDtx = Convert.ToInt32(_qtaDtx); + } + catch { } + if (qtaUDC == qtaDtx) + { + answ = "glyphicon glyphicon-print btn-lg"; + } + return answ; + } + /// + /// effettua processo di sistemazione UDC e stampa + /// + /// + /// + protected void lbtStampaUDC_Click(object sender, EventArgs e) + { + // verifico postazione sia valida... + if (Postazione.name != "" && Postazione.IP != "" && Postazione.currCodCella != "") + { + // in base ad AL sorgente e destinazione, fa le operazioni di update x UDC e poi lo stampa + bool fatto = false; + string noteTrim = txtNote.Text.Trim(); + try + { + // update UDC! + fatto = MagClass.magazzino.liquidiFullUpdate("", flussoAnc, currUDC, ddlImballi.SelectedValue, noteTrim, MagClass.magazzino.CodSoggCurrUser); + } + catch + { } + if (fatto) + { + // lancio stampa + MagClass.magazzino.stampaUdc(currUDC, Postazione.printer, tipoCartellino.cartFinitiSP, Request.UserHostName); + // registro creazione AL + MagClass.magazzino.taSAO.insertQuery(DateTime.Now, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, currUDC, currParticolare, "stampaUDC", string.Format("Stampato UDC Dtx {0} su linea anomalie {1}, note: {2} ", currUDC, Postazione.currCodLinea, noteTrim)); + Postazione.CssClass = cssAtt; + Postazione.warningText = ""; + Postazione.messaggiText = traduci("cartUDCStampato"); + // calcolo particolare completo di descrizione + DS_Applicazione.ElencoCartelliniRow riga = DataProxy.obj.taCartellini.stp_getByUdc(currUDC)[0]; + string particolare = string.Format("{0} - {1}", riga.Particolare, riga.DescParticolare); + // resetto... + grViewDest.SelectedIndex = -1; + qta = 0; + currUDC = ""; + } + doUpdate(); + } + else + { + // ricarico che mi manca postazione! + Postazione.CssClass = cssAtt; + Postazione.warningText = traduci("ERR-POS-001"); + Postazione.messaggiText = ""; + Response.Redirect(user_std.pagCorrente); + } + } + /// + /// udc da stampare + /// + protected string udcReq + { + get + { + return memLayer.ML.StringSessionObj("udcSelSAO"); + } + } + /// + /// preseleziono (se possibile) imballo... + /// + /// + /// + protected void ddlImballi_DataBound(object sender, EventArgs e) + { + selezionaImballo(); + } + /// + /// seleziona imballo corretto + /// + private void selezionaImballo() + { + string codImb = ""; + // cerco se c'è un imballo x particolare corrente... + if (currParticolare != "") + { + codImb = lastCodImb; + } + else + { + codImb = memLayer.ML.cdv("CodImballoFiniti"); + } + try + { + // preseleziono + ddlImballi.SelectedValue = codImb; + } + catch + { } + } + + } } \ No newline at end of file diff --git a/GMW/WebUserControls/mod_PostFin_DT.ascx.cs b/GMW/WebUserControls/mod_PostFin_DT.ascx.cs index de14861c..9e6d63e2 100644 --- a/GMW/WebUserControls/mod_PostFin_DT.ascx.cs +++ b/GMW/WebUserControls/mod_PostFin_DT.ascx.cs @@ -11,6 +11,10 @@ namespace GMW.WebUserControls /// public partial class mod_PostFin_DT : GMW_data.UserControlBCodeMan { + /// + /// Oggetto locale gestione classe datamatrix... + /// + protected DataMatrix DataMatrix_mgr = new DataMatrix(); /// /// Imposta variabili specifiche classe /// @@ -219,7 +223,7 @@ namespace GMW.WebUserControls bool answ = false; try { - answ = DataMatrix.mgr.taDtx2UDC.getByAL(AL).Rows.Count > 0; + answ = DataMatrix_mgr.taDtx2UDC.getByAL(AL).Rows.Count > 0; } catch { } @@ -341,7 +345,7 @@ namespace GMW.WebUserControls else { // verifico UDC in ingresso NON abbia DTX associati - int numDtx = DataMatrix.mgr.taDtx2UDC.getByUDC(barcodeIn).Count; + int numDtx = DataMatrix_mgr.taDtx2UDC.getByUDC(barcodeIn).Count; if (numDtx > 0 && cartUDC.CodStato == statoUDC_pre) { Postazione.warningText = traduci("ERR-UDC-DTX-002"); @@ -508,7 +512,7 @@ namespace GMW.WebUserControls bool isOk = false; try { - isOk = DataMatrix.mgr.taVerifica.GetData(barcodeIn)[0].StatoDtx == "OK"; + isOk = DataMatrix_mgr.taVerifica.GetData(barcodeIn)[0].StatoDtx == "OK"; } catch { } @@ -530,7 +534,7 @@ namespace GMW.WebUserControls bool dtxInDestAL = false; try { - dtxFree = DataMatrix.mgr.taDtx2UDC.getByDtx(barcodeIn).Count == 0; + dtxFree = DataMatrix_mgr.taDtx2UDC.getByDtx(barcodeIn).Count == 0; } catch(Exception exc) { @@ -539,7 +543,7 @@ namespace GMW.WebUserControls } try { - dtxInDestAL = DataMatrix.mgr.taDtx2UDC.getByDtxAl(destAL, barcodeIn).Rows.Count == 1; + dtxInDestAL = DataMatrix_mgr.taDtx2UDC.getByDtxAl(destAL, barcodeIn).Rows.Count == 1; } catch (Exception exc) { @@ -562,7 +566,7 @@ namespace GMW.WebUserControls string partDtx = ""; try { - partDtx = DataMatrix.mgr.taDtxAcq.getByKey(barcodeIn)[0].Particolare; + partDtx = DataMatrix_mgr.taDtxAcq.getByKey(barcodeIn)[0].Particolare; } catch (Exception exc) { @@ -680,7 +684,7 @@ namespace GMW.WebUserControls if (chkDtxMode.Checked) { // verifico che sia nell'AL DEST x poter rimuovere... - if (DataMatrix.mgr.taDtx2UDC.getByDtxAl(destAL, barcodeIn).Rows.Count != 1) + if (DataMatrix_mgr.taDtx2UDC.getByDtxAl(destAL, barcodeIn).Rows.Count != 1) { Postazione.warningText = traduci("ERR-DTX-018"); Postazione.CssClass = cssAtt; @@ -688,7 +692,7 @@ namespace GMW.WebUserControls else { // elimino associazione DTX e UDC dest... - DataMatrix.mgr.taDtx2UDC.deleteQuery(udcDest, barcodeIn, MagClass.magazzino.CodSoggCurrUser, IdxPosizioneOut, Postazione.currIdxCella); + DataMatrix_mgr.taDtx2UDC.deleteQuery(udcDest, barcodeIn, MagClass.magazzino.CodSoggCurrUser, IdxPosizioneOut, Postazione.currIdxCella); fatto = true; Postazione.messaggiText += " " + traduci("DtxRem"); Postazione.warningText = ""; @@ -706,7 +710,7 @@ namespace GMW.WebUserControls else { // verifico che NON sia nell'AL DEST x poter aggiungere... - if (DataMatrix.mgr.taDtx2UDC.getByDtxAl(destAL, barcodeIn).Rows.Count == 1) + if (DataMatrix_mgr.taDtx2UDC.getByDtxAl(destAL, barcodeIn).Rows.Count == 1) { Postazione.warningText = traduci("ERR-DTX-006"); Postazione.CssClass = cssAtt; @@ -714,7 +718,7 @@ namespace GMW.WebUserControls else { // se lo trovo chiamo procedura di spostamento Dtx tra UDC sorgente --> dest (con eventuale creazione dest) - DataMatrix.mgr.taDtx2UDC.UpdateUDC(udcDest, barcodeIn, statoUDC, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, false, false); + DataMatrix_mgr.taDtx2UDC.UpdateUDC(udcDest, barcodeIn, statoUDC, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, false, false); // fix messaggi Postazione.messaggiText += " " + traduci("ConfermatoDtx"); Postazione.warningText = ""; @@ -883,7 +887,7 @@ namespace GMW.WebUserControls bool answ = false; try { - answ = DataMatrix.mgr.taDtx2UDC.getByAL(AL).Rows.Count == 0; + answ = DataMatrix_mgr.taDtx2UDC.getByAL(AL).Rows.Count == 0; } catch { } return answ; diff --git a/GMW/WebUserControls/mod_PostLiq_DT.ascx.cs b/GMW/WebUserControls/mod_PostLiq_DT.ascx.cs index cdef7e05..271a3a3d 100644 --- a/GMW/WebUserControls/mod_PostLiq_DT.ascx.cs +++ b/GMW/WebUserControls/mod_PostLiq_DT.ascx.cs @@ -5,1199 +5,1203 @@ using System.Web.UI; namespace GMW.WebUserControls { + /// + /// Pagina liquidi DT + /// + public partial class mod_PostLiq_DT : GMW_data.UserControlBCodeMan + { /// - /// Pagina liquidi DT + /// Oggetto locale gestione classe datamatrix... /// - public partial class mod_PostLiq_DT : GMW_data.UserControlBCodeMan + protected DataMatrix DataMatrix_mgr = new DataMatrix(); + /// + /// Imposta variabili specifiche classe + /// + public override void setupVariabili() { - /// - /// Imposta variabili specifiche classe - /// - public override void setupVariabili() - { - flusso = "FI"; - flussoAnc = "TT"; - // temporaneo TL (Trattati/Liquidi) - flussoTemp = "TL"; - statoUDC = "Fin"; - statoUDC_pre = "Tratt"; - eventoUDC = "UDC_TL_DT"; //UDC_FINWIP ??? - eventoUDC_qta = "UDC_QTY"; - eventoUDC_temp = "UDC_TRATT"; - codLineaKo = "W8200"; - QtaImballoStd = memLayer.ML.cdvi("QtaImballoFiniti"); - CodImballoStd = memLayer.ML.cdv("CodImballoFiniti"); + flusso = "FI"; + flussoAnc = "TT"; + // temporaneo TL (Trattati/Liquidi) + flussoTemp = "TL"; + statoUDC = "Fin"; + statoUDC_pre = "Tratt"; + eventoUDC = "UDC_TL_DT"; //UDC_FINWIP ??? + eventoUDC_qta = "UDC_QTY"; + eventoUDC_temp = "UDC_TRATT"; + codLineaKo = "W8200"; + QtaImballoStd = memLayer.ML.cdvi("QtaImballoFiniti"); + CodImballoStd = memLayer.ML.cdv("CodImballoFiniti"); - tipoUdcLinea = "Finito"; - IdxPosizioneIn = memLayer.ML.cdvi("IdxPosizioneTrattati"); - IdxPosizioneOut = memLayer.ML.cdvi("IdxPosizioneFiniti"); - IdxPosizioneOutTempName = "IdxPosizioneFinTemp"; - sVarIdxCella = "IdxCellaLineaFiniti"; - IdxPosizioneOutTemp = memLayer.ML.cdvi(IdxPosizioneOutTempName); - tipoCartCurr = tipoCartellino.cartFiniti; - enableBCodeParticolare = false; - } - /// - /// Codice AL in carico - /// - public override string sourceAL + tipoUdcLinea = "Finito"; + IdxPosizioneIn = memLayer.ML.cdvi("IdxPosizioneTrattati"); + IdxPosizioneOut = memLayer.ML.cdvi("IdxPosizioneFiniti"); + IdxPosizioneOutTempName = "IdxPosizioneFinTemp"; + sVarIdxCella = "IdxCellaLineaFiniti"; + IdxPosizioneOutTemp = memLayer.ML.cdvi(IdxPosizioneOutTempName); + tipoCartCurr = tipoCartellino.cartFiniti; + enableBCodeParticolare = false; + } + /// + /// Codice AL in carico + /// + public override string sourceAL + { + get + { + string answ = ""; + // cerco su controllo + answ = lblAL.Text.Trim(); + // se vuoto cerco in sessione (ed eventualmente aggiorno + if (answ == "") { - get - { - string answ = ""; - // cerco su controllo - answ = lblAL.Text.Trim(); - // se vuoto cerco in sessione (ed eventualmente aggiorno - if (answ == "") - { - answ = memLayer.ML.StringSessionObj(string.Format("sourceAL_{0}", uid)); - lblAL.Text = answ; - } - // restituisco! - return answ; - } - set - { - // salvo in sessione - memLayer.ML.setSessionVal(string.Format("sourceAL_{0}", uid), value); - // salvo su controllo - lblAL.Text = value; - } + answ = memLayer.ML.StringSessionObj(string.Format("sourceAL_{0}", uid)); + lblAL.Text = answ; } - /// - /// Codice AL della cella corrente - /// - public override string destAL + // restituisco! + return answ; + } + set + { + // salvo in sessione + memLayer.ML.setSessionVal(string.Format("sourceAL_{0}", uid), value); + // salvo su controllo + lblAL.Text = value; + } + } + /// + /// Codice AL della cella corrente + /// + public override string destAL + { + get + { + return lblDestAL.Text.Trim(); + } + set + { + lblDestAL.Text = value; + } + } + /// + /// qta pezzi x UDC + /// + public override int qta + { + get + { + int qta = 0; + try { - get - { - return lblDestAL.Text.Trim(); - } - set - { - lblDestAL.Text = value; - } + qta = Convert.ToInt32(txtQta.Text.Trim()); } - /// - /// qta pezzi x UDC - /// - public override int qta + catch + { } + return qta; + } + set + { + txtQta.Text = value.ToString(); + } + } + /// + /// valore barcode + /// + public override string barcodeIn + { + get + { + return txtBarcode.Text.Trim(); + } + set + { + txtBarcode.Text = value; + } + } + /// + /// caricamento pagina + /// + /// + /// + public override void Page_Load(object sender, EventArgs e) + { + // inizializzazione base! + base.Page_Load(sender, e); + // inizializzazione custom... + if (!Page.IsPostBack) + { + currUDC = ""; + forceDelete = false; + setDefaultVal(); + odsAL.DataBind(); + grViewSource.DataBind(); + } + } + /// + /// imposta i valori di default all'avvio + /// + private void setDefaultVal() + { + if (sourceAL == "") + { + sourceAL = currAL != "" ? currAL : ""; + } + destAL = AlByCella; + } + /// + /// Sistema css del panel AL + /// + /// + private void fixCssAL(string tipoPanel) + { + divAL.Attributes.Remove("class"); + divAL.Attributes.Add("class", string.Format("panel panel-{0} panel-sm", tipoPanel)); + } + /// + /// sistema modalità input + /// + public override void setVisibility() + { + bool showBtn = false; + if (sourceAL != "" && currAL == "") + { + showBtn = true; + fixCssAL("warning"); + } + else + { + fixCssAL("success"); + } + lbtPrendeCaricoAL.Visible = showBtn; + // X btn chiusura: solo chiudo SOLO se c'è AL in carico.. + lbtChiudiAL.Visible = (currAL != ""); + // ora controllo btn quantità + showBtn = false; + if (grViewDest.SelectedIndex >= 0) + { + showBtn = true; + } + divQta.Visible = showBtn; + divImballi.Visible = showBtn; + if (showBtn) + { + selezionaImballo(); + } + } + /// + /// reset maschera... + /// + protected void doReset() + { + // resetta + fixCssAL("warning"); + lastBarcodeIn = ""; + Postazione.messaggiText = ""; + Postazione.warningText = ""; + Postazione.CssClass = cssAtt; + doUpdate(); + } + /// + /// Verifica l'AL se sia ok x procedere: + /// - Attivo + /// + /// + /// T/L + /// + protected bool checkAL(string AL, string tipo) + { + bool answ = false; + try + { + answ = MagClass.magazzino.taEA.getByAL_TipoAttivo(AL, tipo).Rows.Count > 0; + } + catch + { } + if (answ) + { + Postazione.warningText = ""; + Postazione.CssClass = cssOk; + } + else + { + Postazione.warningText = traduci("ErroreAlNonTtAttivo"); + Postazione.CssClass = cssErr; + } + + return answ; + } + /// + /// Verifica l'AL se abbia datamatrix + /// + /// + /// + protected bool checkDtxAL(string AL) + { + bool answ = false; + try + { + answ = DataMatrix_mgr.taDtx2UDC.getByAL(AL).Rows.Count > 0; + } + catch + { } + if (!answ) + { + Postazione.warningText = traduci("ErroreAlNonDtx"); + Postazione.CssClass = cssErr; + } + else + { + Postazione.warningText = ""; + Postazione.CssClass = cssOk; + } + return answ; + } + /// + /// controlla se ci sia un barcode e cosa farne... + /// + public override void checkBarcode() + { + // solo se ho una NUOVA chiamata... + TimeSpan ritardo = DateTime.Now.Subtract(lastCall); + if (ritardo.TotalMinutes > 1 || DateTime.Now.Subtract(lastCall).Milliseconds > memLayer.ML.CRI("minWaitProcMs")) + { + lastCall = DateTime.Now; + if (barcodeIn != "") { - get - { - int qta = 0; - try - { - qta = Convert.ToInt32(txtQta.Text.Trim()); - } - catch - { } - return qta; - } - set - { - txtQta.Text = value.ToString(); - } - } - /// - /// valore barcode - /// - public override string barcodeIn - { - get - { - return txtBarcode.Text.Trim(); - } - set - { - txtBarcode.Text = value; - } - } - /// - /// caricamento pagina - /// - /// - /// - public override void Page_Load(object sender, EventArgs e) - { - // inizializzazione base! - base.Page_Load(sender, e); - // inizializzazione custom... - if (!Page.IsPostBack) - { - currUDC = ""; - forceDelete = false; - setDefaultVal(); - odsAL.DataBind(); - grViewSource.DataBind(); - } - } - /// - /// imposta i valori di default all'avvio - /// - private void setDefaultVal() - { - if (sourceAL == "") - { - sourceAL = currAL != "" ? currAL : ""; - } - destAL = AlByCella; - } - /// - /// Sistema css del panel AL - /// - /// - private void fixCssAL(string tipoPanel) - { - divAL.Attributes.Remove("class"); - divAL.Attributes.Add("class", string.Format("panel panel-{0} panel-sm", tipoPanel)); - } - /// - /// sistema modalità input - /// - public override void setVisibility() - { - bool showBtn = false; - if (sourceAL != "" && currAL == "") - { - showBtn = true; - fixCssAL("warning"); - } - else - { - fixCssAL("success"); - } - lbtPrendeCaricoAL.Visible = showBtn; - // X btn chiusura: solo chiudo SOLO se c'è AL in carico.. - lbtChiudiAL.Visible = (currAL != ""); - // ora controllo btn quantità - showBtn = false; - if (grViewDest.SelectedIndex >= 0) - { - showBtn = true; - } - divQta.Visible = showBtn; - divImballi.Visible = showBtn; - if (showBtn) - { - selezionaImballo(); - } - } - /// - /// reset maschera... - /// - protected void doReset() - { - // resetta - fixCssAL("warning"); + Postazione.messaggiText = string.Format("{0}: {1}", traduci("BCodeIns"), barcodeIn); + tipoCodiceBarcode tipoBC = MagClass.tipoBCode_L5(barcodeIn); + // per prima cosa: SE NON HO AL SELEZIONATO e non ho sparato un AL o un imballo sollevo errore... + if (!(tipoBC == tipoCodiceBarcode.AL || tipoBC == tipoCodiceBarcode.Imballo) && currAL == "") + { + // sollevo errore, in primis va definito AL sorgente... + Postazione.warningText = traduci("ERR-ALT-001"); + Postazione.CssClass = cssErr; + sendUpdateTablet("ND", "-", traduci("ERR-ALT-001"), "-", "-", "-", cssErr, cssErr, cssErr); lastBarcodeIn = ""; - Postazione.messaggiText = ""; - Postazione.warningText = ""; - Postazione.CssClass = cssAtt; - doUpdate(); - } - /// - /// Verifica l'AL se sia ok x procedere: - /// - Attivo - /// - /// - /// T/L - /// - protected bool checkAL(string AL, string tipo) - { - bool answ = false; - try + } + else + { + switch (tipoBC) { - answ = MagClass.magazzino.taEA.getByAL_TipoAttivo(AL, tipo).Rows.Count > 0; - } - catch - { } - if (answ) - { - Postazione.warningText = ""; - Postazione.CssClass = cssOk; - } - else - { - Postazione.warningText = traduci("ErroreAlNonTtAttivo"); - Postazione.CssClass = cssErr; - } - - return answ; - } - /// - /// Verifica l'AL se abbia datamatrix - /// - /// - /// - protected bool checkDtxAL(string AL) - { - bool answ = false; - try - { - answ = DataMatrix.mgr.taDtx2UDC.getByAL(AL).Rows.Count > 0; - } - catch - { } - if (!answ) - { - Postazione.warningText = traduci("ErroreAlNonDtx"); - Postazione.CssClass = cssErr; - } - else - { - Postazione.warningText = ""; - Postazione.CssClass = cssOk; - } - return answ; - } - /// - /// controlla se ci sia un barcode e cosa farne... - /// - public override void checkBarcode() - { - // solo se ho una NUOVA chiamata... - TimeSpan ritardo = DateTime.Now.Subtract(lastCall); - if (ritardo.TotalMinutes > 1 || DateTime.Now.Subtract(lastCall).Milliseconds > memLayer.ML.CRI("minWaitProcMs")) - { - lastCall = DateTime.Now; - if (barcodeIn != "") - { - Postazione.messaggiText = string.Format("{0}: {1}", traduci("BCodeIns"), barcodeIn); - tipoCodiceBarcode tipoBC = MagClass.tipoBCode_L5(barcodeIn); - // per prima cosa: SE NON HO AL SELEZIONATO e non ho sparato un AL o un imballo sollevo errore... - if (!(tipoBC == tipoCodiceBarcode.AL || tipoBC == tipoCodiceBarcode.Imballo) && currAL == "") - { - // sollevo errore, in primis va definito AL sorgente... - Postazione.warningText = traduci("ERR-ALT-001"); - Postazione.CssClass = cssErr; - sendUpdateTablet("ND", "-", traduci("ERR-ALT-001"), "-", "-", "-", cssErr, cssErr, cssErr); - lastBarcodeIn = ""; - } - else - { - switch (tipoBC) - { - case tipoCodiceBarcode.Imballo: - // cerco di selezionare! - try - { - ddlImballi.SelectedValue = barcodeIn; - lastBarcodeIn = ""; - } - catch - { - Postazione.warningText = traduci("ERR-IMB-001"); - Postazione.CssClass = cssErr; - } - break; - case tipoCodiceBarcode.Comando: - // se è reset cancello tutto! - if (barcodeIn == memLayer.ML.cdv("cmdReset")) - { - doReset(); - lastBarcodeIn = ""; - } - else if (barcodeIn == memLayer.ML.cdv("cmdCloseAL")) - { - // forza reset linea - currAL = ""; - sourceAL = ""; - lastBarcodeIn = ""; - // resetta! - doReset(); - } - break; - case tipoCodiceBarcode.UDC: - // controllo di avere destAL valido, sennò ricarico pagina... - if (destAL.Length > 5) - { - // controllo se sia un UDC valido... - if (MagClass.magazzino.checkUDC(barcodeIn)) - { - // controllo se sia un UDC di finiti LIQ in posizione 4... - DS_magazzino.ElencoCartelliniRow cartUDC = MagClass.magazzino.taCartellini.getByUdc(barcodeIn)[0]; - if (cartUDC.CodStato == statoUDC && cartUDC.IdxPosizione == memLayer.ML.cdvi("IdxPosizioneFiniti")) - { - // controllo NON ci sia già un UDC di pari particolare caricato nella postazione corrente (non posso avere 2 UDC a pari particolare da riempire...) - if (MagClass.magazzino.taCartellini.getByParticolareAL(cartUDC.Particolare, destAL).Rows.Count == 0) - { - // controllo NON abbia blocco x FinDtx... - if (MagClass.magazzino.udcHasAttr(barcodeIn, "BL")) - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-LIQ-006"); - Postazione.CssClass = cssErr; - } - else - { - // controllo NON sia UDC in LDP e già PRELEVATO - if (MagClass.magazzino.taRigheListePrelievo.getByUdc(barcodeIn).Select("Prelevato = 1").Length == 0) - { - // se è ok RICARICO UDC in posizione corrente... - bool fatto = MagClass.magazzino.liquidiRiprendiInCaricoUDC(barcodeIn, MagClass.magazzino.CodSoggCurrUser, destAL, Postazione.currIdxCella); - if (fatto) - { - Postazione.messaggiText = traduci("RiCaricatoUdcLiq"); - Postazione.warningText = ""; - Postazione.CssClass = cssOk; - checkUpdateTablet(barcodeIn); - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-LIQ-001"); - Postazione.CssClass = cssErr; - } - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-LIQ-005"); - Postazione.CssClass = cssErr; - } - } - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-LIQ-004"); - Postazione.CssClass = cssErr; - } - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-LIQ-002"); - Postazione.CssClass = cssErr; - } - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-LIQ-003"); - Postazione.CssClass = cssErr; - } - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-ALF-001"); - Postazione.CssClass = cssErr; - } - break; - case tipoCodiceBarcode.AL: - // se linea libera... - if (currAL == "") - { - // verifico barcode valido - if (checkAL(barcodeIn, "T")) - { - // verifico AL sia con datamatrix... - if (checkDtxAL(barcodeIn)) - { - // controllo: se avevo già letto lo steso AL è conferma presa in carico... - if (sourceAL == barcodeIn) - { - presaCaricoAL(); - } - else - { - // mostro AL sorgente - sourceAL = barcodeIn; - fixCssAL("warning"); - // sistemo grafica - Postazione.messaggiText = traduci("ConfermareAL"); - Postazione.warningText = ""; - Postazione.CssClass = cssOk; - } - } - else - { - sourceAL = ""; - } - } - else - { - sourceAL = ""; - } - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-ALT-002"); - Postazione.CssClass = cssErr; - } - break; - case tipoCodiceBarcode.DataMatrixTrovato: - string OldUDC = ""; - int IdxPosizione = 0; - string NewUDC = ""; - // verifica preliminare: se OK procedo, se è KO NON LO CONSIDERO PROPRIO - bool isOk = false; - try - { - isOk = DataMatrix.mgr.taVerifica.GetData(barcodeIn)[0].StatoDtx == "OK"; - } - catch - { } - if (!isOk) - { - // non accetto Dtx e mostro errore - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("ERR-DTX-012"); - Postazione.CssClass = cssErr; - } - else // PROCEDO!!! - { - // verifico DTX sia in quelli dell'AL sorgente - if (DataMatrix.mgr.taDtx2UDC.getByDtxAl(sourceAL, barcodeIn).Rows.Count > 0) - { - // cerco se ci sia UDC di destinazione - DateTime adesso = DateTime.Now; - try - { - OldUDC = DataMatrix.mgr.taDtx2UDC.getByDtxAl(sourceAL, barcodeIn)[0].UDC; - IdxPosizione = MagClass.magazzino.taCartellini.getByUdc(OldUDC)[0].IdxPosizione; - currParticolare = MagClass.magazzino.taCartellini.getByUdc(OldUDC)[0].Particolare; - } - catch - { - currParticolare = ""; - } - if (currParticolare != "") - { - try - { - NewUDC = MagClass.magazzino.taCartellini.getByParticolareAL(currParticolare, destAL)[0].UDC; - } - catch - { - NewUDC = ""; - } - if (NewUDC == "") - { - // CASO 01: DTX in AL sorgente, particolare OK, NON C'E' UDC dest - procDtx_Caso01(ref OldUDC, ref NewUDC, adesso); - } - else - { - // CASO 02: DTX in AL sorgente, particolare OK, C'E' UDC dest - OldUDC = procDtx_Caso02(OldUDC, NewUDC); - } - checkUpdateTablet(NewUDC); - } - else - { - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("UdcNonTrovato"); - Postazione.CssClass = cssErr; - } - } - // se non lo trovo in AL sorgente... - else - { - // faccio ulteriore verifica: se il datamatrix sia "libero" o già tra i "Missing In Action".. - if (DataMatrix.mgr.taDtxAvailFree.GetData(barcodeIn).Rows.Count > 0) - { - // CASO 03: DTX NON in sorgente ma libero/missing in action - NewUDC = procDtx_Caso03(NewUDC); - } - else - { - // CASO 04: DTX NON in sorgente e NON libero/missing in action - procDTX_Caso04(ref OldUDC, ref IdxPosizione, ref NewUDC); - } - } - } - break; - default: - Postazione.warningText = traduci("ERR-BCD-001"); - Postazione.CssClass = cssErr; - lastBarcodeIn = ""; - break; - } - } - barcodeIn = ""; - } - doUpdate(); - } - txtBarcode.Focus(); - } - - #region metodi processing DataMatrix letto da BarCode - - /// - /// CASO 01: DTX in AL sorgente, particolare OK, NON C'E' UDC dest - /// - /// - /// - /// - private void procDtx_Caso01(ref string OldUDC, ref string NewUDC, DateTime adesso) - { - // verifico che NON sia modalità "rimozione" datamatrix - if (!chkDtxMode.Checked) - { - // scambio UDC e prendo quello TT - OldUDC = OldUDC.Replace(flussoTemp, flussoAnc); - // calcolo codImballo - - string codImballo = ""; + case tipoCodiceBarcode.Imballo: + // cerco di selezionare! try { - codImballo = ddlImballi.SelectedValue; + ddlImballi.SelectedValue = barcodeIn; + lastBarcodeIn = ""; } catch { - codImballo = memLayer.ML.cdv("CodImballoFiniti"); + Postazione.warningText = traduci("ERR-IMB-001"); + Postazione.CssClass = cssErr; } - // se NON HA selezionato prendo default... - if (codImballo == "" || codImballo == "-") + break; + case tipoCodiceBarcode.Comando: + // se è reset cancello tutto! + if (barcodeIn == memLayer.ML.cdv("cmdReset")) { - codImballo = memLayer.ML.cdv("CodImballoFiniti"); + doReset(); + lastBarcodeIn = ""; } - // controllo se devo usare chiamata a stored unica (UDC + aggancio AL + cella corretta) o due chiamate - if (memLayer.ML.confReadBool("useStoredLiqSP")) + else if (barcodeIn == memLayer.ML.cdv("cmdCloseAL")) { - // nuova stored con AL e cella...... - NewUDC = MagClass.magazzino.creaUdcWithAlCella(destAL, sourceAL, barcodeIn, statoUDC, Postazione.currCodCella, flusso, "", currParticolare, "", "", "", "", OldUDC, 0, codImballo, "U", MagClass.magazzino.CodSoggCurrUser, pezziUdc, 0, 0, adesso, 0, statoUDC, memLayer.ML.cdvi("IdxPosizioneFinTemp"), "IdxPosizioneFinTemp", eventoUDC, "", "", adesso.Year, Request.UserHostName); - // registro creazione nuovo UDC - MagClass.magazzino.taSAO.insertQuery(adesso, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, NewUDC, currParticolare, "creaUDC", string.Format("Creato nuovo UDC PostLiquidi DT, qta: {0} {1}", qta, "")); + // forza reset linea + currAL = ""; + sourceAL = ""; + lastBarcodeIn = ""; + // resetta! + doReset(); + } + break; + case tipoCodiceBarcode.UDC: + // controllo di avere destAL valido, sennò ricarico pagina... + if (destAL.Length > 5) + { + // controllo se sia un UDC valido... + if (MagClass.magazzino.checkUDC(barcodeIn)) + { + // controllo se sia un UDC di finiti LIQ in posizione 4... + DS_magazzino.ElencoCartelliniRow cartUDC = MagClass.magazzino.taCartellini.getByUdc(barcodeIn)[0]; + if (cartUDC.CodStato == statoUDC && cartUDC.IdxPosizione == memLayer.ML.cdvi("IdxPosizioneFiniti")) + { + // controllo NON ci sia già un UDC di pari particolare caricato nella postazione corrente (non posso avere 2 UDC a pari particolare da riempire...) + if (MagClass.magazzino.taCartellini.getByParticolareAL(cartUDC.Particolare, destAL).Rows.Count == 0) + { + // controllo NON abbia blocco x FinDtx... + if (MagClass.magazzino.udcHasAttr(barcodeIn, "BL")) + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-LIQ-006"); + Postazione.CssClass = cssErr; + } + else + { + // controllo NON sia UDC in LDP e già PRELEVATO + if (MagClass.magazzino.taRigheListePrelievo.getByUdc(barcodeIn).Select("Prelevato = 1").Length == 0) + { + // se è ok RICARICO UDC in posizione corrente... + bool fatto = MagClass.magazzino.liquidiRiprendiInCaricoUDC(barcodeIn, MagClass.magazzino.CodSoggCurrUser, destAL, Postazione.currIdxCella); + if (fatto) + { + Postazione.messaggiText = traduci("RiCaricatoUdcLiq"); + Postazione.warningText = ""; + Postazione.CssClass = cssOk; + checkUpdateTablet(barcodeIn); + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-LIQ-001"); + Postazione.CssClass = cssErr; + } + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-LIQ-005"); + Postazione.CssClass = cssErr; + } + } + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-LIQ-004"); + Postazione.CssClass = cssErr; + } + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-LIQ-002"); + Postazione.CssClass = cssErr; + } + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-LIQ-003"); + Postazione.CssClass = cssErr; + } } else { - // oppure lo creo... - NewUDC = MagClass.magazzino.creaUdc(flusso, "", currParticolare, "", "", "", "", OldUDC, 0, codImballo, "U", MagClass.magazzino.CodSoggCurrUser, pezziUdc, 0, 0, adesso, 0, statoUDC, memLayer.ML.cdvi("IdxPosizioneFinTemp"), "IdxPosizioneFinTemp", eventoUDC, "", "", adesso.Year, Request.UserHostName); - // registro creazione nuovo UDC - MagClass.magazzino.taSAO.insertQuery(adesso, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, NewUDC, currParticolare, "creaUDC", string.Format("Creato nuovo UDC PostLiquidi DT, qta: {0} {1}", qta, "")); - // lo associo all'AL! - MagClass.magazzino.taAL2UDC.Insert(destAL, NewUDC, adesso, MagClass.magazzino.CodSoggCurrUser); - - - DataMatrix.mgr.taDtx2UDC.UpdateUDC(NewUDC, barcodeIn, statoUDC, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, false, false); - // disattivo AL (se non era già disattivo...) x evitare si possa togliere senza chiudere... - MagClass.magazzino.taEA.DisattivaAL(sourceAL); - // fix messaggi - Postazione.messaggiText = traduci("ConfermatoDtx"); - Postazione.warningText = ""; - Postazione.CssClass = cssAtt; + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-ALF-001"); + Postazione.CssClass = cssErr; } - } - else - { - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("UdcNonTrovato"); - Postazione.CssClass = cssErr; - } - } - /// - /// CASO 02: DTX in AL sorgente, particolare OK, C'E' UDC dest - /// - /// - /// - /// - private string procDtx_Caso02(string OldUDC, string NewUDC) - { - // verifico se sia modalità "rimozione" datamatrix x cui tolgo i datamatrix dall'UDC finale.. - if (chkDtxMode.Checked) - { - // chiamo stored di verifica spostabilità (ovvero: dato Dtx è nell'UDC di dest e UDC TL è ancora in carico ad AL sorgente...) - bool dtxInUdcDest = false; - bool udcSourceOk = false; + break; + case tipoCodiceBarcode.AL: + // se linea libera... + if (currAL == "") + { + // verifico barcode valido + if (checkAL(barcodeIn, "T")) + { + // verifico AL sia con datamatrix... + if (checkDtxAL(barcodeIn)) + { + // controllo: se avevo già letto lo steso AL è conferma presa in carico... + if (sourceAL == barcodeIn) + { + presaCaricoAL(); + } + else + { + // mostro AL sorgente + sourceAL = barcodeIn; + fixCssAL("warning"); + // sistemo grafica + Postazione.messaggiText = traduci("ConfermareAL"); + Postazione.warningText = ""; + Postazione.CssClass = cssOk; + } + } + else + { + sourceAL = ""; + } + } + else + { + sourceAL = ""; + } + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-ALT-002"); + Postazione.CssClass = cssErr; + } + break; + case tipoCodiceBarcode.DataMatrixTrovato: + string OldUDC = ""; + int IdxPosizione = 0; + string NewUDC = ""; + // verifica preliminare: se OK procedo, se è KO NON LO CONSIDERO PROPRIO + bool isOk = false; try { - dtxInUdcDest = DataMatrix.mgr.taDtx2UDC.getByDtx(barcodeIn).Select(string.Format("UDC = '{0}'", NewUDC)).Length > 0; - // ricalcolo vecchio UDC - OldUDC = ((DS_DataMatrix.Dtx2UDCRow)DataMatrix.mgr.taDtx2UDC.getByDtx(barcodeIn).Select(string.Format("CodStato = '{0}'", statoUDC_pre))[0]).UDC.Replace(flussoAnc, flussoTemp); - // verifico SE sia in carico ad AL... - if (OldUDC != "") - { - if (MagClass.magazzino.taAL2UDC.getByAL(sourceAL).Select(string.Format("UDC = '{0}'", OldUDC)).Length > 0) - { - udcSourceOk = true; - } - } + isOk = DataMatrix_mgr.taVerifica.GetData(barcodeIn)[0].StatoDtx == "OK"; } catch { } - if (dtxInUdcDest && udcSourceOk) + if (!isOk) { - // tolgo da AL (se caricato), faccio update e sposto su UDC sorgente... - DataMatrix.mgr.taDtx2UDC.UpdateUDC(OldUDC, barcodeIn, statoUDC, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, false, false); - // fix messaggi - Postazione.messaggiText = traduci("ToltoDtxDaDest"); - Postazione.warningText = ""; - Postazione.CssClass = cssAtt; + // non accetto Dtx e mostro errore + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("ERR-DTX-012"); + Postazione.CssClass = cssErr; } - else + else // PROCEDO!!! { - if (dtxInUdcDest) + // verifico DTX sia in quelli dell'AL sorgente + if (DataMatrix_mgr.taDtx2UDC.getByDtxAl(sourceAL, barcodeIn).Rows.Count > 0) + { + // cerco se ci sia UDC di destinazione + DateTime adesso = DateTime.Now; + try { - // segno che NON posso spostare DTX - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-DTX-010"); - Postazione.CssClass = cssAtt; + OldUDC = DataMatrix_mgr.taDtx2UDC.getByDtxAl(sourceAL, barcodeIn)[0].UDC; + IdxPosizione = MagClass.magazzino.taCartellini.getByUdc(OldUDC)[0].IdxPosizione; + currParticolare = MagClass.magazzino.taCartellini.getByUdc(OldUDC)[0].Particolare; + } + catch + { + currParticolare = ""; + } + if (currParticolare != "") + { + try + { + NewUDC = MagClass.magazzino.taCartellini.getByParticolareAL(currParticolare, destAL)[0].UDC; + } + catch + { + NewUDC = ""; + } + if (NewUDC == "") + { + // CASO 01: DTX in AL sorgente, particolare OK, NON C'E' UDC dest + procDtx_Caso01(ref OldUDC, ref NewUDC, adesso); + } + else + { + // CASO 02: DTX in AL sorgente, particolare OK, C'E' UDC dest + OldUDC = procDtx_Caso02(OldUDC, NewUDC); + } + checkUpdateTablet(NewUDC); } else { - // segno che NON posso spostare DTX - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-DTX-011"); - Postazione.CssClass = cssAtt; + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("UdcNonTrovato"); + Postazione.CssClass = cssErr; } + } + // se non lo trovo in AL sorgente... + else + { + // faccio ulteriore verifica: se il datamatrix sia "libero" o già tra i "Missing In Action".. + if (DataMatrix_mgr.taDtxAvailFree.GetData(barcodeIn).Rows.Count > 0) + { + // CASO 03: DTX NON in sorgente ma libero/missing in action + NewUDC = procDtx_Caso03(NewUDC); + } + else + { + // CASO 04: DTX NON in sorgente e NON libero/missing in action + procDTX_Caso04(ref OldUDC, ref IdxPosizione, ref NewUDC); + } + } } + break; + default: + Postazione.warningText = traduci("ERR-BCD-001"); + Postazione.CssClass = cssErr; + lastBarcodeIn = ""; + break; } - else + } + barcodeIn = ""; + } + doUpdate(); + } + txtBarcode.Focus(); + } + + #region metodi processing DataMatrix letto da BarCode + + /// + /// CASO 01: DTX in AL sorgente, particolare OK, NON C'E' UDC dest + /// + /// + /// + /// + private void procDtx_Caso01(ref string OldUDC, ref string NewUDC, DateTime adesso) + { + // verifico che NON sia modalità "rimozione" datamatrix + if (!chkDtxMode.Checked) + { + // scambio UDC e prendo quello TT + OldUDC = OldUDC.Replace(flussoTemp, flussoAnc); + // calcolo codImballo + + string codImballo = ""; + try + { + codImballo = ddlImballi.SelectedValue; + } + catch + { + codImballo = memLayer.ML.cdv("CodImballoFiniti"); + } + // se NON HA selezionato prendo default... + if (codImballo == "" || codImballo == "-") + { + codImballo = memLayer.ML.cdv("CodImballoFiniti"); + } + // controllo se devo usare chiamata a stored unica (UDC + aggancio AL + cella corretta) o due chiamate + if (memLayer.ML.confReadBool("useStoredLiqSP")) + { + // nuova stored con AL e cella...... + NewUDC = MagClass.magazzino.creaUdcWithAlCella(destAL, sourceAL, barcodeIn, statoUDC, Postazione.currCodCella, flusso, "", currParticolare, "", "", "", "", OldUDC, 0, codImballo, "U", MagClass.magazzino.CodSoggCurrUser, pezziUdc, 0, 0, adesso, 0, statoUDC, memLayer.ML.cdvi("IdxPosizioneFinTemp"), "IdxPosizioneFinTemp", eventoUDC, "", "", adesso.Year, Request.UserHostName); + // registro creazione nuovo UDC + MagClass.magazzino.taSAO.insertQuery(adesso, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, NewUDC, currParticolare, "creaUDC", string.Format("Creato nuovo UDC PostLiquidi DT, qta: {0} {1}", qta, "")); + } + else + { + // oppure lo creo... + NewUDC = MagClass.magazzino.creaUdc(flusso, "", currParticolare, "", "", "", "", OldUDC, 0, codImballo, "U", MagClass.magazzino.CodSoggCurrUser, pezziUdc, 0, 0, adesso, 0, statoUDC, memLayer.ML.cdvi("IdxPosizioneFinTemp"), "IdxPosizioneFinTemp", eventoUDC, "", "", adesso.Year, Request.UserHostName); + // registro creazione nuovo UDC + MagClass.magazzino.taSAO.insertQuery(adesso, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, NewUDC, currParticolare, "creaUDC", string.Format("Creato nuovo UDC PostLiquidi DT, qta: {0} {1}", qta, "")); + // lo associo all'AL! + MagClass.magazzino.taAL2UDC.Insert(destAL, NewUDC, adesso, MagClass.magazzino.CodSoggCurrUser); + + + DataMatrix_mgr.taDtx2UDC.UpdateUDC(NewUDC, barcodeIn, statoUDC, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, false, false); + // disattivo AL (se non era già disattivo...) x evitare si possa togliere senza chiudere... + MagClass.magazzino.taEA.DisattivaAL(sourceAL); + // fix messaggi + Postazione.messaggiText = traduci("ConfermatoDtx"); + Postazione.warningText = ""; + Postazione.CssClass = cssAtt; + } + } + else + { + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("UdcNonTrovato"); + Postazione.CssClass = cssErr; + } + } + /// + /// CASO 02: DTX in AL sorgente, particolare OK, C'E' UDC dest + /// + /// + /// + /// + private string procDtx_Caso02(string OldUDC, string NewUDC) + { + // verifico se sia modalità "rimozione" datamatrix x cui tolgo i datamatrix dall'UDC finale.. + if (chkDtxMode.Checked) + { + // chiamo stored di verifica spostabilità (ovvero: dato Dtx è nell'UDC di dest e UDC TL è ancora in carico ad AL sorgente...) + bool dtxInUdcDest = false; + bool udcSourceOk = false; + try + { + dtxInUdcDest = DataMatrix_mgr.taDtx2UDC.getByDtx(barcodeIn).Select(string.Format("UDC = '{0}'", NewUDC)).Length > 0; + // ricalcolo vecchio UDC + OldUDC = ((DS_DataMatrix.Dtx2UDCRow)DataMatrix_mgr.taDtx2UDC.getByDtx(barcodeIn).Select(string.Format("CodStato = '{0}'", statoUDC_pre))[0]).UDC.Replace(flussoAnc, flussoTemp); + // verifico SE sia in carico ad AL... + if (OldUDC != "") + { + if (MagClass.magazzino.taAL2UDC.getByAL(sourceAL).Select(string.Format("UDC = '{0}'", OldUDC)).Length > 0) { - // se lo trovo chiamo procedura di spostamento Dtx tra UDC sorgente --> dest (con eventuale creazione dest) - DataMatrix.mgr.taDtx2UDC.UpdateUDC(NewUDC, barcodeIn, statoUDC, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, false, false); + udcSourceOk = true; + } + } + } + catch + { } + if (dtxInUdcDest && udcSourceOk) + { + // tolgo da AL (se caricato), faccio update e sposto su UDC sorgente... + DataMatrix_mgr.taDtx2UDC.UpdateUDC(OldUDC, barcodeIn, statoUDC, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, false, false); + // fix messaggi + Postazione.messaggiText = traduci("ToltoDtxDaDest"); + Postazione.warningText = ""; + Postazione.CssClass = cssAtt; + } + else + { + if (dtxInUdcDest) + { + // segno che NON posso spostare DTX + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-DTX-010"); + Postazione.CssClass = cssAtt; + } + else + { + // segno che NON posso spostare DTX + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-DTX-011"); + Postazione.CssClass = cssAtt; + } + } + } + else + { + // se lo trovo chiamo procedura di spostamento Dtx tra UDC sorgente --> dest (con eventuale creazione dest) + DataMatrix_mgr.taDtx2UDC.UpdateUDC(NewUDC, barcodeIn, statoUDC, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, false, false); + // fix messaggi + Postazione.messaggiText = traduci("ConfermatoDtx"); + Postazione.warningText = ""; + Postazione.CssClass = cssAtt; + } + // disattivo AL (se non era già disattivo...) x evitare si possa togliere senza chiudere... + MagClass.magazzino.taEA.DisattivaAL(sourceAL); + return OldUDC; + } + /// + /// CASO 03: DTX NON in sorgente ma libero/missing in action + /// + /// + /// + private string procDtx_Caso03(string NewUDC) + { + // verifico se sia modalità "rimozione" --> ERRORE!!! + if (chkDtxMode.Checked) + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-DTX-018"); + Postazione.CssClass = cssErr; + } + else + { + // controllo se sia seconda conferma + if (barcodeIn == lastBarcodeIn) + { + lastBarcodeIn = ""; + // in questo caso aggiungo Dtx con la catena della storia precedente + try + { + // vers 2.9 modifica per multi-datamatrix + currParticolare = partByDtmx(true); + // vers vecchia + //currParticolare = DataMatrix_mgr.taDecode.GetData(barcodeIn, "")[0].Particolare; + } + catch + { + currParticolare = ""; + } + if (currParticolare != "") + { + try + { + NewUDC = MagClass.magazzino.taCartellini.getByParticolareAL(currParticolare, destAL)[0].UDC; + } + catch + { + NewUDC = ""; + } + if (NewUDC != "") + { + + // sono in caso di forzatura Dtx, quindi controllo se l'UDC di destinazione esista e abbia qta DataMatrix associati > 0 + if (DataMatrix_mgr.taDtx2UDC.getByUDC(NewUDC).Rows.Count > 0) + { + // riassocio (se possibile) UDC alla nuova storia (se era un DTX x prove dimensionali post TT non cambio la sua storia ma aggiungo relazioni UDC...) + DataMatrix_mgr.taDtx2UDC.RiassociaDtx(NewUDC, barcodeIn, DateTime.Now, MagClass.magazzino.CodSoggCurrUser); // fix messaggi Postazione.messaggiText = traduci("ConfermatoDtx"); Postazione.warningText = ""; Postazione.CssClass = cssAtt; - } - // disattivo AL (se non era già disattivo...) x evitare si possa togliere senza chiudere... - MagClass.magazzino.taEA.DisattivaAL(sourceAL); - return OldUDC; - } - /// - /// CASO 03: DTX NON in sorgente ma libero/missing in action - /// - /// - /// - private string procDtx_Caso03(string NewUDC) - { - // verifico se sia modalità "rimozione" --> ERRORE!!! - if (chkDtxMode.Checked) - { + checkUpdateTablet(NewUDC); + } + else + { + // errore! UDC dest con qta == 0 Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-DTX-018"); + Postazione.warningText = traduci("ERR-DTX-005"); Postazione.CssClass = cssErr; + } } else { - // controllo se sia seconda conferma - if (barcodeIn == lastBarcodeIn) - { - lastBarcodeIn = ""; - // in questo caso aggiungo Dtx con la catena della storia precedente - try - { - // vers 2.9 modifica per multi-datamatrix - currParticolare = partByDtmx(true); - // vers vecchia - //currParticolare = DataMatrix.mgr.taDecode.GetData(barcodeIn, "")[0].Particolare; - } - catch - { - currParticolare = ""; - } - if (currParticolare != "") - { - try - { - NewUDC = MagClass.magazzino.taCartellini.getByParticolareAL(currParticolare, destAL)[0].UDC; - } - catch - { - NewUDC = ""; - } - if (NewUDC != "") - { - - // sono in caso di forzatura Dtx, quindi controllo se l'UDC di destinazione esista e abbia qta DataMatrix associati > 0 - if (DataMatrix.mgr.taDtx2UDC.getByUDC(NewUDC).Rows.Count > 0) - { - // riassocio (se possibile) UDC alla nuova storia (se era un DTX x prove dimensionali post TT non cambio la sua storia ma aggiungo relazioni UDC...) - DataMatrix.mgr.taDtx2UDC.RiassociaDtx(NewUDC, barcodeIn, DateTime.Now, MagClass.magazzino.CodSoggCurrUser); - // fix messaggi - Postazione.messaggiText = traduci("ConfermatoDtx"); - Postazione.warningText = ""; - Postazione.CssClass = cssAtt; - checkUpdateTablet(NewUDC); - } - else - { - // errore! UDC dest con qta == 0 - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-DTX-005"); - Postazione.CssClass = cssErr; - } - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-DTX-001"); - Postazione.CssClass = cssErr; - } - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-DTX-002"); - Postazione.CssClass = cssErr; - } - } - // salvo prima conferma del dtx x insert - else - { - lastBarcodeIn = barcodeIn; - Postazione.messaggiText = traduci("plsConfDtxLoad"); - Postazione.warningText = traduci("ERR-DTX-003"); - Postazione.CssClass = cssAdd; - } + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-DTX-001"); + Postazione.CssClass = cssErr; } - return NewUDC; + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-DTX-002"); + Postazione.CssClass = cssErr; + } } - /// - /// CASO 04: DTX NON in sorgente e NON libero/missing in action - /// - /// - /// - /// - private void procDTX_Caso04(ref string OldUDC, ref int IdxPosizione, ref string NewUDC) + // salvo prima conferma del dtx x insert + else { - // verifico se sia modalità "rimozione" datamatrix x cui tolgo i datamatrix dall'UDC finale.. - if (chkDtxMode.Checked) - { - // chiamo stored di verifica spostabilità (ovvero: dato Dtx è nell'UDC di dest e UDC TL è ancora in carico ad AL sorgente...) - bool dtxInUdcDest = false; - bool udcSourceOk = false; - try - { - // ricalcolo vecchio UDC - OldUDC = ((DS_DataMatrix.Dtx2UDCRow)DataMatrix.mgr.taDtx2UDC.getByDtx(barcodeIn).Select(string.Format("CodStato = '{0}'", statoUDC_pre))[0]).UDC.Replace(flussoAnc, flussoTemp); - IdxPosizione = MagClass.magazzino.taCartellini.getByUdc(OldUDC)[0].IdxPosizione; - currParticolare = MagClass.magazzino.taCartellini.getByUdc(OldUDC)[0].Particolare; - NewUDC = DataMatrix.mgr.taDtx2UDC.getByDtxAl(destAL, barcodeIn)[0].UDC; - // verifico SE sia in carico ad AL... - if (OldUDC != "") - { - if (MagClass.magazzino.taAL2UDC.getByAL(sourceAL).Select(string.Format("UDC = '{0}'", OldUDC)).Length > 0) - { - udcSourceOk = true; - } - } - dtxInUdcDest = DataMatrix.mgr.taDtx2UDC.getByDtx(barcodeIn).Select(string.Format("UDC = '{0}'", NewUDC)).Length > 0; - } - catch - { } - if (dtxInUdcDest && udcSourceOk) - { - // tolgo da AL (se caricato), faccio update e sposto su UDC sorgente... - DataMatrix.mgr.taDtx2UDC.UpdateUDC(OldUDC, barcodeIn, statoUDC, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, false, false); - // fix messaggi - Postazione.messaggiText = traduci("ToltoDtxDaDest"); - Postazione.warningText = ""; - Postazione.CssClass = cssAtt; - } - else - { - // segno che NON posso spostare DTX - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-DTX-010"); - Postazione.CssClass = cssAtt; - } - } - else - { - // devo distinguere tra il caso dei Dtx già spostati (quindi segnalare che è già in destinazione) - - // verifico DTX sia in quelli dell'AL destinazione - if (DataMatrix.mgr.taDtx2UDC.getByDtxAl(destAL, barcodeIn).Rows.Count > 0) - { - try - { - // vers 2.9 modifica per multi-datamatrix - currParticolare = partByDtmx(true); - // vers vecchia - //currParticolare = DataMatrix.mgr.taDecode.GetData(barcodeIn, "")[0].Particolare; - } - catch - { - currParticolare = ""; - } - NewUDC = MagClass.magazzino.taCartellini.getByParticolareAL(currParticolare, destAL)[0].UDC; - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("ERR-DTX-006"); - Postazione.CssClass = cssWait; - // update tablet! - checkUpdateTablet(NewUDC); - } - // ... dal caso generico di un Dtx NON accettabile - else - { - // volendo qui si potrebbe distinguere tra Dtx già con stato Fin e Dtx di RX/TT non ancora preso in carico ai Liquidi - // errore generico! - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("ERR-DTX-004"); - Postazione.CssClass = cssErr; - } - } - } - - #endregion - - /// - /// prende in carico AL indicato... - /// - private void presaCaricoAL() - { - // salvo presa in carico AL - string AL = MagClass.magazzino.creaAssociaAlTL(sourceAL, tipoAL.AL_LI, MagClass.magazzino.CodSoggCurrUser, Postazione.currCodCella); - if (AL != "NA") - { - // salva ed indica nuovo AL selezionato... - sourceAL = AL; - currAL = sourceAL; - // nascondo elenco UDC dell'AL - fixCssAL("success"); - // sistemo grafica - Postazione.messaggiText = traduci("CaricatoAL"); - Postazione.warningText = ""; - Postazione.CssClass = cssAtt; - } - else - { - // sistemo grafica - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-ALL-001"); - Postazione.CssClass = cssErr; - } - } - /// - /// resetta AL sorgente - /// - public void resetSourceAL() - { - sourceAL = ""; - } - /// - /// aggiorna tabella + focus a barcode - /// - public override void doUpdate() - { - base.doUpdate(); - setDefaultVal(); - grViewSource.DataBind(); - grViewDest.DataBind(); - raiseEvent(ucEvType.ReqUpdateParent); - verificaBtnStampa(); - txtBarcode.Focus(); - } - /// - /// evento selezione grView destinazione: ricarico dati! - /// - /// - /// - protected void grViewDest_SelectedIndexChanged(object sender, EventArgs e) - { - // ricarico dati dell'UDC come particolare e quantità... - currUDC = grViewDest.SelectedDataKey["UDC"].ToString(); - int qtaDtx = 0; - if (MagClass.magazzino.checkUDC(currUDC)) - { - currParticolare = DataProxy.obj.taCartellini.stp_getByUdc(currUDC)[0].Particolare; - qta = Convert.ToInt32(DataProxy.obj.taCartellini.stp_getByUdc(currUDC)[0].Qta); - qtaDtx = Convert.ToInt32(MagClass.magazzino.taA2U2D.getByUDC(currUDC)[0].QtaDtx); - // imposto particolare... - lblPart.Text = currParticolare; - ddlImballi.DataBind(); - } - Postazione.messaggiText = traduci("partSelected"); - Postazione.warningText = ""; - Postazione.CssClass = cssOk; - //setVisibility(); - doUpdate(); - // fisso focus su note! - txtNote.Focus(); - checkUpdateTablet(currUDC); - } - /// - /// effettua check e update tablet - /// - /// - private void checkUpdateTablet(string UDC) - { - if (memLayer.ML.confReadBool("updateTablet")) - { - try - { - string particolare = ""; - int qtaDtx = 0; - int qtaTot = 0; - if (MagClass.magazzino.checkUDC(UDC)) - { - DS_Applicazione.ElencoCartelliniRow riga = DataProxy.obj.taCartellini.stp_getByUdc(UDC)[0]; - particolare = string.Format("{0} - {1}", riga.Particolare, riga.DescParticolare); - qtaTot = Convert.ToInt32(DataProxy.obj.taCartellini.stp_getByUdc(UDC)[0].Qta); - qtaDtx = Convert.ToInt32(MagClass.magazzino.taA2U2D.getByUDC(UDC)[0].QtaDtx); - } - // update tablet - string css = ""; - string mess = ""; - if (qtaDtx > qtaTot) - { - css = cssErr; - mess = traduci("ERR-QTY-001"); - } - else if (qtaDtx == qtaTot) - { - css = cssOk; - mess = traduci("Ready4Print"); - } - else - { - css = cssWait; - mess = "-"; - } - sendUpdateTablet(UDC, particolare, mess, qtaDtx.ToString(), qtaTot.ToString(), string.Format("({0})", qtaDtx - qtaTot), cssOk, cssAtt, css); - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Errore in fase di check dati x tablet: {0}{1}", Environment.NewLine, exc)); - } - } - } - /// - /// prende in carico AL selezionato - /// - /// - /// - protected void lbtPrendeCaricoAL_Click(object sender, EventArgs e) - { - presaCaricoAL(); - doUpdate(); - } - /// - /// chiude l'AL in carico - /// - /// - /// - protected void lbtChiudiAL_Click(object sender, EventArgs e) - { - // controllo se UDC rimasti sono tutti a zero e NON ci sono altri datamatrix - if (assiemeIsEmpty(sourceAL) || forceDelete) - { - // chiamo stored x sistemazione AL: - MagClass.magazzino.eliminaEmptyAL(sourceAL, MagClass.magazzino.CodSoggCurrUser); - Postazione.warningText = ""; - Postazione.messaggiText = ""; - Postazione.CssClass = cssAtt; - // ricarico forzato! - Response.Redirect("PostLiquidi_DT"); - } - else - { - // altrimenti chiedo conferma per fase spostamenti forzati... - forceDelete = true; - Postazione.warningText = traduci("ConfChiusConAnomDtx"); - Postazione.messaggiText = traduci("RichConfChiusAlDtx"); - Postazione.CssClass = cssErr; - } - doUpdate(); - } - /// - /// variabile force delete salvata... - /// - protected bool forceDelete - { - get - { - return memLayer.ML.BoolSessionObj(string.Format("ForceDelAL_{0}", uid)); - } - set - { - memLayer.ML.setSessionVal(string.Format("ForceDelAL_{0}", uid), value); - } - } - /// - /// Verifica se Assieme sia vuoto (no DTX negli UDC) - /// - /// Codice AL - /// - protected bool assiemeIsEmpty(string AL) - { - bool answ = false; - try - { - answ = DataMatrix.mgr.taDtx2UDC.getByAL(AL).Rows.Count == 0; - } - catch { } - return answ; - } - /// - /// reset della selezione - /// - /// - /// - public override void btnReset_Click(object sender, EventArgs e) - { - grViewDest.SelectedIndex = -1; - base.btnReset_Click(sender, e); - } - /// - /// update Qty x UDC selezionato... - /// - /// - /// - public override void lbtUpdQty_Click(object sender, EventArgs e) - { - base.lbtUpdQty_Click(sender, e); - // fix tablet - checkUpdateTablet(currUDC); - grViewDest.SelectedIndex = -1; - doUpdate(); - } - /// - /// verifica visibilità btn stampa UDC - /// - private void verificaBtnStampa() - { - bool showBtnStampa = false; - // se ho selezionato udc... - if (currUDC != "") - { - DS_magazzino.v_A2U2DRow riga; - int qtaUDC = 0; - int qtaDtx = 0; - try - { - riga = MagClass.magazzino.taA2U2D.getByUDC(currUDC)[0]; - qtaUDC = Convert.ToInt32(riga.Qta); - qtaDtx = riga.QtaDtx; - } - catch - { } - if (qtaUDC > 0) - { - // se le qta voluta e dtx sono uguali... - if (qtaUDC == qtaDtx) - { - showBtnStampa = true; - } - } - } - divNote.Visible = showBtnStampa; - } - /// - /// fornisce in output la corretta classe css x icona - /// - /// - /// - /// - public string cssGlyphByQty(object _qta, object _qtaDtx) - { - string answ = "glyphicon glyphicon-pencil btn-lg"; - int qtaUDC = 0; - int qtaDtx = -1; - try - { - qtaUDC = Convert.ToInt32(_qta); - } - catch { } - try - { - qtaDtx = Convert.ToInt32(_qtaDtx); - } - catch { } - if (qtaUDC == qtaDtx) - { - answ = "glyphicon glyphicon-print btn-lg"; - } - return answ; - } - /// - /// effettua processo di sistemazione UDC e stampa - /// - /// - /// - protected void lbtStampaUDC_Click(object sender, EventArgs e) - { - // verifico postazione sia valida... - if (Postazione.name != "" && Postazione.IP != "" && Postazione.currCodCella != "") - { - // in base ad AL sorgente e destinazione, fa le operazioni di update x UDC e poi lo stampa - bool fatto = false; - string noteTrim = txtNote.Text.Trim(); - try - { - // update UDC! - fatto = MagClass.magazzino.liquidiFullUpdate(sourceAL, flussoAnc, currUDC, ddlImballi.SelectedValue, noteTrim, MagClass.magazzino.CodSoggCurrUser); - } - catch - { } - if (fatto) - { - // lancio stampa - MagClass.magazzino.stampaUdc(currUDC, Postazione.printer, tipoCartellino.cartFinitiSP, Request.UserHostName); - // registro creazione AL - MagClass.magazzino.taSAO.insertQuery(DateTime.Now, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, currUDC, currParticolare, "stampaUDC", string.Format("Stampato UDC Dtx {0} su linea {1}, note: {2} ", currUDC, Postazione.currCodLinea, noteTrim)); - Postazione.CssClass = cssAtt; - Postazione.warningText = ""; - Postazione.messaggiText = traduci("cartAlStampato"); - // calcolo particolare completo di descrizione - DS_Applicazione.ElencoCartelliniRow riga = DataProxy.obj.taCartellini.stp_getByUdc(currUDC)[0]; - string particolare = string.Format("{0} - {1}", riga.Particolare, riga.DescParticolare); - // indico su tablet come fatto - sendUpdateTablet(currUDC, particolare, traduci("cartAlStampato"), qta.ToString(), qta.ToString(), "", cssOk, cssOk, cssOk); - // resetto... - grViewDest.SelectedIndex = -1; - qta = 0; - currUDC = ""; - } - doUpdate(); - } - else - { - // ricarico che mi manca postazione! - Postazione.CssClass = cssAtt; - Postazione.warningText = traduci("ERR-POS-001"); - Postazione.messaggiText = ""; - Response.Redirect(user_std.pagCorrente); - } - } - /// - /// Effettua update della pagina tablet RT collegata alla postazione liquidi - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - protected void sendUpdateTablet(string UDC, string particolare, string mess, string qtaIn, string qtaTot, string qtaRim, string css1, string css2, string css3) - { - if (memLayer.ML.confReadBool("updateTablet")) - { - try - { - string answ = SteamWare.urlUtils.callUrl(string.Format(@"{0}/MBC.aspx?txt01={1}&txt02={2}&txt03={3}&txt04={4}&txt05={5}&txt06={6}&css1={7}&css2={8}&css3={9}", memLayer.ML.confReadString("urlRT"), UDC, particolare, mess, qtaIn, qtaTot, qtaRim, css1, css2, css3), false); - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Errore in chiamata a pagina Tablet: {0}{1}", Environment.NewLine, exc)); - barcodeIn = ""; - } - } - } - /// - /// Imposta e legge imballo selezionato - /// - public override string imballoSel - { - get - { - return ddlImballi.SelectedValue; - } - set - { - ddlImballi.SelectedValue = value; - } + lastBarcodeIn = barcodeIn; + Postazione.messaggiText = traduci("plsConfDtxLoad"); + Postazione.warningText = traduci("ERR-DTX-003"); + Postazione.CssClass = cssAdd; } + } + return NewUDC; } + /// + /// CASO 04: DTX NON in sorgente e NON libero/missing in action + /// + /// + /// + /// + private void procDTX_Caso04(ref string OldUDC, ref int IdxPosizione, ref string NewUDC) + { + // verifico se sia modalità "rimozione" datamatrix x cui tolgo i datamatrix dall'UDC finale.. + if (chkDtxMode.Checked) + { + // chiamo stored di verifica spostabilità (ovvero: dato Dtx è nell'UDC di dest e UDC TL è ancora in carico ad AL sorgente...) + bool dtxInUdcDest = false; + bool udcSourceOk = false; + try + { + // ricalcolo vecchio UDC + OldUDC = ((DS_DataMatrix.Dtx2UDCRow)DataMatrix_mgr.taDtx2UDC.getByDtx(barcodeIn).Select(string.Format("CodStato = '{0}'", statoUDC_pre))[0]).UDC.Replace(flussoAnc, flussoTemp); + IdxPosizione = MagClass.magazzino.taCartellini.getByUdc(OldUDC)[0].IdxPosizione; + currParticolare = MagClass.magazzino.taCartellini.getByUdc(OldUDC)[0].Particolare; + NewUDC = DataMatrix_mgr.taDtx2UDC.getByDtxAl(destAL, barcodeIn)[0].UDC; + // verifico SE sia in carico ad AL... + if (OldUDC != "") + { + if (MagClass.magazzino.taAL2UDC.getByAL(sourceAL).Select(string.Format("UDC = '{0}'", OldUDC)).Length > 0) + { + udcSourceOk = true; + } + } + dtxInUdcDest = DataMatrix_mgr.taDtx2UDC.getByDtx(barcodeIn).Select(string.Format("UDC = '{0}'", NewUDC)).Length > 0; + } + catch + { } + if (dtxInUdcDest && udcSourceOk) + { + // tolgo da AL (se caricato), faccio update e sposto su UDC sorgente... + DataMatrix_mgr.taDtx2UDC.UpdateUDC(OldUDC, barcodeIn, statoUDC, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, false, false); + // fix messaggi + Postazione.messaggiText = traduci("ToltoDtxDaDest"); + Postazione.warningText = ""; + Postazione.CssClass = cssAtt; + } + else + { + // segno che NON posso spostare DTX + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-DTX-010"); + Postazione.CssClass = cssAtt; + } + } + else + { + // devo distinguere tra il caso dei Dtx già spostati (quindi segnalare che è già in destinazione) + + // verifico DTX sia in quelli dell'AL destinazione + if (DataMatrix_mgr.taDtx2UDC.getByDtxAl(destAL, barcodeIn).Rows.Count > 0) + { + try + { + // vers 2.9 modifica per multi-datamatrix + currParticolare = partByDtmx(true); + // vers vecchia + //currParticolare = DataMatrix_mgr.taDecode.GetData(barcodeIn, "")[0].Particolare; + } + catch + { + currParticolare = ""; + } + NewUDC = MagClass.magazzino.taCartellini.getByParticolareAL(currParticolare, destAL)[0].UDC; + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("ERR-DTX-006"); + Postazione.CssClass = cssWait; + // update tablet! + checkUpdateTablet(NewUDC); + } + // ... dal caso generico di un Dtx NON accettabile + else + { + // volendo qui si potrebbe distinguere tra Dtx già con stato Fin e Dtx di RX/TT non ancora preso in carico ai Liquidi + // errore generico! + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("ERR-DTX-004"); + Postazione.CssClass = cssErr; + } + } + } + + #endregion + + /// + /// prende in carico AL indicato... + /// + private void presaCaricoAL() + { + // salvo presa in carico AL + string AL = MagClass.magazzino.creaAssociaAlTL(sourceAL, tipoAL.AL_LI, MagClass.magazzino.CodSoggCurrUser, Postazione.currCodCella); + if (AL != "NA") + { + // salva ed indica nuovo AL selezionato... + sourceAL = AL; + currAL = sourceAL; + // nascondo elenco UDC dell'AL + fixCssAL("success"); + // sistemo grafica + Postazione.messaggiText = traduci("CaricatoAL"); + Postazione.warningText = ""; + Postazione.CssClass = cssAtt; + } + else + { + // sistemo grafica + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-ALL-001"); + Postazione.CssClass = cssErr; + } + } + /// + /// resetta AL sorgente + /// + public void resetSourceAL() + { + sourceAL = ""; + } + /// + /// aggiorna tabella + focus a barcode + /// + public override void doUpdate() + { + base.doUpdate(); + setDefaultVal(); + grViewSource.DataBind(); + grViewDest.DataBind(); + raiseEvent(ucEvType.ReqUpdateParent); + verificaBtnStampa(); + txtBarcode.Focus(); + } + /// + /// evento selezione grView destinazione: ricarico dati! + /// + /// + /// + protected void grViewDest_SelectedIndexChanged(object sender, EventArgs e) + { + // ricarico dati dell'UDC come particolare e quantità... + currUDC = grViewDest.SelectedDataKey["UDC"].ToString(); + int qtaDtx = 0; + if (MagClass.magazzino.checkUDC(currUDC)) + { + currParticolare = DataProxy.obj.taCartellini.stp_getByUdc(currUDC)[0].Particolare; + qta = Convert.ToInt32(DataProxy.obj.taCartellini.stp_getByUdc(currUDC)[0].Qta); + qtaDtx = Convert.ToInt32(MagClass.magazzino.taA2U2D.getByUDC(currUDC)[0].QtaDtx); + // imposto particolare... + lblPart.Text = currParticolare; + ddlImballi.DataBind(); + } + Postazione.messaggiText = traduci("partSelected"); + Postazione.warningText = ""; + Postazione.CssClass = cssOk; + //setVisibility(); + doUpdate(); + // fisso focus su note! + txtNote.Focus(); + checkUpdateTablet(currUDC); + } + /// + /// effettua check e update tablet + /// + /// + private void checkUpdateTablet(string UDC) + { + if (memLayer.ML.confReadBool("updateTablet")) + { + try + { + string particolare = ""; + int qtaDtx = 0; + int qtaTot = 0; + if (MagClass.magazzino.checkUDC(UDC)) + { + DS_Applicazione.ElencoCartelliniRow riga = DataProxy.obj.taCartellini.stp_getByUdc(UDC)[0]; + particolare = string.Format("{0} - {1}", riga.Particolare, riga.DescParticolare); + qtaTot = Convert.ToInt32(DataProxy.obj.taCartellini.stp_getByUdc(UDC)[0].Qta); + qtaDtx = Convert.ToInt32(MagClass.magazzino.taA2U2D.getByUDC(UDC)[0].QtaDtx); + } + // update tablet + string css = ""; + string mess = ""; + if (qtaDtx > qtaTot) + { + css = cssErr; + mess = traduci("ERR-QTY-001"); + } + else if (qtaDtx == qtaTot) + { + css = cssOk; + mess = traduci("Ready4Print"); + } + else + { + css = cssWait; + mess = "-"; + } + sendUpdateTablet(UDC, particolare, mess, qtaDtx.ToString(), qtaTot.ToString(), string.Format("({0})", qtaDtx - qtaTot), cssOk, cssAtt, css); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in fase di check dati x tablet: {0}{1}", Environment.NewLine, exc)); + } + } + } + /// + /// prende in carico AL selezionato + /// + /// + /// + protected void lbtPrendeCaricoAL_Click(object sender, EventArgs e) + { + presaCaricoAL(); + doUpdate(); + } + /// + /// chiude l'AL in carico + /// + /// + /// + protected void lbtChiudiAL_Click(object sender, EventArgs e) + { + // controllo se UDC rimasti sono tutti a zero e NON ci sono altri datamatrix + if (assiemeIsEmpty(sourceAL) || forceDelete) + { + // chiamo stored x sistemazione AL: + MagClass.magazzino.eliminaEmptyAL(sourceAL, MagClass.magazzino.CodSoggCurrUser); + Postazione.warningText = ""; + Postazione.messaggiText = ""; + Postazione.CssClass = cssAtt; + // ricarico forzato! + Response.Redirect("PostLiquidi_DT"); + } + else + { + // altrimenti chiedo conferma per fase spostamenti forzati... + forceDelete = true; + Postazione.warningText = traduci("ConfChiusConAnomDtx"); + Postazione.messaggiText = traduci("RichConfChiusAlDtx"); + Postazione.CssClass = cssErr; + } + doUpdate(); + } + /// + /// variabile force delete salvata... + /// + protected bool forceDelete + { + get + { + return memLayer.ML.BoolSessionObj(string.Format("ForceDelAL_{0}", uid)); + } + set + { + memLayer.ML.setSessionVal(string.Format("ForceDelAL_{0}", uid), value); + } + } + /// + /// Verifica se Assieme sia vuoto (no DTX negli UDC) + /// + /// Codice AL + /// + protected bool assiemeIsEmpty(string AL) + { + bool answ = false; + try + { + answ = DataMatrix_mgr.taDtx2UDC.getByAL(AL).Rows.Count == 0; + } + catch { } + return answ; + } + /// + /// reset della selezione + /// + /// + /// + public override void btnReset_Click(object sender, EventArgs e) + { + grViewDest.SelectedIndex = -1; + base.btnReset_Click(sender, e); + } + /// + /// update Qty x UDC selezionato... + /// + /// + /// + public override void lbtUpdQty_Click(object sender, EventArgs e) + { + base.lbtUpdQty_Click(sender, e); + // fix tablet + checkUpdateTablet(currUDC); + grViewDest.SelectedIndex = -1; + doUpdate(); + } + /// + /// verifica visibilità btn stampa UDC + /// + private void verificaBtnStampa() + { + bool showBtnStampa = false; + // se ho selezionato udc... + if (currUDC != "") + { + DS_magazzino.v_A2U2DRow riga; + int qtaUDC = 0; + int qtaDtx = 0; + try + { + riga = MagClass.magazzino.taA2U2D.getByUDC(currUDC)[0]; + qtaUDC = Convert.ToInt32(riga.Qta); + qtaDtx = riga.QtaDtx; + } + catch + { } + if (qtaUDC > 0) + { + // se le qta voluta e dtx sono uguali... + if (qtaUDC == qtaDtx) + { + showBtnStampa = true; + } + } + } + divNote.Visible = showBtnStampa; + } + /// + /// fornisce in output la corretta classe css x icona + /// + /// + /// + /// + public string cssGlyphByQty(object _qta, object _qtaDtx) + { + string answ = "glyphicon glyphicon-pencil btn-lg"; + int qtaUDC = 0; + int qtaDtx = -1; + try + { + qtaUDC = Convert.ToInt32(_qta); + } + catch { } + try + { + qtaDtx = Convert.ToInt32(_qtaDtx); + } + catch { } + if (qtaUDC == qtaDtx) + { + answ = "glyphicon glyphicon-print btn-lg"; + } + return answ; + } + /// + /// effettua processo di sistemazione UDC e stampa + /// + /// + /// + protected void lbtStampaUDC_Click(object sender, EventArgs e) + { + // verifico postazione sia valida... + if (Postazione.name != "" && Postazione.IP != "" && Postazione.currCodCella != "") + { + // in base ad AL sorgente e destinazione, fa le operazioni di update x UDC e poi lo stampa + bool fatto = false; + string noteTrim = txtNote.Text.Trim(); + try + { + // update UDC! + fatto = MagClass.magazzino.liquidiFullUpdate(sourceAL, flussoAnc, currUDC, ddlImballi.SelectedValue, noteTrim, MagClass.magazzino.CodSoggCurrUser); + } + catch + { } + if (fatto) + { + // lancio stampa + MagClass.magazzino.stampaUdc(currUDC, Postazione.printer, tipoCartellino.cartFinitiSP, Request.UserHostName); + // registro creazione AL + MagClass.magazzino.taSAO.insertQuery(DateTime.Now, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, currUDC, currParticolare, "stampaUDC", string.Format("Stampato UDC Dtx {0} su linea {1}, note: {2} ", currUDC, Postazione.currCodLinea, noteTrim)); + Postazione.CssClass = cssAtt; + Postazione.warningText = ""; + Postazione.messaggiText = traduci("cartAlStampato"); + // calcolo particolare completo di descrizione + DS_Applicazione.ElencoCartelliniRow riga = DataProxy.obj.taCartellini.stp_getByUdc(currUDC)[0]; + string particolare = string.Format("{0} - {1}", riga.Particolare, riga.DescParticolare); + // indico su tablet come fatto + sendUpdateTablet(currUDC, particolare, traduci("cartAlStampato"), qta.ToString(), qta.ToString(), "", cssOk, cssOk, cssOk); + // resetto... + grViewDest.SelectedIndex = -1; + qta = 0; + currUDC = ""; + } + doUpdate(); + } + else + { + // ricarico che mi manca postazione! + Postazione.CssClass = cssAtt; + Postazione.warningText = traduci("ERR-POS-001"); + Postazione.messaggiText = ""; + Response.Redirect(user_std.pagCorrente); + } + } + /// + /// Effettua update della pagina tablet RT collegata alla postazione liquidi + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + protected void sendUpdateTablet(string UDC, string particolare, string mess, string qtaIn, string qtaTot, string qtaRim, string css1, string css2, string css3) + { + if (memLayer.ML.confReadBool("updateTablet")) + { + try + { + string answ = SteamWare.urlUtils.callUrl(string.Format(@"{0}/MBC.aspx?txt01={1}&txt02={2}&txt03={3}&txt04={4}&txt05={5}&txt06={6}&css1={7}&css2={8}&css3={9}", memLayer.ML.confReadString("urlRT"), UDC, particolare, mess, qtaIn, qtaTot, qtaRim, css1, css2, css3), false); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in chiamata a pagina Tablet: {0}{1}", Environment.NewLine, exc)); + barcodeIn = ""; + } + } + } + /// + /// Imposta e legge imballo selezionato + /// + public override string imballoSel + { + get + { + return ddlImballi.SelectedValue; + } + set + { + ddlImballi.SelectedValue = value; + } + } + } } \ No newline at end of file diff --git a/GMW/WebUserControls/mod_PostRX_DT.ascx.cs b/GMW/WebUserControls/mod_PostRX_DT.ascx.cs index 8d6362a3..d9391056 100644 --- a/GMW/WebUserControls/mod_PostRX_DT.ascx.cs +++ b/GMW/WebUserControls/mod_PostRX_DT.ascx.cs @@ -9,6 +9,10 @@ namespace GMW.WebUserControls { public partial class mod_PostRX_DT : System.Web.UI.UserControl { + /// + /// Oggetto locale gestione classe datamatrix... + /// + protected DataMatrix DataMatrix_mgr = new DataMatrix(); /// /// flusso associato (hard coded) a RX /// @@ -23,10 +27,6 @@ namespace GMW.WebUserControls protected string codEventoUdc = "UDC_RX_DT"; public event EventHandler eh_reqUpdate; /// - /// Oggetto locale gestione classe datamatrix... - /// - protected DataMatrix DataMatrix_mgr = new DataMatrix(); - /// /// stringa UID univoca /// public string uid diff --git a/GMW/WebUserControls/mod_PostTT_Pre_DT.ascx.cs b/GMW/WebUserControls/mod_PostTT_Pre_DT.ascx.cs index 38c56be2..4bcd8f59 100644 --- a/GMW/WebUserControls/mod_PostTT_Pre_DT.ascx.cs +++ b/GMW/WebUserControls/mod_PostTT_Pre_DT.ascx.cs @@ -5,356 +5,360 @@ using System.Web.UI; namespace GMW.WebUserControls { - public partial class mod_PostTT_Pre_DT : System.Web.UI.UserControl + public partial class mod_PostTT_Pre_DT : System.Web.UI.UserControl + { + /// + /// Oggetto locale gestione classe datamatrix... + /// + protected DataMatrix DataMatrix_mgr = new DataMatrix(); + /// + /// evento richiesta update + /// + public event EventHandler eh_reqUpdate; + /// + /// flusso associato (hard coded) a RX + /// + protected string flusso = "RX"; + /// + /// stato associato (hard coded) a Controllato RX + /// + protected string statoUDC = "ContrRx"; + /// + /// codice evento dell'UDC che si crea + /// + protected string codEventoUdc = "UDC_RX_TT_DT"; + /// + /// Tipo AL accettabile (RX = R) + /// + protected string codTipoAL = "R"; + /// + /// stringa UID univoca + /// + public string uid { - /// - /// evento richiesta update - /// - public event EventHandler eh_reqUpdate; - /// - /// flusso associato (hard coded) a RX - /// - protected string flusso = "RX"; - /// - /// stato associato (hard coded) a Controllato RX - /// - protected string statoUDC = "ContrRx"; - /// - /// codice evento dell'UDC che si crea - /// - protected string codEventoUdc = "UDC_RX_TT_DT"; - /// - /// Tipo AL accettabile (RX = R) - /// - protected string codTipoAL = "R"; - /// - /// stringa UID univoca - /// - public string uid - { - get - { - return this.UniqueID.Replace("$", "_").Replace("-", "_"); - } - } - /// - /// Codice AL target - /// - protected string destAL - { - get - { - return lblAL.Text.Trim(); - } - set - { - lblAL.Text = value; - } - } - /// - /// Codice UDC sorgente - /// - protected string sourceUDC - { - get - { - return lblUdc.Text.Trim(); - } - set - { - lblUdc.Text = value; - } - } - /// - /// Codice AL sorgente - /// - protected string sourceAL - { - get - { - return lblAlFrom.Text.Trim(); - } - set - { - lblAlFrom.Text = value; - } - } - /// - /// caricamento pagina - /// - /// - /// - protected void Page_Load(object sender, EventArgs e) - { - if (!Page.IsPostBack) - { - sourceAL = ""; - sourceUDC = ""; - destAL = ""; - Postazione.messaggiText = ""; - Postazione.warningText = ""; - } - checkBarcode(); - } - /// - /// resetta AL destinazione ed AL/UDC sorgente - /// - public void resetSourceDestAL() - { - sourceAL = ""; - sourceUDC = ""; - destAL = ""; - } - /// - /// wrapper traduzione - /// - /// - /// - public string traduci(object lemma) - { - return user_std.UtSn.Traduci(lemma.ToString()); - } - /// - /// valore barcode - /// - public string barcodeIn - { - get - { - return txtBarcode.Text.Trim(); - } - set - { - txtBarcode.Text = value; - } - } - /// - /// controlla se ci sia un barcode - /// - private void checkBarcode() - { - if (barcodeIn != "") - { - Postazione.messaggiText = string.Format("{0}: {1}", traduci("BCodeIns"), barcodeIn); - switch (MagClass.tipoBCode_L5(barcodeIn)) - { - case tipoCodiceBarcode.AL: - // verifico codice AL sia coerente: ACCETTO SOLO ALR... - if (checkAL(barcodeIn)) - { - // verifico se è accettabile (DTX) - if (DataMatrix.mgr.taDtx2UDC.getByAL(barcodeIn).Rows.Count > 0) - { - // imposto AL corrente... - destAL = barcodeIn; - Postazione.CssClass = "stileAttesa"; - Postazione.warningText = ""; - } - else - { - Postazione.warningText = traduci("ErrAL_NoDtx"); - Postazione.CssClass = "stileComandoKo"; - } - } - break; - case tipoCodiceBarcode.UDC: - // verifico se è accettabile (DTX) - if (DataMatrix.mgr.taDtx2UDC.getByUDC(barcodeIn).Rows.Count > 0) - { - // imposto UDC corrente... - sourceUDC = barcodeIn; - string newAL = MagClass.magazzino.taAL2UDC.getByUDC(barcodeIn)[0].AL; - // verifico codice AL sia coerente: ACCETTO SOLO ALR... - if (checkAL(newAL)) - { - // imposto AL sorgente - sourceAL = newAL; - //sourceAL = MagClass.magazzino.taAL2UDC.getByUDC(barcodeIn)[0].AL; - Postazione.CssClass = "stileAttesa"; - Postazione.warningText = ""; - } - } - else - { - Postazione.warningText = traduci("ErrUDC_NoDtx"); - Postazione.CssClass = "stileComandoKo"; - } - break; - case tipoCodiceBarcode.Comando: - // se è reset cancello tutto! - if (barcodeIn == memLayer.ML.cdv("cmdReset")) - { - sourceUDC = ""; - destAL = ""; - Postazione.messaggiText = ""; - Postazione.warningText = ""; - doUpdate(); - } - Postazione.CssClass = "stileAttesa"; - break; - default: - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-UNK-001"); - Postazione.CssClass = "stileComandoND"; - break; - } - barcodeIn = ""; - } - else - { - Postazione.messaggiText = traduci("AttesaBCode"); - Postazione.CssClass = "stileAttesa"; - - } - doUpdate(); - } - /// - /// Verifica l'AL se sia ok x procedere: - /// - Tipo "R" - /// - Attivo - /// - /// The al. - /// - protected bool checkAL(string AL) - { - bool answ = false; - // verifico codice AL sia coerente: ACCETTO SOLO ALR... - if (AL.StartsWith("AL" + codTipoAL)) - { - try - { - answ = MagClass.magazzino.taEA.getByAL_TipoAttivo(AL, codTipoAL).Rows.Count > 0; - } - catch - { } - if (!answ) - { - Postazione.warningText = traduci("ErroreAlNonRxAttivo"); - Postazione.CssClass = "stileComandoKo"; - } - else - { - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoOk"; - } - } - else - { - Postazione.warningText = traduci("ErrAL_TipoErrato"); - Postazione.CssClass = "stileComandoKo"; - } - return answ; - } - /// - /// aggiorna componenti + focus a barcode - /// - public void doUpdate() - { - grViewDest.DataBind(); - grViewSource.DataBind(); - updateBtns(); - // raise dell'evento - if (eh_reqUpdate != null) - { - eh_reqUpdate(this, new EventArgs()); - } - txtBarcode.Focus(); - } - /// - /// fix visibilità btnMove - /// - private void updateBtns() - { - bool btnVis = false; - // se ho source e dest mostro travasa... - if (destAL != "" && sourceAL != "") - { - DS_magazzino.V_statoCelleCapienzaAssegnatiRow riga; - int capienza = 6; // hard coded... - try - { - riga = MagClass.magazzino.taStatoCelle.getByIdxCella(Postazione.currIdxCella)[0]; - capienza = riga.Capienza; - } - catch - { - capienza = 6; // hard coded... - } - // se ho somma UDC < (capienza) tra AL sorgente e destinazione - if (MagClass.magazzino.taAnagPart.getDistinctByAlSourceDest(sourceAL, destAL).Rows.Count < capienza) - { - btnVis = true; - } - else - { - Postazione.warningText = traduci("ErrAlPieno"); - } - } - divTravasa.Visible = btnVis; - divStampa.Visible = btnVis; - } - /// - /// sposto la qta richiesta, eventualmente creando nuovo UDC - /// - /// - /// - protected void lbtMove_Click(object sender, EventArgs e) - { - MagClass.magazzino.travasoAL(sourceAL, destAL, Postazione.IP); - Postazione.warningText = ""; - Postazione.messaggiText = string.Format("{0} AL {1} --> AL {2}", traduci("Spostato"), sourceAL, destAL); - doUpdate(); - } - /// - /// richiesta (ri)stampa UDC - /// - /// - /// - public void ristampa() - { - MagClass.magazzino.stampaAL(udcReq, Postazione.printer, Request.UserHostName); - // registro ri-stampa UDC - MagClass.magazzino.taSAO.insertQuery(DateTime.Now, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, udcReq, "", "stampaAL", "Ri-Stampato AL Rx DT in post PRE TT"); - Postazione.CssClass = "stileAttesa"; - } - /// - /// udc da stampare - /// - protected string udcReq - { - get - { - return memLayer.ML.StringSessionObj("udcSelSAO"); - } - } - /// - /// (ri)stampa AL - /// - /// - /// - protected void lbtStampaAL_Click(object sender, EventArgs e) - { - // verifico postazione sia valida... - if (Postazione.name != "" && Postazione.IP != "" && Postazione.currCodCella != "") - { - // lancio stampa - MagClass.magazzino.stampaAL(destAL, Postazione.printer, Request.UserHostName); - Postazione.CssClass = "stileAttesa"; - Postazione.warningText = ""; - Postazione.messaggiText = traduci("cartAlStampato"); - sourceUDC = ""; - sourceAL = ""; - destAL = ""; - doUpdate(); - } - else - { - // ricarico che mi manca postazione! - Postazione.CssClass = "stileAttesa"; - Postazione.warningText = traduci("ERR-POS-001"); - Postazione.messaggiText = ""; - Response.Redirect(user_std.pagCorrente); - } - } + get + { + return this.UniqueID.Replace("$", "_").Replace("-", "_"); + } } + /// + /// Codice AL target + /// + protected string destAL + { + get + { + return lblAL.Text.Trim(); + } + set + { + lblAL.Text = value; + } + } + /// + /// Codice UDC sorgente + /// + protected string sourceUDC + { + get + { + return lblUdc.Text.Trim(); + } + set + { + lblUdc.Text = value; + } + } + /// + /// Codice AL sorgente + /// + protected string sourceAL + { + get + { + return lblAlFrom.Text.Trim(); + } + set + { + lblAlFrom.Text = value; + } + } + /// + /// caricamento pagina + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + sourceAL = ""; + sourceUDC = ""; + destAL = ""; + Postazione.messaggiText = ""; + Postazione.warningText = ""; + } + checkBarcode(); + } + /// + /// resetta AL destinazione ed AL/UDC sorgente + /// + public void resetSourceDestAL() + { + sourceAL = ""; + sourceUDC = ""; + destAL = ""; + } + /// + /// wrapper traduzione + /// + /// + /// + public string traduci(object lemma) + { + return user_std.UtSn.Traduci(lemma.ToString()); + } + /// + /// valore barcode + /// + public string barcodeIn + { + get + { + return txtBarcode.Text.Trim(); + } + set + { + txtBarcode.Text = value; + } + } + /// + /// controlla se ci sia un barcode + /// + private void checkBarcode() + { + if (barcodeIn != "") + { + Postazione.messaggiText = string.Format("{0}: {1}", traduci("BCodeIns"), barcodeIn); + switch (MagClass.tipoBCode_L5(barcodeIn)) + { + case tipoCodiceBarcode.AL: + // verifico codice AL sia coerente: ACCETTO SOLO ALR... + if (checkAL(barcodeIn)) + { + // verifico se è accettabile (DTX) + if (DataMatrix_mgr.taDtx2UDC.getByAL(barcodeIn).Rows.Count > 0) + { + // imposto AL corrente... + destAL = barcodeIn; + Postazione.CssClass = "stileAttesa"; + Postazione.warningText = ""; + } + else + { + Postazione.warningText = traduci("ErrAL_NoDtx"); + Postazione.CssClass = "stileComandoKo"; + } + } + break; + case tipoCodiceBarcode.UDC: + // verifico se è accettabile (DTX) + if (DataMatrix_mgr.taDtx2UDC.getByUDC(barcodeIn).Rows.Count > 0) + { + // imposto UDC corrente... + sourceUDC = barcodeIn; + string newAL = MagClass.magazzino.taAL2UDC.getByUDC(barcodeIn)[0].AL; + // verifico codice AL sia coerente: ACCETTO SOLO ALR... + if (checkAL(newAL)) + { + // imposto AL sorgente + sourceAL = newAL; + //sourceAL = MagClass.magazzino.taAL2UDC.getByUDC(barcodeIn)[0].AL; + Postazione.CssClass = "stileAttesa"; + Postazione.warningText = ""; + } + } + else + { + Postazione.warningText = traduci("ErrUDC_NoDtx"); + Postazione.CssClass = "stileComandoKo"; + } + break; + case tipoCodiceBarcode.Comando: + // se è reset cancello tutto! + if (barcodeIn == memLayer.ML.cdv("cmdReset")) + { + sourceUDC = ""; + destAL = ""; + Postazione.messaggiText = ""; + Postazione.warningText = ""; + doUpdate(); + } + Postazione.CssClass = "stileAttesa"; + break; + default: + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-UNK-001"); + Postazione.CssClass = "stileComandoND"; + break; + } + barcodeIn = ""; + } + else + { + Postazione.messaggiText = traduci("AttesaBCode"); + Postazione.CssClass = "stileAttesa"; + + } + doUpdate(); + } + /// + /// Verifica l'AL se sia ok x procedere: + /// - Tipo "R" + /// - Attivo + /// + /// The al. + /// + protected bool checkAL(string AL) + { + bool answ = false; + // verifico codice AL sia coerente: ACCETTO SOLO ALR... + if (AL.StartsWith("AL" + codTipoAL)) + { + try + { + answ = MagClass.magazzino.taEA.getByAL_TipoAttivo(AL, codTipoAL).Rows.Count > 0; + } + catch + { } + if (!answ) + { + Postazione.warningText = traduci("ErroreAlNonRxAttivo"); + Postazione.CssClass = "stileComandoKo"; + } + else + { + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoOk"; + } + } + else + { + Postazione.warningText = traduci("ErrAL_TipoErrato"); + Postazione.CssClass = "stileComandoKo"; + } + return answ; + } + /// + /// aggiorna componenti + focus a barcode + /// + public void doUpdate() + { + grViewDest.DataBind(); + grViewSource.DataBind(); + updateBtns(); + // raise dell'evento + if (eh_reqUpdate != null) + { + eh_reqUpdate(this, new EventArgs()); + } + txtBarcode.Focus(); + } + /// + /// fix visibilità btnMove + /// + private void updateBtns() + { + bool btnVis = false; + // se ho source e dest mostro travasa... + if (destAL != "" && sourceAL != "") + { + DS_magazzino.V_statoCelleCapienzaAssegnatiRow riga; + int capienza = 6; // hard coded... + try + { + riga = MagClass.magazzino.taStatoCelle.getByIdxCella(Postazione.currIdxCella)[0]; + capienza = riga.Capienza; + } + catch + { + capienza = 6; // hard coded... + } + // se ho somma UDC < (capienza) tra AL sorgente e destinazione + if (MagClass.magazzino.taAnagPart.getDistinctByAlSourceDest(sourceAL, destAL).Rows.Count < capienza) + { + btnVis = true; + } + else + { + Postazione.warningText = traduci("ErrAlPieno"); + } + } + divTravasa.Visible = btnVis; + divStampa.Visible = btnVis; + } + /// + /// sposto la qta richiesta, eventualmente creando nuovo UDC + /// + /// + /// + protected void lbtMove_Click(object sender, EventArgs e) + { + MagClass.magazzino.travasoAL(sourceAL, destAL, Postazione.IP); + Postazione.warningText = ""; + Postazione.messaggiText = string.Format("{0} AL {1} --> AL {2}", traduci("Spostato"), sourceAL, destAL); + doUpdate(); + } + /// + /// richiesta (ri)stampa UDC + /// + /// + /// + public void ristampa() + { + MagClass.magazzino.stampaAL(udcReq, Postazione.printer, Request.UserHostName); + // registro ri-stampa UDC + MagClass.magazzino.taSAO.insertQuery(DateTime.Now, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, udcReq, "", "stampaAL", "Ri-Stampato AL Rx DT in post PRE TT"); + Postazione.CssClass = "stileAttesa"; + } + /// + /// udc da stampare + /// + protected string udcReq + { + get + { + return memLayer.ML.StringSessionObj("udcSelSAO"); + } + } + /// + /// (ri)stampa AL + /// + /// + /// + protected void lbtStampaAL_Click(object sender, EventArgs e) + { + // verifico postazione sia valida... + if (Postazione.name != "" && Postazione.IP != "" && Postazione.currCodCella != "") + { + // lancio stampa + MagClass.magazzino.stampaAL(destAL, Postazione.printer, Request.UserHostName); + Postazione.CssClass = "stileAttesa"; + Postazione.warningText = ""; + Postazione.messaggiText = traduci("cartAlStampato"); + sourceUDC = ""; + sourceAL = ""; + destAL = ""; + doUpdate(); + } + else + { + // ricarico che mi manca postazione! + Postazione.CssClass = "stileAttesa"; + Postazione.warningText = traduci("ERR-POS-001"); + Postazione.messaggiText = ""; + Response.Redirect(user_std.pagCorrente); + } + } + } } \ No newline at end of file diff --git a/GMW/WebUserControls/mod_PostTT_Pre_NT.ascx.cs b/GMW/WebUserControls/mod_PostTT_Pre_NT.ascx.cs index e6590732..c5e16f30 100644 --- a/GMW/WebUserControls/mod_PostTT_Pre_NT.ascx.cs +++ b/GMW/WebUserControls/mod_PostTT_Pre_NT.ascx.cs @@ -5,421 +5,425 @@ using System.Web.UI; namespace GMW.WebUserControls { - public partial class mod_PostTT_Pre_NT : System.Web.UI.UserControl + public partial class mod_PostTT_Pre_NT : System.Web.UI.UserControl + { + /// + /// Oggetto locale gestione classe datamatrix... + /// + protected DataMatrix DataMatrix_mgr = new DataMatrix(); + /// + /// evento richiesta update + /// + public event EventHandler eh_reqUpdate; + /// + /// flusso associato (hard coded) a RX + /// + protected string flusso = "RX"; + /// + /// stato associato (hard coded) a Controllato RX + /// + protected string statoUDC = "ContrRx"; + /// + /// codice evento dell'UDC che si crea + /// + protected string codEventoUdc = "UDC_RX_TT"; + /// + /// Tipo AL accettabile (RX = R) + /// + protected string codTipoAL = "R"; + /// + /// stringa UID univoca + /// + public string uid { - /// - /// evento richiesta update - /// - public event EventHandler eh_reqUpdate; - /// - /// flusso associato (hard coded) a RX - /// - protected string flusso = "RX"; - /// - /// stato associato (hard coded) a Controllato RX - /// - protected string statoUDC = "ContrRx"; - /// - /// codice evento dell'UDC che si crea - /// - protected string codEventoUdc = "UDC_RX_TT"; - /// - /// Tipo AL accettabile (RX = R) - /// - protected string codTipoAL = "R"; - /// - /// stringa UID univoca - /// - public string uid - { - get - { - return this.UniqueID.Replace("$", "_").Replace("-", "_"); - } - } - /// - /// Codice AL target - /// - protected string destAL - { - get - { - return lblAL.Text.Trim(); - } - set - { - lblAL.Text = value; - } - } - /// - /// Codice UDC sorgente - /// - protected string sourceUDC - { - get - { - return lblUdc.Text.Trim(); - } - set - { - lblUdc.Text = value; - } - } - /// - /// indica il codice articolo correntemente selezionato - /// - protected string currParticolare - { - get - { - return memLayer.ML.StringSessionObj(string.Format("currParticolare_{0}", uid)); - } - set - { - memLayer.ML.setSessionVal(string.Format("currParticolare_{0}", uid), value, memLayer.ML.confReadBool("keepParticolareSel")); - } - } - /// - /// qta pezzi x UDC - /// - public int qta - { - get - { - int qta = 0; - try - { - qta = Convert.ToInt32(txtQta.Text.Trim()); - } - catch - { } - return qta; - } - set - { - txtQta.Text = value.ToString(); - } - } - /// - /// caricamento pagina - /// - /// - /// - protected void Page_Load(object sender, EventArgs e) - { - if (!Page.IsPostBack) - { - Postazione.messaggiText = ""; - Postazione.warningText = ""; - currParticolare = ""; - } - checkBarcode(); - } - /// - /// wrapper traduzione - /// - /// - /// - public string traduci(object lemma) - { - return user_std.UtSn.Traduci(lemma.ToString()); - } - /// - /// valore barcode - /// - public string barcodeIn - { - get - { - return txtBarcode.Text.Trim(); - } - set - { - txtBarcode.Text = value; - } - } - /// - /// controlla se ci sia un barcode - /// - private void checkBarcode() - { - if (barcodeIn != "") - { - Postazione.messaggiText = string.Format("{0}: {1}", traduci("BCodeIns"), barcodeIn); - switch (MagClass.tipoBCode_L5(barcodeIn)) - { - case tipoCodiceBarcode.AL: - // verifico codice AL sia coerente: ACCETTO SOLO ALR... - if (checkAL(barcodeIn)) - { - // verifico se è accettabile (non DTX) - if (DataMatrix.mgr.taDtx2UDC.getByAL(barcodeIn).Rows.Count == 0) - { - // imposto AL corrente... - destAL = barcodeIn; - Postazione.CssClass = "stileAttesa"; - Postazione.warningText = ""; - } - else - { - Postazione.warningText = traduci("ErrAL_Dtx"); - Postazione.CssClass = "stileComandoKo"; - } - } - break; - case tipoCodiceBarcode.UDC: - // verifico se è accettabile (non DTX) - if (DataMatrix.mgr.taDtx2UDC.getByUDC(barcodeIn).Rows.Count == 0) - { - // imposto UDC corrente... - sourceUDC = barcodeIn; - currParticolare = MagClass.magazzino.taCartellini.getByUdc(sourceUDC)[0].Particolare; - qta = Convert.ToInt32(DataProxy.obj.taCartellini.stp_getByUdc(barcodeIn)[0].Qta); - Postazione.CssClass = "stileAttesa"; - Postazione.warningText = ""; - } - else - { - Postazione.warningText = traduci("ErrUDC_Dtx"); - Postazione.CssClass = "stileComandoKo"; - } - break; - case tipoCodiceBarcode.Comando: - // se è reset cancello tutto! - if (barcodeIn == memLayer.ML.cdv("cmdReset")) - { - sourceUDC = ""; - destAL = ""; - Postazione.messaggiText = ""; - Postazione.warningText = ""; - doUpdate(); - } - Postazione.CssClass = "stileAttesa"; - break; - default: - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-UNK-001"); - Postazione.CssClass = "stileComandoND"; - break; - } - barcodeIn = ""; - } - else - { - Postazione.messaggiText = traduci("AttesaBCode"); - Postazione.CssClass = "stileAttesa"; - } - doUpdate(); - } - /// - /// Verifica l'AL se sia ok x procedere: - /// - Tipo "R" - /// - Attivo - /// - /// - /// - protected bool checkAL(string AL) - { - bool answ = false; - // verifico codice AL sia coerente: ACCETTO SOLO ALR... - if (AL.StartsWith("AL" + codTipoAL)) - { - try - { - answ = MagClass.magazzino.taEA.getByAL_TipoAttivo(AL, codTipoAL).Rows.Count > 0; - } - catch - { } - if (!answ) - { - Postazione.warningText = traduci("ErroreAlNonRxAttivo"); - Postazione.CssClass = "stileComandoKo"; - } - else - { - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoOk"; - } - } - else - { - Postazione.warningText = traduci("ErrAL_TipoErrato"); - Postazione.CssClass = "stileComandoKo"; - } - return answ; - } - /// - /// aggiorna componenti + focus a barcode - /// - public void doUpdate() - { - grViewDest.DataBind(); - grViewSource.DataBind(); - updateBtns(); - // raise dell'evento - if (eh_reqUpdate != null) - { - eh_reqUpdate(this, new EventArgs()); - } - txtBarcode.Focus(); - } - /// - /// fix visibilità btnMove - /// - private void updateBtns() - { - bool btnVis = false; - // se ho source e dest mostro travasa... - if (destAL != "" && sourceUDC != "") - { - DS_magazzino.V_statoCelleCapienzaAssegnatiRow riga; - int capienza = 6; // hard coded... - try - { - riga = MagClass.magazzino.taStatoCelle.getByIdxCella(Postazione.currIdxCella)[0]; - capienza = riga.Capienza; - } - catch - { - capienza = 6; // hard coded... - } - // se ho particolare già in AL - if (MagClass.magazzino.taCartellini.getByParticolareAL(currParticolare, destAL).Rows.Count > 0) - { - btnVis = true; - } - // oppure ho < (capienza) UDC/part in AL - else if (MagClass.magazzino.taAL2UDC.getByAL(destAL).Rows.Count < capienza) - { - btnVis = true; - } - else - { - Postazione.warningText = traduci("ErrAlPieno"); - } - } - divTravasa.Visible = btnVis; - divStampa.Visible = btnVis; - } - /// - /// sposto la qta richiesta, eventualmente creando nuovo UDC - /// - /// - /// - protected void lbtMove_Click(object sender, EventArgs e) - { - // controlli preliminari - if (qta > 0) - { - string destUDC = checkCreaUDC(); - // sposta la qta richiesta da UDC sorgente ad UDC dest - MagClass.magazzino.travasoQtaUDC(sourceUDC, destUDC, qta, Postazione.IP); - Postazione.warningText = ""; - Postazione.messaggiText = string.Format("{0} {1}", qta, traduci("Spostati")); - } - else - { - Postazione.warningText = traduci("ErroreNoQta"); - Postazione.CssClass = "stileComandoKo"; - } - doUpdate(); - } - /// - /// crea eventualmente UDC per particolare in AL di destinazione e restituisce codice UDC - /// - /// - /// - private string checkCreaUDC() - { - string udcDest = ""; - DateTime adesso = DateTime.Now; - // verifico se ho già quel particolare tra quelli dell'AL... - try - { - udcDest = MagClass.magazzino.taCartellini.getByParticolareAL(currParticolare, destAL)[0].UDC; - } - catch - { - udcDest = ""; - } - if (udcDest == "") - { - try - { - // creo nuovo UDC RX... direttamente in posizione definitiva e con un evento differente... - udcDest = MagClass.magazzino.creaUdc(flusso, "", currParticolare, "", "", "", "", "", 0, memLayer.ML.cdv("CodImballoRX"), "U", MagClass.magazzino.CodSoggCurrUser, 0, 0, 0, adesso, 0, statoUDC, memLayer.ML.cdvi("IdxPosizioneRX"), "IdxPosizioneRx", codEventoUdc, "", "", adesso.Year, Request.UserHostName); - // associo UDC a AL... - MagClass.magazzino.taAL2UDC.Insert(destAL, udcDest, adesso, MagClass.magazzino.CodSoggCurrUser); - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Errore in creazione UDC temp RX x travaso: {0}{1}", Environment.NewLine, exc)); - } - } - if (udcDest != "") - { - Postazione.CssClass = "stileAttesa"; - Postazione.warningText = ""; - Postazione.messaggiText = traduci("partAdded"); - } - else - { - Postazione.CssClass = "stileComandoKo"; - Postazione.warningText = traduci("ErroreUdcDest"); - } - return udcDest; - } - /// - /// richiesta (ri)stampa UDC - /// - /// - /// - public void ristampa() - { - MagClass.magazzino.stampaAL(udcReq, Postazione.printer, Request.UserHostName); - // registro ri-stampa UDC - MagClass.magazzino.taSAO.insertQuery(DateTime.Now, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, udcReq, "", "stampaAL", "Ri-Stampato AL Rx NT in post PRE TT"); - Postazione.CssClass = "stileAttesa"; - } - /// - /// udc da stampare - /// - protected string udcReq - { - get - { - return memLayer.ML.StringSessionObj("udcSelSAO"); - } - } - /// - /// (ri)stampa AL - /// - /// - /// - protected void lbtStampaAL_Click(object sender, EventArgs e) - { - // verifico postazione sia valida... - if (Postazione.name != "" && Postazione.IP != "" && Postazione.currCodCella != "") - { - // lancio stampa - MagClass.magazzino.stampaAL(destAL, Postazione.printer, Request.UserHostName); - Postazione.CssClass = "stileAttesa"; - Postazione.warningText = ""; - Postazione.messaggiText = traduci("cartAlStampato"); - // resetto particolare... - currParticolare = ""; - sourceUDC = ""; - destAL = ""; - doUpdate(); - } - else - { - // ricarico che mi manca postazione! - Postazione.CssClass = "stileAttesa"; - Postazione.warningText = traduci("ERR-POS-001"); - Postazione.messaggiText = ""; - Response.Redirect(user_std.pagCorrente); - } - } + get + { + return this.UniqueID.Replace("$", "_").Replace("-", "_"); + } } + /// + /// Codice AL target + /// + protected string destAL + { + get + { + return lblAL.Text.Trim(); + } + set + { + lblAL.Text = value; + } + } + /// + /// Codice UDC sorgente + /// + protected string sourceUDC + { + get + { + return lblUdc.Text.Trim(); + } + set + { + lblUdc.Text = value; + } + } + /// + /// indica il codice articolo correntemente selezionato + /// + protected string currParticolare + { + get + { + return memLayer.ML.StringSessionObj(string.Format("currParticolare_{0}", uid)); + } + set + { + memLayer.ML.setSessionVal(string.Format("currParticolare_{0}", uid), value, memLayer.ML.confReadBool("keepParticolareSel")); + } + } + /// + /// qta pezzi x UDC + /// + public int qta + { + get + { + int qta = 0; + try + { + qta = Convert.ToInt32(txtQta.Text.Trim()); + } + catch + { } + return qta; + } + set + { + txtQta.Text = value.ToString(); + } + } + /// + /// caricamento pagina + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + Postazione.messaggiText = ""; + Postazione.warningText = ""; + currParticolare = ""; + } + checkBarcode(); + } + /// + /// wrapper traduzione + /// + /// + /// + public string traduci(object lemma) + { + return user_std.UtSn.Traduci(lemma.ToString()); + } + /// + /// valore barcode + /// + public string barcodeIn + { + get + { + return txtBarcode.Text.Trim(); + } + set + { + txtBarcode.Text = value; + } + } + /// + /// controlla se ci sia un barcode + /// + private void checkBarcode() + { + if (barcodeIn != "") + { + Postazione.messaggiText = string.Format("{0}: {1}", traduci("BCodeIns"), barcodeIn); + switch (MagClass.tipoBCode_L5(barcodeIn)) + { + case tipoCodiceBarcode.AL: + // verifico codice AL sia coerente: ACCETTO SOLO ALR... + if (checkAL(barcodeIn)) + { + // verifico se è accettabile (non DTX) + if (DataMatrix_mgr.taDtx2UDC.getByAL(barcodeIn).Rows.Count == 0) + { + // imposto AL corrente... + destAL = barcodeIn; + Postazione.CssClass = "stileAttesa"; + Postazione.warningText = ""; + } + else + { + Postazione.warningText = traduci("ErrAL_Dtx"); + Postazione.CssClass = "stileComandoKo"; + } + } + break; + case tipoCodiceBarcode.UDC: + // verifico se è accettabile (non DTX) + if (DataMatrix_mgr.taDtx2UDC.getByUDC(barcodeIn).Rows.Count == 0) + { + // imposto UDC corrente... + sourceUDC = barcodeIn; + currParticolare = MagClass.magazzino.taCartellini.getByUdc(sourceUDC)[0].Particolare; + qta = Convert.ToInt32(DataProxy.obj.taCartellini.stp_getByUdc(barcodeIn)[0].Qta); + Postazione.CssClass = "stileAttesa"; + Postazione.warningText = ""; + } + else + { + Postazione.warningText = traduci("ErrUDC_Dtx"); + Postazione.CssClass = "stileComandoKo"; + } + break; + case tipoCodiceBarcode.Comando: + // se è reset cancello tutto! + if (barcodeIn == memLayer.ML.cdv("cmdReset")) + { + sourceUDC = ""; + destAL = ""; + Postazione.messaggiText = ""; + Postazione.warningText = ""; + doUpdate(); + } + Postazione.CssClass = "stileAttesa"; + break; + default: + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-UNK-001"); + Postazione.CssClass = "stileComandoND"; + break; + } + barcodeIn = ""; + } + else + { + Postazione.messaggiText = traduci("AttesaBCode"); + Postazione.CssClass = "stileAttesa"; + } + doUpdate(); + } + /// + /// Verifica l'AL se sia ok x procedere: + /// - Tipo "R" + /// - Attivo + /// + /// + /// + protected bool checkAL(string AL) + { + bool answ = false; + // verifico codice AL sia coerente: ACCETTO SOLO ALR... + if (AL.StartsWith("AL" + codTipoAL)) + { + try + { + answ = MagClass.magazzino.taEA.getByAL_TipoAttivo(AL, codTipoAL).Rows.Count > 0; + } + catch + { } + if (!answ) + { + Postazione.warningText = traduci("ErroreAlNonRxAttivo"); + Postazione.CssClass = "stileComandoKo"; + } + else + { + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoOk"; + } + } + else + { + Postazione.warningText = traduci("ErrAL_TipoErrato"); + Postazione.CssClass = "stileComandoKo"; + } + return answ; + } + /// + /// aggiorna componenti + focus a barcode + /// + public void doUpdate() + { + grViewDest.DataBind(); + grViewSource.DataBind(); + updateBtns(); + // raise dell'evento + if (eh_reqUpdate != null) + { + eh_reqUpdate(this, new EventArgs()); + } + txtBarcode.Focus(); + } + /// + /// fix visibilità btnMove + /// + private void updateBtns() + { + bool btnVis = false; + // se ho source e dest mostro travasa... + if (destAL != "" && sourceUDC != "") + { + DS_magazzino.V_statoCelleCapienzaAssegnatiRow riga; + int capienza = 6; // hard coded... + try + { + riga = MagClass.magazzino.taStatoCelle.getByIdxCella(Postazione.currIdxCella)[0]; + capienza = riga.Capienza; + } + catch + { + capienza = 6; // hard coded... + } + // se ho particolare già in AL + if (MagClass.magazzino.taCartellini.getByParticolareAL(currParticolare, destAL).Rows.Count > 0) + { + btnVis = true; + } + // oppure ho < (capienza) UDC/part in AL + else if (MagClass.magazzino.taAL2UDC.getByAL(destAL).Rows.Count < capienza) + { + btnVis = true; + } + else + { + Postazione.warningText = traduci("ErrAlPieno"); + } + } + divTravasa.Visible = btnVis; + divStampa.Visible = btnVis; + } + /// + /// sposto la qta richiesta, eventualmente creando nuovo UDC + /// + /// + /// + protected void lbtMove_Click(object sender, EventArgs e) + { + // controlli preliminari + if (qta > 0) + { + string destUDC = checkCreaUDC(); + // sposta la qta richiesta da UDC sorgente ad UDC dest + MagClass.magazzino.travasoQtaUDC(sourceUDC, destUDC, qta, Postazione.IP); + Postazione.warningText = ""; + Postazione.messaggiText = string.Format("{0} {1}", qta, traduci("Spostati")); + } + else + { + Postazione.warningText = traduci("ErroreNoQta"); + Postazione.CssClass = "stileComandoKo"; + } + doUpdate(); + } + /// + /// crea eventualmente UDC per particolare in AL di destinazione e restituisce codice UDC + /// + /// + /// + private string checkCreaUDC() + { + string udcDest = ""; + DateTime adesso = DateTime.Now; + // verifico se ho già quel particolare tra quelli dell'AL... + try + { + udcDest = MagClass.magazzino.taCartellini.getByParticolareAL(currParticolare, destAL)[0].UDC; + } + catch + { + udcDest = ""; + } + if (udcDest == "") + { + try + { + // creo nuovo UDC RX... direttamente in posizione definitiva e con un evento differente... + udcDest = MagClass.magazzino.creaUdc(flusso, "", currParticolare, "", "", "", "", "", 0, memLayer.ML.cdv("CodImballoRX"), "U", MagClass.magazzino.CodSoggCurrUser, 0, 0, 0, adesso, 0, statoUDC, memLayer.ML.cdvi("IdxPosizioneRX"), "IdxPosizioneRx", codEventoUdc, "", "", adesso.Year, Request.UserHostName); + // associo UDC a AL... + MagClass.magazzino.taAL2UDC.Insert(destAL, udcDest, adesso, MagClass.magazzino.CodSoggCurrUser); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in creazione UDC temp RX x travaso: {0}{1}", Environment.NewLine, exc)); + } + } + if (udcDest != "") + { + Postazione.CssClass = "stileAttesa"; + Postazione.warningText = ""; + Postazione.messaggiText = traduci("partAdded"); + } + else + { + Postazione.CssClass = "stileComandoKo"; + Postazione.warningText = traduci("ErroreUdcDest"); + } + return udcDest; + } + /// + /// richiesta (ri)stampa UDC + /// + /// + /// + public void ristampa() + { + MagClass.magazzino.stampaAL(udcReq, Postazione.printer, Request.UserHostName); + // registro ri-stampa UDC + MagClass.magazzino.taSAO.insertQuery(DateTime.Now, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, udcReq, "", "stampaAL", "Ri-Stampato AL Rx NT in post PRE TT"); + Postazione.CssClass = "stileAttesa"; + } + /// + /// udc da stampare + /// + protected string udcReq + { + get + { + return memLayer.ML.StringSessionObj("udcSelSAO"); + } + } + /// + /// (ri)stampa AL + /// + /// + /// + protected void lbtStampaAL_Click(object sender, EventArgs e) + { + // verifico postazione sia valida... + if (Postazione.name != "" && Postazione.IP != "" && Postazione.currCodCella != "") + { + // lancio stampa + MagClass.magazzino.stampaAL(destAL, Postazione.printer, Request.UserHostName); + Postazione.CssClass = "stileAttesa"; + Postazione.warningText = ""; + Postazione.messaggiText = traduci("cartAlStampato"); + // resetto particolare... + currParticolare = ""; + sourceUDC = ""; + destAL = ""; + doUpdate(); + } + else + { + // ricarico che mi manca postazione! + Postazione.CssClass = "stileAttesa"; + Postazione.warningText = traduci("ERR-POS-001"); + Postazione.messaggiText = ""; + Response.Redirect(user_std.pagCorrente); + } + } + } } \ No newline at end of file diff --git a/GMW/WebUserControls/mod_SearchProvDtx.ascx.cs b/GMW/WebUserControls/mod_SearchProvDtx.ascx.cs index 5e493fdc..1437ae7b 100644 --- a/GMW/WebUserControls/mod_SearchProvDtx.ascx.cs +++ b/GMW/WebUserControls/mod_SearchProvDtx.ascx.cs @@ -4,58 +4,62 @@ using System; namespace GMW.WebUserControls { - public partial class mod_SearchProvDtx : System.Web.UI.UserControl + public partial class mod_SearchProvDtx : System.Web.UI.UserControl + { + /// + /// Oggetto locale gestione classe datamatrix... + /// + protected DataMatrix DataMatrix_mgr = new DataMatrix(); + protected void Page_Load(object sender, EventArgs e) { - protected void Page_Load(object sender, EventArgs e) - { - doSearch(); - } - /// - /// wrapper metodo traduzione - /// - /// - /// - public string traduci(string lemma) - { - return user_std.UtSn.Traduci(lemma); - } - public void doSearch() - { - lblDtx.Text = dtx_sel; - lblPart.Text = part_sel; - mod_listDtx1.doUpdate(); - } - /// - /// codice Dtx cercato - /// - public string dtx_sel - { - get - { - string answ = memLayer.ML.StringSessionObj("FullSearchValue"); - // cerco se esista il datamatrix cercato... se non trovo ritorno "" - if (DataMatrix.mgr.taDtx2UDC.getByDtx(answ).Rows.Count == 0) answ = ""; - return answ; - } - } - /// - /// particolare associato al datamatrix - /// - public string part_sel - { - get - { - string answ = ""; - try - { - // vers 2.9 modifica per multi-datamatrix - answ = DataMatrix.mgr.taDecode.GetData(dtx_sel, "")[0].Particolare; - } - catch - { } - return answ; - } - } - + doSearch(); } + /// + /// wrapper metodo traduzione + /// + /// + /// + public string traduci(string lemma) + { + return user_std.UtSn.Traduci(lemma); + } + public void doSearch() + { + lblDtx.Text = dtx_sel; + lblPart.Text = part_sel; + mod_listDtx1.doUpdate(); + } + /// + /// codice Dtx cercato + /// + public string dtx_sel + { + get + { + string answ = memLayer.ML.StringSessionObj("FullSearchValue"); + // cerco se esista il datamatrix cercato... se non trovo ritorno "" + if (DataMatrix_mgr.taDtx2UDC.getByDtx(answ).Rows.Count == 0) answ = ""; + return answ; + } + } + /// + /// particolare associato al datamatrix + /// + public string part_sel + { + get + { + string answ = ""; + try + { + // vers 2.9 modifica per multi-datamatrix + answ = DataMatrix_mgr.taDecode.GetData(dtx_sel, "")[0].Particolare; + } + catch + { } + return answ; + } + } + + } } \ No newline at end of file diff --git a/GMW/WebUserControls/mod_anagFormatiDtx.ascx.cs b/GMW/WebUserControls/mod_anagFormatiDtx.ascx.cs index 2ca9a869..145377ab 100644 --- a/GMW/WebUserControls/mod_anagFormatiDtx.ascx.cs +++ b/GMW/WebUserControls/mod_anagFormatiDtx.ascx.cs @@ -6,179 +6,181 @@ using System.Web.UI.WebControls; namespace GMW.WebUserControls { - public partial class mod_anagFormatiDtx : ApplicationUserControl + public partial class mod_anagFormatiDtx : ApplicationUserControl + { + /// + /// Oggetto locale gestione classe datamatrix... + /// + protected DataMatrix DataMatrix_mgr = new DataMatrix(); + /// + /// reset della selezione + /// + /// + /// + protected void btnReset_Click(object sender, EventArgs e) { - - - /// - /// reset della selezione - /// - /// - /// - protected void btnReset_Click(object sender, EventArgs e) - { - resetSelezione(); - } - /// - /// resetta la selezione dei valori in caso di modifiche su altri controlli - /// - public void resetSelezione() - { - grView.SelectedIndex = -1; - grView.DataBind(); - raiseEvent(ucEvType.Reset); - } - /// - /// inserisce nuovo valore da footer - /// - /// - /// - protected void lblIns_click(object sender, EventArgs e) - { - // click su inserimento, chiamo il metodo insert dell'ObjectDataSource - ods.Insert(); - } - /// - /// gestione evento richiesta nuovo valore (mostra footer, ...) - /// - /// - /// - protected void btnNew_Click(object sender, EventArgs e) - { - // reset selezione... - resetSelezione(); - // mostro il footer oppure la riga dei dettagli x nuovo... - if (grView.FooterRow != null) - { - grView.FooterRow.Visible = true; - } - } - /// - /// determina se sia eliminabile il record (=non usato) - /// - /// - /// - public bool delEnabled(object idxObj) - { - bool answ = isWritable(); - // solo se ha diritti scrittura controllo - if (answ) - { - string cod = idxObj.ToString(); - // "" == ND NON VA modificato... - if (cod != "") - { - // se non ND cerco se ci sono specifiche --> non eliminabile! - int trovati = 0; - // controllo se ci siano celle associate - trovati = DataMatrix.mgr.taSpecDtmx.getByFormatoDtmx(cod).Rows.Count; - // controllo se ci sono record correlati... - if (trovati > 0) - { - answ = false; - } - } - else - { - answ = false; - } - } - return answ; - } - - /// - /// elenco colonne del datagrid - /// - /// - protected DataColumnCollection colonneObj() - { - DS_DataMatrix.AnagFormatiDtmxDataTable tabella = new DS_DataMatrix.AnagFormatiDtmxDataTable(); - DataColumnCollection colonne = tabella.Columns; - return colonne; - } - /// - /// recupera i dati di un nuovo record contenuti nel footer di un gridView; - /// questi devono essere opportunamente nominati (es: txt{0}, dl{0}, ...) - /// - /// - /// - protected void recuperaFooter(object sender, ObjectDataSourceMethodEventArgs e) - { - //recupero la riga footer... - DataColumnCollection colonne = colonneObj(); - string nomeCol; - string tipoColonna = ""; - foreach (DataColumn colonna in colonne) - { - nomeCol = colonna.ColumnName; - // cerco un textbox o quello che sia... - if (grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol)) != null) - { - tipoColonna = "textBox"; - } - else if (grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol)) != null) - { - tipoColonna = "dropDownList"; - } - else if (grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol)) != null) - { - tipoColonna = "checkBox"; - } - else if (grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol)) != null) - { - tipoColonna = "selAjax"; - } - // in base al tipo salvo negli inputparameters dell'ODS - switch (tipoColonna) - { - case "textBox": - e.InputParameters[nomeCol] = ((TextBox)grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol))).Text; - break; - case "dropDownList": - e.InputParameters[nomeCol] = ((DropDownList)grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol))).SelectedValue; - break; - case "checkBox": - e.InputParameters[nomeCol] = ((CheckBox)grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol))).Checked; - break; - case "selAjax": - e.InputParameters[nomeCol] = ((mod_selettore_ajax)grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol))).valore; - break; - default: - break; - } - tipoColonna = ""; - } - if (e.InputParameters["DataFormat"] == null) e.InputParameters["DataFormat"] = ""; - } - - protected void grView_SelectedIndexChanged(object sender, EventArgs e) - { - raiseEvent(ucEvType.Selected); - } - - public string FormatoDtmxSel - { - get - { - string answ = ""; - try - { - answ = grView.SelectedValue.ToString(); - } - catch - { } - return answ; - } - } - - protected void ods_Updating(object sender, ObjectDataSourceMethodEventArgs e) - { - if (e.InputParameters["DataFormat"] == null) e.InputParameters["DataFormat"] = ""; - } - - protected void grView_PageIndexChanged(object sender, EventArgs e) - { - resetSelezione(); - } + resetSelezione(); } + /// + /// resetta la selezione dei valori in caso di modifiche su altri controlli + /// + public void resetSelezione() + { + grView.SelectedIndex = -1; + grView.DataBind(); + raiseEvent(ucEvType.Reset); + } + /// + /// inserisce nuovo valore da footer + /// + /// + /// + protected void lblIns_click(object sender, EventArgs e) + { + // click su inserimento, chiamo il metodo insert dell'ObjectDataSource + ods.Insert(); + } + /// + /// gestione evento richiesta nuovo valore (mostra footer, ...) + /// + /// + /// + protected void btnNew_Click(object sender, EventArgs e) + { + // reset selezione... + resetSelezione(); + // mostro il footer oppure la riga dei dettagli x nuovo... + if (grView.FooterRow != null) + { + grView.FooterRow.Visible = true; + } + } + /// + /// determina se sia eliminabile il record (=non usato) + /// + /// + /// + public bool delEnabled(object idxObj) + { + bool answ = isWritable(); + // solo se ha diritti scrittura controllo + if (answ) + { + string cod = idxObj.ToString(); + // "" == ND NON VA modificato... + if (cod != "") + { + // se non ND cerco se ci sono specifiche --> non eliminabile! + int trovati = 0; + // controllo se ci siano celle associate + trovati = DataMatrix_mgr.taSpecDtmx.getByFormatoDtmx(cod).Rows.Count; + // controllo se ci sono record correlati... + if (trovati > 0) + { + answ = false; + } + } + else + { + answ = false; + } + } + return answ; + } + + /// + /// elenco colonne del datagrid + /// + /// + protected DataColumnCollection colonneObj() + { + DS_DataMatrix.AnagFormatiDtmxDataTable tabella = new DS_DataMatrix.AnagFormatiDtmxDataTable(); + DataColumnCollection colonne = tabella.Columns; + return colonne; + } + /// + /// recupera i dati di un nuovo record contenuti nel footer di un gridView; + /// questi devono essere opportunamente nominati (es: txt{0}, dl{0}, ...) + /// + /// + /// + protected void recuperaFooter(object sender, ObjectDataSourceMethodEventArgs e) + { + //recupero la riga footer... + DataColumnCollection colonne = colonneObj(); + string nomeCol; + string tipoColonna = ""; + foreach (DataColumn colonna in colonne) + { + nomeCol = colonna.ColumnName; + // cerco un textbox o quello che sia... + if (grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol)) != null) + { + tipoColonna = "textBox"; + } + else if (grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol)) != null) + { + tipoColonna = "dropDownList"; + } + else if (grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol)) != null) + { + tipoColonna = "checkBox"; + } + else if (grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol)) != null) + { + tipoColonna = "selAjax"; + } + // in base al tipo salvo negli inputparameters dell'ODS + switch (tipoColonna) + { + case "textBox": + e.InputParameters[nomeCol] = ((TextBox)grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol))).Text; + break; + case "dropDownList": + e.InputParameters[nomeCol] = ((DropDownList)grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol))).SelectedValue; + break; + case "checkBox": + e.InputParameters[nomeCol] = ((CheckBox)grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol))).Checked; + break; + case "selAjax": + e.InputParameters[nomeCol] = ((mod_selettore_ajax)grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol))).valore; + break; + default: + break; + } + tipoColonna = ""; + } + if (e.InputParameters["DataFormat"] == null) e.InputParameters["DataFormat"] = ""; + } + + protected void grView_SelectedIndexChanged(object sender, EventArgs e) + { + raiseEvent(ucEvType.Selected); + } + + public string FormatoDtmxSel + { + get + { + string answ = ""; + try + { + answ = grView.SelectedValue.ToString(); + } + catch + { } + return answ; + } + } + + protected void ods_Updating(object sender, ObjectDataSourceMethodEventArgs e) + { + if (e.InputParameters["DataFormat"] == null) e.InputParameters["DataFormat"] = ""; + } + + protected void grView_PageIndexChanged(object sender, EventArgs e) + { + resetSelezione(); + } + } } \ No newline at end of file diff --git a/GMW/WebUserControls/mod_elencoListePrelievo.ascx.cs b/GMW/WebUserControls/mod_elencoListePrelievo.ascx.cs index 231a06b3..d5e130bf 100644 --- a/GMW/WebUserControls/mod_elencoListePrelievo.ascx.cs +++ b/GMW/WebUserControls/mod_elencoListePrelievo.ascx.cs @@ -7,1318 +7,1322 @@ using System.Web.UI.WebControls; namespace GMW.WebUserControls { - public partial class mod_elencoListePrelievo : SteamWare.ApplicationUserControl + public partial class mod_elencoListePrelievo : SteamWare.ApplicationUserControl + { + /// + /// Oggetto locale gestione classe datamatrix... + /// + protected DataMatrix DataMatrix_mgr = new DataMatrix(); + #region area da NON modificare + + #region area protected + + protected string _idxGridView; + protected string _idxGridViewExt; + protected string _tabCache; + protected bool _showNewBtn = false; + + /// + /// imposta errore non cancellabilità per record correlati + /// + protected void setNoDeletableErrorMessage() { - #region area da NON modificare - - #region area protected - - protected string _idxGridView; - protected string _idxGridViewExt; - protected string _tabCache; - protected bool _showNewBtn = false; - - /// - /// imposta errore non cancellabilità per record correlati - /// - protected void setNoDeletableErrorMessage() - { - // mostro avviso di non cancellabilità... - lblWarning.Text = traduci("notDeletable_hasChild"); - lblWarning.Visible = true; - grView.DataBind(); - } - /// - /// esegue cancellazioen record - /// - protected void doDelete() - { - // posso cancellare... - lblWarning.Visible = false; - ods.Delete(); - } - /// - /// Valida la cancellazione per i dati mostrati dal gridView - /// richiede sia preventivamentedichiarato _idxGridView - /// - /// - /// - protected virtual void validaDelete(object sender, ObjectDataSourceMethodEventArgs e) - { - int idx = Convert.ToInt32(e.InputParameters[string.Format("Original_{0}", _idxGridView)]); - if (objIsNotRelated(idx)) - { - // annullo cancellazione... - e.Cancel = true; - // seleziono record... metto in session valore idx e poi ridisegno... - SteamWare.memLayer.ML.setSessionVal(_idxGridView, idx); - setNoDeletableErrorMessage(); - } - else - { - doDelete(); - } - } - - /// - /// recupera i dati di un nuovo record contenuti nel footer di un gridView; - /// questi devono esses opportunamente nominati (es: txt{0}, dl{0}, ...) - /// - /// - /// - protected void recuperaFooter(object sender, ObjectDataSourceMethodEventArgs e) - { - //recupero la riga footer... - DataColumnCollection colonne = colonneObj(); - string nomeCol; - string tipoColonna = ""; - foreach (DataColumn colonna in colonne) - { - nomeCol = colonna.ColumnName; - // cerco un textbox o quello che sia... - if (grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol)) != null) - { - tipoColonna = "textBox"; - } - else if (grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol)) != null) - { - tipoColonna = "dropDownList"; - } - else if (grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol)) != null) - { - tipoColonna = "checkBox"; - } - else if (grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol)) != null) - { - tipoColonna = "selAjax"; - } - // in base al tipo salvo negli inputparameters dell'ODS - switch (tipoColonna) - { - case "textBox": - e.InputParameters[nomeCol] = ((TextBox)grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol))).Text; - break; - case "dropDownList": - e.InputParameters[nomeCol] = ((DropDownList)grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol))).SelectedValue; - break; - case "checkBox": - e.InputParameters[nomeCol] = ((CheckBox)grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol))).Checked; - break; - case "selAjax": - e.InputParameters[nomeCol] = ((mod_selettore_ajax)grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol))).valore; - break; - default: - break; - } - tipoColonna = ""; - } - } - /// - /// inserisce nuovo valore da footer - /// - /// - /// - protected void lblIns_click(object sender, EventArgs e) - { - // click su inserimento, chiamo il metodo insert dell'ObjectDataSource - ods.Insert(); - SteamWare.memLayer.ML.emptyCacheVal(_tabCache); - } - /// - /// annulla inserimento nuovo valore da footer - /// - /// - /// - protected void lblCanc_click(object sender, EventArgs e) - { - // annullo inserimento: nascondo footer, bind controlli... - grView.FooterRow.Visible = false; - } - - /// - /// traduce gli header delle colonne - /// - /// - /// - protected void grView_DataBound(object sender, EventArgs e) - { - if (grView.Rows.Count > 0) - { - LinkButton lb; - // aggiorno gli headers - foreach (TableCell cella in grView.HeaderRow.Cells) - { - try - { - lb = (LinkButton)cella.Controls[0]; - lb.Text = traduci(lb.Text); - } - catch - { } - } - int totRecord = grView.Rows.Count + grView.PageSize * (grView.PageCount - 1); - lblNumRec.Text = string.Format("{0} records of ~ {1}", grView.Rows.Count, totRecord); - } - else - { - lblNumRec.Text = ""; - } - } - /// - /// gestione evento richiesta nuovo valore (mostra footer, ...) - /// - /// - /// - protected void btnNew_Click(object sender, EventArgs e) - { - // reset selezione... - resetSelezione(); - // mostro il footer oppure la riga dei dettagli x nuovo... - if (grView.FooterRow != null) - { - grView.FooterRow.Visible = true; - } - // sollevo evento nuovo valore... - if (eh_nuovoValore != null) - { - eh_nuovoValore(this, new EventArgs()); - } - } - /// - /// reset della selezione - /// - /// - /// - protected void btnReset_Click(object sender, EventArgs e) - { - resetSelezione(); - } - - /// - /// collega i controlli - /// - protected override void bindControlli() - { - base.bindControlli(); - caricaTabelle(); - } - - #endregion - - #region gestione eventi - - //public event EventHandler eh_resetSelezione; - public event EventHandler eh_nuovoValore; - //public event EventHandler eh_selValore; - - #endregion - - #region public - - /// - /// definisce visibilità btnNew - /// - public bool showNewBtn - { - get - { - return _showNewBtn; - } - set - { - _showNewBtn = value; - } - } - /// - /// effettua update del modulo - /// - public void doUpdate() - { - resetSelezione(); - } - - - #endregion - - #endregion - - #region area codice variabile - - /// - /// numero righe gridview da mostrare legato a controllo textbox - /// - public int numRigheGrView - { - get - { - int answ = _righeDataGridMed; - try - { - answ = Convert.ToInt32(txtNumRighe.Text.Trim()); - if (answ == 0) - { - answ = _righeDataGridMed; - txtNumRighe.Text = _righeDataGridMed.ToString(); - } - } - catch - { } - return answ; - } - set - { - txtNumRighe.Text = value.ToString(); - } - } - /// - /// aggiorna controlli datagrid e numero righe in pagina - /// - protected override void aggiornaControlliDataGL() - { - base.aggiornaControlliDataGL(); - // indico num righe da controllo - grView.PageSize = numRigheGrView; - } - /// - /// carico le tabelle - /// - private void caricaTabelle() - { - } - /// - /// verifica complessiva non esistenza record child - /// - /// - /// - protected bool objIsNotRelated(object idxObj) - { - bool answ = true; - return answ; - } - /// - /// elenco colonne del datagrid - /// - /// - protected DataColumnCollection colonneObj() - { - DS_magazzino.ElencoListePrelievoDataTable tabella = new DS_magazzino.ElencoListePrelievoDataTable(); - DataColumnCollection colonne = tabella.Columns; - return colonne; - } - /// - /// inizializzazione valori di default - /// - /// - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - _idxGridView = "CodLista"; - if (!Page.IsPostBack) - { - // imposto page num... - numRigheGrView = _righeDataGridMed; - // continuo setup - btnForceReload.Text = traduci("ReloadDataMatrix"); - btnForceReload.Visible = memLayer.ML.confReadBool("showReloadDataMatrix"); - setBtnState(); - mod_viewRigheListaPrelievo1.Visible = false; - mod_selPeriodo1.setPeriodoFree(); - mod_filtroStato.ods = odsFiltroStati; - mod_filtroTipo.ods = odsTipoLista; - mod_filtroTipoPart.ods = odsTipoPart; - // controllo se ci sia richiesta x creare nuova lista, nel caso precompilo valori... - if (memLayer.ML.BoolSessionObj("PrecompilaListaPrelievo")) - { - mod_nuovaListaPrelievo1.Visible = true; - mod_nuovaListaPrelievo1.ParticolareRichiesto = memLayer.ML.StringSessionObj("Particolare_sel"); - memLayer.ML.emptySessionVal("PrecompilaListaPrelievo"); - } - else - { - mod_nuovaListaPrelievo1.Visible = false; - } - pnlSetDestTipo.Visible = false; - } - // registro evento update - mod_viewRigheListaPrelievo1.eh_nuovoValore += new EventHandler(mod_viewRigheListaPrelievo1_eh_nuovoValore); - mod_selPeriodo1.eh_doUpdate += new EventHandler(mod_periodoAnalisi1_eh_doUpdate); - mod_nuovaListaPrelievo1.eh_nuovoValore += new EventHandler(mod_nuovaListaPrelievo1_eh_nuovoValore); - } - /// - /// seleziona/deseleziona le righe indicate... - /// - /// - /// - protected void btnSelAll_Click(object sender, EventArgs e) - { - // seleziono tutti i valori visibili nel datagrid - CheckBox chkbox = ((CheckBox)sender); - bool isChecked = chkbox.Checked; - if (!isChecked) - { - chkbox.ToolTip = traduci("btnSelAll"); - } - else - { - chkbox.ToolTip = traduci("btnDeselAll"); - } - foreach (GridViewRow riga in grView.Rows) - { - ((CheckBox)riga.FindControl("chkSelect")).Checked = isChecked; - } - } - /// - /// mostra oggetti x creare una nuova lista di prelievo - /// - /// - /// - void mod_nuovaListaPrelievo1_eh_nuovoValore(object sender, EventArgs e) - { - if (modo == ctrlMode.standard) - { - modo = ctrlMode.nuovaLDP; - } - else - { - modo = ctrlMode.standard; - } - setBtnState(); - checkFixOds(); - } - /// - /// aggiorno x update selettore date - /// - /// - /// - void mod_periodoAnalisi1_eh_doUpdate(object sender, EventArgs e) - { - setBtnState(); - checkFixOds(); - } - /// - /// aggiorno x update valori righe prelievo - /// - /// - /// - void mod_viewRigheListaPrelievo1_eh_nuovoValore(object sender, EventArgs e) - { - setBtnState(); - checkFixOds(); - } - /// - /// svuoto da cache post update - /// - /// - /// - protected void ods_Updated(object sender, ObjectDataSourceStatusEventArgs e) - { - resetSelezione(); - } - /// - /// aggiorno visualizzazione - /// - private void updateOds() - { - grView.DataBind(); - } - - /// - /// determina se sia eliminabile il record (=non usato oppure smart) - /// - /// stato lista - /// - public bool delEnabled(object CodStato) - { - bool answ = isWritable(); - try - { - answ = ((int)CodStato < (int)statoLista.iniziata); - } - catch - { } - return answ; - } - /// - /// determina se sia abilitato il pulsante x attivare una lista di prelievo - /// - /// - /// - public bool attivaEnabled(object CodStato) - { - bool answ = false; - try - { - answ = ((int)CodStato == (int)statoLista.bozza); - } - catch - { } - return answ; - } - /// - /// determina se sia abilitato il pulsante x iniziare una lista di prelievo - /// - /// - /// - public bool iniziaEnabled(object CodStato) - { - bool answ = false; - try - { - answ = ((int)CodStato == (int)statoLista.generata); - } - catch - { } - return answ; - } - /// - /// determina se sia abilitato il pulsante x completare una lista di prelievo - /// - /// - /// - public bool completaEnabled(object CodStato) - { - bool answ = false; - try - { - answ = ((int)CodStato == (int)statoLista.iniziata); - } - catch - { } - return answ; - } - /// - /// determina se sia abilitato il pulsante x approvare e scaricare una lista di prelievo - /// - /// stato lista - /// tipo lista di prelievo - /// - public bool ScaricaEnabled(object CodStato, object codTipo) - { - bool answ = false; - // se la lista è di tipo smart NON si può comunque scaricare, cerco smart nel codice e NON lo deve contenere - if (!codTipo.ToString().Contains("Smart")) - { - try - { - answ = ((int)CodStato == (int)statoLista.completata); - } - catch - { } - } - return answ; - } - /// - /// determina se sia abilitato export su AS400 da codLista - /// - /// - /// - protected bool as400Export(string codLista) - { - // 2014.07.09 inserisco controllo da TIPO LISTA --> se si debba scaricare su AS400... - bool answ = false; - DS_magazzino.ElencoListePrelievoDataTable tabElencoListe = new DS_magazzino.ElencoListePrelievoDataTable(); - try - { - tabElencoListe = MagClass.magazzino.taElencoListePrelievo.getByCodLista(codLista); - answ = MagClass.magazzino.taTipoListaPrelievo.getByCodTipoLista(tabElencoListe[0].CodTipoLista)[0].toAs400; - } - catch - { - answ = false; - } - return answ; - } - - /// - /// determina se sia abilitato il pulsante x resettare una lista di prelievo a bozza - /// - /// codice univoco lista prelievo - /// stato lista - /// - public bool ResetVisible(object codLista, object CodStato) - { - bool answ = false; - // condizione: NON CI SIANO ODETTE - bool condOdette = false; - // 2014.06.12 modifica x NUOVA gestione packing list, NON permetto reset se scaricata... - // condizione: SOLO COMPLETATA può essere resettata SE c'è export 2 as400, altrimenti ANCHE scaricata - bool condStato = false; - try - { - // controllo SE c'è export su AS400 accetto SOLO in stato completata - if (as400Export(codLista.ToString())) - { - // se == completata resetto - condStato = ((int)CodStato == (int)statoLista.completata); - } - else // NON ESPORTO in AS400 - { - // se >= completata resetto - condStato = ((int)CodStato >= (int)statoLista.completata); - } - // cerco odette x la LDP, se NON ci sono è ok! - condOdette = !Odette.mgr.listaHasOdette(codLista.ToString()); - } - catch - { } - answ = (condOdette && condStato); // aggiungere controllo scrivibilità? isWritable(); - return answ; - } - /// - /// determina se sia abilitato il pulsante x resettare una lista di prelievo a bozza - /// - /// codice univoco lista prelievo - /// stato lista - /// tipo lista di prelievo - /// - public bool ResetEnabled(object codLista, object CodStato, object codTipo) - { - bool answ = false; - // se la lista è di tipo smart NON si può comunque scaricare, cerco smart nel codice e NON lo deve contenere - if (!codTipo.ToString().Contains("Smart")) - { - // condizione: NON CI SIANO ODETTE - bool condOdette = false; - // condizione: non in carico ad operatore - bool condStato = false; - try - { - // controllo SE c'è export su AS400 accetto SOLO in stato completata - if (as400Export(codLista.ToString())) - { - // se == completata resetto - condStato = ((int)CodStato == (int)statoLista.completata); - } - else // NON ESPORTO in AS400 - { - // se >= completata resetto - condStato = ((int)CodStato >= (int)statoLista.completata); - } - // cerco odette x la LDP, se NON ci sono è ok! - condOdette = !Odette.mgr.listaHasOdette(codLista.ToString()); - } - catch - { } - answ = (condOdette && condStato); - } - return answ; - } - /// - /// sistema il tooltip di reset - /// - /// - /// - public string tooltipReset(object codTipo) - { - string answ = ""; - if (!codTipo.ToString().Contains("Smart")) - { - answ = traduci("ResetListaPrelievo"); - } - else - { - answ = traduci("ResetSmartNotEnabled"); - } - return answ; - } - /// - /// imposta immagine reset - /// - /// - /// - public string imgReset(object codTipo) - { - string answ = ""; - if (!codTipo.ToString().Contains("Smart")) - { - answ = "~/images/resetBozza.png"; - } - else - { - answ = "~/images/resetBozza_disabled.png"; - } - // ULTERIORE CONTROLLO POSSIBILE: CHECK tabTranPosizioneEventi - return answ; - } - /// - /// gestione cambio selezione valore - /// - /// - /// - protected void grView_SelectedIndexChanged(object sender, EventArgs e) - { - setBtnState(); - checkFixOds(); - } - /// - /// aggiorna visualizzazione - /// - private void aggiornaElencoRighe() - { - // salvo in session il valore selezionato... - SteamWare.memLayer.ML.setSessionVal(string.Format("{0}_sel", _idxGridView), grView.SelectedValue, true); - // setto se sia possibile prelevare le righe (SOLO se iniziata) - bool prelievoOk = false; - bool cambioUdcOk = false; - int CodStato = 0; - string codTipoLista = ""; - DS_magazzino.ElencoListePrelievoDataTable tabElencoListe = new DS_magazzino.ElencoListePrelievoDataTable(); - try - { - tabElencoListe = MagClass.magazzino.taElencoListePrelievo.getByCodLista(grView.SelectedValue.ToString()); - CodStato = tabElencoListe[0].CodStatoLista; - codTipoLista = tabElencoListe[0].CodTipoLista; - cambioUdcOk = (CodStato == (int)statoLista.bozza); - prelievoOk = (CodStato == (int)statoLista.iniziata); - } - catch - { } - mod_viewRigheListaPrelievo1.prelievoEnabled = prelievoOk; // abilito il prelievo SOLO se la lista è già iniziata... - mod_viewRigheListaPrelievo1.editRigheEnabled = cambioUdcOk; // abilito il prelievo SOLO se la lista è in BOZZA... - mod_viewRigheListaPrelievo1.intStatoLista = CodStato; // salvo il cod (INT) stato della lista - mod_viewRigheListaPrelievo1.codTipoLista = codTipoLista; // salvo il tipo lista - // mostra con dettagli - mod_viewRigheListaPrelievo1.Visible = true; - mod_viewRigheListaPrelievo1.resetSelezione(); - } - /// - /// resetta la selezione dei valori in caso di modifiche su altri controlli - /// - public void resetSelezione() - { - currCodLista = ""; - lblErroriLDP.Text = ""; - SteamWare.memLayer.ML.emptySessionVal(string.Format("{0}_sel", _idxGridView)); - grView.SelectedIndex = -1; - setBtnState(); - checkFixOds(); - lblWarning.Visible = false; - // nasconde dettagli - mod_viewRigheListaPrelievo1.Visible = false; - } - /// - /// salvo in session il prox comando - /// - /// - /// - protected void img_Click(object sender, ImageClickEventArgs e) - { - SteamWare.memLayer.ML.setSessionVal("nextObjCommand", ((ImageButton)sender).CommandArgument); - } - /// - /// codice lista selezionata - /// - protected string currCodLista - { - get - { - return memLayer.ML.StringSessionObj("CodListaSel"); - } - set - { - memLayer.ML.setSessionVal("CodListaSel", value); - } - } - /// - /// in caso di aggiornamento verifico se sia salvato un comando inizia o completa lista prelievo... - /// - /// - /// - protected void grView_RowUpdating(object sender, GridViewUpdateEventArgs e) - { - // carico l'idx dell'oggetto - string codLista = e.Keys["CodLista"].ToString(); - currCodLista = codLista; - // quale comando? - string _comando = ""; - if (SteamWare.memLayer.ML.isInSessionObject("nextObjCommand")) - { - _comando = SteamWare.memLayer.ML.StringSessionObj("nextObjCommand"); - SteamWare.memLayer.ML.emptySessionVal("nextObjCommand"); - } - string CodSoggetto = MagClass.magazzino.CodSoggCurrUser; - esitoOperazione result = esitoOperazione.ok; - switch (_comando) - { - case "attivaListaPrelievo": - result = MagClass.magazzino.attivaListaPrelievo(memLayer.ML.StringSessionObj("CodCS"), codLista, CodSoggetto); - showErrorLDP(result); - updateOds(); - grView.EditIndex = -1; - grView.DataBind(); - // sollevo evento nuovo valore... - if (eh_nuovoValore != null) - { - eh_nuovoValore(this, new EventArgs()); - } - mod_viewRigheListaPrelievo1.Visible = false; - // blocco update! - e.Cancel = true; - break; - case "iniziaListaPrelievo": - result = MagClass.magazzino.iniziaListaPrelievo(memLayer.ML.StringSessionObj("CodCS"), codLista, CodSoggetto); - showErrorLDP(result); - updateOds(); - grView.EditIndex = -1; - grView.DataBind(); - // sollevo evento nuovo valore... - if (eh_nuovoValore != null) - { - eh_nuovoValore(this, new EventArgs()); - } - mod_viewRigheListaPrelievo1.Visible = false; - // blocco update! - e.Cancel = true; - break; - case "completaListaPrelievo": - result = MagClass.magazzino.completaListaPrelievo(memLayer.ML.StringSessionObj("CodCS"), codLista, CodSoggetto, Request.UserHostName); - showErrorLDP(result); - updateOds(); - grView.EditIndex = -1; - grView.DataBind(); - // sollevo evento nuovo valore... - if (eh_nuovoValore != null) - { - eh_nuovoValore(this, new EventArgs()); - } - mod_viewRigheListaPrelievo1.Visible = false; - // blocco update! - e.Cancel = true; - break; - case "scaricaListaPrelievo": - int slotPL = Convert.ToInt32(ddlSlotLPAS.SelectedValue); - result = MagClass.magazzino.scaricaListaPrelievo(memLayer.ML.StringSessionObj("CodCS"), codLista, CodSoggetto, Request.UserHostName, slotPL); - showErrorLDP(result); - updateOds(); - grView.EditIndex = -1; - grView.DataBind(); - // sollevo evento nuovo valore... - if (eh_nuovoValore != null) - { - eh_nuovoValore(this, new EventArgs()); - } - mod_viewRigheListaPrelievo1.Visible = false; - // blocco update! - e.Cancel = true; - break; - case "resetListaPrelievo": - result = MagClass.magazzino.resetListaPrelievo(memLayer.ML.StringSessionObj("CodCS"), codLista, CodSoggetto, Request.UserHostName); - showErrorLDP(result); - updateOds(); - grView.EditIndex = -1; - grView.DataBind(); - // sollevo evento nuovo valore... - if (eh_nuovoValore != null) - { - eh_nuovoValore(this, new EventArgs()); - } - mod_viewRigheListaPrelievo1.Visible = false; - // blocco update! - e.Cancel = true; - break; - default: - // faccio update! - break; - } - } - /// - /// imposta la visualizzazione di un codice di errore a seconda di come è andata l'operazione sulla LDP - /// - /// - private void showErrorLDP(esitoOperazione result) - { - if (result != esitoOperazione.ok) - { - switch (result) - { - case esitoOperazione.errore: - lblErroriLDP.Text = traduci("ERR-RLP-001"); - break; - case esitoOperazione.errore_mismatch: - lblErroriLDP.Text = traduci("ERR-RLP-002"); - break; - case esitoOperazione.errore_readOnly: - lblErroriLDP.Text = traduci("ERR-RLP-003"); - break; - case esitoOperazione.errore_posUDC: - lblErroriLDP.Text = traduci("ERR-RLP-004"); - break; - case esitoOperazione.errore_noUdc: - lblErroriLDP.Text = traduci("ERR-RLP-005"); - break; - case esitoOperazione.errore_nonScaricabile: - lblErroriLDP.Text = traduci("ERR-RLP-006"); - break; - case esitoOperazione.errore_noDeliberPM: - lblErroriLDP.Text = traduci("ERR-RLP-007"); - lbtForzaDL.Visible = true; - break; - case esitoOperazione.errore_UdcNc: - lblErroriLDP.Text = traduci("ERR-RLP-008"); - lbtForzaDL.Visible = true; - break; - case esitoOperazione.errore_DtmxNc: - lblErroriLDP.Text = traduci("ERR-RLP-009"); - lbtForzaDL.Visible = true; - break; - } - lblErroriLDP.Visible = true; - } - else - { - lblErroriLDP.Visible = false; - } - } - /// - /// chiamato post modifica valore check/selezione nel selettore filtro stato - /// - /// - /// - public void eh_selectedStato(object sender, EventArgs e) - { - checkFixOds(); - } - /// - /// ssitema visualizzazione dal filtraggi - /// - private void checkFixOds() - { - ods.FilterParameters.Clear(); - ods.FilterExpression = "(CodLista LIKE '%{0}%' OR Particolare LIKE '%{0}%' OR DescParticolare LIKE '%{0}%')"; - - // parametro ricerca attuale - SessionParameter parametroFiltro = new SessionParameter(); - parametroFiltro.SessionField = "valoreCercato"; - parametroFiltro.Name = "ricerca"; - parametroFiltro.DefaultValue = "*"; - ods.FilterParameters.Add(parametroFiltro); - - // filtro stato lista - if (mod_filtroStato.valore != "*") - { - ods.FilterExpression += " AND CodStatoLista = {1}"; - } - ControlParameter parametroListaStato = new ControlParameter(); - parametroListaStato.ControlID = "mod_filtroStato"; - parametroListaStato.PropertyName = "valore"; - parametroListaStato.Name = "CodStato"; - parametroListaStato.DefaultValue = "0"; - ods.FilterParameters.Add(parametroListaStato); - - // filtro tipo lista - if (mod_filtroTipo.valore != "*") - { - ods.FilterExpression += " AND CodTipoLista = '{2}'"; - } - ControlParameter parametroListaTipo = new ControlParameter(); - parametroListaTipo.ControlID = "mod_filtroTipo"; - parametroListaTipo.PropertyName = "valore"; - parametroListaTipo.Name = "CodTipoLista"; - parametroListaTipo.DefaultValue = "0"; - ods.FilterParameters.Add(parametroListaTipo); - - // se sono in modalità scarico multiplo nascondo stati !=3 e SmartList... - if (modo == ctrlMode.scaricaMultiLDP) - { - ods.FilterExpression += " AND CodStatoLista = 3 AND CodTipoLista <> '00-Smart'"; - } - - // chiamo procedura che aggiorna ods principale - updateOds(); - // ridisegno controllo child! - aggiornaElencoRighe(); - } - /// - /// chiamato post modifica valore check/selezione nel selettore filtro tipo - /// - /// - /// - public void eh_selectedTipo(object sender, EventArgs e) - { - checkFixOds(); - } - /// - /// chiamato post modifica valore check/selezione nel selettore filtro tipo particolare - /// - /// - /// - public void eh_selectedTipoPart(object sender, EventArgs e) - { - checkFixOds(); - } - /// - /// restituisce URL immagine del codice da mostrare x stato lista - /// - /// - /// - public string pathImgStato(object CodStato) - { - return string.Format("~/images/circle_s_{0}.png", CodStato); - } - /// - /// restituisce tooltip da mostrare x STATO lista - /// - /// - /// - public string tooltipStato(object codice) - { - return traduci(string.Format("StatoLista_{0}", codice)); - } - /// - /// restituisce URL immagine del codice da mostrare x TIPO lista - /// - /// - /// - public string pathImgTipo(object codice) - { - return string.Format("~/images/lista_{0}_m.png", codice); - } - /// - /// restituisce tooltip da mostrare x TIPO lista - /// - /// - /// - public string tooltipTipo(object codice) - { - return traduci(codice.ToString()); - } - /// - /// mostra controllo per creare nuove liste di prelievo - /// - /// - /// - protected void btnNewLista_Click(object sender, EventArgs e) - { - if (modo == ctrlMode.standard) - { - modo = ctrlMode.nuovaLDP; - } - else - { - modo = ctrlMode.standard; - } - grView.SelectedIndex = -1; - setBtnState(); - checkFixOds(); - } - /// - /// mostra controllo per modificare destinatario e tipo lista - /// - /// - /// - protected void btnSetDestTipo_Click(object sender, EventArgs e) - { - if (modo == ctrlMode.standard) - { - modo = ctrlMode.setDestTipoLDP; - } - else - { - modo = ctrlMode.standard; - } - grView.SelectedIndex = -1; - setBtnState(); - checkFixOds(); - } - /// - /// va in modalità scaricamento liste multiple in blocco - /// - /// - /// - protected void btnSetModeScaricaListeSel_Click(object sender, EventArgs e) - { - if (modo == ctrlMode.standard) - { - modo = ctrlMode.scaricaMultiLDP; - } - else - { - modo = ctrlMode.standard; - } - grView.SelectedIndex = -1; - setBtnState(); - checkFixOds(); - } - /// - /// imposta lo stato dei buttons (visibilità, label...) in base a stato controllo - /// - protected void setBtnState() - { - // traduzioni "base" - btnNewLista.Text = traduci("NuovaListaPrelievo"); - btnSetDestTipo.Text = traduci("ImpostaDestTipo"); - btnUpdateDestTipo.Text = traduci("SalvaDestTipo"); - btnSetModeScaricaListeSel.Text = traduci("btnSetModeScaricaListeSel"); - btnScaricaSelLDP.Text = traduci("btnScaricaSelLDP"); - // visibilità "base" - btnNewLista.Enabled = true; - btnSetDestTipo.Enabled = true; - btnSetModeScaricaListeSel.Enabled = true; - pnlSetDestTipo.Visible = false; - pnlScaricaMultiLDP.Visible = false; - mod_nuovaListaPrelievo1.Visible = false; - - // in base a modo imposto... - switch (modo) - { - case ctrlMode.standard: - // tutto standard... - break; - case ctrlMode.nuovaLDP: - // traduzioni - btnNewLista.Text = traduci("NascondiNuovaListaPrelievo"); - // visibilità - btnSetDestTipo.Enabled = false; - btnSetModeScaricaListeSel.Enabled = false; - mod_nuovaListaPrelievo1.Visible = true; - break; - case ctrlMode.setDestTipoLDP: - // traduzioni - btnSetDestTipo.Text = traduci("NascondiImpostaDestTipo"); - // visibilità - btnNewLista.Enabled = false; - btnSetModeScaricaListeSel.Enabled = false; - pnlSetDestTipo.Visible = true; - break; - case ctrlMode.scaricaMultiLDP: - // traduzioni - btnSetModeScaricaListeSel.Text = traduci("btnUnSetModeScaricaListeSel"); - // visibilità - btnNewLista.Enabled = false; - btnSetDestTipo.Enabled = false; - pnlScaricaMultiLDP.Visible = true; - break; - default: - break; - } - } - /// - /// traduce il cod soggetto in cognome-nome operatore - /// - /// - /// In carico a: / Completato da: / ... - /// - public string traduciCodSogg(object CodSogg, object stringaPre) - { - string answ = "-"; - try - { - DS_Applicazione.AnagOperatoriRow oper = DataProxy.obj.taAnagOperatore.getByCodSoggetto(CodSogg.ToString())[0]; - answ = string.Format("{3} {0} {1} ({2})", oper.Cognome, oper.Nome, oper.CodDipendente, stringaPre); // Ermanno: traduzione testo! - } - catch - { } - return answ; - } - - /// - /// restituisce l'url formattato del il report della stampa come da web.config - /// - /// - /// - public string formattaUrlReport(object codLista) - { - string url, urlFormat, opzPdf, nomeRep, urlWebServer; - try - { - urlFormat = SteamWare.memLayer.ML.confReadString("urlReporting"); - urlWebServer = SteamWare.memLayer.ML.confReadString("urlWebServer"); - opzPdf = ""; - nomeRep = SteamWare.memLayer.ML.confReadString("reportName"); - // versione con reporting services - url = string.Format(urlFormat, SteamWare.memLayer.ML.AppConf["reportingServerAddress"], SteamWare.memLayer.ML.confReadString("reportDir"), nomeRep, codLista, opzPdf); - - } - catch - { - url = ""; - } - return url; - } - /// - /// forza ricaricamento dati datamatrix/gitterbox/odette - /// - /// - /// - protected void btnForceReload_Click(object sender, EventArgs e) - { - DataMatrix.mgr.importNuoviDati(); - } - /// - /// aggiorna destinatario e tipo lista selezionate da valori indicati - /// - /// - /// - protected void btnUpdateDestTipo_Click(object sender, EventArgs e) - { - string CodLista = ""; - foreach (GridViewRow riga in grView.Rows) - { - if (((CheckBox)riga.FindControl("chkSelect")).Checked && ((CheckBox)riga.FindControl("chkSelect")).Visible) - { - CodLista = ((Label)riga.FindControl("lblCodLista")).Text; - updateDestTipoLDP(CodLista); - } - } - if (modo == ctrlMode.standard) - { - modo = ctrlMode.setDestTipoLDP; - } - else - { - modo = ctrlMode.standard; - } - setBtnState(); - checkFixOds(); - } - /// - /// scarica le LDP selezionate... - /// - /// - /// - protected void btnScaricaSelLDP_Click(object sender, EventArgs e) - { - string CodLista = ""; - esitoOperazione result = esitoOperazione.ok; - int slotPL = Convert.ToInt32(ddlSlotLPAS.SelectedValue); - foreach (GridViewRow riga in grView.Rows) - { - if (((CheckBox)riga.FindControl("chkSelect")).Checked && ((CheckBox)riga.FindControl("chkSelect")).Visible) - { - CodLista = ((Label)riga.FindControl("lblCodLista")).Text; - result = MagClass.magazzino.scaricaListaPrelievo(memLayer.ML.StringSessionObj("CodCS"), CodLista, MagClass.magazzino.CodSoggCurrUser, Request.UserHostName, slotPL); - } - } - if (modo == ctrlMode.standard) - { - modo = ctrlMode.scaricaMultiLDP; - } - else - { - modo = ctrlMode.standard; - } - setBtnState(); - checkFixOds(); - } - /// - /// determina abilitazione pulsante check: se siano modificabili destinatario e tipo lista, SOLO in stato completato (3/4) - /// - /// - /// - public bool modDestAndTipo(object CodStato) - { - bool answ = false; - try - { - answ = ((int)CodStato == (int)statoLista.completata); - } - catch - { } - return answ; - } - /// - /// aggiorna la lista di prelievo indicata impostando destinatario e tipo - /// - /// - private void updateDestTipoLDP(string CodLista) - { - MagClass.magazzino.taElencoListePrelievo.stp_LP_updateDestTipo(CodLista, ddlTipoLista.SelectedValue, ddlDestin.SelectedValue, ddlDestin.SelectedItem.Text, MagClass.magazzino.CodSoggCurrUser, DateTime.Now); - } - /// - /// modo di funzionamento del controllo - /// - protected ctrlMode modo - { - get - { - ctrlMode answ = ctrlMode.standard; - try - { - answ = (ctrlMode)memLayer.ML.objSessionObj("ctrlMode"); - } - catch - { } - return answ; - } - set - { - memLayer.ML.setSessionVal("ctrlMode", value, false); - } - } - /// - /// chiamata post page change gridview - /// - /// - /// - protected void grView_PageIndexChanged(object sender, EventArgs e) - { - // sistemazione dell'ods post evento cambio pagina - checkFixOds(); - } - /// - /// chiamata post sort gridview - /// - /// - /// - protected void grView_Sorted(object sender, EventArgs e) - { - // sistemazione dell'ods - checkFixOds(); - } - /// - /// entrando in editing fix ods - /// - /// - /// - protected void grView_RowEditing(object sender, GridViewEditEventArgs e) - { - // sistemazione dell'ods post evento sort - checkFixOds(); - } - /// - /// post edit fix ods - /// - /// - /// - protected void grView_RowUpdated(object sender, GridViewUpdatedEventArgs e) - { - // sistemazione dell'ods - checkFixOds(); - } - /// - /// aggiorno controllo paginazione... - /// - /// - /// - protected void txtNumRighe_TextChanged(object sender, EventArgs e) - { - aggiornaControlliDataGL(); - checkFixOds(); - } - /// - /// forza le delibere: - /// - la delibera DC x ogni NC aperta su UDC della lista - /// - la delibera logistica x gli UDC di trattamenti senza PM - /// - /// - protected void lbtForzaDL_Click(object sender, EventArgs e) - { - MagClass.magazzino.taRigheListePrelievo.setDlUdcSenzaDeliberaPM(currCodLista, DateTime.Now, MagClass.magazzino.CodSoggCurrUser); - lbtForzaDL.Visible = false; - resetSelezione(); - } - - - #endregion + // mostro avviso di non cancellabilità... + lblWarning.Text = traduci("notDeletable_hasChild"); + lblWarning.Visible = true; + grView.DataBind(); } + /// + /// esegue cancellazioen record + /// + protected void doDelete() + { + // posso cancellare... + lblWarning.Visible = false; + ods.Delete(); + } + /// + /// Valida la cancellazione per i dati mostrati dal gridView + /// richiede sia preventivamentedichiarato _idxGridView + /// + /// + /// + protected virtual void validaDelete(object sender, ObjectDataSourceMethodEventArgs e) + { + int idx = Convert.ToInt32(e.InputParameters[string.Format("Original_{0}", _idxGridView)]); + if (objIsNotRelated(idx)) + { + // annullo cancellazione... + e.Cancel = true; + // seleziono record... metto in session valore idx e poi ridisegno... + SteamWare.memLayer.ML.setSessionVal(_idxGridView, idx); + setNoDeletableErrorMessage(); + } + else + { + doDelete(); + } + } + + /// + /// recupera i dati di un nuovo record contenuti nel footer di un gridView; + /// questi devono esses opportunamente nominati (es: txt{0}, dl{0}, ...) + /// + /// + /// + protected void recuperaFooter(object sender, ObjectDataSourceMethodEventArgs e) + { + //recupero la riga footer... + DataColumnCollection colonne = colonneObj(); + string nomeCol; + string tipoColonna = ""; + foreach (DataColumn colonna in colonne) + { + nomeCol = colonna.ColumnName; + // cerco un textbox o quello che sia... + if (grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol)) != null) + { + tipoColonna = "textBox"; + } + else if (grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol)) != null) + { + tipoColonna = "dropDownList"; + } + else if (grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol)) != null) + { + tipoColonna = "checkBox"; + } + else if (grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol)) != null) + { + tipoColonna = "selAjax"; + } + // in base al tipo salvo negli inputparameters dell'ODS + switch (tipoColonna) + { + case "textBox": + e.InputParameters[nomeCol] = ((TextBox)grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol))).Text; + break; + case "dropDownList": + e.InputParameters[nomeCol] = ((DropDownList)grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol))).SelectedValue; + break; + case "checkBox": + e.InputParameters[nomeCol] = ((CheckBox)grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol))).Checked; + break; + case "selAjax": + e.InputParameters[nomeCol] = ((mod_selettore_ajax)grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol))).valore; + break; + default: + break; + } + tipoColonna = ""; + } + } + /// + /// inserisce nuovo valore da footer + /// + /// + /// + protected void lblIns_click(object sender, EventArgs e) + { + // click su inserimento, chiamo il metodo insert dell'ObjectDataSource + ods.Insert(); + SteamWare.memLayer.ML.emptyCacheVal(_tabCache); + } + /// + /// annulla inserimento nuovo valore da footer + /// + /// + /// + protected void lblCanc_click(object sender, EventArgs e) + { + // annullo inserimento: nascondo footer, bind controlli... + grView.FooterRow.Visible = false; + } + + /// + /// traduce gli header delle colonne + /// + /// + /// + protected void grView_DataBound(object sender, EventArgs e) + { + if (grView.Rows.Count > 0) + { + LinkButton lb; + // aggiorno gli headers + foreach (TableCell cella in grView.HeaderRow.Cells) + { + try + { + lb = (LinkButton)cella.Controls[0]; + lb.Text = traduci(lb.Text); + } + catch + { } + } + int totRecord = grView.Rows.Count + grView.PageSize * (grView.PageCount - 1); + lblNumRec.Text = string.Format("{0} records of ~ {1}", grView.Rows.Count, totRecord); + } + else + { + lblNumRec.Text = ""; + } + } + /// + /// gestione evento richiesta nuovo valore (mostra footer, ...) + /// + /// + /// + protected void btnNew_Click(object sender, EventArgs e) + { + // reset selezione... + resetSelezione(); + // mostro il footer oppure la riga dei dettagli x nuovo... + if (grView.FooterRow != null) + { + grView.FooterRow.Visible = true; + } + // sollevo evento nuovo valore... + if (eh_nuovoValore != null) + { + eh_nuovoValore(this, new EventArgs()); + } + } + /// + /// reset della selezione + /// + /// + /// + protected void btnReset_Click(object sender, EventArgs e) + { + resetSelezione(); + } + + /// + /// collega i controlli + /// + protected override void bindControlli() + { + base.bindControlli(); + caricaTabelle(); + } + + #endregion + + #region gestione eventi + + //public event EventHandler eh_resetSelezione; + public event EventHandler eh_nuovoValore; + //public event EventHandler eh_selValore; + + #endregion + + #region public + + /// + /// definisce visibilità btnNew + /// + public bool showNewBtn + { + get + { + return _showNewBtn; + } + set + { + _showNewBtn = value; + } + } + /// + /// effettua update del modulo + /// + public void doUpdate() + { + resetSelezione(); + } + + + #endregion + + #endregion + + #region area codice variabile + + /// + /// numero righe gridview da mostrare legato a controllo textbox + /// + public int numRigheGrView + { + get + { + int answ = _righeDataGridMed; + try + { + answ = Convert.ToInt32(txtNumRighe.Text.Trim()); + if (answ == 0) + { + answ = _righeDataGridMed; + txtNumRighe.Text = _righeDataGridMed.ToString(); + } + } + catch + { } + return answ; + } + set + { + txtNumRighe.Text = value.ToString(); + } + } + /// + /// aggiorna controlli datagrid e numero righe in pagina + /// + protected override void aggiornaControlliDataGL() + { + base.aggiornaControlliDataGL(); + // indico num righe da controllo + grView.PageSize = numRigheGrView; + } + /// + /// carico le tabelle + /// + private void caricaTabelle() + { + } + /// + /// verifica complessiva non esistenza record child + /// + /// + /// + protected bool objIsNotRelated(object idxObj) + { + bool answ = true; + return answ; + } + /// + /// elenco colonne del datagrid + /// + /// + protected DataColumnCollection colonneObj() + { + DS_magazzino.ElencoListePrelievoDataTable tabella = new DS_magazzino.ElencoListePrelievoDataTable(); + DataColumnCollection colonne = tabella.Columns; + return colonne; + } + /// + /// inizializzazione valori di default + /// + /// + protected override void OnInit(EventArgs e) + { + base.OnInit(e); + _idxGridView = "CodLista"; + if (!Page.IsPostBack) + { + // imposto page num... + numRigheGrView = _righeDataGridMed; + // continuo setup + btnForceReload.Text = traduci("ReloadDataMatrix"); + btnForceReload.Visible = memLayer.ML.confReadBool("showReloadDataMatrix"); + setBtnState(); + mod_viewRigheListaPrelievo1.Visible = false; + mod_selPeriodo1.setPeriodoFree(); + mod_filtroStato.ods = odsFiltroStati; + mod_filtroTipo.ods = odsTipoLista; + mod_filtroTipoPart.ods = odsTipoPart; + // controllo se ci sia richiesta x creare nuova lista, nel caso precompilo valori... + if (memLayer.ML.BoolSessionObj("PrecompilaListaPrelievo")) + { + mod_nuovaListaPrelievo1.Visible = true; + mod_nuovaListaPrelievo1.ParticolareRichiesto = memLayer.ML.StringSessionObj("Particolare_sel"); + memLayer.ML.emptySessionVal("PrecompilaListaPrelievo"); + } + else + { + mod_nuovaListaPrelievo1.Visible = false; + } + pnlSetDestTipo.Visible = false; + } + // registro evento update + mod_viewRigheListaPrelievo1.eh_nuovoValore += new EventHandler(mod_viewRigheListaPrelievo1_eh_nuovoValore); + mod_selPeriodo1.eh_doUpdate += new EventHandler(mod_periodoAnalisi1_eh_doUpdate); + mod_nuovaListaPrelievo1.eh_nuovoValore += new EventHandler(mod_nuovaListaPrelievo1_eh_nuovoValore); + } + /// + /// seleziona/deseleziona le righe indicate... + /// + /// + /// + protected void btnSelAll_Click(object sender, EventArgs e) + { + // seleziono tutti i valori visibili nel datagrid + CheckBox chkbox = ((CheckBox)sender); + bool isChecked = chkbox.Checked; + if (!isChecked) + { + chkbox.ToolTip = traduci("btnSelAll"); + } + else + { + chkbox.ToolTip = traduci("btnDeselAll"); + } + foreach (GridViewRow riga in grView.Rows) + { + ((CheckBox)riga.FindControl("chkSelect")).Checked = isChecked; + } + } + /// + /// mostra oggetti x creare una nuova lista di prelievo + /// + /// + /// + void mod_nuovaListaPrelievo1_eh_nuovoValore(object sender, EventArgs e) + { + if (modo == ctrlMode.standard) + { + modo = ctrlMode.nuovaLDP; + } + else + { + modo = ctrlMode.standard; + } + setBtnState(); + checkFixOds(); + } + /// + /// aggiorno x update selettore date + /// + /// + /// + void mod_periodoAnalisi1_eh_doUpdate(object sender, EventArgs e) + { + setBtnState(); + checkFixOds(); + } + /// + /// aggiorno x update valori righe prelievo + /// + /// + /// + void mod_viewRigheListaPrelievo1_eh_nuovoValore(object sender, EventArgs e) + { + setBtnState(); + checkFixOds(); + } + /// + /// svuoto da cache post update + /// + /// + /// + protected void ods_Updated(object sender, ObjectDataSourceStatusEventArgs e) + { + resetSelezione(); + } + /// + /// aggiorno visualizzazione + /// + private void updateOds() + { + grView.DataBind(); + } + + /// + /// determina se sia eliminabile il record (=non usato oppure smart) + /// + /// stato lista + /// + public bool delEnabled(object CodStato) + { + bool answ = isWritable(); + try + { + answ = ((int)CodStato < (int)statoLista.iniziata); + } + catch + { } + return answ; + } + /// + /// determina se sia abilitato il pulsante x attivare una lista di prelievo + /// + /// + /// + public bool attivaEnabled(object CodStato) + { + bool answ = false; + try + { + answ = ((int)CodStato == (int)statoLista.bozza); + } + catch + { } + return answ; + } + /// + /// determina se sia abilitato il pulsante x iniziare una lista di prelievo + /// + /// + /// + public bool iniziaEnabled(object CodStato) + { + bool answ = false; + try + { + answ = ((int)CodStato == (int)statoLista.generata); + } + catch + { } + return answ; + } + /// + /// determina se sia abilitato il pulsante x completare una lista di prelievo + /// + /// + /// + public bool completaEnabled(object CodStato) + { + bool answ = false; + try + { + answ = ((int)CodStato == (int)statoLista.iniziata); + } + catch + { } + return answ; + } + /// + /// determina se sia abilitato il pulsante x approvare e scaricare una lista di prelievo + /// + /// stato lista + /// tipo lista di prelievo + /// + public bool ScaricaEnabled(object CodStato, object codTipo) + { + bool answ = false; + // se la lista è di tipo smart NON si può comunque scaricare, cerco smart nel codice e NON lo deve contenere + if (!codTipo.ToString().Contains("Smart")) + { + try + { + answ = ((int)CodStato == (int)statoLista.completata); + } + catch + { } + } + return answ; + } + /// + /// determina se sia abilitato export su AS400 da codLista + /// + /// + /// + protected bool as400Export(string codLista) + { + // 2014.07.09 inserisco controllo da TIPO LISTA --> se si debba scaricare su AS400... + bool answ = false; + DS_magazzino.ElencoListePrelievoDataTable tabElencoListe = new DS_magazzino.ElencoListePrelievoDataTable(); + try + { + tabElencoListe = MagClass.magazzino.taElencoListePrelievo.getByCodLista(codLista); + answ = MagClass.magazzino.taTipoListaPrelievo.getByCodTipoLista(tabElencoListe[0].CodTipoLista)[0].toAs400; + } + catch + { + answ = false; + } + return answ; + } + + /// + /// determina se sia abilitato il pulsante x resettare una lista di prelievo a bozza + /// + /// codice univoco lista prelievo + /// stato lista + /// + public bool ResetVisible(object codLista, object CodStato) + { + bool answ = false; + // condizione: NON CI SIANO ODETTE + bool condOdette = false; + // 2014.06.12 modifica x NUOVA gestione packing list, NON permetto reset se scaricata... + // condizione: SOLO COMPLETATA può essere resettata SE c'è export 2 as400, altrimenti ANCHE scaricata + bool condStato = false; + try + { + // controllo SE c'è export su AS400 accetto SOLO in stato completata + if (as400Export(codLista.ToString())) + { + // se == completata resetto + condStato = ((int)CodStato == (int)statoLista.completata); + } + else // NON ESPORTO in AS400 + { + // se >= completata resetto + condStato = ((int)CodStato >= (int)statoLista.completata); + } + // cerco odette x la LDP, se NON ci sono è ok! + condOdette = !Odette.mgr.listaHasOdette(codLista.ToString()); + } + catch + { } + answ = (condOdette && condStato); // aggiungere controllo scrivibilità? isWritable(); + return answ; + } + /// + /// determina se sia abilitato il pulsante x resettare una lista di prelievo a bozza + /// + /// codice univoco lista prelievo + /// stato lista + /// tipo lista di prelievo + /// + public bool ResetEnabled(object codLista, object CodStato, object codTipo) + { + bool answ = false; + // se la lista è di tipo smart NON si può comunque scaricare, cerco smart nel codice e NON lo deve contenere + if (!codTipo.ToString().Contains("Smart")) + { + // condizione: NON CI SIANO ODETTE + bool condOdette = false; + // condizione: non in carico ad operatore + bool condStato = false; + try + { + // controllo SE c'è export su AS400 accetto SOLO in stato completata + if (as400Export(codLista.ToString())) + { + // se == completata resetto + condStato = ((int)CodStato == (int)statoLista.completata); + } + else // NON ESPORTO in AS400 + { + // se >= completata resetto + condStato = ((int)CodStato >= (int)statoLista.completata); + } + // cerco odette x la LDP, se NON ci sono è ok! + condOdette = !Odette.mgr.listaHasOdette(codLista.ToString()); + } + catch + { } + answ = (condOdette && condStato); + } + return answ; + } + /// + /// sistema il tooltip di reset + /// + /// + /// + public string tooltipReset(object codTipo) + { + string answ = ""; + if (!codTipo.ToString().Contains("Smart")) + { + answ = traduci("ResetListaPrelievo"); + } + else + { + answ = traduci("ResetSmartNotEnabled"); + } + return answ; + } + /// + /// imposta immagine reset + /// + /// + /// + public string imgReset(object codTipo) + { + string answ = ""; + if (!codTipo.ToString().Contains("Smart")) + { + answ = "~/images/resetBozza.png"; + } + else + { + answ = "~/images/resetBozza_disabled.png"; + } + // ULTERIORE CONTROLLO POSSIBILE: CHECK tabTranPosizioneEventi + return answ; + } + /// + /// gestione cambio selezione valore + /// + /// + /// + protected void grView_SelectedIndexChanged(object sender, EventArgs e) + { + setBtnState(); + checkFixOds(); + } + /// + /// aggiorna visualizzazione + /// + private void aggiornaElencoRighe() + { + // salvo in session il valore selezionato... + SteamWare.memLayer.ML.setSessionVal(string.Format("{0}_sel", _idxGridView), grView.SelectedValue, true); + // setto se sia possibile prelevare le righe (SOLO se iniziata) + bool prelievoOk = false; + bool cambioUdcOk = false; + int CodStato = 0; + string codTipoLista = ""; + DS_magazzino.ElencoListePrelievoDataTable tabElencoListe = new DS_magazzino.ElencoListePrelievoDataTable(); + try + { + tabElencoListe = MagClass.magazzino.taElencoListePrelievo.getByCodLista(grView.SelectedValue.ToString()); + CodStato = tabElencoListe[0].CodStatoLista; + codTipoLista = tabElencoListe[0].CodTipoLista; + cambioUdcOk = (CodStato == (int)statoLista.bozza); + prelievoOk = (CodStato == (int)statoLista.iniziata); + } + catch + { } + mod_viewRigheListaPrelievo1.prelievoEnabled = prelievoOk; // abilito il prelievo SOLO se la lista è già iniziata... + mod_viewRigheListaPrelievo1.editRigheEnabled = cambioUdcOk; // abilito il prelievo SOLO se la lista è in BOZZA... + mod_viewRigheListaPrelievo1.intStatoLista = CodStato; // salvo il cod (INT) stato della lista + mod_viewRigheListaPrelievo1.codTipoLista = codTipoLista; // salvo il tipo lista + // mostra con dettagli + mod_viewRigheListaPrelievo1.Visible = true; + mod_viewRigheListaPrelievo1.resetSelezione(); + } + /// + /// resetta la selezione dei valori in caso di modifiche su altri controlli + /// + public void resetSelezione() + { + currCodLista = ""; + lblErroriLDP.Text = ""; + SteamWare.memLayer.ML.emptySessionVal(string.Format("{0}_sel", _idxGridView)); + grView.SelectedIndex = -1; + setBtnState(); + checkFixOds(); + lblWarning.Visible = false; + // nasconde dettagli + mod_viewRigheListaPrelievo1.Visible = false; + } + /// + /// salvo in session il prox comando + /// + /// + /// + protected void img_Click(object sender, ImageClickEventArgs e) + { + SteamWare.memLayer.ML.setSessionVal("nextObjCommand", ((ImageButton)sender).CommandArgument); + } + /// + /// codice lista selezionata + /// + protected string currCodLista + { + get + { + return memLayer.ML.StringSessionObj("CodListaSel"); + } + set + { + memLayer.ML.setSessionVal("CodListaSel", value); + } + } + /// + /// in caso di aggiornamento verifico se sia salvato un comando inizia o completa lista prelievo... + /// + /// + /// + protected void grView_RowUpdating(object sender, GridViewUpdateEventArgs e) + { + // carico l'idx dell'oggetto + string codLista = e.Keys["CodLista"].ToString(); + currCodLista = codLista; + // quale comando? + string _comando = ""; + if (SteamWare.memLayer.ML.isInSessionObject("nextObjCommand")) + { + _comando = SteamWare.memLayer.ML.StringSessionObj("nextObjCommand"); + SteamWare.memLayer.ML.emptySessionVal("nextObjCommand"); + } + string CodSoggetto = MagClass.magazzino.CodSoggCurrUser; + esitoOperazione result = esitoOperazione.ok; + switch (_comando) + { + case "attivaListaPrelievo": + result = MagClass.magazzino.attivaListaPrelievo(memLayer.ML.StringSessionObj("CodCS"), codLista, CodSoggetto); + showErrorLDP(result); + updateOds(); + grView.EditIndex = -1; + grView.DataBind(); + // sollevo evento nuovo valore... + if (eh_nuovoValore != null) + { + eh_nuovoValore(this, new EventArgs()); + } + mod_viewRigheListaPrelievo1.Visible = false; + // blocco update! + e.Cancel = true; + break; + case "iniziaListaPrelievo": + result = MagClass.magazzino.iniziaListaPrelievo(memLayer.ML.StringSessionObj("CodCS"), codLista, CodSoggetto); + showErrorLDP(result); + updateOds(); + grView.EditIndex = -1; + grView.DataBind(); + // sollevo evento nuovo valore... + if (eh_nuovoValore != null) + { + eh_nuovoValore(this, new EventArgs()); + } + mod_viewRigheListaPrelievo1.Visible = false; + // blocco update! + e.Cancel = true; + break; + case "completaListaPrelievo": + result = MagClass.magazzino.completaListaPrelievo(memLayer.ML.StringSessionObj("CodCS"), codLista, CodSoggetto, Request.UserHostName); + showErrorLDP(result); + updateOds(); + grView.EditIndex = -1; + grView.DataBind(); + // sollevo evento nuovo valore... + if (eh_nuovoValore != null) + { + eh_nuovoValore(this, new EventArgs()); + } + mod_viewRigheListaPrelievo1.Visible = false; + // blocco update! + e.Cancel = true; + break; + case "scaricaListaPrelievo": + int slotPL = Convert.ToInt32(ddlSlotLPAS.SelectedValue); + result = MagClass.magazzino.scaricaListaPrelievo(memLayer.ML.StringSessionObj("CodCS"), codLista, CodSoggetto, Request.UserHostName, slotPL); + showErrorLDP(result); + updateOds(); + grView.EditIndex = -1; + grView.DataBind(); + // sollevo evento nuovo valore... + if (eh_nuovoValore != null) + { + eh_nuovoValore(this, new EventArgs()); + } + mod_viewRigheListaPrelievo1.Visible = false; + // blocco update! + e.Cancel = true; + break; + case "resetListaPrelievo": + result = MagClass.magazzino.resetListaPrelievo(memLayer.ML.StringSessionObj("CodCS"), codLista, CodSoggetto, Request.UserHostName); + showErrorLDP(result); + updateOds(); + grView.EditIndex = -1; + grView.DataBind(); + // sollevo evento nuovo valore... + if (eh_nuovoValore != null) + { + eh_nuovoValore(this, new EventArgs()); + } + mod_viewRigheListaPrelievo1.Visible = false; + // blocco update! + e.Cancel = true; + break; + default: + // faccio update! + break; + } + } + /// + /// imposta la visualizzazione di un codice di errore a seconda di come è andata l'operazione sulla LDP + /// + /// + private void showErrorLDP(esitoOperazione result) + { + if (result != esitoOperazione.ok) + { + switch (result) + { + case esitoOperazione.errore: + lblErroriLDP.Text = traduci("ERR-RLP-001"); + break; + case esitoOperazione.errore_mismatch: + lblErroriLDP.Text = traduci("ERR-RLP-002"); + break; + case esitoOperazione.errore_readOnly: + lblErroriLDP.Text = traduci("ERR-RLP-003"); + break; + case esitoOperazione.errore_posUDC: + lblErroriLDP.Text = traduci("ERR-RLP-004"); + break; + case esitoOperazione.errore_noUdc: + lblErroriLDP.Text = traduci("ERR-RLP-005"); + break; + case esitoOperazione.errore_nonScaricabile: + lblErroriLDP.Text = traduci("ERR-RLP-006"); + break; + case esitoOperazione.errore_noDeliberPM: + lblErroriLDP.Text = traduci("ERR-RLP-007"); + lbtForzaDL.Visible = true; + break; + case esitoOperazione.errore_UdcNc: + lblErroriLDP.Text = traduci("ERR-RLP-008"); + lbtForzaDL.Visible = true; + break; + case esitoOperazione.errore_DtmxNc: + lblErroriLDP.Text = traduci("ERR-RLP-009"); + lbtForzaDL.Visible = true; + break; + } + lblErroriLDP.Visible = true; + } + else + { + lblErroriLDP.Visible = false; + } + } + /// + /// chiamato post modifica valore check/selezione nel selettore filtro stato + /// + /// + /// + public void eh_selectedStato(object sender, EventArgs e) + { + checkFixOds(); + } + /// + /// ssitema visualizzazione dal filtraggi + /// + private void checkFixOds() + { + ods.FilterParameters.Clear(); + ods.FilterExpression = "(CodLista LIKE '%{0}%' OR Particolare LIKE '%{0}%' OR DescParticolare LIKE '%{0}%')"; + + // parametro ricerca attuale + SessionParameter parametroFiltro = new SessionParameter(); + parametroFiltro.SessionField = "valoreCercato"; + parametroFiltro.Name = "ricerca"; + parametroFiltro.DefaultValue = "*"; + ods.FilterParameters.Add(parametroFiltro); + + // filtro stato lista + if (mod_filtroStato.valore != "*") + { + ods.FilterExpression += " AND CodStatoLista = {1}"; + } + ControlParameter parametroListaStato = new ControlParameter(); + parametroListaStato.ControlID = "mod_filtroStato"; + parametroListaStato.PropertyName = "valore"; + parametroListaStato.Name = "CodStato"; + parametroListaStato.DefaultValue = "0"; + ods.FilterParameters.Add(parametroListaStato); + + // filtro tipo lista + if (mod_filtroTipo.valore != "*") + { + ods.FilterExpression += " AND CodTipoLista = '{2}'"; + } + ControlParameter parametroListaTipo = new ControlParameter(); + parametroListaTipo.ControlID = "mod_filtroTipo"; + parametroListaTipo.PropertyName = "valore"; + parametroListaTipo.Name = "CodTipoLista"; + parametroListaTipo.DefaultValue = "0"; + ods.FilterParameters.Add(parametroListaTipo); + + // se sono in modalità scarico multiplo nascondo stati !=3 e SmartList... + if (modo == ctrlMode.scaricaMultiLDP) + { + ods.FilterExpression += " AND CodStatoLista = 3 AND CodTipoLista <> '00-Smart'"; + } + + // chiamo procedura che aggiorna ods principale + updateOds(); + // ridisegno controllo child! + aggiornaElencoRighe(); + } + /// + /// chiamato post modifica valore check/selezione nel selettore filtro tipo + /// + /// + /// + public void eh_selectedTipo(object sender, EventArgs e) + { + checkFixOds(); + } + /// + /// chiamato post modifica valore check/selezione nel selettore filtro tipo particolare + /// + /// + /// + public void eh_selectedTipoPart(object sender, EventArgs e) + { + checkFixOds(); + } + /// + /// restituisce URL immagine del codice da mostrare x stato lista + /// + /// + /// + public string pathImgStato(object CodStato) + { + return string.Format("~/images/circle_s_{0}.png", CodStato); + } + /// + /// restituisce tooltip da mostrare x STATO lista + /// + /// + /// + public string tooltipStato(object codice) + { + return traduci(string.Format("StatoLista_{0}", codice)); + } + /// + /// restituisce URL immagine del codice da mostrare x TIPO lista + /// + /// + /// + public string pathImgTipo(object codice) + { + return string.Format("~/images/lista_{0}_m.png", codice); + } + /// + /// restituisce tooltip da mostrare x TIPO lista + /// + /// + /// + public string tooltipTipo(object codice) + { + return traduci(codice.ToString()); + } + /// + /// mostra controllo per creare nuove liste di prelievo + /// + /// + /// + protected void btnNewLista_Click(object sender, EventArgs e) + { + if (modo == ctrlMode.standard) + { + modo = ctrlMode.nuovaLDP; + } + else + { + modo = ctrlMode.standard; + } + grView.SelectedIndex = -1; + setBtnState(); + checkFixOds(); + } + /// + /// mostra controllo per modificare destinatario e tipo lista + /// + /// + /// + protected void btnSetDestTipo_Click(object sender, EventArgs e) + { + if (modo == ctrlMode.standard) + { + modo = ctrlMode.setDestTipoLDP; + } + else + { + modo = ctrlMode.standard; + } + grView.SelectedIndex = -1; + setBtnState(); + checkFixOds(); + } + /// + /// va in modalità scaricamento liste multiple in blocco + /// + /// + /// + protected void btnSetModeScaricaListeSel_Click(object sender, EventArgs e) + { + if (modo == ctrlMode.standard) + { + modo = ctrlMode.scaricaMultiLDP; + } + else + { + modo = ctrlMode.standard; + } + grView.SelectedIndex = -1; + setBtnState(); + checkFixOds(); + } + /// + /// imposta lo stato dei buttons (visibilità, label...) in base a stato controllo + /// + protected void setBtnState() + { + // traduzioni "base" + btnNewLista.Text = traduci("NuovaListaPrelievo"); + btnSetDestTipo.Text = traduci("ImpostaDestTipo"); + btnUpdateDestTipo.Text = traduci("SalvaDestTipo"); + btnSetModeScaricaListeSel.Text = traduci("btnSetModeScaricaListeSel"); + btnScaricaSelLDP.Text = traduci("btnScaricaSelLDP"); + // visibilità "base" + btnNewLista.Enabled = true; + btnSetDestTipo.Enabled = true; + btnSetModeScaricaListeSel.Enabled = true; + pnlSetDestTipo.Visible = false; + pnlScaricaMultiLDP.Visible = false; + mod_nuovaListaPrelievo1.Visible = false; + + // in base a modo imposto... + switch (modo) + { + case ctrlMode.standard: + // tutto standard... + break; + case ctrlMode.nuovaLDP: + // traduzioni + btnNewLista.Text = traduci("NascondiNuovaListaPrelievo"); + // visibilità + btnSetDestTipo.Enabled = false; + btnSetModeScaricaListeSel.Enabled = false; + mod_nuovaListaPrelievo1.Visible = true; + break; + case ctrlMode.setDestTipoLDP: + // traduzioni + btnSetDestTipo.Text = traduci("NascondiImpostaDestTipo"); + // visibilità + btnNewLista.Enabled = false; + btnSetModeScaricaListeSel.Enabled = false; + pnlSetDestTipo.Visible = true; + break; + case ctrlMode.scaricaMultiLDP: + // traduzioni + btnSetModeScaricaListeSel.Text = traduci("btnUnSetModeScaricaListeSel"); + // visibilità + btnNewLista.Enabled = false; + btnSetDestTipo.Enabled = false; + pnlScaricaMultiLDP.Visible = true; + break; + default: + break; + } + } + /// + /// traduce il cod soggetto in cognome-nome operatore + /// + /// + /// In carico a: / Completato da: / ... + /// + public string traduciCodSogg(object CodSogg, object stringaPre) + { + string answ = "-"; + try + { + DS_Applicazione.AnagOperatoriRow oper = DataProxy.obj.taAnagOperatore.getByCodSoggetto(CodSogg.ToString())[0]; + answ = string.Format("{3} {0} {1} ({2})", oper.Cognome, oper.Nome, oper.CodDipendente, stringaPre); // Ermanno: traduzione testo! + } + catch + { } + return answ; + } + + /// + /// restituisce l'url formattato del il report della stampa come da web.config + /// + /// + /// + public string formattaUrlReport(object codLista) + { + string url, urlFormat, opzPdf, nomeRep, urlWebServer; + try + { + urlFormat = SteamWare.memLayer.ML.confReadString("urlReporting"); + urlWebServer = SteamWare.memLayer.ML.confReadString("urlWebServer"); + opzPdf = ""; + nomeRep = SteamWare.memLayer.ML.confReadString("reportName"); + // versione con reporting services + url = string.Format(urlFormat, SteamWare.memLayer.ML.AppConf["reportingServerAddress"], SteamWare.memLayer.ML.confReadString("reportDir"), nomeRep, codLista, opzPdf); + + } + catch + { + url = ""; + } + return url; + } + /// + /// forza ricaricamento dati datamatrix/gitterbox/odette + /// + /// + /// + protected void btnForceReload_Click(object sender, EventArgs e) + { + DataMatrix_mgr.importNuoviDati(); + } + /// + /// aggiorna destinatario e tipo lista selezionate da valori indicati + /// + /// + /// + protected void btnUpdateDestTipo_Click(object sender, EventArgs e) + { + string CodLista = ""; + foreach (GridViewRow riga in grView.Rows) + { + if (((CheckBox)riga.FindControl("chkSelect")).Checked && ((CheckBox)riga.FindControl("chkSelect")).Visible) + { + CodLista = ((Label)riga.FindControl("lblCodLista")).Text; + updateDestTipoLDP(CodLista); + } + } + if (modo == ctrlMode.standard) + { + modo = ctrlMode.setDestTipoLDP; + } + else + { + modo = ctrlMode.standard; + } + setBtnState(); + checkFixOds(); + } + /// + /// scarica le LDP selezionate... + /// + /// + /// + protected void btnScaricaSelLDP_Click(object sender, EventArgs e) + { + string CodLista = ""; + esitoOperazione result = esitoOperazione.ok; + int slotPL = Convert.ToInt32(ddlSlotLPAS.SelectedValue); + foreach (GridViewRow riga in grView.Rows) + { + if (((CheckBox)riga.FindControl("chkSelect")).Checked && ((CheckBox)riga.FindControl("chkSelect")).Visible) + { + CodLista = ((Label)riga.FindControl("lblCodLista")).Text; + result = MagClass.magazzino.scaricaListaPrelievo(memLayer.ML.StringSessionObj("CodCS"), CodLista, MagClass.magazzino.CodSoggCurrUser, Request.UserHostName, slotPL); + } + } + if (modo == ctrlMode.standard) + { + modo = ctrlMode.scaricaMultiLDP; + } + else + { + modo = ctrlMode.standard; + } + setBtnState(); + checkFixOds(); + } + /// + /// determina abilitazione pulsante check: se siano modificabili destinatario e tipo lista, SOLO in stato completato (3/4) + /// + /// + /// + public bool modDestAndTipo(object CodStato) + { + bool answ = false; + try + { + answ = ((int)CodStato == (int)statoLista.completata); + } + catch + { } + return answ; + } + /// + /// aggiorna la lista di prelievo indicata impostando destinatario e tipo + /// + /// + private void updateDestTipoLDP(string CodLista) + { + MagClass.magazzino.taElencoListePrelievo.stp_LP_updateDestTipo(CodLista, ddlTipoLista.SelectedValue, ddlDestin.SelectedValue, ddlDestin.SelectedItem.Text, MagClass.magazzino.CodSoggCurrUser, DateTime.Now); + } + /// + /// modo di funzionamento del controllo + /// + protected ctrlMode modo + { + get + { + ctrlMode answ = ctrlMode.standard; + try + { + answ = (ctrlMode)memLayer.ML.objSessionObj("ctrlMode"); + } + catch + { } + return answ; + } + set + { + memLayer.ML.setSessionVal("ctrlMode", value, false); + } + } + /// + /// chiamata post page change gridview + /// + /// + /// + protected void grView_PageIndexChanged(object sender, EventArgs e) + { + // sistemazione dell'ods post evento cambio pagina + checkFixOds(); + } + /// + /// chiamata post sort gridview + /// + /// + /// + protected void grView_Sorted(object sender, EventArgs e) + { + // sistemazione dell'ods + checkFixOds(); + } + /// + /// entrando in editing fix ods + /// + /// + /// + protected void grView_RowEditing(object sender, GridViewEditEventArgs e) + { + // sistemazione dell'ods post evento sort + checkFixOds(); + } + /// + /// post edit fix ods + /// + /// + /// + protected void grView_RowUpdated(object sender, GridViewUpdatedEventArgs e) + { + // sistemazione dell'ods + checkFixOds(); + } + /// + /// aggiorno controllo paginazione... + /// + /// + /// + protected void txtNumRighe_TextChanged(object sender, EventArgs e) + { + aggiornaControlliDataGL(); + checkFixOds(); + } + /// + /// forza le delibere: + /// - la delibera DC x ogni NC aperta su UDC della lista + /// - la delibera logistica x gli UDC di trattamenti senza PM + /// + /// + protected void lbtForzaDL_Click(object sender, EventArgs e) + { + MagClass.magazzino.taRigheListePrelievo.setDlUdcSenzaDeliberaPM(currCodLista, DateTime.Now, MagClass.magazzino.CodSoggCurrUser); + lbtForzaDL.Visible = false; + resetSelezione(); + } + + + #endregion + } } /// /// possibili stati del controllo /// public enum ctrlMode { - standard = 0, - nuovaLDP, - setDestTipoLDP, - scaricaMultiLDP + standard = 0, + nuovaLDP, + setDestTipoLDP, + scaricaMultiLDP } \ No newline at end of file diff --git a/GMW/WebUserControls/mod_postRX_DT_LIST.ascx.cs b/GMW/WebUserControls/mod_postRX_DT_LIST.ascx.cs index 2faef903..1cc1d4eb 100644 --- a/GMW/WebUserControls/mod_postRX_DT_LIST.ascx.cs +++ b/GMW/WebUserControls/mod_postRX_DT_LIST.ascx.cs @@ -8,921 +8,925 @@ using System.Web.UI.WebControls; namespace GMW.WebUserControls { - public partial class mod_postRX_DT_LIST : System.Web.UI.UserControl + public partial class mod_postRX_DT_LIST : System.Web.UI.UserControl + { + /// + /// Oggetto locale gestione classe datamatrix... + /// + protected DataMatrix DataMatrix_mgr = new DataMatrix(); + /// + /// flusso associato (hard coded) a RX + /// + protected string flusso = "RX"; + /// + /// stato associato (hard coded) a Controllato RX + /// + protected string statoUDC = "ContrRx"; + /// + /// codice evento dell'UDC che si crea + /// + protected string codEventoUdc = "UDC_RX_DTE"; + public event EventHandler eh_reqUpdate; + /// + /// stringa UID univoca + /// + public string uid { - /// - /// flusso associato (hard coded) a RX - /// - protected string flusso = "RX"; - /// - /// stato associato (hard coded) a Controllato RX - /// - protected string statoUDC = "ContrRx"; - /// - /// codice evento dell'UDC che si crea - /// - protected string codEventoUdc = "UDC_RX_DTE"; - public event EventHandler eh_reqUpdate; - /// - /// stringa UID univoca - /// - public string uid + get + { + return this.UniqueID.Replace("$", "_").Replace("-", "_"); + } + } + /// + /// caricamento pagina + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + currParticolare = ""; + lblDTFus.Text = string.Format("{0:ddd dd/MM/yyyy, HH:mm}", dataFus); + lblLinFus.Text = lineaFus; + Postazione.messaggiText = ""; + Postazione.warningText = ""; + fixTipoInput(); + fixCella(); + traduciObj(); + divDetDtx.Visible = false; + showAL(false, false); + } + doChecks(); + } + /// + /// qta pezzi x UDC + /// + public int qta + { + get + { + int qta = 0; + try { - get - { - return this.UniqueID.Replace("$", "_").Replace("-", "_"); - } + qta = Convert.ToInt32(txtQta.Text.Trim()); } - /// - /// caricamento pagina - /// - /// - /// - protected void Page_Load(object sender, EventArgs e) + catch + { } + return qta; + } + set + { + txtQta.Text = value.ToString(); + } + } + /// + /// data fusione impostata SALVATA SU DB... + /// + public DateTime dataFus + { + get + { + DateTime answ = Convert.ToDateTime("1900-01-01"); + try { - if (!Page.IsPostBack) + + answ = Convert.ToDateTime(utils.obj.RTVal(user_std.pagCorrente, "dataFus" + Postazione.currCodLinea)); + } + catch + { } + return answ; + } + set + { + utils.obj.taRTPV.upsert(user_std.pagCorrente, "dataFus" + Postazione.currCodLinea, string.Format("{0:yyyy/MM/dd HH:mm}", value)); + lblDTFus.Text = string.Format("{0:ddd dd/MM/yyyy, HH:mm}", value); + } + } + /// + /// LINEA fusione impostata SALVATA SU DB... + /// + public string lineaFus + { + get + { + string answ = ""; + try + { + + answ = utils.obj.RTVal(user_std.pagCorrente, "lineaFus" + Postazione.currCodLinea); + } + catch + { } + //2016.01.25 se vuoto metto ND!!! + if (answ == "") + { + answ = "ND"; + } + return answ; + } + set + { + utils.obj.taRTPV.upsert(user_std.pagCorrente, "lineaFus" + Postazione.currCodLinea, value); + lblLinFus.Text = value; + } + } + /// + /// aggiorna visualizzazioen dati particolare + /// + private void updatePart() + { + if (currParticolare != "") + { + lblParticolareAttivo.Text = string.Format("{0} {1}", traduci("particSel"), currParticolare); + // aggiungo descrizione del particolare + string descr = ""; + string disegno = ""; + try + { + DS_magazzino.AnagParticolariRow riga = MagClass.magazzino.taAnagPart.likeSearch(currParticolare, memLayer.ML.StringSessionObj("CodCS"))[0]; + descr = riga.DescParticolare; + disegno = string.Format("( {0} )", riga.DisegnoGrezzo); + } + catch + { } + lblDescrAttivo.Text = descr; + lblDisegno.Text = disegno; + } + else + { + lblParticolareAttivo.Text = "..."; + lblDescrAttivo.Text = ""; + lblDisegno.Text = ""; + } + } + /// + /// sistema modalità input + /// + private void fixTipoInput() + { + bool barcodeEnabled = false; + if (rblInputMode.SelectedValue.ToUpper() == "BARCODE") + { + barcodeEnabled = true; + } + Postazione.messaggiText = traduci("attesaInput"); + Postazione.warningText = ""; + divElenco.Visible = !barcodeEnabled; + divBarcode.Visible = barcodeEnabled; + doUpdate(); + } + /// + /// verifica se si debab mostrare un campo ricerca UDC attivo... + /// + private void fixCella() + { + hfCodLinea.Value = Postazione.currCodLinea; + } + /// + /// richiesta (ri)stampa UDC + /// + /// + /// + public void ristampa() + { + MagClass.magazzino.stampaAL(udcReq, Postazione.printer, Request.UserHostName); + // registro ri-stampa UDC + MagClass.magazzino.taSAO.insertQuery(DateTime.Now, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, udcReq, "", "creaAL", "Ri-Stampato AL Rx NT"); + } + /// + /// udc da stampare + /// + protected string udcReq + { + get + { + return memLayer.ML.StringSessionObj("udcSelSAO"); + } + } + /// + /// effettua controlli visibilità + /// + private void doChecks() + { + checkBarcode(); + } + /// + /// sistemo labels oggetti + /// + private void traduciObj() + { + + } + /// + /// wrapper traduzione + /// + /// + /// + public string traduci(object lemma) + { + return user_std.UtSn.Traduci(lemma.ToString()); + } + /// + /// indica se i caratteri vadano forzati a maiuscoli + /// + public bool forceUppercase + { + get + { + return memLayer.ML.confReadBool("forceUppercase"); + } + } + /// + /// Formato Datamatrix della linea selezionata + /// + protected string FormatoDtmxLinea + { + get + { + string answ = ""; + try + { + answ = MagClass.magazzino.taAL.getByKey(Postazione.currCodLinea)[0].FormatoDtmx; + } + catch + { } + return answ; + } + } + /// + /// Formato Datamatrix dell'ultimo barcode letto + /// + protected string FormatoDtmxBarcode + { + get + { + string answ = ""; + try + { + answ = DataMatrix_mgr.taVerifica.GetData(barcodeIn)[0].FormatoDtmx; + } + catch + { } + return answ; + } + } + /// + /// codice particolare da datamatrix + /// + /// bollean: + /// true = utilizza lookUp su tabella dati acquisiti + /// false = prova a decodificare (da formato Dtmx linea) + /// + protected string partByDtmx(bool byTable) + { + string answ = ""; + if (byTable) + { + try + { + answ = DataMatrix_mgr.taDtxAcquisiti.getByKey(barcodeIn)[0].Particolare; // Decode.GetData(barcodeIn, FormatoDtmxLinea)[0].Particolare; + } + catch + { + answ = DataMatrix_mgr.taDecode.GetData(barcodeIn, FormatoDtmxLinea)[0].Particolare; + } + } + else + { + answ = DataMatrix_mgr.taDecode.GetData(barcodeIn, FormatoDtmxLinea)[0].Particolare; + } + return answ; + } + /// + /// valore barcode + /// + public string barcodeIn + { + get + { + return txtBarcode.Text.Trim(); + } + set + { + txtBarcode.Text = value; + } + } + /// + /// controlla se ci sia un barcode + /// + private void checkBarcode() + { + bool okDTL = false; + if (barcodeIn != "") + { + Postazione.messaggiText = string.Format("{0}: {1}", traduci("BCodeIns"), barcodeIn); + switch (MagClass.tipoBCode_L5(barcodeIn)) + { + case tipoCodiceBarcode.DateTime: + // permetto SOLO SE ho già AL --> lo associo + if (rigaCurr != null && rigaCurr.AL != "") { - currParticolare = ""; - lblDTFus.Text = string.Format("{0:ddd dd/MM/yyyy, HH:mm}", dataFus); - lblLinFus.Text = lineaFus; - Postazione.messaggiText = ""; + string AlOk = rigaCurr.AL; + okDTL = getDateTimeLine(barcodeIn, false); + if (okDTL) + { + Postazione.messaggiText = traduci("SetDataFus"); Postazione.warningText = ""; - fixTipoInput(); - fixCella(); - traduciObj(); - divDetDtx.Visible = false; - showAL(false, false); - } - doChecks(); - } - /// - /// qta pezzi x UDC - /// - public int qta - { - get - { - int qta = 0; - try + Postazione.CssClass = "stileComandoOk"; + // aggiunta fusione x tutti UDC dell'AL... + string AlOut = ""; + DataMatrix_mgr.taL2D.addFusione(Postazione.currCodLinea, FormatoDtmxLinea, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, barcodeIn, ref AlOut); + if (AlOk != AlOut) { - qta = Convert.ToInt32(txtQta.Text.Trim()); - } - catch - { } - return qta; - } - set - { - txtQta.Text = value.ToString(); - } - } - /// - /// data fusione impostata SALVATA SU DB... - /// - public DateTime dataFus - { - get - { - DateTime answ = Convert.ToDateTime("1900-01-01"); - try - { - - answ = Convert.ToDateTime(utils.obj.RTVal(user_std.pagCorrente, "dataFus" + Postazione.currCodLinea)); - } - catch - { } - return answ; - } - set - { - utils.obj.taRTPV.upsert(user_std.pagCorrente, "dataFus" + Postazione.currCodLinea, string.Format("{0:yyyy/MM/dd HH:mm}", value)); - lblDTFus.Text = string.Format("{0:ddd dd/MM/yyyy, HH:mm}", value); - } - } - /// - /// LINEA fusione impostata SALVATA SU DB... - /// - public string lineaFus - { - get - { - string answ = ""; - try - { - - answ = utils.obj.RTVal(user_std.pagCorrente, "lineaFus" + Postazione.currCodLinea); - } - catch - { } - //2016.01.25 se vuoto metto ND!!! - if (answ == "") - { - answ = "ND"; - } - return answ; - } - set - { - utils.obj.taRTPV.upsert(user_std.pagCorrente, "lineaFus" + Postazione.currCodLinea, value); - lblLinFus.Text = value; - } - } - /// - /// aggiorna visualizzazioen dati particolare - /// - private void updatePart() - { - if (currParticolare != "") - { - lblParticolareAttivo.Text = string.Format("{0} {1}", traduci("particSel"), currParticolare); - // aggiungo descrizione del particolare - string descr = ""; - string disegno = ""; - try - { - DS_magazzino.AnagParticolariRow riga = MagClass.magazzino.taAnagPart.likeSearch(currParticolare, memLayer.ML.StringSessionObj("CodCS"))[0]; - descr = riga.DescParticolare; - disegno = string.Format("( {0} )", riga.DisegnoGrezzo); - } - catch - { } - lblDescrAttivo.Text = descr; - lblDisegno.Text = disegno; - } - else - { - lblParticolareAttivo.Text = "..."; - lblDescrAttivo.Text = ""; - lblDisegno.Text = ""; - } - } - /// - /// sistema modalità input - /// - private void fixTipoInput() - { - bool barcodeEnabled = false; - if (rblInputMode.SelectedValue.ToUpper() == "BARCODE") - { - barcodeEnabled = true; - } - Postazione.messaggiText = traduci("attesaInput"); - Postazione.warningText = ""; - divElenco.Visible = !barcodeEnabled; - divBarcode.Visible = barcodeEnabled; - doUpdate(); - } - /// - /// verifica se si debab mostrare un campo ricerca UDC attivo... - /// - private void fixCella() - { - hfCodLinea.Value = Postazione.currCodLinea; - } - /// - /// richiesta (ri)stampa UDC - /// - /// - /// - public void ristampa() - { - MagClass.magazzino.stampaAL(udcReq, Postazione.printer, Request.UserHostName); - // registro ri-stampa UDC - MagClass.magazzino.taSAO.insertQuery(DateTime.Now, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, udcReq, "", "creaAL", "Ri-Stampato AL Rx NT"); - } - /// - /// udc da stampare - /// - protected string udcReq - { - get - { - return memLayer.ML.StringSessionObj("udcSelSAO"); - } - } - /// - /// effettua controlli visibilità - /// - private void doChecks() - { - checkBarcode(); - } - /// - /// sistemo labels oggetti - /// - private void traduciObj() - { - - } - /// - /// wrapper traduzione - /// - /// - /// - public string traduci(object lemma) - { - return user_std.UtSn.Traduci(lemma.ToString()); - } - /// - /// indica se i caratteri vadano forzati a maiuscoli - /// - public bool forceUppercase - { - get - { - return memLayer.ML.confReadBool("forceUppercase"); - } - } - /// - /// Formato Datamatrix della linea selezionata - /// - protected string FormatoDtmxLinea - { - get - { - string answ = ""; - try - { - answ = MagClass.magazzino.taAL.getByKey(Postazione.currCodLinea)[0].FormatoDtmx; - } - catch - { } - return answ; - } - } - /// - /// Formato Datamatrix dell'ultimo barcode letto - /// - protected string FormatoDtmxBarcode - { - get - { - string answ = ""; - try - { - answ = DataMatrix.mgr.taVerifica.GetData(barcodeIn)[0].FormatoDtmx; - } - catch - { } - return answ; - } - } - /// - /// codice particolare da datamatrix - /// - /// bollean: - /// true = utilizza lookUp su tabella dati acquisiti - /// false = prova a decodificare (da formato Dtmx linea) - /// - protected string partByDtmx(bool byTable) - { - string answ = ""; - if (byTable) - { - try - { - answ = DataMatrix.mgr.taDtxAcquisiti.getByKey(barcodeIn)[0].Particolare; // Decode.GetData(barcodeIn, FormatoDtmxLinea)[0].Particolare; - } - catch - { - answ = DataMatrix.mgr.taDecode.GetData(barcodeIn, FormatoDtmxLinea)[0].Particolare; - } - } - else - { - answ = DataMatrix.mgr.taDecode.GetData(barcodeIn, FormatoDtmxLinea)[0].Particolare; - } - return answ; - } - /// - /// valore barcode - /// - public string barcodeIn - { - get - { - return txtBarcode.Text.Trim(); - } - set - { - txtBarcode.Text = value; - } - } - /// - /// controlla se ci sia un barcode - /// - private void checkBarcode() - { - bool okDTL = false; - if (barcodeIn != "") - { - Postazione.messaggiText = string.Format("{0}: {1}", traduci("BCodeIns"), barcodeIn); - switch (MagClass.tipoBCode_L5(barcodeIn)) - { - case tipoCodiceBarcode.DateTime: - // permetto SOLO SE ho già AL --> lo associo - if (rigaCurr != null && rigaCurr.AL != "") - { - string AlOk = rigaCurr.AL; - okDTL = getDateTimeLine(barcodeIn, false); - if (okDTL) - { - Postazione.messaggiText = traduci("SetDataFus"); - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoOk"; - // aggiunta fusione x tutti UDC dell'AL... - string AlOut = ""; - DataMatrix.mgr.taL2D.addFusione(Postazione.currCodLinea, FormatoDtmxLinea, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, barcodeIn, ref AlOut); - if (AlOk != AlOut) - { - Postazione.messaggiText = traduci("ERR-BCD-006"); - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoKo"; - } - barcodeIn = ""; - } - else - { - Postazione.messaggiText = traduci("ERR-BCD-004"); - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoKo"; - } - } - else - { - Postazione.messaggiText = traduci("ERR-BCD-005"); - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoKo"; - } - break; - case tipoCodiceBarcode.DateTimeLine: - // permetto SOLO SE ho già AL --> lo associo - if (rigaCurr != null && rigaCurr.AL != "") - { - string AlOk = rigaCurr.AL; - okDTL = getDateTimeLine(barcodeIn, true); - if (okDTL) - { - Postazione.messaggiText = traduci("SetDataFus"); - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoOk"; - // aggiunta fusione x tutti UDC dell'AL... - string AlOut = ""; - DataMatrix.mgr.taL2D.addFusione(Postazione.currCodLinea, FormatoDtmxLinea, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, barcodeIn, ref AlOut); - if (AlOk != AlOut) - { - Postazione.messaggiText = traduci("ERR-BCD-006"); - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoKo"; - } - barcodeIn = ""; - } - else - { - Postazione.messaggiText = traduci("ERR-BCD-004"); - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoKo"; - } - } - else - { - Postazione.messaggiText = traduci("ERR-BCD-005"); - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoKo"; - } - break; - case tipoCodiceBarcode.DataMatrixTrovato: - // controllo che il DTX non sia già assegnato... - if (DataMatrix.mgr.taDtx2UDC.getByDtx(barcodeIn).Rows.Count == 0) - { - // vers 2.9 - // controllo formato datamatrix sia impostato sulla linea (altrimenti errore linea "non battezzata") - if (FormatoDtmxLinea == "") - { - // errore poiché non è stato non specificato tipo Dtmx assegnato alla linea! - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("ERR-DTX-013"); - Postazione.CssClass = "stileComandoKo"; - } - else - { - // verifico formato datamatrix letto sia quello della linea... - if (FormatoDtmxBarcode != FormatoDtmxLinea) - { - // errore corrispondenza formato Dtmx - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("ERR-DTX-014"); - Postazione.CssClass = "stileComandoKo"; - } - else - { - // datamatrix ok: setto css e labels - Postazione.messaggiText = traduci("partSelected"); - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoOk"; - // controllo il particolare da Dtx + check capienza celle - if (Postazione.currCodCella != "") - { - // calcolo particolare! - try - { - // vers 2.9 modifica per multi-datamatrix - currParticolare = partByDtmx(true); - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Errore in decodifica particolare da DataMatrix:{0}dtx:{1}{0}Formato Linea:{2}{0}Eccezione:{0}{3}", Environment.NewLine, barcodeIn, exc), tipoLog.EXCEPTION); - currParticolare = ""; - } - if (currParticolare != "") - { - // dataOra timbratura dtx... - DateTime dataLett = DateTime.Now; - // ricavo dati particolare - string descrPart = ""; - //string disegnoPart = ""; - try - { - DS_magazzino.AnagParticolariRow riga = MagClass.magazzino.taAnagPart.likeSearch(currParticolare, memLayer.ML.StringSessionObj("CodCS"))[0]; - descrPart = riga.DescParticolare; - } - catch - { } - - // 2016.01.25 aggiunta lettura codice x data-ora + linea fusione - // controllo per recuperare da datamatrix i dati di codice linea e data fusione - DS_DataMatrix.v_ElencoDmtxDataTable tabDmtx = DataMatrix.mgr.taVED.getByKey(barcodeIn); - bool marcaturaOk = false; - if (tabDmtx.Rows.Count > 0) - { - // verifica esitoMarcatura - marcaturaOk = (tabDmtx[0].EsitoMarcatura == "OK"); - } - - qta = 1; // tanto poi si ricalcola... - // 2017.02.21 verifico DTX sia OK - if (marcaturaOk) - { - // verifico SE NON HO ancora un record... - bool nuovaLettura = true; - try - { - //nuovaLettura = DataMatrix.mgr.taL2D.getByLineaPart(Postazione.currCodLinea, currParticolare).Rows.Count == 0; - nuovaLettura = rigaCurr == null; - } - catch - { } - // non ho il record --> creo con NUOVO DTX letto (inizio) - if (nuovaLettura) - { - DataMatrix.mgr.taL2D.insertIni(Postazione.currCodLinea, FormatoDtmxLinea, barcodeIn, MagClass.magazzino.CodSoggCurrUser, dataLett); - } - // c'è già un record --> chiudo impostando/aggiornando il record di ULTIMO DMTX - else - { - DataMatrix.mgr.taL2D.updateEnd(Postazione.currCodLinea, FormatoDtmxLinea, barcodeIn, MagClass.magazzino.CodSoggCurrUser, dataLett); - } - - } - else - { - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("ERR-DTX-012"); - Postazione.CssClass = "stileComandoKo"; - } - - // 2017.07.22 svuoto barcodeIn.. - barcodeIn = ""; - } - } - } - } - } - else - { - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("DtxGiaAssegnato"); - Postazione.CssClass = "stileComandoKo"; - } - break; - - default: - Postazione.warningText = traduci("ERR-UNK-001"); - Postazione.CssClass = "stileComandoND"; - break; + Postazione.messaggiText = traduci("ERR-BCD-006"); + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoKo"; } barcodeIn = ""; + } + else + { + Postazione.messaggiText = traduci("ERR-BCD-004"); + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoKo"; + } } else { - Postazione.messaggiText = traduci("AttesaBCode"); - Postazione.CssClass = "stileAttesa"; + Postazione.messaggiText = traduci("ERR-BCD-005"); + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoKo"; } - doUpdate(); - } - /// - /// recupera da barcode dataOra e linea fusione (SE presenti) - /// - /// valore x decodificare dataora - linea - /// SE si debba cercare ANCHE linea... - /// - private bool getDateTimeLine(string val2decode, bool readline) - { - bool okData = false; - bool okLinea = false; - DateTime oldDataFus = new DateTime(1900, 1, 1); - // imposto NUOVA dataora fusione... - string newData = ""; - string newLinea = ""; - // tento di recuperare e verifico validità dei 2 valori separatamente... - try + break; + case tipoCodiceBarcode.DateTimeLine: + // permetto SOLO SE ho già AL --> lo associo + if (rigaCurr != null && rigaCurr.AL != "") { - newData = val2decode.Replace(memLayer.ML.AppConf["prefDateTime"], "").Substring(0, 10); - if (newData != "") + string AlOk = rigaCurr.AL; + okDTL = getDateTimeLine(barcodeIn, true); + if (okDTL) + { + Postazione.messaggiText = traduci("SetDataFus"); + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoOk"; + // aggiunta fusione x tutti UDC dell'AL... + string AlOut = ""; + DataMatrix_mgr.taL2D.addFusione(Postazione.currCodLinea, FormatoDtmxLinea, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, barcodeIn, ref AlOut); + if (AlOk != AlOut) { - dataFus = DateTime.ParseExact(newData, "yyMMddHHmm", CultureInfo.InvariantCulture); - okData = true; + Postazione.messaggiText = traduci("ERR-BCD-006"); + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoKo"; } + barcodeIn = ""; + } + else + { + Postazione.messaggiText = traduci("ERR-BCD-004"); + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoKo"; + } } - catch + else { - dataFus = oldDataFus; + Postazione.messaggiText = traduci("ERR-BCD-005"); + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoKo"; } - if (readline) + break; + case tipoCodiceBarcode.DataMatrixTrovato: + // controllo che il DTX non sia già assegnato... + if (DataMatrix_mgr.taDtx2UDC.getByDtx(barcodeIn).Rows.Count == 0) { - if (okData) + // vers 2.9 + // controllo formato datamatrix sia impostato sulla linea (altrimenti errore linea "non battezzata") + if (FormatoDtmxLinea == "") + { + // errore poiché non è stato non specificato tipo Dtmx assegnato alla linea! + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("ERR-DTX-013"); + Postazione.CssClass = "stileComandoKo"; + } + else + { + // verifico formato datamatrix letto sia quello della linea... + if (FormatoDtmxBarcode != FormatoDtmxLinea) { + // errore corrispondenza formato Dtmx + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("ERR-DTX-014"); + Postazione.CssClass = "stileComandoKo"; + } + else + { + // datamatrix ok: setto css e labels + Postazione.messaggiText = traduci("partSelected"); + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoOk"; + // controllo il particolare da Dtx + check capienza celle + if (Postazione.currCodCella != "") + { + // calcolo particolare! try { - newLinea = val2decode.Replace(memLayer.ML.AppConf["prefDateTime"], "").Substring(10, val2decode.Length - 10 - memLayer.ML.AppConf["prefDateTime"].Length); - if ((newLinea != "") && (DataProxy.obj.taElPost.getByCod(newLinea).Rows.Count > 0)) + // vers 2.9 modifica per multi-datamatrix + currParticolare = partByDtmx(true); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in decodifica particolare da DataMatrix:{0}dtx:{1}{0}Formato Linea:{2}{0}Eccezione:{0}{3}", Environment.NewLine, barcodeIn, exc), tipoLog.EXCEPTION); + currParticolare = ""; + } + if (currParticolare != "") + { + // dataOra timbratura dtx... + DateTime dataLett = DateTime.Now; + // ricavo dati particolare + string descrPart = ""; + //string disegnoPart = ""; + try + { + DS_magazzino.AnagParticolariRow riga = MagClass.magazzino.taAnagPart.likeSearch(currParticolare, memLayer.ML.StringSessionObj("CodCS"))[0]; + descrPart = riga.DescParticolare; + } + catch + { } + + // 2016.01.25 aggiunta lettura codice x data-ora + linea fusione + // controllo per recuperare da datamatrix i dati di codice linea e data fusione + DS_DataMatrix.v_ElencoDmtxDataTable tabDmtx = DataMatrix_mgr.taVED.getByKey(barcodeIn); + bool marcaturaOk = false; + if (tabDmtx.Rows.Count > 0) + { + // verifica esitoMarcatura + marcaturaOk = (tabDmtx[0].EsitoMarcatura == "OK"); + } + + qta = 1; // tanto poi si ricalcola... + // 2017.02.21 verifico DTX sia OK + if (marcaturaOk) + { + // verifico SE NON HO ancora un record... + bool nuovaLettura = true; + try { - lineaFus = newLinea; - okLinea = true; + //nuovaLettura = DataMatrix_mgr.taL2D.getByLineaPart(Postazione.currCodLinea, currParticolare).Rows.Count == 0; + nuovaLettura = rigaCurr == null; } + catch + { } + // non ho il record --> creo con NUOVO DTX letto (inizio) + if (nuovaLettura) + { + DataMatrix_mgr.taL2D.insertIni(Postazione.currCodLinea, FormatoDtmxLinea, barcodeIn, MagClass.magazzino.CodSoggCurrUser, dataLett); + } + // c'è già un record --> chiudo impostando/aggiornando il record di ULTIMO DMTX else { - lineaFus = ""; - dataFus = oldDataFus; + DataMatrix_mgr.taL2D.updateEnd(Postazione.currCodLinea, FormatoDtmxLinea, barcodeIn, MagClass.magazzino.CodSoggCurrUser, dataLett); } + + } + else + { + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("ERR-DTX-012"); + Postazione.CssClass = "stileComandoKo"; + } + + // 2017.07.22 svuoto barcodeIn.. + barcodeIn = ""; } - catch - { - lineaFus = ""; - dataFus = oldDataFus; - } - } - else - { - lineaFus = ""; + } } + } } else { - okLinea = true; + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("DtxGiaAssegnato"); + Postazione.CssClass = "stileComandoKo"; } - return okData && okLinea; - } - /// - /// aggiorna tabella + focus a barcode - /// - public void doUpdate() - { - fixCella(); - grView.DataBind(); - // se selezionato qualcosa mostro dettaglio - divDetDtx.Visible = (grView.SelectedIndex >= 0); - grViewDet.DataBind(); - // fix dataFus - lblDTFus.Text = string.Format("{0:ddd dd/MM/yyyy, HH:mm}", dataFus); - lblLinFus.Text = lineaFus; - // aggiorno le qta! - qta = pezziUdc; - // update particolare - updatePart(); - verificaBtnStampa(); - txtBarcode.Focus(); - } - /// - /// reset della selezione - /// - /// - /// - protected void btnReset_Click(object sender, EventArgs e) - { - resetSelezione(); - } - /// - /// resetta la selezione dei valori in caso di modifiche su altri controlli - /// - public void resetSelezione() - { - grView.SelectedIndex = -1; - doUpdate(); - } - /// - /// effettua reset dati - /// - private void doResetData() - { - // resetto i dati QtaTot e particolare... - doChecks(); - } - /// - /// indica il codice articolo correntemente selezionato - /// - protected string currParticolare - { - get - { - return memLayer.ML.StringSessionObj(string.Format("currParticolare_{0}", uid)); - } - set - { - memLayer.ML.setSessionVal(string.Format("currParticolare_{0}", uid), value, memLayer.ML.confReadBool("keepParticolareSel")); - } - } - /// - /// num pezzi dell'intero AL (temporaneo) - /// - public int pezziUdc - { - get - { - int answ = 0; - // calcolo qta a partire da particolare selezionato... - try - { - //DS_DataMatrix.Linea2Dtx_IEDataTable tabL2D = DataMatrix.mgr.taL2D.getByLineaPart(Postazione.currCodLinea, currParticolare); - //if (tabL2D.Rows.Count > 0) - //{ - // answ = tabL2D[0].Qta; - //} - DS_DataMatrix.Linea2Dtx_IERow riga = rigaCurr; - if (riga != null) - { - answ = riga.Qta; - } - } - catch (Exception exc) - { - if (memLayer.ML.confReadInt("_logLevel") > 5) logger.lg.scriviLog(exc.ToString(), tipoLog.EXCEPTION); - answ = 0; - } - return answ; - } - } - /// - /// traduce gli header delle colonne - /// - /// - /// - protected void grView_DataBound(object sender, EventArgs e) - { - if (grView.Rows.Count > 0) - { - LinkButton lb; - // aggiorno gli headers - foreach (TableCell cella in grView.HeaderRow.Cells) - { - try - { - lb = (LinkButton)cella.Controls[0]; - lb.Text = traduci(lb.Text); - } - catch - { } - } - int totRecord = grView.Rows.Count + grView.PageSize * (grView.PageCount - 1); - } - } - /// - /// cambiato tipo di richiesta di input - /// - /// - /// - protected void rblInputMode_SelectedIndexChanged(object sender, EventArgs e) - { - fixTipoInput(); - } - /// - /// salvo il particolare selezionato... - /// - /// - /// - protected void lbtAddPart_Click(object sender, EventArgs e) - { - // imposto il particolare corrente - currParticolare = ddlPart.SelectedValue; - Postazione.messaggiText = traduci("partSelected"); - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoOk"; - // leggo la qta dell'ultimo UDC del particolare, SE C'E', e la imposto... - if (pezziUdc > 0) - { - qta = pezziUdc; - } - else // rimette default - { - qta = memLayer.ML.cdvi("QtaImballoRX"); - } - doUpdate(); - } + break; - /// - /// evento selezione: ricarico dati! - /// - /// - /// - protected void grView_SelectedIndexChanged(object sender, EventArgs e) - { - doUpdate(); - } - /// - /// Numero cesta inserito - /// - public string numCesta - { - get - { - return txtCesta.Text.Trim(); - } - set - { - txtCesta.Text = value; - } - } - /// - /// evento cambio num cesta/grappolo - /// - /// - /// - protected void txtCesta_TextChanged(object sender, EventArgs e) - { - txtCesta.Text = txtCesta.Text.ToUpper().Trim().PadLeft(4, '0').Substring(0, 4); - doUpdate(); - } - /// - /// Restituisce record riga corrente - /// - protected DS_DataMatrix.Linea2Dtx_IERow rigaCurr - { - get - { - DS_DataMatrix.Linea2Dtx_IERow answ = null; - DS_DataMatrix.Linea2Dtx_IEDataTable tab = null; - try - { - - tab = DataMatrix.mgr.taL2D.getByLineFormato(Postazione.currCodLinea, FormatoDtmxLinea); - if (tab.Rows.Count > 0) - { - answ = tab[0]; - } - } - catch - { } - return answ; - } - } - /// - /// verifica visibilità btn stampa UDC - /// - private void verificaBtnStampa() - { - // SOLO SE ho la riga.. - if (rigaCurr != null) - { - DS_DataMatrix.Linea2Dtx_IERow riga = rigaCurr; - // controllo cosa posso visualizzare tra CREA UDC e STAMPA AL - bool hasAL = false; - bool hasQta = false; - bool hasPmUm = false; - try - { - if (riga.AL != "") hasAL = true; - if (riga.Qta > 0) hasQta = true; - if (riga.DTX_INI != "" && riga.DTX_END != "") hasPmUm = true; - } - catch - { } - // se ho AL mostro stampa! - showAL(hasQta && hasPmUm && numCesta != "", hasAL); - } - } - /// - /// Determina se mostrare creazione/stampa AL - /// - /// - /// - private void showAL(bool showCreate, bool showPrint) - { - divNote.Visible = showCreate || showPrint; - lbtGeneraAl.Visible = showCreate && !showPrint; - lbtStampaAL.Visible = showPrint; - txtCesta.Enabled = !showPrint; - } - - /// - /// genera e stampa AL - /// - /// - /// - protected void lbtGeneraAl_Click(object sender, EventArgs e) - { - // verifico postazione sia valida... - if (Postazione.name != "" && Postazione.IP != "" && Postazione.currCodCella != "") - { - /* generazione AL DA RIVEDERE */ - string AL = ""; - string noteTrim = txtNote.Text.Trim(); - // creazione AL ed associazione UDC / spostamento... - try - { - // creo UDC ed AL - AL = MagClass.magazzino.creaAssociaAlUdcRxDt(Postazione.currCodLinea, FormatoDtmxLinea, codEventoUdc, statoUDC, tipoAL.AL_RxDt, Postazione.currCodCella, MagClass.magazzino.CodSoggCurrUser, DateTime.Now.Year, numCesta, noteTrim); - } - catch - { } - if (AL != "") - { - Postazione.CssClass = "stileComandoOk"; - Postazione.warningText = ""; - Postazione.messaggiText = traduci("GEN-AL-UDC-OK"); - Response.Redirect(user_std.pagCorrente); - } - } - else - { - // ricarico che mi manca postazione! - Postazione.CssClass = "stileAttesa"; - Postazione.warningText = traduci("ERR-POS-001"); - Postazione.messaggiText = ""; - Response.Redirect(user_std.pagCorrente); - } - } - - protected void ods_Deleted(object sender, ObjectDataSourceStatusEventArgs e) - { - Postazione.CssClass = "stileAttesa"; - Postazione.warningText = ""; - Postazione.messaggiText = ""; - currParticolare = ""; - qta = 0; - doUpdate(); - eh_reqUpdate?.Invoke(this, new EventArgs()); - } - - protected void lbtStampaAL_Click(object sender, EventArgs e) - { - // verifico postazione sia valida... - if (Postazione.name != "" && Postazione.IP != "" && Postazione.currCodCella != "") - { - string noteTrim = txtNote.Text.Trim(); - /* stampa AL */ - string AlOut = ""; - string AL = rigaCurr.AL; - // sistemo pre-stampa - try - { - // update pre-stampa... - DataMatrix.mgr.taL2D.sistemaPreStampa(Postazione.currCodLinea, FormatoDtmxLinea, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, codEventoUdc, noteTrim, ref AlOut); - } - catch - { } - // se gli AL corrispondono... - if (AL != AlOut) - { - Postazione.messaggiText = traduci("ERR-BCD-006"); - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoKo"; - } - else - { - // lancio stampa - MagClass.magazzino.stampaAL(AL, Postazione.printer, Request.UserHostName); - // registro creazione AL - MagClass.magazzino.taSAO.insertQuery(DateTime.Now, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, AL, "", "creaAL", string.Format("Creato AL RX su linea {0}, note: {1} ", Postazione.currCodLinea, noteTrim)); - Postazione.CssClass = "stileAttesa"; - Postazione.warningText = ""; - Postazione.messaggiText = traduci("cartAlStampato"); - txtCesta.Text = ""; - // elimino note - txtNote.Text = ""; - // resetto particolare... - currParticolare = ""; - qta = 0; - } - Response.Redirect(user_std.pagCorrente); - } - else - { - // ricarico che mi manca postazione! - Postazione.CssClass = "stileAttesa"; - Postazione.warningText = traduci("ERR-POS-001"); - Postazione.messaggiText = ""; - Response.Redirect(user_std.pagCorrente); - } + default: + Postazione.warningText = traduci("ERR-UNK-001"); + Postazione.CssClass = "stileComandoND"; + break; } + barcodeIn = ""; + } + else + { + Postazione.messaggiText = traduci("AttesaBCode"); + Postazione.CssClass = "stileAttesa"; + } + doUpdate(); } + /// + /// recupera da barcode dataOra e linea fusione (SE presenti) + /// + /// valore x decodificare dataora - linea + /// SE si debba cercare ANCHE linea... + /// + private bool getDateTimeLine(string val2decode, bool readline) + { + bool okData = false; + bool okLinea = false; + DateTime oldDataFus = new DateTime(1900, 1, 1); + // imposto NUOVA dataora fusione... + string newData = ""; + string newLinea = ""; + // tento di recuperare e verifico validità dei 2 valori separatamente... + try + { + newData = val2decode.Replace(memLayer.ML.AppConf["prefDateTime"], "").Substring(0, 10); + if (newData != "") + { + dataFus = DateTime.ParseExact(newData, "yyMMddHHmm", CultureInfo.InvariantCulture); + okData = true; + } + } + catch + { + dataFus = oldDataFus; + } + if (readline) + { + if (okData) + { + try + { + newLinea = val2decode.Replace(memLayer.ML.AppConf["prefDateTime"], "").Substring(10, val2decode.Length - 10 - memLayer.ML.AppConf["prefDateTime"].Length); + if ((newLinea != "") && (DataProxy.obj.taElPost.getByCod(newLinea).Rows.Count > 0)) + { + lineaFus = newLinea; + okLinea = true; + } + else + { + lineaFus = ""; + dataFus = oldDataFus; + } + } + catch + { + lineaFus = ""; + dataFus = oldDataFus; + } + } + else + { + lineaFus = ""; + } + } + else + { + okLinea = true; + } + return okData && okLinea; + } + /// + /// aggiorna tabella + focus a barcode + /// + public void doUpdate() + { + fixCella(); + grView.DataBind(); + // se selezionato qualcosa mostro dettaglio + divDetDtx.Visible = (grView.SelectedIndex >= 0); + grViewDet.DataBind(); + // fix dataFus + lblDTFus.Text = string.Format("{0:ddd dd/MM/yyyy, HH:mm}", dataFus); + lblLinFus.Text = lineaFus; + // aggiorno le qta! + qta = pezziUdc; + // update particolare + updatePart(); + verificaBtnStampa(); + txtBarcode.Focus(); + } + /// + /// reset della selezione + /// + /// + /// + protected void btnReset_Click(object sender, EventArgs e) + { + resetSelezione(); + } + /// + /// resetta la selezione dei valori in caso di modifiche su altri controlli + /// + public void resetSelezione() + { + grView.SelectedIndex = -1; + doUpdate(); + } + /// + /// effettua reset dati + /// + private void doResetData() + { + // resetto i dati QtaTot e particolare... + doChecks(); + } + /// + /// indica il codice articolo correntemente selezionato + /// + protected string currParticolare + { + get + { + return memLayer.ML.StringSessionObj(string.Format("currParticolare_{0}", uid)); + } + set + { + memLayer.ML.setSessionVal(string.Format("currParticolare_{0}", uid), value, memLayer.ML.confReadBool("keepParticolareSel")); + } + } + /// + /// num pezzi dell'intero AL (temporaneo) + /// + public int pezziUdc + { + get + { + int answ = 0; + // calcolo qta a partire da particolare selezionato... + try + { + //DS_DataMatrix.Linea2Dtx_IEDataTable tabL2D = DataMatrix_mgr.taL2D.getByLineaPart(Postazione.currCodLinea, currParticolare); + //if (tabL2D.Rows.Count > 0) + //{ + // answ = tabL2D[0].Qta; + //} + DS_DataMatrix.Linea2Dtx_IERow riga = rigaCurr; + if (riga != null) + { + answ = riga.Qta; + } + } + catch (Exception exc) + { + if (memLayer.ML.confReadInt("_logLevel") > 5) logger.lg.scriviLog(exc.ToString(), tipoLog.EXCEPTION); + answ = 0; + } + return answ; + } + } + /// + /// traduce gli header delle colonne + /// + /// + /// + protected void grView_DataBound(object sender, EventArgs e) + { + if (grView.Rows.Count > 0) + { + LinkButton lb; + // aggiorno gli headers + foreach (TableCell cella in grView.HeaderRow.Cells) + { + try + { + lb = (LinkButton)cella.Controls[0]; + lb.Text = traduci(lb.Text); + } + catch + { } + } + int totRecord = grView.Rows.Count + grView.PageSize * (grView.PageCount - 1); + } + } + /// + /// cambiato tipo di richiesta di input + /// + /// + /// + protected void rblInputMode_SelectedIndexChanged(object sender, EventArgs e) + { + fixTipoInput(); + } + /// + /// salvo il particolare selezionato... + /// + /// + /// + protected void lbtAddPart_Click(object sender, EventArgs e) + { + // imposto il particolare corrente + currParticolare = ddlPart.SelectedValue; + Postazione.messaggiText = traduci("partSelected"); + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoOk"; + // leggo la qta dell'ultimo UDC del particolare, SE C'E', e la imposto... + if (pezziUdc > 0) + { + qta = pezziUdc; + } + else // rimette default + { + qta = memLayer.ML.cdvi("QtaImballoRX"); + } + doUpdate(); + } + + /// + /// evento selezione: ricarico dati! + /// + /// + /// + protected void grView_SelectedIndexChanged(object sender, EventArgs e) + { + doUpdate(); + } + /// + /// Numero cesta inserito + /// + public string numCesta + { + get + { + return txtCesta.Text.Trim(); + } + set + { + txtCesta.Text = value; + } + } + /// + /// evento cambio num cesta/grappolo + /// + /// + /// + protected void txtCesta_TextChanged(object sender, EventArgs e) + { + txtCesta.Text = txtCesta.Text.ToUpper().Trim().PadLeft(4, '0').Substring(0, 4); + doUpdate(); + } + /// + /// Restituisce record riga corrente + /// + protected DS_DataMatrix.Linea2Dtx_IERow rigaCurr + { + get + { + DS_DataMatrix.Linea2Dtx_IERow answ = null; + DS_DataMatrix.Linea2Dtx_IEDataTable tab = null; + try + { + + tab = DataMatrix_mgr.taL2D.getByLineFormato(Postazione.currCodLinea, FormatoDtmxLinea); + if (tab.Rows.Count > 0) + { + answ = tab[0]; + } + } + catch + { } + return answ; + } + } + /// + /// verifica visibilità btn stampa UDC + /// + private void verificaBtnStampa() + { + // SOLO SE ho la riga.. + if (rigaCurr != null) + { + DS_DataMatrix.Linea2Dtx_IERow riga = rigaCurr; + // controllo cosa posso visualizzare tra CREA UDC e STAMPA AL + bool hasAL = false; + bool hasQta = false; + bool hasPmUm = false; + try + { + if (riga.AL != "") hasAL = true; + if (riga.Qta > 0) hasQta = true; + if (riga.DTX_INI != "" && riga.DTX_END != "") hasPmUm = true; + } + catch + { } + // se ho AL mostro stampa! + showAL(hasQta && hasPmUm && numCesta != "", hasAL); + } + } + /// + /// Determina se mostrare creazione/stampa AL + /// + /// + /// + private void showAL(bool showCreate, bool showPrint) + { + divNote.Visible = showCreate || showPrint; + lbtGeneraAl.Visible = showCreate && !showPrint; + lbtStampaAL.Visible = showPrint; + txtCesta.Enabled = !showPrint; + } + + /// + /// genera e stampa AL + /// + /// + /// + protected void lbtGeneraAl_Click(object sender, EventArgs e) + { + // verifico postazione sia valida... + if (Postazione.name != "" && Postazione.IP != "" && Postazione.currCodCella != "") + { + /* generazione AL DA RIVEDERE */ + string AL = ""; + string noteTrim = txtNote.Text.Trim(); + // creazione AL ed associazione UDC / spostamento... + try + { + // creo UDC ed AL + AL = MagClass.magazzino.creaAssociaAlUdcRxDt(Postazione.currCodLinea, FormatoDtmxLinea, codEventoUdc, statoUDC, tipoAL.AL_RxDt, Postazione.currCodCella, MagClass.magazzino.CodSoggCurrUser, DateTime.Now.Year, numCesta, noteTrim); + } + catch + { } + if (AL != "") + { + Postazione.CssClass = "stileComandoOk"; + Postazione.warningText = ""; + Postazione.messaggiText = traduci("GEN-AL-UDC-OK"); + Response.Redirect(user_std.pagCorrente); + } + } + else + { + // ricarico che mi manca postazione! + Postazione.CssClass = "stileAttesa"; + Postazione.warningText = traduci("ERR-POS-001"); + Postazione.messaggiText = ""; + Response.Redirect(user_std.pagCorrente); + } + } + + protected void ods_Deleted(object sender, ObjectDataSourceStatusEventArgs e) + { + Postazione.CssClass = "stileAttesa"; + Postazione.warningText = ""; + Postazione.messaggiText = ""; + currParticolare = ""; + qta = 0; + doUpdate(); + eh_reqUpdate?.Invoke(this, new EventArgs()); + } + + protected void lbtStampaAL_Click(object sender, EventArgs e) + { + // verifico postazione sia valida... + if (Postazione.name != "" && Postazione.IP != "" && Postazione.currCodCella != "") + { + string noteTrim = txtNote.Text.Trim(); + /* stampa AL */ + string AlOut = ""; + string AL = rigaCurr.AL; + // sistemo pre-stampa + try + { + // update pre-stampa... + DataMatrix_mgr.taL2D.sistemaPreStampa(Postazione.currCodLinea, FormatoDtmxLinea, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, codEventoUdc, noteTrim, ref AlOut); + } + catch + { } + // se gli AL corrispondono... + if (AL != AlOut) + { + Postazione.messaggiText = traduci("ERR-BCD-006"); + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoKo"; + } + else + { + // lancio stampa + MagClass.magazzino.stampaAL(AL, Postazione.printer, Request.UserHostName); + // registro creazione AL + MagClass.magazzino.taSAO.insertQuery(DateTime.Now, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, AL, "", "creaAL", string.Format("Creato AL RX su linea {0}, note: {1} ", Postazione.currCodLinea, noteTrim)); + Postazione.CssClass = "stileAttesa"; + Postazione.warningText = ""; + Postazione.messaggiText = traduci("cartAlStampato"); + txtCesta.Text = ""; + // elimino note + txtNote.Text = ""; + // resetto particolare... + currParticolare = ""; + qta = 0; + } + Response.Redirect(user_std.pagCorrente); + } + else + { + // ricarico che mi manca postazione! + Postazione.CssClass = "stileAttesa"; + Postazione.warningText = traduci("ERR-POS-001"); + Postazione.messaggiText = ""; + Response.Redirect(user_std.pagCorrente); + } + } + } } \ No newline at end of file diff --git a/GMW/WebUserControls/mod_post_B48.ascx.cs b/GMW/WebUserControls/mod_post_B48.ascx.cs index d00f53b1..0f07a23d 100644 --- a/GMW/WebUserControls/mod_post_B48.ascx.cs +++ b/GMW/WebUserControls/mod_post_B48.ascx.cs @@ -5,1081 +5,1084 @@ using System.Web.UI; namespace GMW.WebUserControls { - public partial class mod_post_B48 : System.Web.UI.UserControl + public partial class mod_post_B48 : System.Web.UI.UserControl + { + /// + /// Oggetto locale gestione classe datamatrix... + /// + protected DataMatrix DataMatrix_mgr = new DataMatrix(); + /// + /// flusso associato (hard coded) a FI + /// + protected string flusso = "FI"; + /// + /// stato associato (hard coded) a RX in GitterBox + /// + protected string statoUdcOut = "FinRx"; + /// + /// codice evento dell'UDC che si crea + /// + protected string codEventoUdcOut = "UDC_RXF_DT"; + /// + /// Qta imbalo desiderato + /// + protected int QtaImballoRXFin { - - /// - /// flusso associato (hard coded) a FI - /// - protected string flusso = "FI"; - /// - /// stato associato (hard coded) a RX in GitterBox - /// - protected string statoUdcOut = "FinRx"; - /// - /// codice evento dell'UDC che si crea - /// - protected string codEventoUdcOut = "UDC_RXF_DT"; - /// - /// Qta imbalo desiderato - /// - protected int QtaImballoRXFin - { - get - { - return memLayer.ML.cdvi("QtaImballoRXFin"); - } - } - - - /// - /// stringa UID univoca - /// - public string uid - { - get - { - return this.UniqueID.Replace("$", "_").Replace("-", "_"); - } - } - - /// - /// flusso associato (hard coded) ad ancestor TT (Trattati) - /// - protected string flussoAnc = "TT"; - /// - /// flusso associato (hard coded) a temporaneo TL (Trattati/Liquidi) - /// - protected string flussoTemp = "TL"; - /// - /// stato associato (hard coded) a UDC in IN: Trattato da travaso AL - /// - protected string statoUdcIn = "Tratt"; - /// - /// codice evento dell'UDC temporaneo (IN) che si crea - /// - protected string codEventoUdcIn = "UDC_TRATT"; - - protected string cssOk = "stileComandoOk"; - protected string cssErr = "stileComandoKo"; - protected string cssWait = "stileComandoND"; - protected string cssAtt = "stileAttesa"; - protected string cssWarn = "stileComandoWarn"; - protected string cssAdd = "stileComandoAdd"; - public event EventHandler eh_reqUpdate; - - /// - /// ultimo valore barcode letto (x confronto conferme doppio input...) - /// - protected string lastBarcodeIn - { - get - { - return memLayer.ML.StringSessionObj(string.Format("lastBCode_{0}", uid)); - } - set - { - memLayer.ML.setSessionVal(string.Format("lastBCode_{0}", uid), value, false); - } - } - /// - /// Codice AL della cella corrente - /// - protected string destAL - { - get - { - return lblDestAL.Text.Trim(); - } - set - { - lblDestAL.Text = value; - } - } - /// - /// Codice AL associato alla cella corrente... - /// - protected string AlByCella - { - get - { - string answ = ""; - try - { - answ = string.Format("ALF00{0}", Postazione.currCodCella); - // controllo se esista AL sennò lo creo... - if (MagClass.magazzino.taEA.getByAL(answ).Rows.Count == 0) - { - MagClass.magazzino.taEA.Insert(answ, true, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, "", ""); - } - } - catch - { } - return answ; - } - } - /// - /// indica il codice articolo correntemente selezionato - /// - protected string currParticolare - { - get - { - return memLayer.ML.StringSessionObj(string.Format("currParticolare_{0}", uid)); - } - set - { - memLayer.ML.setSessionVal(string.Format("currParticolare_{0}", uid), value, memLayer.ML.confReadBool("keepParticolareSel")); - } - } - /// - /// indica UDC correntemente selezionato - /// - protected string currUDC - { - get - { - return memLayer.ML.StringSessionObj(string.Format("UDC_{0}", uid)); - } - set - { - memLayer.ML.setSessionVal(string.Format("UDC_{0}", uid), value, memLayer.ML.confReadBool("keepParticolareSel")); - } - } - /// - /// num pezzi dell'ultimo UDC di uguale particolare e stato fatto... - /// - public int pezziUdc - { - get - { - int answ = 0; - try - { - answ = (int)MagClass.magazzino.taCartellini.getLastByParticolareStatoConImb(memLayer.ML.StringSessionObj("CodCS"), currParticolare, statoUdcOut)[0].Qta; - } - catch - { - answ = memLayer.ML.cdvi("QtaImballoFiniti"); - } - return answ; - } - } - /// - /// cod imballo dell'ultimo UDC del particolare generato - /// - public string lastCodImb - { - get - { - string answ = ""; - try - { - answ = MagClass.magazzino.taCartellini.getLastByParticolareStatoConImb(memLayer.ML.StringSessionObj("CodCS"), currParticolare, statoUdcOut)[0].CodImballo; - } - catch - { - answ = memLayer.ML.cdv("CodImballoFiniti"); - } - return answ; - } - } - /// - /// qta pezzi x UDC - /// - public int qta - { - get - { - int qta = 0; - try - { - qta = Convert.ToInt32(txtQta.Text.Trim()); - } - catch - { } - return qta; - } - set - { - txtQta.Text = value.ToString(); - } - } - /// - /// wrapper traduzione - /// - /// - /// - public string traduci(object lemma) - { - return user_std.UtSn.Traduci(lemma.ToString()); - } - /// - /// indica se i caratteri vadano forzati a maiuscoli - /// - public bool forceUppercase - { - get - { - return memLayer.ML.confReadBool("forceUppercase"); - } - } - /// - /// Formato Datamatrix della linea selezionata - /// - protected string FormatoDtmxLinea - { - get - { - string answ = ""; - try - { - answ = MagClass.magazzino.taAL.getByKey(Postazione.currCodLinea)[0].FormatoDtmx; - } - catch - { } - return answ; - } - } - /// - /// Formato Datamatrix dell'ultimo barcode letto - /// - protected string FormatoDtmxBarcode - { - get - { - string answ = ""; - try - { - answ = DataMatrix.mgr.taVerifica.GetData(barcodeIn)[0].FormatoDtmx; - } - catch - { } - return answ; - } - } - /// - /// codice particolare da datamatrix - /// - /// bollean: - /// true = utilizza lookUp su tabella dati acquisiti - /// false = prova a decodificare (da formato Dtmx linea) - /// - protected string partByDtmx(bool byTable) - { - string answ = ""; - if (byTable) - { - answ = DataMatrix.mgr.taDtxAcquisiti.getByKey(barcodeIn)[0].Particolare; // Decode.GetData(barcodeIn, FormatoDtmxLinea)[0].Particolare; - } - else - { - answ = DataMatrix.mgr.taDecode.GetData(barcodeIn, FormatoDtmxLinea)[0].Particolare; - } - return answ; - } - /// - /// valore barcode - /// - public string barcodeIn - { - get - { - return txtBarcode.Text.Trim(); - } - set - { - txtBarcode.Text = value; - } - } - /// - /// caricamento pagina - /// - /// - /// - protected void Page_Load(object sender, EventArgs e) - { - if (!Page.IsPostBack) - { - Postazione.messaggiText = ""; - Postazione.warningText = ""; - qta = 0; - currUDC = ""; - forceDelete = false; - setDefaultVal(); - checkNumKeyIn(); - } - setVisibility(!Page.IsPostBack); - checkBarcode(); - } - /// - /// verifico se ci sia in sessione un input da NumKeyb e nel caso lometto in barcodeIn e processo... - /// - private void checkNumKeyIn() - { - if (memLayer.ML.isInSessionObject("numKeyIn")) - { - barcodeIn = memLayer.ML.StringSessionObj("numKeyIn"); - // svuoto valore in sessione... - memLayer.ML.emptySessionVal("numKeyIn"); - // controllo barcode... - checkBarcode(); - } - } - /// - /// imposta i valori di default ad avvio - /// - private void setDefaultVal() - { - destAL = AlByCella; - } - /// - /// sistema modalità input - /// - /// forza reload imballo? - private void setVisibility(bool forceReloadImb) - { - bool showBtn = false; - // controllo btn quantità - if (grViewDest.SelectedIndex >= 0) - { - showBtn = true; - } - divQta.Visible = showBtn; - divImballi.Visible = showBtn; - if (showBtn && forceReloadImb) - { - selezionaImballo(); - } - } - /// - /// reset maschera... - /// - protected void doReset() - { - // resetta - lastBarcodeIn = ""; - Postazione.messaggiText = ""; - Postazione.warningText = ""; - Postazione.CssClass = cssAtt; - doUpdate(); - } - /// - /// Verifica l'AL se sia ok x procedere: - /// - Attivo - /// - /// - /// T/L - /// - protected bool checkAL(string AL, string tipo) - { - bool answ = false; - try - { - answ = MagClass.magazzino.taEA.getByAL_TipoAttivo(AL, tipo).Rows.Count > 0; - } - catch - { } - if (answ) - { - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoOk"; - } - else - { - Postazione.warningText = traduci("ErroreAlNonTtAttivo"); - Postazione.CssClass = "stileComandoKo"; - } - - return answ; - } - /// - /// Verifica l'AL se abbia datamatrix - /// - /// - /// - protected bool checkDtxAL(string AL) - { - bool answ = false; - try - { - answ = DataMatrix.mgr.taDtx2UDC.getByAL(AL).Rows.Count > 0; - } - catch - { } - if (!answ) - { - Postazione.warningText = traduci("ErroreAlNonDtx"); - Postazione.CssClass = "stileComandoKo"; - } - else - { - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoOk"; - } - return answ; - } - /// - /// controlla se ci sia un barcode e cosa farne... - /// - private void checkBarcode() - { - if (barcodeIn != "") - { - Postazione.messaggiText = string.Format("{0}: {1}", traduci("BCodeIns"), barcodeIn); - tipoCodiceBarcode tipoBC = MagClass.tipoBCode_L5(barcodeIn); - switch (tipoBC) - { - case tipoCodiceBarcode.Operatore: - // calcolo matricola utente - int MatrUtente = -1; - string preCodSogg = memLayer.ML.AppConf["prefCodSogg"]; - if (barcodeIn.StartsWith(preCodSogg)) - { - MatrUtente = DataProxy.obj.taTrascSogg.getByKey(barcodeIn, 0)[0].CodMatricola; - } - else - { - MatrUtente = Convert.ToInt32(barcodeIn); - } - if (MatrUtente >= 0) - { - // salvo in sessione operatore con AUTH - OpAuth.startOpAuth(MatrUtente); - // mostro che ho autorizzato... - Postazione.messaggiText += traduci("userAuthRec"); - Postazione.CssClass = "stileComandoOk"; - Response.Redirect(user_std.pagCorrente); - } - else - { - Postazione.messaggiText += " - codice non riconosciuto!"; - Postazione.CssClass = "stileComandoND"; - } - break; - case tipoCodiceBarcode.Imballo: - // cerco di selezionare! - try - { - ddlImballi.SelectedValue = barcodeIn; - } - catch - { - Postazione.warningText = traduci("ERR-IMB-001"); - Postazione.CssClass = "stileComandoKo"; - } - break; - case tipoCodiceBarcode.Comando: - // se è reset cancello tutto! - if (barcodeIn == memLayer.ML.cdv("cmdReset")) - { - doReset(); - } - break; - case tipoCodiceBarcode.UDC: - // controllo di avere destAL valido, sennò ricarico pagina... - if (destAL.Length > 5) - { - // controllo se sia un UDC valido... - if (MagClass.magazzino.checkUDC(barcodeIn)) - { - // controllo se sia un UDC di finiti LIQ in posizione 4... - DS_magazzino.ElencoCartelliniRow cartUDC = MagClass.magazzino.taCartellini.getByUdc(barcodeIn)[0]; - if (cartUDC.CodStato == statoUdcOut && cartUDC.IdxPosizione == memLayer.ML.cdvi("IdxPosizioneFiniti")) - { - // controllo NON ci sia già un UDC di pari particolare caricato nella postazione corrente (non posso avere 2 UDC a pari particolare da riempire...) - if (MagClass.magazzino.taCartellini.getByParticolareAL(cartUDC.Particolare, destAL).Rows.Count == 0) - { - // controllo NON sia UDC in LDP e già PRELEVATO - if (MagClass.magazzino.taRigheListePrelievo.getByUdc(barcodeIn).Select("Prelevato = 1").Length == 0) - { - // controllo NON abbia blocco x FinDtx... - if (MagClass.magazzino.udcHasAttr(barcodeIn, "BL")) - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-LIQ-006"); - Postazione.CssClass = cssErr; - } - else - { - // se è ok RICARICO UDC in posizione corrente... - bool fatto = MagClass.magazzino.finRxRiprendiInCaricoUDC(barcodeIn, MagClass.magazzino.CodSoggCurrUser, destAL, Postazione.currIdxCella); - if (fatto) - { - Postazione.messaggiText = traduci("RiCaricatoUdcLiq"); - Postazione.warningText = ""; - Postazione.CssClass = cssOk; - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-LIQ-001"); - Postazione.CssClass = cssErr; - } - } - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-LIQ-005"); - Postazione.CssClass = cssErr; - } - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-LIQ-004"); - Postazione.CssClass = cssErr; - } - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-LIQ-002"); - Postazione.CssClass = cssErr; - } - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-LIQ-003"); - Postazione.CssClass = cssErr; - } - } - else - { - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-ALF-001"); - Postazione.CssClass = cssErr; - } - break; - case tipoCodiceBarcode.DataMatrixTrovato: - // ciclo controllo x B48 - string NewUDC = ""; - // verifica preliminare: se Dtx OK procedo, se è KO NON LO CONSIDERO PROPRIO - bool isOk = false; - // controllo anche NC - bool isOkNc = false; - // controllo sia libero (= non assegnato) - bool isFree= false; - try - { - isOk = DataMatrix.mgr.taVerifica.GetData(barcodeIn)[0].StatoDtx == "OK"; - } - catch - { } - try - { - isOkNc = DataMatrix.mgr.taAtt2Dtx.getByDtx(barcodeIn).Select("CodAttr = 'XF'").Length == 0; - } - catch - { } - try - { - isFree = DataMatrix.mgr.taDtx2UDC.getByDtx(barcodeIn).Rows.Count == 0; - } - catch - { } - // controlli x procedere - if (!isOkNc && !chkDtxMode.Checked) - { - // non accetto Dtx e mostro errore - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("ERR-DTX-016"); - Postazione.CssClass = cssErr; - } - else if (!isOk && !chkDtxMode.Checked) - { - // non accetto Dtx e mostro errore - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("ERR-DTX-012"); - Postazione.CssClass = cssErr; - } - else if (!isFree && !chkDtxMode.Checked) - { - // non accetto Dtx e mostro errore - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("ERR-DTX-017"); - Postazione.CssClass = cssErr; - } - else if (isFree && chkDtxMode.Checked) - { - // non accetto Dtx e mostro errore - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("ERR-DTX-018"); - Postazione.CssClass = cssErr; - } - else // PROCEDO!!! - { - - // controllo formato datamatrix sia impostato sulla linea (altrimenti errore linea "non battezzata") - if (FormatoDtmxLinea == "") - { - // errore poiché non è stato non specificato tipo Dtmx assegnato alla linea! - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("ERR-DTX-013"); - Postazione.CssClass = "stileComandoKo"; - } - else - { - // verifico formato datamatrix letto sia quello della linea... - if (FormatoDtmxBarcode != FormatoDtmxLinea) - { - // errore corrispondenza formato Dtmx - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("ERR-DTX-014"); - Postazione.CssClass = "stileComandoKo"; - } - else - { - // calcolo particolare + UDC dest - try - { - currParticolare = partByDtmx(true); - // se non ho UDC lo creo... - checkCreaUDC(); - // verifico se ho UDC... - NewUDC = MagClass.magazzino.taCartellini.getByParticolareAL(currParticolare, destAL)[0].UDC; - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Errore in decodifica particolare da DataMatrix:{0}dtx:{1}{0}Eccezione:{0}{2}", Environment.NewLine, barcodeIn, exc), tipoLog.EXCEPTION); - NewUDC = ""; - } - // ora proseguo... - if (currParticolare != "" && NewUDC != "") - { - // chiamo procedure aggiunta/rimozione secondo caso di selezione ADD/REM Dtx - if (!chkDtxMode.Checked) - { - Postazione.messaggiText = string.Format("{0}: {1}", traduci("DtxAdd"), barcodeIn); - Postazione.CssClass = "stileComandoOk"; - procDtx_add(ref NewUDC); - } - // modalità "rimozione" datamatrix - else - { - Postazione.messaggiText = string.Format("{0}: {1}", traduci("DtxRem"), barcodeIn); - Postazione.CssClass = "stileComandoWarn"; - procDtx_rem(ref NewUDC); - } - } - } - } - } - break; - default: - Postazione.warningText = traduci("ERR-BCD-001"); - Postazione.CssClass = cssErr; - break; - } - barcodeIn = ""; - } - doUpdate(); - } - - /// - /// crea eventualmente UDC per particolare - /// - /// - /// - private void checkCreaUDC() - { - string newUdcChild = ""; - string noteTrim = ""; - DateTime adesso = DateTime.Now; - // verifico se ho già quel particolare tra quelli inseriti in linea... - try - { - newUdcChild = DataProxy.obj.taCartellini.getByParticolareIdxPosIdxCella(currParticolare, memLayer.ML.cdvi("IdxPosizioneRxFinTemp"), Postazione.currIdxCella)[0].UDC; - } - catch - { - newUdcChild = ""; - } - if (newUdcChild == "") - { - // controllo NON ci siano troppi UDC in posizione... da capienza ed assegnati - DS_magazzino.V_statoCelleCapienzaAssegnatiRow riga; - bool piena = false; - try - { - riga = MagClass.magazzino.taStatoCelle.getByIdxCella(Postazione.currIdxCella)[0]; - if (riga.UdcAssegnati >= riga.Capienza) piena = true; - } - catch - { - } - if (!piena) - { - try - { - // forzo qta a 0 x generare nuovo UDC - qta = 0; - // creo nuovo UDC RX - newUdcChild = MagClass.magazzino.creaUdc(flusso, "", currParticolare, "", "", "", "", "", 0, memLayer.ML.cdv("CodImballoRX"), "U", MagClass.magazzino.CodSoggCurrUser, qta, 0, 0, adesso, 0, statoUdcOut, memLayer.ML.cdvi("IdxPosizioneRxFinTemp"), "IdxPosizioneRxFinTemp", codEventoUdcOut, noteTrim, "", adesso.Year, Request.UserHostName); - // lo associo all'AL... - MagClass.magazzino.taAL2UDC.Insert(destAL, newUdcChild, adesso, MagClass.magazzino.CodSoggCurrUser); - - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Errore in creazione UDC temp RX Fin: {0}{1}", Environment.NewLine, exc)); - } - } - else - { - Postazione.warningText = traduci("ErroreAL-Full"); - doUpdate(); - } - } - if (newUdcChild != "") - { - // lo posiziono nella cella corrente... - MagClass.magazzino.spostaUDC(memLayer.ML.StringSessionObj("CodCS"), newUdcChild, Postazione.currIdxCella, memLayer.ML.confReadBool("spostaUdcResettaLdp"), Request.UserHostName); - Postazione.CssClass = "stileAttesa"; - Postazione.warningText = ""; - Postazione.messaggiText = traduci("partAdded"); - doUpdate(); - } - } - - #region metodi processing DataMatrix letto da BarCode - - /// - /// processa aggiunta datamatrix (SE POSSIBILE) - /// - /// - private void procDtx_add(ref string NewUDC) - { - // genera eventuale UDC del particolare su cella/posizione corrente - qta = 1; // tanto poi si ricalcola... - checkCreaUDC(); - // controllo che il DTX non sia già assegnato... - if (DataMatrix.mgr.taDtx2UDC.getByDtx(barcodeIn).Rows.Count == 0) - { - // verifico NON CI SIANO attributi DC pendenti (nel qual caso memorizzo primo comando e poi chiedo conferma... !!!FARE!!! - bool hasXQ = false; - if (DataMatrix.mgr.taAtt2Dtx.getByDtx(barcodeIn).Rows.Count > 0) - { - // cerco se abbia "XQ"... - if (DataMatrix.mgr.taAtt2Dtx.getByDtx(barcodeIn).Select("CodAttr = 'XQ'").Length > 0) - { - hasXQ = true; - } - } - if (hasXQ) - { - // verifico se c'è già in sessione la lettura di questo DataMatrix... - if (memLayer.ML.StringSessionObj("prevDmtx") == barcodeIn) - { - // è seconda lettura: allora procedo - hasXQ = false; - // svuoto da sessione - memLayer.ML.emptySessionVal("prevDmtx"); - } - } - // se non ho pendenze... - if (!hasXQ) - { - // chiamo la stored che associa Dtx a UDC - DataMatrix.mgr.taDtx2UDC.RxSetDtx2Udc(barcodeIn, MagClass.magazzino.CodSoggCurrUser, statoUdcOut, memLayer.ML.cdvi("IdxPosizioneRxFinTemp"), Postazione.currIdxCella); - } - else - { - // mostro messaggio che chiede seconda lettura conferma e salvo in sessione... - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("B48_ReadTwiceToConfirm"); - Postazione.CssClass = "stileComandoWarn"; - // salvo in sessione dmtx x conferma - memLayer.ML.setSessionVal("prevDmtx", barcodeIn); - } - } - } - /// - /// processa rimozione datamatrix (se possibile) - /// - /// - private void procDtx_rem(ref string NewUDC) - { - // verifico sia nell'UDC dest - if (DataMatrix.mgr.taDtx2UDC.getByDtxAl(destAL, barcodeIn).Rows.Count != 0) - { - // rimuovo Dtx - DataMatrix.mgr.taDtx2UDC.deleteQuery(DataMatrix.mgr.taDtx2UDC.getByDtxAl(destAL, barcodeIn)[0].UDC, barcodeIn, MagClass.magazzino.CodSoggCurrUser, memLayer.ML.cdvi("IdxPosizioneRxFinTemp"), Postazione.currIdxCella); - // assegno Attributo x indicare che è stato rimosso... - DataMatrix.mgr.taAtt2Dtx.insertAndProc(barcodeIn, true, "XQ", "Rim. UDC B48", DateTime.Now, MagClass.magazzino.CodSoggCurrUser); - } - } - - #endregion - - /// - /// aggiorna tabella + focus a barcode - /// - public void doUpdate() - { - setDefaultVal(); - setVisibility(!Page.IsPostBack); - grViewDest.DataBind(); - // raise dell'evento - if (eh_reqUpdate != null) - { - eh_reqUpdate(this, new EventArgs()); - } - verificaBtnStampa(); - txtBarcode.Focus(); - } - /// - /// evento selezione grView destinazione: ricarico dati! - /// - /// - /// - protected void grViewDest_SelectedIndexChanged(object sender, EventArgs e) - { - // ricarico dati dell'UDC come particolare e quantità... - currUDC = grViewDest.SelectedDataKey["UDC"].ToString(); - int qtaDtx = 0; - if (MagClass.magazzino.checkUDC(currUDC)) - { - currParticolare = DataProxy.obj.taCartellini.stp_getByUdc(currUDC)[0].Particolare; - qta = Convert.ToInt32(DataProxy.obj.taCartellini.stp_getByUdc(currUDC)[0].Qta); - qtaDtx = Convert.ToInt32(MagClass.magazzino.taA2U2D.getByUDC(currUDC)[0].QtaDtx); - // imposto particolare... - lblPart.Text = currParticolare; - ddlImballi.DataBind(); - } - Postazione.messaggiText = traduci("partSelected"); - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoOk"; - setVisibility(true); - doUpdate(); - // fisso focus su note! - txtNote.Focus(); - } - /// - /// prende in carico AL selezionato - /// - /// - /// - protected void lbtPrendeCaricoAL_Click(object sender, EventArgs e) - { - doUpdate(); - } - /// - /// variabile force delete salvata... - /// - protected bool forceDelete - { - get - { - return memLayer.ML.BoolSessionObj(string.Format("ForceDelAL_{0}", uid)); - } - set - { - memLayer.ML.setSessionVal(string.Format("ForceDelAL_{0}", uid), value); - } - } - /// - /// Verifica se Assieme sia vuoto (no DTX negli UDC) - /// - /// Codice AL - /// - protected bool assiemeIsEmpty(string AL) - { - bool answ = false; - try - { - answ = DataMatrix.mgr.taDtx2UDC.getByAL(AL).Rows.Count == 0; - } - catch { } - return answ; - } - /// - /// reset della selezione - /// - /// - /// - protected void btnReset_Click(object sender, EventArgs e) - { - grViewDest.SelectedIndex = -1; - qta = 0; - currUDC = ""; - setVisibility(false); - doUpdate(); - } - /// - /// update Qty x UDC selezionato... - /// - /// - /// - protected void lbtUpdQty_Click(object sender, EventArgs e) - { - MagClass.magazzino.taCartellini.updateQty(currUDC, MagClass.magazzino.CodSoggCurrUser, "U", codEventoUdcOut, qta); - currUDC = ""; - currParticolare = ""; - grViewDest.SelectedIndex = -1; - doUpdate(); - } - /// - /// richiesta (ri)stampa UDC - /// - /// - /// - public void ristampa() - { - bool fatto = false; - fatto = MagClass.magazzino.ristampaUdc(udcReq, Postazione.printer, Request.UserHostName); - // registro ri-stampa UDC - if (fatto) MagClass.magazzino.taSAO.insertQuery(DateTime.Now, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, udcReq, "", "stampaUDC", string.Format("Ri-Stampato UDC Dtx {0} su linea {1}", currUDC, Postazione.currCodLinea)); - } - /// - /// verifica visibilità btn stampa UDC - /// - private void verificaBtnStampa() - { - bool showBtnStampa = false; - // se ho selezionato udc... - if (currUDC != "") - { - DS_magazzino.v_A2U2DRow riga; - int qtaUDC = 0; - int qtaDtx = 0; - try - { - riga = MagClass.magazzino.taA2U2D.getByUDC(currUDC)[0]; - qtaUDC = Convert.ToInt32(riga.Qta); - qtaDtx = riga.QtaDtx; - } - catch - { } - if (qtaUDC > 0 && (qtaUDC <= QtaImballoRXFin)) - { - // se le qta voluta e dtx sono uguali... - if (qtaUDC == qtaDtx) - { - showBtnStampa = true; - } - } - } - divNote.Visible = showBtnStampa; - } - /// - /// fornisce in output la corretta classe css x icona - /// - /// - /// - /// - public string cssGlyphByQty(object _qta, object _qtaDtx) - { - string answ = "glyphicon glyphicon-pencil btn-lg"; - int qtaUDC = 0; - int qtaDtx = -1; - try - { - qtaUDC = Convert.ToInt32(_qta); - } - catch { } - try - { - qtaDtx = Convert.ToInt32(_qtaDtx); - } - catch { } - if ((qtaUDC == qtaDtx) && (qtaUDC == QtaImballoRXFin)) - { - answ = "glyphicon glyphicon-print btn-lg"; - } - return answ; - } - /// - /// effettua processo di sistemazione UDC e stampa - /// - /// - /// - protected void lbtStampaUDC_Click(object sender, EventArgs e) - { - // verifico postazione sia valida... - if (Postazione.name != "" && Postazione.IP != "" && Postazione.currCodCella != "") - { - // fa le operazioni di update x UDC e poi lo stampa - bool fatto = false; - string noteTrim = txtNote.Text.Trim(); - try - { - // update UDC! - fatto = MagClass.magazzino.Udc_B48_FullUpdate(currUDC, ddlImballi.SelectedValue, noteTrim, MagClass.magazzino.CodSoggCurrUser); - } - catch - { } - if (fatto) - { - // lancio stampa - MagClass.magazzino.stampaUdc(currUDC, Postazione.printer, tipoCartellino.cartFinitiRxSP, Request.UserHostName); - // registro creazione AL - MagClass.magazzino.taSAO.insertQuery(DateTime.Now, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, currUDC, currParticolare, "stampaUDC", string.Format("Stampato UDC Dtx RxFin {0} su linea {1}, note: {2} ", currUDC, Postazione.currCodLinea, noteTrim)); - Postazione.CssClass = cssAtt; - Postazione.warningText = ""; - Postazione.messaggiText = traduci("cartAlStampato"); - // calcolo particolare completo di descrizione - DS_Applicazione.ElencoCartelliniRow riga = DataProxy.obj.taCartellini.stp_getByUdc(currUDC)[0]; - string particolare = string.Format("{0} - {1}", riga.Particolare, riga.DescParticolare); - // resetto... - grViewDest.SelectedIndex = -1; - qta = 0; - currUDC = ""; - } - doUpdate(); - } - else - { - // ricarico che mi manca postazione! - Postazione.CssClass = cssAtt; - Postazione.warningText = traduci("ERR-POS-001"); - Postazione.messaggiText = ""; - Response.Redirect(user_std.pagCorrente); - } - } - /// - /// udc da stampare - /// - protected string udcReq - { - get - { - return memLayer.ML.StringSessionObj("udcSelSAO"); - } - } - /// - /// preseleziono (se possibile) imballo... - /// - /// - /// - protected void ddlImballi_DataBound(object sender, EventArgs e) - { - selezionaImballo(); - } - /// - /// seleziona imballo corretto - /// - private void selezionaImballo() - { - string codImb = ""; - // cerco se c'è un imballo x particolare corrente... - if (currParticolare != "") - { - codImb = lastCodImb; - } - else - { - codImb = memLayer.ML.cdv("CodImballoFiniti"); - } - try - { - // preseleziono - ddlImballi.SelectedValue = codImb; - } - catch - { } - } + get + { + return memLayer.ML.cdvi("QtaImballoRXFin"); + } } + + + /// + /// stringa UID univoca + /// + public string uid + { + get + { + return this.UniqueID.Replace("$", "_").Replace("-", "_"); + } + } + + /// + /// flusso associato (hard coded) ad ancestor TT (Trattati) + /// + protected string flussoAnc = "TT"; + /// + /// flusso associato (hard coded) a temporaneo TL (Trattati/Liquidi) + /// + protected string flussoTemp = "TL"; + /// + /// stato associato (hard coded) a UDC in IN: Trattato da travaso AL + /// + protected string statoUdcIn = "Tratt"; + /// + /// codice evento dell'UDC temporaneo (IN) che si crea + /// + protected string codEventoUdcIn = "UDC_TRATT"; + + protected string cssOk = "stileComandoOk"; + protected string cssErr = "stileComandoKo"; + protected string cssWait = "stileComandoND"; + protected string cssAtt = "stileAttesa"; + protected string cssWarn = "stileComandoWarn"; + protected string cssAdd = "stileComandoAdd"; + public event EventHandler eh_reqUpdate; + + /// + /// ultimo valore barcode letto (x confronto conferme doppio input...) + /// + protected string lastBarcodeIn + { + get + { + return memLayer.ML.StringSessionObj(string.Format("lastBCode_{0}", uid)); + } + set + { + memLayer.ML.setSessionVal(string.Format("lastBCode_{0}", uid), value, false); + } + } + /// + /// Codice AL della cella corrente + /// + protected string destAL + { + get + { + return lblDestAL.Text.Trim(); + } + set + { + lblDestAL.Text = value; + } + } + /// + /// Codice AL associato alla cella corrente... + /// + protected string AlByCella + { + get + { + string answ = ""; + try + { + answ = string.Format("ALF00{0}", Postazione.currCodCella); + // controllo se esista AL sennò lo creo... + if (MagClass.magazzino.taEA.getByAL(answ).Rows.Count == 0) + { + MagClass.magazzino.taEA.Insert(answ, true, DateTime.Now, MagClass.magazzino.CodSoggCurrUser, "", ""); + } + } + catch + { } + return answ; + } + } + /// + /// indica il codice articolo correntemente selezionato + /// + protected string currParticolare + { + get + { + return memLayer.ML.StringSessionObj(string.Format("currParticolare_{0}", uid)); + } + set + { + memLayer.ML.setSessionVal(string.Format("currParticolare_{0}", uid), value, memLayer.ML.confReadBool("keepParticolareSel")); + } + } + /// + /// indica UDC correntemente selezionato + /// + protected string currUDC + { + get + { + return memLayer.ML.StringSessionObj(string.Format("UDC_{0}", uid)); + } + set + { + memLayer.ML.setSessionVal(string.Format("UDC_{0}", uid), value, memLayer.ML.confReadBool("keepParticolareSel")); + } + } + /// + /// num pezzi dell'ultimo UDC di uguale particolare e stato fatto... + /// + public int pezziUdc + { + get + { + int answ = 0; + try + { + answ = (int)MagClass.magazzino.taCartellini.getLastByParticolareStatoConImb(memLayer.ML.StringSessionObj("CodCS"), currParticolare, statoUdcOut)[0].Qta; + } + catch + { + answ = memLayer.ML.cdvi("QtaImballoFiniti"); + } + return answ; + } + } + /// + /// cod imballo dell'ultimo UDC del particolare generato + /// + public string lastCodImb + { + get + { + string answ = ""; + try + { + answ = MagClass.magazzino.taCartellini.getLastByParticolareStatoConImb(memLayer.ML.StringSessionObj("CodCS"), currParticolare, statoUdcOut)[0].CodImballo; + } + catch + { + answ = memLayer.ML.cdv("CodImballoFiniti"); + } + return answ; + } + } + /// + /// qta pezzi x UDC + /// + public int qta + { + get + { + int qta = 0; + try + { + qta = Convert.ToInt32(txtQta.Text.Trim()); + } + catch + { } + return qta; + } + set + { + txtQta.Text = value.ToString(); + } + } + /// + /// wrapper traduzione + /// + /// + /// + public string traduci(object lemma) + { + return user_std.UtSn.Traduci(lemma.ToString()); + } + /// + /// indica se i caratteri vadano forzati a maiuscoli + /// + public bool forceUppercase + { + get + { + return memLayer.ML.confReadBool("forceUppercase"); + } + } + /// + /// Formato Datamatrix della linea selezionata + /// + protected string FormatoDtmxLinea + { + get + { + string answ = ""; + try + { + answ = MagClass.magazzino.taAL.getByKey(Postazione.currCodLinea)[0].FormatoDtmx; + } + catch + { } + return answ; + } + } + /// + /// Formato Datamatrix dell'ultimo barcode letto + /// + protected string FormatoDtmxBarcode + { + get + { + string answ = ""; + try + { + answ = DataMatrix_mgr.taVerifica.GetData(barcodeIn)[0].FormatoDtmx; + } + catch + { } + return answ; + } + } + /// + /// codice particolare da datamatrix + /// + /// bollean: + /// true = utilizza lookUp su tabella dati acquisiti + /// false = prova a decodificare (da formato Dtmx linea) + /// + protected string partByDtmx(bool byTable) + { + string answ = ""; + if (byTable) + { + answ = DataMatrix_mgr.taDtxAcquisiti.getByKey(barcodeIn)[0].Particolare; // Decode.GetData(barcodeIn, FormatoDtmxLinea)[0].Particolare; + } + else + { + answ = DataMatrix_mgr.taDecode.GetData(barcodeIn, FormatoDtmxLinea)[0].Particolare; + } + return answ; + } + /// + /// valore barcode + /// + public string barcodeIn + { + get + { + return txtBarcode.Text.Trim(); + } + set + { + txtBarcode.Text = value; + } + } + /// + /// caricamento pagina + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + Postazione.messaggiText = ""; + Postazione.warningText = ""; + qta = 0; + currUDC = ""; + forceDelete = false; + setDefaultVal(); + checkNumKeyIn(); + } + setVisibility(!Page.IsPostBack); + checkBarcode(); + } + /// + /// verifico se ci sia in sessione un input da NumKeyb e nel caso lometto in barcodeIn e processo... + /// + private void checkNumKeyIn() + { + if (memLayer.ML.isInSessionObject("numKeyIn")) + { + barcodeIn = memLayer.ML.StringSessionObj("numKeyIn"); + // svuoto valore in sessione... + memLayer.ML.emptySessionVal("numKeyIn"); + // controllo barcode... + checkBarcode(); + } + } + /// + /// imposta i valori di default ad avvio + /// + private void setDefaultVal() + { + destAL = AlByCella; + } + /// + /// sistema modalità input + /// + /// forza reload imballo? + private void setVisibility(bool forceReloadImb) + { + bool showBtn = false; + // controllo btn quantità + if (grViewDest.SelectedIndex >= 0) + { + showBtn = true; + } + divQta.Visible = showBtn; + divImballi.Visible = showBtn; + if (showBtn && forceReloadImb) + { + selezionaImballo(); + } + } + /// + /// reset maschera... + /// + protected void doReset() + { + // resetta + lastBarcodeIn = ""; + Postazione.messaggiText = ""; + Postazione.warningText = ""; + Postazione.CssClass = cssAtt; + doUpdate(); + } + /// + /// Verifica l'AL se sia ok x procedere: + /// - Attivo + /// + /// + /// T/L + /// + protected bool checkAL(string AL, string tipo) + { + bool answ = false; + try + { + answ = MagClass.magazzino.taEA.getByAL_TipoAttivo(AL, tipo).Rows.Count > 0; + } + catch + { } + if (answ) + { + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoOk"; + } + else + { + Postazione.warningText = traduci("ErroreAlNonTtAttivo"); + Postazione.CssClass = "stileComandoKo"; + } + + return answ; + } + /// + /// Verifica l'AL se abbia datamatrix + /// + /// + /// + protected bool checkDtxAL(string AL) + { + bool answ = false; + try + { + answ = DataMatrix_mgr.taDtx2UDC.getByAL(AL).Rows.Count > 0; + } + catch + { } + if (!answ) + { + Postazione.warningText = traduci("ErroreAlNonDtx"); + Postazione.CssClass = "stileComandoKo"; + } + else + { + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoOk"; + } + return answ; + } + /// + /// controlla se ci sia un barcode e cosa farne... + /// + private void checkBarcode() + { + if (barcodeIn != "") + { + Postazione.messaggiText = string.Format("{0}: {1}", traduci("BCodeIns"), barcodeIn); + tipoCodiceBarcode tipoBC = MagClass.tipoBCode_L5(barcodeIn); + switch (tipoBC) + { + case tipoCodiceBarcode.Operatore: + // calcolo matricola utente + int MatrUtente = -1; + string preCodSogg = memLayer.ML.AppConf["prefCodSogg"]; + if (barcodeIn.StartsWith(preCodSogg)) + { + MatrUtente = DataProxy.obj.taTrascSogg.getByKey(barcodeIn, 0)[0].CodMatricola; + } + else + { + MatrUtente = Convert.ToInt32(barcodeIn); + } + if (MatrUtente >= 0) + { + // salvo in sessione operatore con AUTH + OpAuth.startOpAuth(MatrUtente); + // mostro che ho autorizzato... + Postazione.messaggiText += traduci("userAuthRec"); + Postazione.CssClass = "stileComandoOk"; + Response.Redirect(user_std.pagCorrente); + } + else + { + Postazione.messaggiText += " - codice non riconosciuto!"; + Postazione.CssClass = "stileComandoND"; + } + break; + case tipoCodiceBarcode.Imballo: + // cerco di selezionare! + try + { + ddlImballi.SelectedValue = barcodeIn; + } + catch + { + Postazione.warningText = traduci("ERR-IMB-001"); + Postazione.CssClass = "stileComandoKo"; + } + break; + case tipoCodiceBarcode.Comando: + // se è reset cancello tutto! + if (barcodeIn == memLayer.ML.cdv("cmdReset")) + { + doReset(); + } + break; + case tipoCodiceBarcode.UDC: + // controllo di avere destAL valido, sennò ricarico pagina... + if (destAL.Length > 5) + { + // controllo se sia un UDC valido... + if (MagClass.magazzino.checkUDC(barcodeIn)) + { + // controllo se sia un UDC di finiti LIQ in posizione 4... + DS_magazzino.ElencoCartelliniRow cartUDC = MagClass.magazzino.taCartellini.getByUdc(barcodeIn)[0]; + if (cartUDC.CodStato == statoUdcOut && cartUDC.IdxPosizione == memLayer.ML.cdvi("IdxPosizioneFiniti")) + { + // controllo NON ci sia già un UDC di pari particolare caricato nella postazione corrente (non posso avere 2 UDC a pari particolare da riempire...) + if (MagClass.magazzino.taCartellini.getByParticolareAL(cartUDC.Particolare, destAL).Rows.Count == 0) + { + // controllo NON sia UDC in LDP e già PRELEVATO + if (MagClass.magazzino.taRigheListePrelievo.getByUdc(barcodeIn).Select("Prelevato = 1").Length == 0) + { + // controllo NON abbia blocco x FinDtx... + if (MagClass.magazzino.udcHasAttr(barcodeIn, "BL")) + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-LIQ-006"); + Postazione.CssClass = cssErr; + } + else + { + // se è ok RICARICO UDC in posizione corrente... + bool fatto = MagClass.magazzino.finRxRiprendiInCaricoUDC(barcodeIn, MagClass.magazzino.CodSoggCurrUser, destAL, Postazione.currIdxCella); + if (fatto) + { + Postazione.messaggiText = traduci("RiCaricatoUdcLiq"); + Postazione.warningText = ""; + Postazione.CssClass = cssOk; + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-LIQ-001"); + Postazione.CssClass = cssErr; + } + } + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-LIQ-005"); + Postazione.CssClass = cssErr; + } + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-LIQ-004"); + Postazione.CssClass = cssErr; + } + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-LIQ-002"); + Postazione.CssClass = cssErr; + } + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-LIQ-003"); + Postazione.CssClass = cssErr; + } + } + else + { + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-ALF-001"); + Postazione.CssClass = cssErr; + } + break; + case tipoCodiceBarcode.DataMatrixTrovato: + // ciclo controllo x B48 + string NewUDC = ""; + // verifica preliminare: se Dtx OK procedo, se è KO NON LO CONSIDERO PROPRIO + bool isOk = false; + // controllo anche NC + bool isOkNc = false; + // controllo sia libero (= non assegnato) + bool isFree = false; + try + { + isOk = DataMatrix_mgr.taVerifica.GetData(barcodeIn)[0].StatoDtx == "OK"; + } + catch + { } + try + { + isOkNc = DataMatrix_mgr.taAtt2Dtx.getByDtx(barcodeIn).Select("CodAttr = 'XF'").Length == 0; + } + catch + { } + try + { + isFree = DataMatrix_mgr.taDtx2UDC.getByDtx(barcodeIn).Rows.Count == 0; + } + catch + { } + // controlli x procedere + if (!isOkNc && !chkDtxMode.Checked) + { + // non accetto Dtx e mostro errore + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("ERR-DTX-016"); + Postazione.CssClass = cssErr; + } + else if (!isOk && !chkDtxMode.Checked) + { + // non accetto Dtx e mostro errore + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("ERR-DTX-012"); + Postazione.CssClass = cssErr; + } + else if (!isFree && !chkDtxMode.Checked) + { + // non accetto Dtx e mostro errore + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("ERR-DTX-017"); + Postazione.CssClass = cssErr; + } + else if (isFree && chkDtxMode.Checked) + { + // non accetto Dtx e mostro errore + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("ERR-DTX-018"); + Postazione.CssClass = cssErr; + } + else // PROCEDO!!! + { + + // controllo formato datamatrix sia impostato sulla linea (altrimenti errore linea "non battezzata") + if (FormatoDtmxLinea == "") + { + // errore poiché non è stato non specificato tipo Dtmx assegnato alla linea! + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("ERR-DTX-013"); + Postazione.CssClass = "stileComandoKo"; + } + else + { + // verifico formato datamatrix letto sia quello della linea... + if (FormatoDtmxBarcode != FormatoDtmxLinea) + { + // errore corrispondenza formato Dtmx + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("ERR-DTX-014"); + Postazione.CssClass = "stileComandoKo"; + } + else + { + // calcolo particolare + UDC dest + try + { + currParticolare = partByDtmx(true); + // se non ho UDC lo creo... + checkCreaUDC(); + // verifico se ho UDC... + NewUDC = MagClass.magazzino.taCartellini.getByParticolareAL(currParticolare, destAL)[0].UDC; + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in decodifica particolare da DataMatrix:{0}dtx:{1}{0}Eccezione:{0}{2}", Environment.NewLine, barcodeIn, exc), tipoLog.EXCEPTION); + NewUDC = ""; + } + // ora proseguo... + if (currParticolare != "" && NewUDC != "") + { + // chiamo procedure aggiunta/rimozione secondo caso di selezione ADD/REM Dtx + if (!chkDtxMode.Checked) + { + Postazione.messaggiText = string.Format("{0}: {1}", traduci("DtxAdd"), barcodeIn); + Postazione.CssClass = "stileComandoOk"; + procDtx_add(ref NewUDC); + } + // modalità "rimozione" datamatrix + else + { + Postazione.messaggiText = string.Format("{0}: {1}", traduci("DtxRem"), barcodeIn); + Postazione.CssClass = "stileComandoWarn"; + procDtx_rem(ref NewUDC); + } + } + } + } + } + break; + default: + Postazione.warningText = traduci("ERR-BCD-001"); + Postazione.CssClass = cssErr; + break; + } + barcodeIn = ""; + } + doUpdate(); + } + + /// + /// crea eventualmente UDC per particolare + /// + /// + /// + private void checkCreaUDC() + { + string newUdcChild = ""; + string noteTrim = ""; + DateTime adesso = DateTime.Now; + // verifico se ho già quel particolare tra quelli inseriti in linea... + try + { + newUdcChild = DataProxy.obj.taCartellini.getByParticolareIdxPosIdxCella(currParticolare, memLayer.ML.cdvi("IdxPosizioneRxFinTemp"), Postazione.currIdxCella)[0].UDC; + } + catch + { + newUdcChild = ""; + } + if (newUdcChild == "") + { + // controllo NON ci siano troppi UDC in posizione... da capienza ed assegnati + DS_magazzino.V_statoCelleCapienzaAssegnatiRow riga; + bool piena = false; + try + { + riga = MagClass.magazzino.taStatoCelle.getByIdxCella(Postazione.currIdxCella)[0]; + if (riga.UdcAssegnati >= riga.Capienza) piena = true; + } + catch + { + } + if (!piena) + { + try + { + // forzo qta a 0 x generare nuovo UDC + qta = 0; + // creo nuovo UDC RX + newUdcChild = MagClass.magazzino.creaUdc(flusso, "", currParticolare, "", "", "", "", "", 0, memLayer.ML.cdv("CodImballoRX"), "U", MagClass.magazzino.CodSoggCurrUser, qta, 0, 0, adesso, 0, statoUdcOut, memLayer.ML.cdvi("IdxPosizioneRxFinTemp"), "IdxPosizioneRxFinTemp", codEventoUdcOut, noteTrim, "", adesso.Year, Request.UserHostName); + // lo associo all'AL... + MagClass.magazzino.taAL2UDC.Insert(destAL, newUdcChild, adesso, MagClass.magazzino.CodSoggCurrUser); + + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in creazione UDC temp RX Fin: {0}{1}", Environment.NewLine, exc)); + } + } + else + { + Postazione.warningText = traduci("ErroreAL-Full"); + doUpdate(); + } + } + if (newUdcChild != "") + { + // lo posiziono nella cella corrente... + MagClass.magazzino.spostaUDC(memLayer.ML.StringSessionObj("CodCS"), newUdcChild, Postazione.currIdxCella, memLayer.ML.confReadBool("spostaUdcResettaLdp"), Request.UserHostName); + Postazione.CssClass = "stileAttesa"; + Postazione.warningText = ""; + Postazione.messaggiText = traduci("partAdded"); + doUpdate(); + } + } + + #region metodi processing DataMatrix letto da BarCode + + /// + /// processa aggiunta datamatrix (SE POSSIBILE) + /// + /// + private void procDtx_add(ref string NewUDC) + { + // genera eventuale UDC del particolare su cella/posizione corrente + qta = 1; // tanto poi si ricalcola... + checkCreaUDC(); + // controllo che il DTX non sia già assegnato... + if (DataMatrix_mgr.taDtx2UDC.getByDtx(barcodeIn).Rows.Count == 0) + { + // verifico NON CI SIANO attributi DC pendenti (nel qual caso memorizzo primo comando e poi chiedo conferma... !!!FARE!!! + bool hasXQ = false; + if (DataMatrix_mgr.taAtt2Dtx.getByDtx(barcodeIn).Rows.Count > 0) + { + // cerco se abbia "XQ"... + if (DataMatrix_mgr.taAtt2Dtx.getByDtx(barcodeIn).Select("CodAttr = 'XQ'").Length > 0) + { + hasXQ = true; + } + } + if (hasXQ) + { + // verifico se c'è già in sessione la lettura di questo DataMatrix... + if (memLayer.ML.StringSessionObj("prevDmtx") == barcodeIn) + { + // è seconda lettura: allora procedo + hasXQ = false; + // svuoto da sessione + memLayer.ML.emptySessionVal("prevDmtx"); + } + } + // se non ho pendenze... + if (!hasXQ) + { + // chiamo la stored che associa Dtx a UDC + DataMatrix_mgr.taDtx2UDC.RxSetDtx2Udc(barcodeIn, MagClass.magazzino.CodSoggCurrUser, statoUdcOut, memLayer.ML.cdvi("IdxPosizioneRxFinTemp"), Postazione.currIdxCella); + } + else + { + // mostro messaggio che chiede seconda lettura conferma e salvo in sessione... + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("B48_ReadTwiceToConfirm"); + Postazione.CssClass = "stileComandoWarn"; + // salvo in sessione dmtx x conferma + memLayer.ML.setSessionVal("prevDmtx", barcodeIn); + } + } + } + /// + /// processa rimozione datamatrix (se possibile) + /// + /// + private void procDtx_rem(ref string NewUDC) + { + // verifico sia nell'UDC dest + if (DataMatrix_mgr.taDtx2UDC.getByDtxAl(destAL, barcodeIn).Rows.Count != 0) + { + // rimuovo Dtx + DataMatrix_mgr.taDtx2UDC.deleteQuery(DataMatrix_mgr.taDtx2UDC.getByDtxAl(destAL, barcodeIn)[0].UDC, barcodeIn, MagClass.magazzino.CodSoggCurrUser, memLayer.ML.cdvi("IdxPosizioneRxFinTemp"), Postazione.currIdxCella); + // assegno Attributo x indicare che è stato rimosso... + DataMatrix_mgr.taAtt2Dtx.insertAndProc(barcodeIn, true, "XQ", "Rim. UDC B48", DateTime.Now, MagClass.magazzino.CodSoggCurrUser); + } + } + + #endregion + + /// + /// aggiorna tabella + focus a barcode + /// + public void doUpdate() + { + setDefaultVal(); + setVisibility(!Page.IsPostBack); + grViewDest.DataBind(); + // raise dell'evento + if (eh_reqUpdate != null) + { + eh_reqUpdate(this, new EventArgs()); + } + verificaBtnStampa(); + txtBarcode.Focus(); + } + /// + /// evento selezione grView destinazione: ricarico dati! + /// + /// + /// + protected void grViewDest_SelectedIndexChanged(object sender, EventArgs e) + { + // ricarico dati dell'UDC come particolare e quantità... + currUDC = grViewDest.SelectedDataKey["UDC"].ToString(); + int qtaDtx = 0; + if (MagClass.magazzino.checkUDC(currUDC)) + { + currParticolare = DataProxy.obj.taCartellini.stp_getByUdc(currUDC)[0].Particolare; + qta = Convert.ToInt32(DataProxy.obj.taCartellini.stp_getByUdc(currUDC)[0].Qta); + qtaDtx = Convert.ToInt32(MagClass.magazzino.taA2U2D.getByUDC(currUDC)[0].QtaDtx); + // imposto particolare... + lblPart.Text = currParticolare; + ddlImballi.DataBind(); + } + Postazione.messaggiText = traduci("partSelected"); + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoOk"; + setVisibility(true); + doUpdate(); + // fisso focus su note! + txtNote.Focus(); + } + /// + /// prende in carico AL selezionato + /// + /// + /// + protected void lbtPrendeCaricoAL_Click(object sender, EventArgs e) + { + doUpdate(); + } + /// + /// variabile force delete salvata... + /// + protected bool forceDelete + { + get + { + return memLayer.ML.BoolSessionObj(string.Format("ForceDelAL_{0}", uid)); + } + set + { + memLayer.ML.setSessionVal(string.Format("ForceDelAL_{0}", uid), value); + } + } + /// + /// Verifica se Assieme sia vuoto (no DTX negli UDC) + /// + /// Codice AL + /// + protected bool assiemeIsEmpty(string AL) + { + bool answ = false; + try + { + answ = DataMatrix_mgr.taDtx2UDC.getByAL(AL).Rows.Count == 0; + } + catch { } + return answ; + } + /// + /// reset della selezione + /// + /// + /// + protected void btnReset_Click(object sender, EventArgs e) + { + grViewDest.SelectedIndex = -1; + qta = 0; + currUDC = ""; + setVisibility(false); + doUpdate(); + } + /// + /// update Qty x UDC selezionato... + /// + /// + /// + protected void lbtUpdQty_Click(object sender, EventArgs e) + { + MagClass.magazzino.taCartellini.updateQty(currUDC, MagClass.magazzino.CodSoggCurrUser, "U", codEventoUdcOut, qta); + currUDC = ""; + currParticolare = ""; + grViewDest.SelectedIndex = -1; + doUpdate(); + } + /// + /// richiesta (ri)stampa UDC + /// + /// + /// + public void ristampa() + { + bool fatto = false; + fatto = MagClass.magazzino.ristampaUdc(udcReq, Postazione.printer, Request.UserHostName); + // registro ri-stampa UDC + if (fatto) MagClass.magazzino.taSAO.insertQuery(DateTime.Now, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, udcReq, "", "stampaUDC", string.Format("Ri-Stampato UDC Dtx {0} su linea {1}", currUDC, Postazione.currCodLinea)); + } + /// + /// verifica visibilità btn stampa UDC + /// + private void verificaBtnStampa() + { + bool showBtnStampa = false; + // se ho selezionato udc... + if (currUDC != "") + { + DS_magazzino.v_A2U2DRow riga; + int qtaUDC = 0; + int qtaDtx = 0; + try + { + riga = MagClass.magazzino.taA2U2D.getByUDC(currUDC)[0]; + qtaUDC = Convert.ToInt32(riga.Qta); + qtaDtx = riga.QtaDtx; + } + catch + { } + if (qtaUDC > 0 && (qtaUDC <= QtaImballoRXFin)) + { + // se le qta voluta e dtx sono uguali... + if (qtaUDC == qtaDtx) + { + showBtnStampa = true; + } + } + } + divNote.Visible = showBtnStampa; + } + /// + /// fornisce in output la corretta classe css x icona + /// + /// + /// + /// + public string cssGlyphByQty(object _qta, object _qtaDtx) + { + string answ = "glyphicon glyphicon-pencil btn-lg"; + int qtaUDC = 0; + int qtaDtx = -1; + try + { + qtaUDC = Convert.ToInt32(_qta); + } + catch { } + try + { + qtaDtx = Convert.ToInt32(_qtaDtx); + } + catch { } + if ((qtaUDC == qtaDtx) && (qtaUDC == QtaImballoRXFin)) + { + answ = "glyphicon glyphicon-print btn-lg"; + } + return answ; + } + /// + /// effettua processo di sistemazione UDC e stampa + /// + /// + /// + protected void lbtStampaUDC_Click(object sender, EventArgs e) + { + // verifico postazione sia valida... + if (Postazione.name != "" && Postazione.IP != "" && Postazione.currCodCella != "") + { + // fa le operazioni di update x UDC e poi lo stampa + bool fatto = false; + string noteTrim = txtNote.Text.Trim(); + try + { + // update UDC! + fatto = MagClass.magazzino.Udc_B48_FullUpdate(currUDC, ddlImballi.SelectedValue, noteTrim, MagClass.magazzino.CodSoggCurrUser); + } + catch + { } + if (fatto) + { + // lancio stampa + MagClass.magazzino.stampaUdc(currUDC, Postazione.printer, tipoCartellino.cartFinitiRxSP, Request.UserHostName); + // registro creazione AL + MagClass.magazzino.taSAO.insertQuery(DateTime.Now, MagClass.magazzino.CodSoggCurrUser, Postazione.name, Postazione.IP, currUDC, currParticolare, "stampaUDC", string.Format("Stampato UDC Dtx RxFin {0} su linea {1}, note: {2} ", currUDC, Postazione.currCodLinea, noteTrim)); + Postazione.CssClass = cssAtt; + Postazione.warningText = ""; + Postazione.messaggiText = traduci("cartAlStampato"); + // calcolo particolare completo di descrizione + DS_Applicazione.ElencoCartelliniRow riga = DataProxy.obj.taCartellini.stp_getByUdc(currUDC)[0]; + string particolare = string.Format("{0} - {1}", riga.Particolare, riga.DescParticolare); + // resetto... + grViewDest.SelectedIndex = -1; + qta = 0; + currUDC = ""; + } + doUpdate(); + } + else + { + // ricarico che mi manca postazione! + Postazione.CssClass = cssAtt; + Postazione.warningText = traduci("ERR-POS-001"); + Postazione.messaggiText = ""; + Response.Redirect(user_std.pagCorrente); + } + } + /// + /// udc da stampare + /// + protected string udcReq + { + get + { + return memLayer.ML.StringSessionObj("udcSelSAO"); + } + } + /// + /// preseleziono (se possibile) imballo... + /// + /// + /// + protected void ddlImballi_DataBound(object sender, EventArgs e) + { + selezionaImballo(); + } + /// + /// seleziona imballo corretto + /// + private void selezionaImballo() + { + string codImb = ""; + // cerco se c'è un imballo x particolare corrente... + if (currParticolare != "") + { + codImb = lastCodImb; + } + else + { + codImb = memLayer.ML.cdv("CodImballoFiniti"); + } + try + { + // preseleziono + ddlImballi.SelectedValue = codImb; + } + catch + { } + } + } } \ No newline at end of file diff --git a/GMW/WebUserControls/mod_recAttributiDtx.ascx.cs b/GMW/WebUserControls/mod_recAttributiDtx.ascx.cs index 7bb6cb13..83172460 100644 --- a/GMW/WebUserControls/mod_recAttributiDtx.ascx.cs +++ b/GMW/WebUserControls/mod_recAttributiDtx.ascx.cs @@ -5,207 +5,211 @@ using System.Web.UI; namespace GMW.WebUserControls { - public partial class mod_recAttributiDtx : System.Web.UI.UserControl + public partial class mod_recAttributiDtx : System.Web.UI.UserControl + { + /// + /// Oggetto locale gestione classe datamatrix... + /// + protected DataMatrix DataMatrix_mgr = new DataMatrix(); + public event EventHandler eh_reqUpdate; + /// + /// Avvio pagina + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) { - public event EventHandler eh_reqUpdate; - /// - /// Avvio pagina - /// - /// - /// - protected void Page_Load(object sender, EventArgs e) - { - if (!Page.IsPostBack) - { - resetIN(); - } - checkBarcode(); - } - /// - /// restta input - /// - private void resetIN() - { - AddAttr = true; - lblCodAttr.Text = currAttr; - } - /// - /// Aggiungi/Rimuovi attributo - /// - public bool AddAttr - { - get - { - return chkAdd.Checked; - } - set - { - chkAdd.Checked = value; - } - } - /// - /// wrapper traduzione - /// - /// - /// - public string traduci(object lemma) - { - return user_std.UtSn.Traduci(lemma.ToString()); - } - /// - /// tipologia di attributo registrato con DataMatrix - /// - public tipoAttrDtx tipologia { get; set; } - /// - /// valore barcode - /// - public string barcodeIn - { - get - { - return txtBarcode.Text.Trim(); - } - set - { - txtBarcode.Text = value; - } - } - /// - /// controlla se ci sia un barcode - /// - private void checkBarcode() - { - if (barcodeIn != "") - { - Postazione.messaggiText = string.Format("{0}: {1}", traduci("BCodeIns"), barcodeIn); - switch (MagClass.tipoBCode_L5(barcodeIn)) - { - case tipoCodiceBarcode.DataMatrixTrovato: - // recupero da UDC - try - { - // se si tratta di prove distruttive registrando attributi si fa update di UDC e link... - DataMatrix.mgr.taAtt2Dtx.insertAndProc(barcodeIn, AddAttr, currAttr, tipologia.ToString(), DateTime.Now, MagClass.magazzino.CodSoggCurrUser); - if (AddAttr) - { - Postazione.messaggiText = string.Format("{0}: {1}", traduci("RegistratoAttributo"), tipologia); - } - else - { - Postazione.messaggiText = string.Format("{0}: {1}", traduci("EliminatoAttributo"), tipologia); - } - Postazione.warningText = ""; - Postazione.CssClass = "stileComandoOk"; - } - catch - { - Postazione.warningText = traduci("ERR-A2D-001"); - Postazione.CssClass = "stileComandoKo"; - } - break; - case tipoCodiceBarcode.Comando: - // se è reset cancello tutto! - if (barcodeIn == memLayer.ML.cdv("cmdReset")) - { - resetIN(); - Postazione.messaggiText = ""; - Postazione.warningText = ""; - doUpdate(); - } - Postazione.CssClass = "stileAttesa"; - break; - default: - Postazione.messaggiText = ""; - Postazione.warningText = traduci("ERR-UNK-001"); - Postazione.CssClass = "stileComandoND"; - break; - } - barcodeIn = ""; - } - else - { - Postazione.messaggiText = traduci("AttesaBCode"); - Postazione.CssClass = "stileAttesa"; - } - doUpdate(); - } - /// - /// modificato attributo registra/elimina attributo - /// - /// - /// - protected void chkAdd_CheckedChanged(object sender, EventArgs e) - { - doUpdate(); - } - /// - /// aggiorna componenti + focus a barcode - /// - public void doUpdate() - { - if (AddAttr) - { - chkAdd.Text = traduci("AggiungiAttr"); - lblAdd.Attributes.Remove("class"); - lblAdd.Attributes.Add("class", "btn btn-warning"); - } - else - { - chkAdd.Text = traduci("TogliAttr"); - lblAdd.Attributes.Remove("class"); - lblAdd.Attributes.Add("class", "btn btn-danger"); - } - grView.DataBind(); - // raise dell'evento - if (eh_reqUpdate != null) - { - eh_reqUpdate(this, new EventArgs()); - } - txtBarcode.Focus(); - } - /// - /// codice attributo corrente da tipologia attributi controllo (hard coded) - /// - public string currAttr - { - get - { - string answ = ""; - switch (tipologia) - { - case tipoAttrDtx.ExtraCiclo: - answ = "EC"; - break; - case tipoAttrDtx.ProveDimensionali: - answ = "PD"; - break; - case tipoAttrDtx.ProveDistruttive: - answ = "DI"; - break; - default: - answ = ""; - break; - } - return answ; - } - } + if (!Page.IsPostBack) + { + resetIN(); + } + checkBarcode(); } + /// + /// restta input + /// + private void resetIN() + { + AddAttr = true; + lblCodAttr.Text = currAttr; + } + /// + /// Aggiungi/Rimuovi attributo + /// + public bool AddAttr + { + get + { + return chkAdd.Checked; + } + set + { + chkAdd.Checked = value; + } + } + /// + /// wrapper traduzione + /// + /// + /// + public string traduci(object lemma) + { + return user_std.UtSn.Traduci(lemma.ToString()); + } + /// + /// tipologia di attributo registrato con DataMatrix + /// + public tipoAttrDtx tipologia { get; set; } + /// + /// valore barcode + /// + public string barcodeIn + { + get + { + return txtBarcode.Text.Trim(); + } + set + { + txtBarcode.Text = value; + } + } + /// + /// controlla se ci sia un barcode + /// + private void checkBarcode() + { + if (barcodeIn != "") + { + Postazione.messaggiText = string.Format("{0}: {1}", traduci("BCodeIns"), barcodeIn); + switch (MagClass.tipoBCode_L5(barcodeIn)) + { + case tipoCodiceBarcode.DataMatrixTrovato: + // recupero da UDC + try + { + // se si tratta di prove distruttive registrando attributi si fa update di UDC e link... + DataMatrix_mgr.taAtt2Dtx.insertAndProc(barcodeIn, AddAttr, currAttr, tipologia.ToString(), DateTime.Now, MagClass.magazzino.CodSoggCurrUser); + if (AddAttr) + { + Postazione.messaggiText = string.Format("{0}: {1}", traduci("RegistratoAttributo"), tipologia); + } + else + { + Postazione.messaggiText = string.Format("{0}: {1}", traduci("EliminatoAttributo"), tipologia); + } + Postazione.warningText = ""; + Postazione.CssClass = "stileComandoOk"; + } + catch + { + Postazione.warningText = traduci("ERR-A2D-001"); + Postazione.CssClass = "stileComandoKo"; + } + break; + case tipoCodiceBarcode.Comando: + // se è reset cancello tutto! + if (barcodeIn == memLayer.ML.cdv("cmdReset")) + { + resetIN(); + Postazione.messaggiText = ""; + Postazione.warningText = ""; + doUpdate(); + } + Postazione.CssClass = "stileAttesa"; + break; + default: + Postazione.messaggiText = ""; + Postazione.warningText = traduci("ERR-UNK-001"); + Postazione.CssClass = "stileComandoND"; + break; + } + barcodeIn = ""; + } + else + { + Postazione.messaggiText = traduci("AttesaBCode"); + Postazione.CssClass = "stileAttesa"; + } + doUpdate(); + } + /// + /// modificato attributo registra/elimina attributo + /// + /// + /// + protected void chkAdd_CheckedChanged(object sender, EventArgs e) + { + doUpdate(); + } + /// + /// aggiorna componenti + focus a barcode + /// + public void doUpdate() + { + if (AddAttr) + { + chkAdd.Text = traduci("AggiungiAttr"); + lblAdd.Attributes.Remove("class"); + lblAdd.Attributes.Add("class", "btn btn-warning"); + } + else + { + chkAdd.Text = traduci("TogliAttr"); + lblAdd.Attributes.Remove("class"); + lblAdd.Attributes.Add("class", "btn btn-danger"); + } + grView.DataBind(); + // raise dell'evento + if (eh_reqUpdate != null) + { + eh_reqUpdate(this, new EventArgs()); + } + txtBarcode.Focus(); + } + /// + /// codice attributo corrente da tipologia attributi controllo (hard coded) + /// + public string currAttr + { + get + { + string answ = ""; + switch (tipologia) + { + case tipoAttrDtx.ExtraCiclo: + answ = "EC"; + break; + case tipoAttrDtx.ProveDimensionali: + answ = "PD"; + break; + case tipoAttrDtx.ProveDistruttive: + answ = "DI"; + break; + default: + answ = ""; + break; + } + return answ; + } + } + } } /// /// Tipologia attributi legati a DTX ammessi/Gestiti /// public enum tipoAttrDtx { - /// - /// Gestione ExtraCiclo - /// - ExtraCiclo, - /// - /// Gestione prove dimensionali - /// - ProveDimensionali, - /// - /// Gestione prove distruttive - /// - ProveDistruttive + /// + /// Gestione ExtraCiclo + /// + ExtraCiclo, + /// + /// Gestione prove dimensionali + /// + ProveDimensionali, + /// + /// Gestione prove distruttive + /// + ProveDistruttive } diff --git a/GMW/WebUserControls/mod_setAttrDtx.ascx.cs b/GMW/WebUserControls/mod_setAttrDtx.ascx.cs index 64c8624a..353cda49 100644 --- a/GMW/WebUserControls/mod_setAttrDtx.ascx.cs +++ b/GMW/WebUserControls/mod_setAttrDtx.ascx.cs @@ -5,325 +5,330 @@ using System.Web.UI; namespace GMW.WebUserControls { - public partial class mod_setAttrDtx : System.Web.UI.UserControl - { /// - /// flusso associato (hard coded) a sterrati - /// - protected string flusso = "ST"; - /// - /// stato associato (hard coded) a sterrati - /// - protected string statoUDC = "Sterr"; - /// - /// tipo di evento associato alla creazione dell'UDC - /// - protected string eventoUDC = "UDC_SBFUS"; - public event EventHandler eh_reqUpdate; - /// - /// stringa UID univoca - /// - public string uid + public partial class mod_setAttrDtx : System.Web.UI.UserControl + { + /// + /// Oggetto locale gestione classe datamatrix... + /// + protected DataMatrix DataMatrix_mgr = new DataMatrix(); + /// + /// flusso associato (hard coded) a sterrati + /// + protected string flusso = "ST"; + /// + /// stato associato (hard coded) a sterrati + /// + protected string statoUDC = "Sterr"; + /// + /// tipo di evento associato alla creazione dell'UDC + /// + protected string eventoUDC = "UDC_SBFUS"; + public event EventHandler eh_reqUpdate; + /// + /// stringa UID univoca + /// + public string uid + { + get + { + return this.UniqueID.Replace("$", "_").Replace("-", "_"); + } + } + /// + /// caricamento pagina + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + traduciObj(); + divBlocca.Visible = false; + idxCella = Postazione.currIdxCella; + } + doChecks(); + } + /// + /// IDX cella associata alla linea corrente + /// + protected int idxCella + { + get + { + int answ = 0; + if (memLayer.ML.isInSessionObject("IdxCellaLineaST")) { - get - { - return this.UniqueID.Replace("$", "_").Replace("-", "_"); - } + answ = memLayer.ML.IntSessionObj("IdxCellaLineaST"); } - /// - /// caricamento pagina - /// - /// - /// - protected void Page_Load(object sender, EventArgs e) + return answ; + } + set + { + memLayer.ML.setSessionVal("IdxCellaLineaST", value); + } + } + /// + /// effettua controlli visibilità + /// + private void doChecks() + { + checkBarcode(); + } + /// + /// sistemo labels oggetti + /// + private void traduciObj() + { + } + /// + /// restituisce il nome della pagina corrente + /// + protected string PagCorrente + { + get + { + string answ = ""; + Uri MyUrl = Request.Url; + string delimStr = "/"; + char[] delimiter = delimStr.ToCharArray(); + string[] finalUrl = MyUrl.LocalPath.ToString().Split(delimiter); + int n = finalUrl.Length; + answ = finalUrl[n - 1].ToString(); + DataLayer_AnagGen.PermessiRow riga = (DataLayer_AnagGen.PermessiRow)user_std.UtSn.permessi.Select(string.Format("URL = '{0}'", answ))[0]; + answ = riga.NOME; + return answ; + } + } + /// + /// wrapper traduzione + /// + /// + /// + public string traduci(object lemma) + { + return user_std.UtSn.Traduci(lemma.ToString()); + } + /// + /// indica il codice articolo correntemente selezionato + /// + protected string currParticolare + { + get + { + return memLayer.ML.StringSessionObj(string.Format("currParticolare_{0}", uid)); + } + set + { + memLayer.ML.setSessionVal(string.Format("currParticolare_{0}", uid), value, memLayer.ML.confReadBool("keepParticolareSel")); + } + } + /// + /// indica UDC correntemente selezionato + /// + protected string currUDC + { + get + { + return memLayer.ML.StringSessionObj(string.Format("UDC_{0}", uid)); + } + set + { + memLayer.ML.setSessionVal(string.Format("UDC_{0}", uid), value, memLayer.ML.confReadBool("keepParticolareSel")); + } + } + /// + /// indica se i caratteri vadano forzati a maiuscoli + /// + public bool forceUppercase + { + get + { + return memLayer.ML.confReadBool("forceUppercase"); + } + } + /// + /// valore barcode + /// + public string barcodeIn + { + get + { + return txtBarcode.Text.Trim(); + } + set + { + txtBarcode.Text = value; + } + } + /// + /// Formato Datamatrix della linea selezionata + /// + protected string FormatoDtmxLinea + { + get + { + return ddlFormDmtx.SelectedValue; + } + } + /// + /// Formato Datamatrix dell'ultimo barcode letto + /// + protected string FormatoDtmxBarcode + { + get + { + string answ = ""; + try { - if (!Page.IsPostBack) - { - traduciObj(); - divBlocca.Visible = false; - idxCella = Postazione.currIdxCella; - } - doChecks(); + answ = DataMatrix_mgr.taVerifica.GetData(barcodeIn)[0].FormatoDtmx; } - /// - /// IDX cella associata alla linea corrente - /// - protected int idxCella + catch + { } + return answ; + } + } + /// + /// controlla se ci sia un barcode + /// + private void checkBarcode() + { + if (barcodeIn != "") + { + Postazione.messaggiText = string.Format("Barcode digitato: {0}", barcodeIn); + tipoCodiceBarcode tipoBC = MagClass.tipoBCode_L5(barcodeIn); + switch (tipoBC) { - get + case tipoCodiceBarcode.DataMatrixTrovato: + // verifico formato datamatrix letto sia quello della linea... + if (FormatoDtmxBarcode != FormatoDtmxLinea) { - int answ = 0; - if (memLayer.ML.isInSessionObject("IdxCellaLineaST")) - { - answ = memLayer.ML.IntSessionObj("IdxCellaLineaST"); - } - return answ; - } - set - { - memLayer.ML.setSessionVal("IdxCellaLineaST", value); - } - } - /// - /// effettua controlli visibilità - /// - private void doChecks() - { - checkBarcode(); - } - /// - /// sistemo labels oggetti - /// - private void traduciObj() - { - } - /// - /// restituisce il nome della pagina corrente - /// - protected string PagCorrente - { - get - { - string answ = ""; - Uri MyUrl = Request.Url; - string delimStr = "/"; - char[] delimiter = delimStr.ToCharArray(); - string[] finalUrl = MyUrl.LocalPath.ToString().Split(delimiter); - int n = finalUrl.Length; - answ = finalUrl[n - 1].ToString(); - DataLayer_AnagGen.PermessiRow riga = (DataLayer_AnagGen.PermessiRow)user_std.UtSn.permessi.Select(string.Format("URL = '{0}'", answ))[0]; - answ = riga.NOME; - return answ; - } - } - /// - /// wrapper traduzione - /// - /// - /// - public string traduci(object lemma) - { - return user_std.UtSn.Traduci(lemma.ToString()); - } - /// - /// indica il codice articolo correntemente selezionato - /// - protected string currParticolare - { - get - { - return memLayer.ML.StringSessionObj(string.Format("currParticolare_{0}", uid)); - } - set - { - memLayer.ML.setSessionVal(string.Format("currParticolare_{0}", uid), value, memLayer.ML.confReadBool("keepParticolareSel")); - } - } - /// - /// indica UDC correntemente selezionato - /// - protected string currUDC - { - get - { - return memLayer.ML.StringSessionObj(string.Format("UDC_{0}", uid)); - } - set - { - memLayer.ML.setSessionVal(string.Format("UDC_{0}", uid), value, memLayer.ML.confReadBool("keepParticolareSel")); - } - } - /// - /// indica se i caratteri vadano forzati a maiuscoli - /// - public bool forceUppercase - { - get - { - return memLayer.ML.confReadBool("forceUppercase"); - } - } - /// - /// valore barcode - /// - public string barcodeIn - { - get - { - return txtBarcode.Text.Trim(); - } - set - { - txtBarcode.Text = value; - } - } - /// - /// Formato Datamatrix della linea selezionata - /// - protected string FormatoDtmxLinea - { - get - { - return ddlFormDmtx.SelectedValue; - } - } - /// - /// Formato Datamatrix dell'ultimo barcode letto - /// - protected string FormatoDtmxBarcode - { - get - { - string answ = ""; - try - { - answ = DataMatrix.mgr.taVerifica.GetData(barcodeIn)[0].FormatoDtmx; - } - catch - { } - return answ; - } - } - /// - /// controlla se ci sia un barcode - /// - private void checkBarcode() - { - if (barcodeIn != "") - { - Postazione.messaggiText = string.Format("Barcode digitato: {0}", barcodeIn); - tipoCodiceBarcode tipoBC = MagClass.tipoBCode_L5(barcodeIn); - switch (tipoBC) - { - case tipoCodiceBarcode.DataMatrixTrovato: - // verifico formato datamatrix letto sia quello della linea... - if (FormatoDtmxBarcode != FormatoDtmxLinea) - { - // errore corrispondenza formato Dtmx - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("ERR-DTX-014"); - Postazione.CssClass = "stileComandoKo"; - } - else - { - - Postazione.messaggiText = string.Format("{0} {1} su dtx TROVATO {2}", traduci("AssegnatoAttr"), ddlTipoAttr.SelectedValue, barcodeIn); - Postazione.CssClass = "stileComandoOk"; - // assegno attributo! - DataMatrix.mgr.taAtt2Dtx.insertAndProc(barcodeIn, true, "XF", string.Format("Assegnazione Attr {0} su Dtmx TROVATO tipo {1}", ddlTipoAttr.SelectedValue, ddlFormDmtx.SelectedValue), DateTime.Now, MagClass.magazzino.CodSoggCurrUser); - grView.DataBind(); - } - break; - case tipoCodiceBarcode.DataMatrixDecodificato: - // verifico formato datamatrix letto sia quello della linea... - if (FormatoDtmxBarcode != FormatoDtmxLinea) - { - // errore corrispondenza formato Dtmx - Postazione.messaggiText = barcodeIn; - Postazione.warningText = traduci("ERR-DTX-014"); - Postazione.CssClass = "stileComandoKo"; - } - else - { - - Postazione.messaggiText = string.Format("{0} {1} su dtx DECODIFICATO {2}", traduci("AssegnatoAttr"), ddlTipoAttr.SelectedValue, barcodeIn); - Postazione.CssClass = "stileComandoOk"; - // assegno attributo! - DataMatrix.mgr.taAtt2Dtx.insertAndProc(barcodeIn, true, "XF", string.Format("Assegnazione Attr {0} su Dtmx DECODIFICATO tipo {1}", ddlTipoAttr.SelectedValue, ddlFormDmtx.SelectedValue), DateTime.Now, MagClass.magazzino.CodSoggCurrUser); - grView.DataBind(); - } - break; - default: - Postazione.messaggiText += " - codice non riconosciuto!"; - Postazione.CssClass = "stileComandoND"; - divBlocca.Visible = false; - break; - } - barcodeIn = ""; + // errore corrispondenza formato Dtmx + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("ERR-DTX-014"); + Postazione.CssClass = "stileComandoKo"; } else { - Postazione.messaggiText = traduci("AttesaBCode"); - Postazione.CssClass = "stileAttesa"; - } - txtBarcode.Focus(); - } - /// - /// aggiorna tabella + focus a barcode - /// - public void doUpdate() - { - idxCella = Postazione.currIdxCella; - grView.DataBind(); - txtBarcode.Focus(); - // raise dell'evento - if (eh_reqUpdate != null) + Postazione.messaggiText = string.Format("{0} {1} su dtx TROVATO {2}", traduci("AssegnatoAttr"), ddlTipoAttr.SelectedValue, barcodeIn); + Postazione.CssClass = "stileComandoOk"; + // assegno attributo! + DataMatrix_mgr.taAtt2Dtx.insertAndProc(barcodeIn, true, "XF", string.Format("Assegnazione Attr {0} su Dtmx TROVATO tipo {1}", ddlTipoAttr.SelectedValue, ddlFormDmtx.SelectedValue), DateTime.Now, MagClass.magazzino.CodSoggCurrUser); + grView.DataBind(); + } + break; + case tipoCodiceBarcode.DataMatrixDecodificato: + // verifico formato datamatrix letto sia quello della linea... + if (FormatoDtmxBarcode != FormatoDtmxLinea) { - eh_reqUpdate(this, new EventArgs()); + // errore corrispondenza formato Dtmx + Postazione.messaggiText = barcodeIn; + Postazione.warningText = traduci("ERR-DTX-014"); + Postazione.CssClass = "stileComandoKo"; } - } - /// - /// effettua reset dati - /// - public void doResetData() - { - // resetto i dati QtaTot e particolare... - currParticolare = ""; - doChecks(); - } + else + { - protected void grView_PageIndexChanged(object sender, EventArgs e) - { - // fix dell'ODS - checkFixOds(); - } - protected void grView_Sorted(object sender, EventArgs e) - { - // fix dell'ODS - checkFixOds(); - } - /// - /// aggiorno ods al binding.. - /// - /// - /// - protected void ods_DataBinding(object sender, EventArgs e) - { - // fix dell'ODS - checkFixOds(); - } - /// - /// verifica se attivo filtro company e imposta ods di conseguenza... - /// - private void checkFixOds() - { - } - - - /// - /// sblocca UDC - /// - /// - /// - protected void BloccaUDC_Click(object sender, EventArgs e) - { - // va cancellata la sua relazioni Fuso-Sterrato e va spostato in locazione Fusi Terra - DataMatrix.mgr.taAtt2Dtx.insertAndProc(barcodeIn, true, "XF", "NC FUS B48", DateTime.Now, MagClass.magazzino.CodSoggCurrUser); - // resetto selezione + Postazione.messaggiText = string.Format("{0} {1} su dtx DECODIFICATO {2}", traduci("AssegnatoAttr"), ddlTipoAttr.SelectedValue, barcodeIn); + Postazione.CssClass = "stileComandoOk"; + // assegno attributo! + DataMatrix_mgr.taAtt2Dtx.insertAndProc(barcodeIn, true, "XF", string.Format("Assegnazione Attr {0} su Dtmx DECODIFICATO tipo {1}", ddlTipoAttr.SelectedValue, ddlFormDmtx.SelectedValue), DateTime.Now, MagClass.magazzino.CodSoggCurrUser); + grView.DataBind(); + } + break; + default: + Postazione.messaggiText += " - codice non riconosciuto!"; + Postazione.CssClass = "stileComandoND"; divBlocca.Visible = false; - currUDC = ""; - currParticolare = ""; - doUpdate(); - } - - protected void ddlFormDmtx_SelectedIndexChanged(object sender, EventArgs e) - { - checkFixOds(); - } - - protected void ddlTipoAttr_SelectedIndexChanged(object sender, EventArgs e) - { - checkFixOds(); + break; } + barcodeIn = ""; + } + else + { + Postazione.messaggiText = traduci("AttesaBCode"); + Postazione.CssClass = "stileAttesa"; + } + txtBarcode.Focus(); } + + /// + /// aggiorna tabella + focus a barcode + /// + public void doUpdate() + { + idxCella = Postazione.currIdxCella; + grView.DataBind(); + txtBarcode.Focus(); + // raise dell'evento + if (eh_reqUpdate != null) + { + eh_reqUpdate(this, new EventArgs()); + } + } + /// + /// effettua reset dati + /// + public void doResetData() + { + // resetto i dati QtaTot e particolare... + currParticolare = ""; + doChecks(); + } + + protected void grView_PageIndexChanged(object sender, EventArgs e) + { + // fix dell'ODS + checkFixOds(); + } + protected void grView_Sorted(object sender, EventArgs e) + { + // fix dell'ODS + checkFixOds(); + } + /// + /// aggiorno ods al binding.. + /// + /// + /// + protected void ods_DataBinding(object sender, EventArgs e) + { + // fix dell'ODS + checkFixOds(); + } + /// + /// verifica se attivo filtro company e imposta ods di conseguenza... + /// + private void checkFixOds() + { + } + + + /// + /// sblocca UDC + /// + /// + /// + protected void BloccaUDC_Click(object sender, EventArgs e) + { + // va cancellata la sua relazioni Fuso-Sterrato e va spostato in locazione Fusi Terra + DataMatrix_mgr.taAtt2Dtx.insertAndProc(barcodeIn, true, "XF", "NC FUS B48", DateTime.Now, MagClass.magazzino.CodSoggCurrUser); + // resetto selezione + divBlocca.Visible = false; + currUDC = ""; + currParticolare = ""; + doUpdate(); + } + + protected void ddlFormDmtx_SelectedIndexChanged(object sender, EventArgs e) + { + checkFixOds(); + } + + protected void ddlTipoAttr_SelectedIndexChanged(object sender, EventArgs e) + { + checkFixOds(); + } + } } \ No newline at end of file diff --git a/GMW/WebUserControls/mod_specDmtx.ascx.cs b/GMW/WebUserControls/mod_specDmtx.ascx.cs index 0a182935..9bf5da9e 100644 --- a/GMW/WebUserControls/mod_specDmtx.ascx.cs +++ b/GMW/WebUserControls/mod_specDmtx.ascx.cs @@ -7,158 +7,162 @@ using System.Web.UI.WebControls; namespace GMW.WebUserControls { - public partial class mod_specDmtx : ApplicationUserControl + public partial class mod_specDmtx : ApplicationUserControl + { + /// + /// Oggetto locale gestione classe datamatrix... + /// + protected DataMatrix DataMatrix_mgr = new DataMatrix(); + /// + /// reset della selezione + /// + /// + /// + protected void btnReset_Click(object sender, EventArgs e) { - /// - /// reset della selezione - /// - /// - /// - protected void btnReset_Click(object sender, EventArgs e) - { - resetSelezione(); - } - /// - /// resetta la selezione dei valori in caso di modifiche su altri controlli - /// - public void resetSelezione() - { - grView.SelectedIndex = -1; - grView.DataBind(); - raiseEvent(ucEvType.Reset); - } - /// - /// inserisce nuovo valore da footer - /// - /// - /// - protected void lblIns_click(object sender, EventArgs e) - { - // click su inserimento, chiamo il metodo insert dell'ObjectDataSource - ods.Insert(); - } - /// - /// gestione evento richiesta nuovo valore (mostra footer, ...) - /// - /// - /// - protected void btnNew_Click(object sender, EventArgs e) - { - // reset selezione... - resetSelezione(); - // mostro il footer oppure la riga dei dettagli x nuovo... - if (grView.FooterRow != null) - { - grView.FooterRow.Visible = true; - } - } - /// - /// determina se sia eliminabile il record (=non usato) - /// - /// - /// - public bool delEnabled(object idxObj) - { - bool answ = isWritable(); - - return answ; - } - - /// - /// elenco colonne del datagrid - /// - /// - protected DataColumnCollection colonneObj() - { - DS_DataMatrix.TabSpecDtxDataTable tabella = new DS_DataMatrix.TabSpecDtxDataTable(); - DataColumnCollection colonne = tabella.Columns; - return colonne; - } - /// - /// recupera i dati di un nuovo record contenuti nel footer di un gridView; - /// questi devono essere opportunamente nominati (es: txt{0}, dl{0}, ...) - /// - /// - /// - protected void recuperaFooter(object sender, ObjectDataSourceMethodEventArgs e) - { - //recupero la riga footer... - DataColumnCollection colonne = colonneObj(); - string nomeCol; - string tipoColonna = ""; - foreach (DataColumn colonna in colonne) - { - nomeCol = colonna.ColumnName; - // cerco un textbox o quello che sia... - if (grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol)) != null) - { - tipoColonna = "textBox"; - } - else if (grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol)) != null) - { - tipoColonna = "dropDownList"; - } - else if (grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol)) != null) - { - tipoColonna = "checkBox"; - } - else if (grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol)) != null) - { - tipoColonna = "selAjax"; - } - // in base al tipo salvo negli inputparameters dell'ODS - switch (tipoColonna) - { - case "textBox": - e.InputParameters[nomeCol] = ((TextBox)grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol))).Text; - break; - case "dropDownList": - e.InputParameters[nomeCol] = ((DropDownList)grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol))).SelectedValue; - break; - case "checkBox": - e.InputParameters[nomeCol] = ((CheckBox)grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol))).Checked; - break; - case "selAjax": - e.InputParameters[nomeCol] = ((mod_selettore_ajax)grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol))).valore; - break; - default: - break; - } - tipoColonna = ""; - } - // imposto formato Dtmx - e.InputParameters["FormatoDtmx"] = FormatoDtmx; - if (e.InputParameters["ValoreStr"] == null) e.InputParameters["ValoreStr"] = ""; - } - - protected void grView_SelectedIndexChanged(object sender, EventArgs e) - { - raiseEvent(ucEvType.Selected); - } - - public string FormatoDtmx - { - get - { - return hfFormatoDtmx.Value; - } - set - { - hfFormatoDtmx.Value = value; - grView.SelectedIndex = -1; - } - } - - protected void ods_Updating(object sender, ObjectDataSourceMethodEventArgs e) - { - if (e.InputParameters["ValoreStr"] == null) e.InputParameters["ValoreStr"] = ""; - } - - protected void btnNewFromEmpty_Click(object sender, EventArgs e) - { - // creo record x la lunghezza - DataMatrix.mgr.taSpecDtmx.Insert(FormatoDtmx, "LUNGH", "", FormatoDtmx.Length, "", 0, true); - grView.DataBind(); - } + resetSelezione(); } + /// + /// resetta la selezione dei valori in caso di modifiche su altri controlli + /// + public void resetSelezione() + { + grView.SelectedIndex = -1; + grView.DataBind(); + raiseEvent(ucEvType.Reset); + } + /// + /// inserisce nuovo valore da footer + /// + /// + /// + protected void lblIns_click(object sender, EventArgs e) + { + // click su inserimento, chiamo il metodo insert dell'ObjectDataSource + ods.Insert(); + } + /// + /// gestione evento richiesta nuovo valore (mostra footer, ...) + /// + /// + /// + protected void btnNew_Click(object sender, EventArgs e) + { + // reset selezione... + resetSelezione(); + // mostro il footer oppure la riga dei dettagli x nuovo... + if (grView.FooterRow != null) + { + grView.FooterRow.Visible = true; + } + } + /// + /// determina se sia eliminabile il record (=non usato) + /// + /// + /// + public bool delEnabled(object idxObj) + { + bool answ = isWritable(); + + return answ; + } + + /// + /// elenco colonne del datagrid + /// + /// + protected DataColumnCollection colonneObj() + { + DS_DataMatrix.TabSpecDtxDataTable tabella = new DS_DataMatrix.TabSpecDtxDataTable(); + DataColumnCollection colonne = tabella.Columns; + return colonne; + } + /// + /// recupera i dati di un nuovo record contenuti nel footer di un gridView; + /// questi devono essere opportunamente nominati (es: txt{0}, dl{0}, ...) + /// + /// + /// + protected void recuperaFooter(object sender, ObjectDataSourceMethodEventArgs e) + { + //recupero la riga footer... + DataColumnCollection colonne = colonneObj(); + string nomeCol; + string tipoColonna = ""; + foreach (DataColumn colonna in colonne) + { + nomeCol = colonna.ColumnName; + // cerco un textbox o quello che sia... + if (grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol)) != null) + { + tipoColonna = "textBox"; + } + else if (grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol)) != null) + { + tipoColonna = "dropDownList"; + } + else if (grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol)) != null) + { + tipoColonna = "checkBox"; + } + else if (grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol)) != null) + { + tipoColonna = "selAjax"; + } + // in base al tipo salvo negli inputparameters dell'ODS + switch (tipoColonna) + { + case "textBox": + e.InputParameters[nomeCol] = ((TextBox)grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol))).Text; + break; + case "dropDownList": + e.InputParameters[nomeCol] = ((DropDownList)grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol))).SelectedValue; + break; + case "checkBox": + e.InputParameters[nomeCol] = ((CheckBox)grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol))).Checked; + break; + case "selAjax": + e.InputParameters[nomeCol] = ((mod_selettore_ajax)grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol))).valore; + break; + default: + break; + } + tipoColonna = ""; + } + // imposto formato Dtmx + e.InputParameters["FormatoDtmx"] = FormatoDtmx; + if (e.InputParameters["ValoreStr"] == null) e.InputParameters["ValoreStr"] = ""; + } + + protected void grView_SelectedIndexChanged(object sender, EventArgs e) + { + raiseEvent(ucEvType.Selected); + } + + public string FormatoDtmx + { + get + { + return hfFormatoDtmx.Value; + } + set + { + hfFormatoDtmx.Value = value; + grView.SelectedIndex = -1; + } + } + + protected void ods_Updating(object sender, ObjectDataSourceMethodEventArgs e) + { + if (e.InputParameters["ValoreStr"] == null) e.InputParameters["ValoreStr"] = ""; + } + + protected void btnNewFromEmpty_Click(object sender, EventArgs e) + { + // creo record x la lunghezza + DataMatrix_mgr.taSpecDtmx.Insert(FormatoDtmx, "LUNGH", "", FormatoDtmx.Length, "", 0, true); + grView.DataBind(); + } + } } \ No newline at end of file diff --git a/GMW/WebUserControls/mod_spostaDataMatrix.ascx.cs b/GMW/WebUserControls/mod_spostaDataMatrix.ascx.cs index 3130cd37..6dd374a4 100644 --- a/GMW/WebUserControls/mod_spostaDataMatrix.ascx.cs +++ b/GMW/WebUserControls/mod_spostaDataMatrix.ascx.cs @@ -5,344 +5,348 @@ using System.Web.UI; namespace GMW.WebUserControls { - public partial class mod_spostaDataMatrix : System.Web.UI.UserControl + public partial class mod_spostaDataMatrix : System.Web.UI.UserControl + { + /// + /// Oggetto locale gestione classe datamatrix... + /// + protected DataMatrix DataMatrix_mgr = new DataMatrix(); + /// + /// controlli al caricamento pagina + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) { - /// - /// controlli al caricamento pagina - /// - /// - /// - protected void Page_Load(object sender, EventArgs e) + // se primo caricamento resetto gitterbox...) + if (!Page.IsPostBack) + { + currGitterBox = ""; + pnlAll.CssClass = "stileAttesa"; + } + checkBarcode(); + lblPezziGitterbox.Text = string.Format("{0} pz.", pezziGitterbox); + lblCurrentPage.Text = traduci(PagCorrente); + if (currGitterBox != "") + { + lblGitterBoxAttivo.Text = string.Format("Gitterbox selezionato {0}", currGitterBox); + } + else + { + lblGitterBoxAttivo.Text = "..."; + } + } + /// + /// restituisce il nome della pagina corrente + /// + protected string PagCorrente + { + get + { + string answ = ""; + Uri MyUrl = Request.Url; + string delimStr = "/"; + char[] delimiter = delimStr.ToCharArray(); + string[] finalUrl = MyUrl.LocalPath.ToString().Split(delimiter); + int n = finalUrl.Length; + answ = finalUrl[n - 1].ToString(); + DataLayer_AnagGen.PermessiRow riga = (DataLayer_AnagGen.PermessiRow)user_std.UtSn.permessi.Select(string.Format("URL = '{0}'", answ))[0]; + answ = riga.NOME; + return answ; + } + } + /// + /// wrapper traduzione + /// + /// + /// + public string traduci(object lemma) + { + return user_std.UtSn.Traduci(lemma.ToString()); + } + /// + /// num pezzi del gitterbox + /// + public int pezziGitterbox + { + get + { + int answ = 0; + try { - // se primo caricamento resetto gitterbox...) - if (!Page.IsPostBack) + answ = (int)MagClass.magazzino.taCartellini.getByUdc(currGitterBox)[0].Qta; + } + catch + { } + return answ; + } + } + /// + /// indica il gitterbox correntemente selezionato + /// + protected string currGitterBox + { + get + { + return memLayer.ML.StringSessionObj("currGitterBox"); + } + set + { + memLayer.ML.setSessionVal("currGitterBox", value); + } + } + /// + /// controllo booleano sul gitterbox se sia ok x caricamento altri pezzi (ovvero en contiene meno del max consentito + /// + protected bool gitterboxOk + { + get + { + bool answ = false; + int maxPezzi = memLayer.ML.confReadInt("qtaOdette"); + int numPezzi = maxPezzi; + try + { + numPezzi = (int)MagClass.magazzino.taCartellini.getByUdc(currGitterBox)[0].Qta; + } + catch + { + httpLog(string.Format("Non sono riuscito a trovare dati per il gitterbox {0}", currGitterBox), tipoLog.ERROR); + } + // controllo se il codice sia "Pieno", ovvero max pezzi + if (numPezzi < maxPezzi) + { + answ = true; + } + return answ; + } + } + /// + /// wrapper per log con salvataggio dell'IP del chiamante + /// + /// + /// + public bool httpLog(string _testoPre) + { + bool answ = false; + string postazione_IP = ""; + try + { + postazione_IP = string.Format(" | {0} | ", Request.UserHostName); + } + catch + { } + logger.lg.scriviLog(postazione_IP + _testoPre); + return answ; + } + /// + /// wrapper per log con salvataggio dell'IP del chiamante + /// + /// + /// + public bool httpLog(string testoLog, tipoLog tipo) + { + bool answ = false; + string postazione_IP = ""; + try + { + postazione_IP = string.Format(" | {0} | ", Request.UserHostName); + } + catch + { } + logger.lg.scriviLog(postazione_IP + testoLog, tipo); + return answ; + } + + /// + /// controlla se ci sia un barcode + /// + private void checkBarcode() + { + if (barcodeIn != "") + { + lblMessaggi.Text = string.Format("Barcode digitato: {0}", barcodeIn); + switch (tipoBCode) + { + case tipoCodiceBarcode.Gitterbox: + // imposto il gitterbox corrente + currGitterBox = barcodeIn; + if (gitterboxOk) { + // controllo se il gitterbox non sia stato già associato ad una etichetta odette - non si può spostare + if (Odette.mgr.gitterboxInOdette(currGitterBox)) + { currGitterBox = ""; - pnlAll.CssClass = "stileAttesa"; + lblMessaggi.Text += " - gitterbox associatoad odette!!! non impostabile."; + pnlAll.CssClass = "stileComandoKo"; + } + else + { + lblMessaggi.Text += " - impostato nuovo gitterbox di destinazione!"; + pnlAll.CssClass = "stileComandoOk"; + } } - checkBarcode(); - lblPezziGitterbox.Text = string.Format("{0} pz.", pezziGitterbox); - lblCurrentPage.Text = traduci(PagCorrente); + else + { + lblMessaggi.Text += " - gitterbox pieno!!! impostato, ma non si possono versare altri pezzi."; + pnlAll.CssClass = "stileComandoKo"; + } + break; + case tipoCodiceBarcode.DataMatrixTrovato: + // se c'è un gitterbox attivo sposto il datamatrix if (currGitterBox != "") { - lblGitterBoxAttivo.Text = string.Format("Gitterbox selezionato {0}", currGitterBox); - } - else - { - lblGitterBoxAttivo.Text = "..."; - } - } - /// - /// restituisce il nome della pagina corrente - /// - protected string PagCorrente - { - get - { - string answ = ""; - Uri MyUrl = Request.Url; - string delimStr = "/"; - char[] delimiter = delimStr.ToCharArray(); - string[] finalUrl = MyUrl.LocalPath.ToString().Split(delimiter); - int n = finalUrl.Length; - answ = finalUrl[n - 1].ToString(); - DataLayer_AnagGen.PermessiRow riga = (DataLayer_AnagGen.PermessiRow)user_std.UtSn.permessi.Select(string.Format("URL = '{0}'", answ))[0]; - answ = riga.NOME; - return answ; - } - } - /// - /// wrapper traduzione - /// - /// - /// - public string traduci(object lemma) - { - return user_std.UtSn.Traduci(lemma.ToString()); - } - /// - /// num pezzi del gitterbox - /// - public int pezziGitterbox - { - get - { - int answ = 0; - try + if (gitterboxOk) + { + decimal dataMatrix = Convert.ToDecimal(barcodeIn); + // controllo che esissta il datamatrix... + if (Odette.mgr.datamatrixEsiste(dataMatrix)) { - answ = (int)MagClass.magazzino.taCartellini.getByUdc(currGitterBox)[0].Qta; - } - catch - { } - return answ; - } - } - /// - /// indica il gitterbox correntemente selezionato - /// - protected string currGitterBox - { - get - { - return memLayer.ML.StringSessionObj("currGitterBox"); - } - set - { - memLayer.ML.setSessionVal("currGitterBox", value); - } - } - /// - /// controllo booleano sul gitterbox se sia ok x caricamento altri pezzi (ovvero en contiene meno del max consentito - /// - protected bool gitterboxOk - { - get - { - bool answ = false; - int maxPezzi = memLayer.ML.confReadInt("qtaOdette"); - int numPezzi = maxPezzi; - try - { - numPezzi = (int)MagClass.magazzino.taCartellini.getByUdc(currGitterBox)[0].Qta; - } - catch - { - httpLog(string.Format("Non sono riuscito a trovare dati per il gitterbox {0}", currGitterBox), tipoLog.ERROR); - } - // controllo se il codice sia "Pieno", ovvero max pezzi - if (numPezzi < maxPezzi) - { - answ = true; - } - return answ; - } - } - /// - /// wrapper per log con salvataggio dell'IP del chiamante - /// - /// - /// - public bool httpLog(string _testoPre) - { - bool answ = false; - string postazione_IP = ""; - try - { - postazione_IP = string.Format(" | {0} | ", Request.UserHostName); - } - catch - { } - logger.lg.scriviLog(postazione_IP + _testoPre); - return answ; - } - /// - /// wrapper per log con salvataggio dell'IP del chiamante - /// - /// - /// - public bool httpLog(string testoLog, tipoLog tipo) - { - bool answ = false; - string postazione_IP = ""; - try - { - postazione_IP = string.Format(" | {0} | ", Request.UserHostName); - } - catch - { } - logger.lg.scriviLog(postazione_IP + testoLog, tipo); - return answ; - } - - /// - /// controlla se ci sia un barcode - /// - private void checkBarcode() - { - if (barcodeIn != "") - { - lblMessaggi.Text = string.Format("Barcode digitato: {0}", barcodeIn); - switch (tipoBCode) - { - case tipoCodiceBarcode.Gitterbox: - // imposto il gitterbox corrente - currGitterBox = barcodeIn; - if (gitterboxOk) - { - // controllo se il gitterbox non sia stato già associato ad una etichetta odette - non si può spostare - if (Odette.mgr.gitterboxInOdette(currGitterBox)) - { - currGitterBox = ""; - lblMessaggi.Text += " - gitterbox associatoad odette!!! non impostabile."; - pnlAll.CssClass = "stileComandoKo"; - } - else - { - lblMessaggi.Text += " - impostato nuovo gitterbox di destinazione!"; - pnlAll.CssClass = "stileComandoOk"; - } - } - else - { - lblMessaggi.Text += " - gitterbox pieno!!! impostato, ma non si possono versare altri pezzi."; - pnlAll.CssClass = "stileComandoKo"; - } - break; - case tipoCodiceBarcode.DataMatrixTrovato: - // se c'è un gitterbox attivo sposto il datamatrix - if (currGitterBox != "") - { - if (gitterboxOk) - { - decimal dataMatrix = Convert.ToDecimal(barcodeIn); - // controllo che esissta il datamatrix... - if (Odette.mgr.datamatrixEsiste(dataMatrix)) - { - // effettuo spostamento del datamatrix nel nuovo gitterbox - if (!Odette.mgr.datamatrixInOdette(dataMatrix)) - { - // controllo che il gitterbox sia coerente col datamatrix per prodotto... - if (Odette.mgr.dtMtxGtboxCompatibili(dataMatrix, currGitterBox)) - { - DataMatrix.mgr.taElencoDM.spostaInGitterbox(dataMatrix, currGitterBox, MagClass.magazzino.CodSoggCurrUser); - lblMessaggi.Text += " - spostato nel gitterbox attivo!"; - pnlAll.CssClass = "stileComandoAdd"; - } - else - { - lblMessaggi.Text += " - datamatrix non spostabile, il gitterbox contiene prodotti diversi!"; - pnlAll.CssClass = "stileErr01"; - } - } - else - { - lblMessaggi.Text += " - datamatrix non spostabile, in gitterbox già associato ad odette!"; - pnlAll.CssClass = "stileErr03"; - } - } - else - { - lblMessaggi.Text += " - datamatrix non trovato!"; - pnlAll.CssClass = "stileErr02"; - } - } - else - { - lblMessaggi.Text += " - il gitterbox è pieno!!!"; - pnlAll.CssClass = "stileComandoKo"; - } - } - else - { - // altrimenti segnalo che manca il gitterbox di destinazione - lblMessaggi.Text += " - errore, manca un gitterbox di destinazione!"; - pnlAll.CssClass = "stileComandoKo"; - } - break; - case tipoCodiceBarcode.Comando: - // controllo se è svuota gitterbox, nel caso lo svuoto - string cmdSvuotaGbox = memLayer.ML.cdv("cmdSvuotaGitterBox"); - string cmdEsci = memLayer.ML.cdv("cmdEsci"); - if (barcodeIn == cmdSvuotaGbox) - { - if (gitterboxOk) - { - DataMatrix.mgr.taElencoDM.svuotaGitterbox(currGitterBox, MagClass.magazzino.CodSoggCurrUser); - lblMessaggi.Text += " - Gitterbox svuotato!"; - pnlAll.CssClass = "stileAttesa"; - } - } - else if (barcodeIn == cmdEsci) - { - currGitterBox = ""; - Response.Redirect("~/menu.aspx"); - } - else - { - lblMessaggi.Text += " - codice comando non riconosciuto!"; - } - break; - default: - lblMessaggi.Text += " - codice non riconosciuto!"; - pnlAll.CssClass = "stileComandoND"; - break; - } - barcodeIn = ""; - } - else - { - lblMessaggi.Text = traduci("AttesaBCode"); - pnlAll.CssClass = "stileAttesa"; - } - grView.DataBind(); - txtBarcode.Focus(); - } - /// - /// - /// - public tipoCodiceBarcode tipoBCode - { - get - { - tipoCodiceBarcode answ = tipoCodiceBarcode.ND; - int trovati = 0; - // controllo non si tratti di un comando... - string preCmd = memLayer.ML.AppConf["prefComandi"]; - if (barcodeIn.StartsWith(preCmd)) - { - answ = tipoCodiceBarcode.Comando; + // effettuo spostamento del datamatrix nel nuovo gitterbox + if (!Odette.mgr.datamatrixInOdette(dataMatrix)) + { + // controllo che il gitterbox sia coerente col datamatrix per prodotto... + if (Odette.mgr.dtMtxGtboxCompatibili(dataMatrix, currGitterBox)) + { + DataMatrix_mgr.taElencoDM.spostaInGitterbox(dataMatrix, currGitterBox, MagClass.magazzino.CodSoggCurrUser); + lblMessaggi.Text += " - spostato nel gitterbox attivo!"; + pnlAll.CssClass = "stileComandoAdd"; + } + else + { + lblMessaggi.Text += " - datamatrix non spostabile, il gitterbox contiene prodotti diversi!"; + pnlAll.CssClass = "stileErr01"; + } + } + else + { + lblMessaggi.Text += " - datamatrix non spostabile, in gitterbox già associato ad odette!"; + pnlAll.CssClass = "stileErr03"; + } } else { - try - { - // cerco tra gitterbox (UDC)... - trovati = MagClass.magazzino.taCartellini.getByUdc(barcodeIn).Rows.Count; - // cerco tra datamatrix - if (trovati > 0) - { - answ = tipoCodiceBarcode.Gitterbox; - } - else - { - trovati = DataMatrix.mgr.taElencoDM.getByCode(Convert.ToDecimal(barcodeIn)).Rows.Count; - if (trovati > 0) - { - answ = tipoCodiceBarcode.DataMatrixTrovato; - } - } - - } - catch - { - } + lblMessaggi.Text += " - datamatrix non trovato!"; + pnlAll.CssClass = "stileErr02"; } - return answ; + } + else + { + lblMessaggi.Text += " - il gitterbox è pieno!!!"; + pnlAll.CssClass = "stileComandoKo"; + } } - } - /// - /// valore barcode - /// - public string barcodeIn - { - get + else { - return txtBarcode.Text.Trim(); + // altrimenti segnalo che manca il gitterbox di destinazione + lblMessaggi.Text += " - errore, manca un gitterbox di destinazione!"; + pnlAll.CssClass = "stileComandoKo"; } - set + break; + case tipoCodiceBarcode.Comando: + // controllo se è svuota gitterbox, nel caso lo svuoto + string cmdSvuotaGbox = memLayer.ML.cdv("cmdSvuotaGitterBox"); + string cmdEsci = memLayer.ML.cdv("cmdEsci"); + if (barcodeIn == cmdSvuotaGbox) { - txtBarcode.Text = value; + if (gitterboxOk) + { + DataMatrix_mgr.taElencoDM.svuotaGitterbox(currGitterBox, MagClass.magazzino.CodSoggCurrUser); + lblMessaggi.Text += " - Gitterbox svuotato!"; + pnlAll.CssClass = "stileAttesa"; + } } - } - /// - /// indica se i caratteri vadano forzati a maiuscoli - /// - public bool forceUppercase - { - get + else if (barcodeIn == cmdEsci) { - return memLayer.ML.confReadBool("forceUppercase"); + currGitterBox = ""; + Response.Redirect("~/menu.aspx"); } + else + { + lblMessaggi.Text += " - codice comando non riconosciuto!"; + } + break; + default: + lblMessaggi.Text += " - codice non riconosciuto!"; + pnlAll.CssClass = "stileComandoND"; + break; } + barcodeIn = ""; + } + else + { + lblMessaggi.Text = traduci("AttesaBCode"); + pnlAll.CssClass = "stileAttesa"; + } + grView.DataBind(); + txtBarcode.Focus(); } + /// + /// + /// + public tipoCodiceBarcode tipoBCode + { + get + { + tipoCodiceBarcode answ = tipoCodiceBarcode.ND; + int trovati = 0; + // controllo non si tratti di un comando... + string preCmd = memLayer.ML.AppConf["prefComandi"]; + if (barcodeIn.StartsWith(preCmd)) + { + answ = tipoCodiceBarcode.Comando; + } + else + { + try + { + // cerco tra gitterbox (UDC)... + trovati = MagClass.magazzino.taCartellini.getByUdc(barcodeIn).Rows.Count; + // cerco tra datamatrix + if (trovati > 0) + { + answ = tipoCodiceBarcode.Gitterbox; + } + else + { + trovati = DataMatrix_mgr.taElencoDM.getByCode(Convert.ToDecimal(barcodeIn)).Rows.Count; + if (trovati > 0) + { + answ = tipoCodiceBarcode.DataMatrixTrovato; + } + } + + } + catch + { + } + } + return answ; + } + } + /// + /// valore barcode + /// + public string barcodeIn + { + get + { + return txtBarcode.Text.Trim(); + } + set + { + txtBarcode.Text = value; + } + } + /// + /// indica se i caratteri vadano forzati a maiuscoli + /// + public bool forceUppercase + { + get + { + return memLayer.ML.confReadBool("forceUppercase"); + } + } + } } \ No newline at end of file diff --git a/GMW/WebUserControls/mod_trascPn2Part.ascx.cs b/GMW/WebUserControls/mod_trascPn2Part.ascx.cs index 3391aa07..63f47d26 100644 --- a/GMW/WebUserControls/mod_trascPn2Part.ascx.cs +++ b/GMW/WebUserControls/mod_trascPn2Part.ascx.cs @@ -6,190 +6,194 @@ using System.Web.UI.WebControls; namespace GMW.WebUserControls { - public partial class mod_trascPn2Part : ApplicationUserControl + public partial class mod_trascPn2Part : ApplicationUserControl + { + /// + /// Oggetto locale gestione classe datamatrix... + /// + protected DataMatrix DataMatrix_mgr = new DataMatrix(); + /// + /// reset della selezione + /// + /// + /// + protected void btnReset_Click(object sender, EventArgs e) { - /// - /// reset della selezione - /// - /// - /// - protected void btnReset_Click(object sender, EventArgs e) - { - resetSelezione(); - } - /// - /// resetta la selezione dei valori in caso di modifiche su altri controlli - /// - public void resetSelezione() - { - grView.SelectedIndex = -1; - grView.DataBind(); - raiseEvent(ucEvType.Reset); - } - /// - /// inserisce nuovo valore da footer - /// - /// - /// - protected void lblIns_click(object sender, EventArgs e) - { - // click su inserimento, chiamo il metodo insert dell'ObjectDataSource - ods.Insert(); - } - /// - /// gestione evento richiesta nuovo valore (mostra footer, ...) - /// - /// - /// - protected void btnNew_Click(object sender, EventArgs e) - { - // reset selezione... - resetSelezione(); - // mostro il footer oppure la riga dei dettagli x nuovo... - if (grView.FooterRow != null) - { - grView.FooterRow.Visible = true; - } - } - /// - /// determina se sia eliminabile il record (=non usato) - /// - /// - /// - public bool delEnabled(object idxObj) - { - bool answ = isWritable(); - - return answ; - } - - /// - /// elenco colonne del datagrid - /// - /// - protected DataColumnCollection colonneObj() - { - DS_DataMatrix.TrascDatamatrixDataTable tabella = new DS_DataMatrix.TrascDatamatrixDataTable(); - DataColumnCollection colonne = tabella.Columns; - return colonne; - } - /// - /// recupera i dati di un nuovo record contenuti nel footer di un gridView; - /// questi devono essere opportunamente nominati (es: txt{0}, dl{0}, ...) - /// - /// - /// - protected void recuperaFooter(object sender, ObjectDataSourceMethodEventArgs e) - { - //recupero la riga footer... - DataColumnCollection colonne = colonneObj(); - string nomeCol; - string tipoColonna = ""; - foreach (DataColumn colonna in colonne) - { - nomeCol = colonna.ColumnName; - // cerco un textbox o quello che sia... - if (grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol)) != null) - { - tipoColonna = "textBox"; - } - else if (grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol)) != null) - { - tipoColonna = "dropDownList"; - } - else if (grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol)) != null) - { - tipoColonna = "checkBox"; - } - else if (grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol)) != null) - { - tipoColonna = "selAjax"; - } - // in base al tipo salvo negli inputparameters dell'ODS - switch (tipoColonna) - { - case "textBox": - e.InputParameters[nomeCol] = ((TextBox)grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol))).Text; - break; - case "dropDownList": - e.InputParameters[nomeCol] = ((DropDownList)grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol))).SelectedValue; - break; - case "checkBox": - e.InputParameters[nomeCol] = ((CheckBox)grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol))).Checked; - break; - case "selAjax": - e.InputParameters[nomeCol] = ((mod_selettore_ajax)grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol))).valore; - break; - default: - break; - } - tipoColonna = ""; - } - if (e.InputParameters["PartNumber"] == null) e.InputParameters["PartNumber"] = ""; - if (e.InputParameters["Particolare"] == null) e.InputParameters["Particolare"] = ""; - if (e.InputParameters["FormatoDtmx"] == null) e.InputParameters["FormatoDtmx"] = ""; - } - - protected void ods_Deleting(object sender, ObjectDataSourceMethodEventArgs e) - { - if (e.InputParameters["Original_PartNumber"] == null) e.InputParameters["Original_PartNumber"] = ""; - } - - protected void grView_SelectedIndexChanged(object sender, EventArgs e) - { - raiseEvent(ucEvType.Selected); - } - public string FormatoDtmx - { - get - { - return hfFormatoDtmx.Value; - } - set - { - hfFormatoDtmx.Value = value; - grView.SelectedIndex = -1; - } - } - public string PartNumber - { - get - { - return hfPartNumber.Value; - } - set - { - hfPartNumber.Value = value; - grView.SelectedIndex = -1; - } - } - public string PartNumberSel - { - get - { - string answ = ""; - try - { - answ = grView.SelectedDataKey["PartNumber"].ToString(); - } - catch - { } - return answ; - } - } - protected void ods_Updating(object sender, ObjectDataSourceMethodEventArgs e) - { - if (e.InputParameters["PartNumber"] == null) e.InputParameters["PartNumber"] = ""; - if (e.InputParameters["Particolare"] == null) e.InputParameters["Particolare"] = ""; - if (e.InputParameters["FormatoDtmx"] == null) e.InputParameters["FormatoDtmx"] = ""; - if (e.InputParameters["Original_PartNumber"] == null) e.InputParameters["Original_PartNumber"] = ""; - } - - protected void btnNewFromEmpty_Click(object sender, EventArgs e) - { - // creo record lunghezza 1... - DataMatrix.mgr.taTDtmx.Insert("000", "000", FormatoDtmx); - grView.DataBind(); - } + resetSelezione(); } + /// + /// resetta la selezione dei valori in caso di modifiche su altri controlli + /// + public void resetSelezione() + { + grView.SelectedIndex = -1; + grView.DataBind(); + raiseEvent(ucEvType.Reset); + } + /// + /// inserisce nuovo valore da footer + /// + /// + /// + protected void lblIns_click(object sender, EventArgs e) + { + // click su inserimento, chiamo il metodo insert dell'ObjectDataSource + ods.Insert(); + } + /// + /// gestione evento richiesta nuovo valore (mostra footer, ...) + /// + /// + /// + protected void btnNew_Click(object sender, EventArgs e) + { + // reset selezione... + resetSelezione(); + // mostro il footer oppure la riga dei dettagli x nuovo... + if (grView.FooterRow != null) + { + grView.FooterRow.Visible = true; + } + } + /// + /// determina se sia eliminabile il record (=non usato) + /// + /// + /// + public bool delEnabled(object idxObj) + { + bool answ = isWritable(); + + return answ; + } + + /// + /// elenco colonne del datagrid + /// + /// + protected DataColumnCollection colonneObj() + { + DS_DataMatrix.TrascDatamatrixDataTable tabella = new DS_DataMatrix.TrascDatamatrixDataTable(); + DataColumnCollection colonne = tabella.Columns; + return colonne; + } + /// + /// recupera i dati di un nuovo record contenuti nel footer di un gridView; + /// questi devono essere opportunamente nominati (es: txt{0}, dl{0}, ...) + /// + /// + /// + protected void recuperaFooter(object sender, ObjectDataSourceMethodEventArgs e) + { + //recupero la riga footer... + DataColumnCollection colonne = colonneObj(); + string nomeCol; + string tipoColonna = ""; + foreach (DataColumn colonna in colonne) + { + nomeCol = colonna.ColumnName; + // cerco un textbox o quello che sia... + if (grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol)) != null) + { + tipoColonna = "textBox"; + } + else if (grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol)) != null) + { + tipoColonna = "dropDownList"; + } + else if (grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol)) != null) + { + tipoColonna = "checkBox"; + } + else if (grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol)) != null) + { + tipoColonna = "selAjax"; + } + // in base al tipo salvo negli inputparameters dell'ODS + switch (tipoColonna) + { + case "textBox": + e.InputParameters[nomeCol] = ((TextBox)grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol))).Text; + break; + case "dropDownList": + e.InputParameters[nomeCol] = ((DropDownList)grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol))).SelectedValue; + break; + case "checkBox": + e.InputParameters[nomeCol] = ((CheckBox)grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol))).Checked; + break; + case "selAjax": + e.InputParameters[nomeCol] = ((mod_selettore_ajax)grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol))).valore; + break; + default: + break; + } + tipoColonna = ""; + } + if (e.InputParameters["PartNumber"] == null) e.InputParameters["PartNumber"] = ""; + if (e.InputParameters["Particolare"] == null) e.InputParameters["Particolare"] = ""; + if (e.InputParameters["FormatoDtmx"] == null) e.InputParameters["FormatoDtmx"] = ""; + } + + protected void ods_Deleting(object sender, ObjectDataSourceMethodEventArgs e) + { + if (e.InputParameters["Original_PartNumber"] == null) e.InputParameters["Original_PartNumber"] = ""; + } + + protected void grView_SelectedIndexChanged(object sender, EventArgs e) + { + raiseEvent(ucEvType.Selected); + } + public string FormatoDtmx + { + get + { + return hfFormatoDtmx.Value; + } + set + { + hfFormatoDtmx.Value = value; + grView.SelectedIndex = -1; + } + } + public string PartNumber + { + get + { + return hfPartNumber.Value; + } + set + { + hfPartNumber.Value = value; + grView.SelectedIndex = -1; + } + } + public string PartNumberSel + { + get + { + string answ = ""; + try + { + answ = grView.SelectedDataKey["PartNumber"].ToString(); + } + catch + { } + return answ; + } + } + protected void ods_Updating(object sender, ObjectDataSourceMethodEventArgs e) + { + if (e.InputParameters["PartNumber"] == null) e.InputParameters["PartNumber"] = ""; + if (e.InputParameters["Particolare"] == null) e.InputParameters["Particolare"] = ""; + if (e.InputParameters["FormatoDtmx"] == null) e.InputParameters["FormatoDtmx"] = ""; + if (e.InputParameters["Original_PartNumber"] == null) e.InputParameters["Original_PartNumber"] = ""; + } + + protected void btnNewFromEmpty_Click(object sender, EventArgs e) + { + // creo record lunghezza 1... + DataMatrix_mgr.taTDtmx.Insert("000", "000", FormatoDtmx); + grView.DataBind(); + } + } } \ No newline at end of file diff --git a/GMW/WebUserControls/mod_verificaDmtx.ascx.cs b/GMW/WebUserControls/mod_verificaDmtx.ascx.cs index fb5d2a5b..8f7a329c 100644 --- a/GMW/WebUserControls/mod_verificaDmtx.ascx.cs +++ b/GMW/WebUserControls/mod_verificaDmtx.ascx.cs @@ -3,150 +3,154 @@ using System; namespace GMW.WebUserControls { - public partial class mod_verificaDmtx : GMW_data.UserControl + public partial class mod_verificaDmtx : GMW_data.UserControl + { + /// + /// Oggetto locale gestione classe datamatrix... + /// + protected DataMatrix DataMatrix_mgr = new DataMatrix(); + protected void Page_Load(object sender, EventArgs e) { - protected void Page_Load(object sender, EventArgs e) - { - txtBarcode.Focus(); - } - /// - /// controlla se ci sia un barcode - /// - private void checkBarcode() - { - bool isDecodOk = false; - bool isInList = true; - - // verifico - isDecodOk = (DataMatrix.mgr.taAnagFormDtx.getFormatiCompatibili(barcodeIn).Rows.Count > 0); - isInList = (DataMatrix.mgr.taVED.getByKey(barcodeIn).Rows.Count > 0); - - // imposto di conseguenza grafica e info - string classDivDec = "col-sm-6 bg-danger"; - string classDivList = "col-sm-6 bg-danger"; - if (isDecodOk) - { - //divDecod.Attributes.Add("class", "col-sm-6 bg-success"); - classDivDec = "col-sm-6 bg-success"; - } - else - { - //divDecod.Attributes.Add("class", "col-sm-6 bg-danger"); - classDivDec = "col-sm-6 bg-danger"; - } - if (isInList) - { - //divElenco.Attributes.Add("class", "col-sm-6 bg-success"); - classDivList = "col-sm-6 bg-success"; - } - else - { - //divElenco.Attributes.Add("class", "col-sm-6 bg-danger"); - classDivList = "col-sm-6 bg-danger"; - } - // aggiorno visualizzazione... - if (isDecodOk || isInList) - { - lblBarcode.Text = string.Format("Datamatrix: {0}", barcodeIn); - if (isDecodOk) - { - lblEsitoDec.Text = string.Format("{0}: OK", traduci("VerificaDecodifica")); - DS_DataMatrix.AnagFormatiDtmxRow riga = (DS_DataMatrix.AnagFormatiDtmxRow)DataMatrix.mgr.taAnagFormDtx.getFormatiCompatibili(barcodeIn).Rows[0]; - lblFormatoDmtxDec.Text = string.Format("Formato: {0}", riga.FormatoDtmx); - // controllo se il PartNum venga decodificato --> lo decodifico e mostro entrambi - string PartNumIn = barcodeIn.Substring(riga.PartNumberPos - 1, riga.PartNumberLun); - string PartNum = ""; - string Particolare = ""; - if (DataMatrix.mgr.taTPN.getByPN_IN(PartNumIn).Rows.Count > 0) - { - PartNum = ((DS_DataMatrix.TrascPartNumRow)DataMatrix.mgr.taTPN.getByPN_IN(PartNumIn).Rows[0]).PartNumberOUT; - } - else - { - PartNum = PartNumIn; - } - try - { - Particolare = ((DS_DataMatrix.TrascDatamatrixRow)DataMatrix.mgr.taTDtmx.getByPnFormato(riga.FormatoDtmx, PartNum).Rows[0]).Particolare; - } - catch - { - Particolare = "Non Trovato"; - lblEsitoDec.Text += "/ND"; - classDivDec = "col-sm-6 bg-warning"; - } - lblPartNumDec.Text = string.Format("Part Num: {0}", PartNum); - // se fosse stato decodificato - if (PartNum != PartNumIn) - { - lblPartNumDec.Text += string.Format("
({0})", PartNumIn); - } - lblCodPartDec.Text = string.Format("Cod Part: {0}", Particolare); - } - else - { - lblEsitoDec.Text += string.Format("{0}: KO", traduci("VerificaDecodifica")); - lblFormatoDmtxDec.Text = "..."; - lblPartNumDec.Text = ".."; - lblCodPartDec.Text = "."; - } - if (isInList) - { - lblEsitoAcq.Text = string.Format("{0}: OK", traduci("VerificaAcquisizioni")); - DS_DataMatrix.v_ElencoDmtxRow riga = ((DS_DataMatrix.v_ElencoDmtxRow)DataMatrix.mgr.taVED.getByKey(barcodeIn).Rows[0]); - lblFormatoDmtxAcq.Text = string.Format("Formato MM: {0}", riga.FormatoDtmxMM); - lblEsitoMarc.Text = string.Format("Esito marcatura MM: {0}", riga.EsitoMarcatura); - lblPartNumAcq.Text = string.Format("Part Num MM: {0}", riga.PartNumber); - } - else - { - lblEsitoAcq.Text = string.Format("{0}: KO", traduci("VerificaAcquisizioni")); - lblFormatoDmtxAcq.Text = "..."; - lblEsitoMarc.Text = ".."; - lblPartNumAcq.Text = "."; - } - } - else - { - lblBarcode.Text = string.Format("Codice non riconosciuto: {0}", barcodeIn); - lblEsitoDec.Text = "...."; - lblFormatoDmtxDec.Text = "..."; - lblPartNumDec.Text = ".."; - lblCodPartDec.Text = "."; - lblEsitoAcq.Text = "...."; - lblFormatoDmtxAcq.Text = "..."; - lblEsitoMarc.Text = ".."; - lblPartNumAcq.Text = "."; - } - - // fix grafico - divDecod.Attributes.Remove("class"); - divDecod.Attributes.Add("class", classDivDec); - divElenco.Attributes.Remove("class"); - divElenco.Attributes.Add("class", classDivList); - - // sistemazione generale - barcodeIn = ""; - txtBarcode.Focus(); - } - /// - /// valore barcode - /// - public string barcodeIn - { - get - { - return txtBarcode.Text.Trim(); - } - set - { - txtBarcode.Text = value; - } - } - - protected void txtBarcode_TextChanged(object sender, EventArgs e) - { - checkBarcode(); - } + txtBarcode.Focus(); } + /// + /// controlla se ci sia un barcode + /// + private void checkBarcode() + { + bool isDecodOk = false; + bool isInList = true; + + // verifico + isDecodOk = (DataMatrix_mgr.taAnagFormDtx.getFormatiCompatibili(barcodeIn).Rows.Count > 0); + isInList = (DataMatrix_mgr.taVED.getByKey(barcodeIn).Rows.Count > 0); + + // imposto di conseguenza grafica e info + string classDivDec = "col-sm-6 bg-danger"; + string classDivList = "col-sm-6 bg-danger"; + if (isDecodOk) + { + //divDecod.Attributes.Add("class", "col-sm-6 bg-success"); + classDivDec = "col-sm-6 bg-success"; + } + else + { + //divDecod.Attributes.Add("class", "col-sm-6 bg-danger"); + classDivDec = "col-sm-6 bg-danger"; + } + if (isInList) + { + //divElenco.Attributes.Add("class", "col-sm-6 bg-success"); + classDivList = "col-sm-6 bg-success"; + } + else + { + //divElenco.Attributes.Add("class", "col-sm-6 bg-danger"); + classDivList = "col-sm-6 bg-danger"; + } + // aggiorno visualizzazione... + if (isDecodOk || isInList) + { + lblBarcode.Text = string.Format("Datamatrix: {0}", barcodeIn); + if (isDecodOk) + { + lblEsitoDec.Text = string.Format("{0}: OK", traduci("VerificaDecodifica")); + DS_DataMatrix.AnagFormatiDtmxRow riga = (DS_DataMatrix.AnagFormatiDtmxRow)DataMatrix_mgr.taAnagFormDtx.getFormatiCompatibili(barcodeIn).Rows[0]; + lblFormatoDmtxDec.Text = string.Format("Formato: {0}", riga.FormatoDtmx); + // controllo se il PartNum venga decodificato --> lo decodifico e mostro entrambi + string PartNumIn = barcodeIn.Substring(riga.PartNumberPos - 1, riga.PartNumberLun); + string PartNum = ""; + string Particolare = ""; + if (DataMatrix_mgr.taTPN.getByPN_IN(PartNumIn).Rows.Count > 0) + { + PartNum = ((DS_DataMatrix.TrascPartNumRow)DataMatrix_mgr.taTPN.getByPN_IN(PartNumIn).Rows[0]).PartNumberOUT; + } + else + { + PartNum = PartNumIn; + } + try + { + Particolare = ((DS_DataMatrix.TrascDatamatrixRow)DataMatrix_mgr.taTDtmx.getByPnFormato(riga.FormatoDtmx, PartNum).Rows[0]).Particolare; + } + catch + { + Particolare = "Non Trovato"; + lblEsitoDec.Text += "/ND"; + classDivDec = "col-sm-6 bg-warning"; + } + lblPartNumDec.Text = string.Format("Part Num: {0}", PartNum); + // se fosse stato decodificato + if (PartNum != PartNumIn) + { + lblPartNumDec.Text += string.Format("
({0})", PartNumIn); + } + lblCodPartDec.Text = string.Format("Cod Part: {0}", Particolare); + } + else + { + lblEsitoDec.Text += string.Format("{0}: KO", traduci("VerificaDecodifica")); + lblFormatoDmtxDec.Text = "..."; + lblPartNumDec.Text = ".."; + lblCodPartDec.Text = "."; + } + if (isInList) + { + lblEsitoAcq.Text = string.Format("{0}: OK", traduci("VerificaAcquisizioni")); + DS_DataMatrix.v_ElencoDmtxRow riga = ((DS_DataMatrix.v_ElencoDmtxRow)DataMatrix_mgr.taVED.getByKey(barcodeIn).Rows[0]); + lblFormatoDmtxAcq.Text = string.Format("Formato MM: {0}", riga.FormatoDtmxMM); + lblEsitoMarc.Text = string.Format("Esito marcatura MM: {0}", riga.EsitoMarcatura); + lblPartNumAcq.Text = string.Format("Part Num MM: {0}", riga.PartNumber); + } + else + { + lblEsitoAcq.Text = string.Format("{0}: KO", traduci("VerificaAcquisizioni")); + lblFormatoDmtxAcq.Text = "..."; + lblEsitoMarc.Text = ".."; + lblPartNumAcq.Text = "."; + } + } + else + { + lblBarcode.Text = string.Format("Codice non riconosciuto: {0}", barcodeIn); + lblEsitoDec.Text = "...."; + lblFormatoDmtxDec.Text = "..."; + lblPartNumDec.Text = ".."; + lblCodPartDec.Text = "."; + lblEsitoAcq.Text = "...."; + lblFormatoDmtxAcq.Text = "..."; + lblEsitoMarc.Text = ".."; + lblPartNumAcq.Text = "."; + } + + // fix grafico + divDecod.Attributes.Remove("class"); + divDecod.Attributes.Add("class", classDivDec); + divElenco.Attributes.Remove("class"); + divElenco.Attributes.Add("class", classDivList); + + // sistemazione generale + barcodeIn = ""; + txtBarcode.Focus(); + } + /// + /// valore barcode + /// + public string barcodeIn + { + get + { + return txtBarcode.Text.Trim(); + } + set + { + txtBarcode.Text = value; + } + } + + protected void txtBarcode_TextChanged(object sender, EventArgs e) + { + checkBarcode(); + } + } } \ No newline at end of file diff --git a/GMW_data/DataMatrix.cs b/GMW_data/DataMatrix.cs index 64761241..58f2417e 100644 --- a/GMW_data/DataMatrix.cs +++ b/GMW_data/DataMatrix.cs @@ -2,161 +2,161 @@ namespace GMW_data { + /// + /// fa da proxy singleton x gli oggetti legati ai DATAMATRIX + /// + public class DataMatrix + { + #region area table adapters + + public DS_DataMatrixTableAdapters.ElencoDataMatrixTableAdapter taElencoDM; + public DS_DataMatrixTableAdapters.v_trasfDataMatrixTableAdapter taDtMtxOrig; + public DS_DataMatrixTableAdapters.stp_verificaDtxTableAdapter taVerifica; + public DS_DataMatrixTableAdapters.stp_decodeDtxTableAdapter taDecode; + public DS_DataMatrixTableAdapters.stp_conteggioDtxTableAdapter taConteggio; + public DS_DataMatrixTableAdapters.v_DtxAcquisitiTableAdapter taDtxAcq; + public DS_DataMatrixTableAdapters.Dtx2UDCTableAdapter taDtx2UDC; + public DS_DataMatrixTableAdapters.stp_getFirstLastDtxTableAdapter taFirstLastUdc; + public DS_DataMatrixTableAdapters.stp_DtxGetAvailFreeAnomTableAdapter taDtxAvailFree; + public DS_DataMatrixTableAdapters.stp_DtxCheckBlockedTableAdapter taDtxBlocked; + public DS_DataMatrixTableAdapters.Attr2DtxTableAdapter taAtt2Dtx; + public DS_DataMatrixTableAdapters.AnagFormatiDtmxTableAdapter taAnagFormDtx; + public DS_DataMatrixTableAdapters.v_DtxAcquisitiTableAdapter taDtxAcquisiti; + public DS_DataMatrixTableAdapters.v_ElencoDmtxTableAdapter taVED; + public DS_DataMatrixTableAdapters.TabSpecDtxTableAdapter taSpecDtmx; + public DS_DataMatrixTableAdapters.TrascPartNumTableAdapter taTPN; + public DS_DataMatrixTableAdapters.TrascDatamatrixTableAdapter taTDtmx; + public DS_DataMatrixTableAdapters.Linea2Dtx_IETableAdapter taL2D; + /// - /// fa da proxy singleton x gli oggetti legati ai DATAMATRIX + /// init dei table adapters /// - public class DataMatrix + protected void initTA() { - #region area table adapters - - public DS_DataMatrixTableAdapters.ElencoDataMatrixTableAdapter taElencoDM; - public DS_DataMatrixTableAdapters.v_trasfDataMatrixTableAdapter taDtMtxOrig; - public DS_DataMatrixTableAdapters.stp_verificaDtxTableAdapter taVerifica; - public DS_DataMatrixTableAdapters.stp_decodeDtxTableAdapter taDecode; - public DS_DataMatrixTableAdapters.stp_conteggioDtxTableAdapter taConteggio; - public DS_DataMatrixTableAdapters.v_DtxAcquisitiTableAdapter taDtxAcq; - public DS_DataMatrixTableAdapters.Dtx2UDCTableAdapter taDtx2UDC; - public DS_DataMatrixTableAdapters.stp_getFirstLastDtxTableAdapter taFirstLastUdc; - public DS_DataMatrixTableAdapters.stp_DtxGetAvailFreeAnomTableAdapter taDtxAvailFree; - public DS_DataMatrixTableAdapters.stp_DtxCheckBlockedTableAdapter taDtxBlocked; - public DS_DataMatrixTableAdapters.Attr2DtxTableAdapter taAtt2Dtx; - public DS_DataMatrixTableAdapters.AnagFormatiDtmxTableAdapter taAnagFormDtx; - public DS_DataMatrixTableAdapters.v_DtxAcquisitiTableAdapter taDtxAcquisiti; - public DS_DataMatrixTableAdapters.v_ElencoDmtxTableAdapter taVED; - public DS_DataMatrixTableAdapters.TabSpecDtxTableAdapter taSpecDtmx; - public DS_DataMatrixTableAdapters.TrascPartNumTableAdapter taTPN; - public DS_DataMatrixTableAdapters.TrascDatamatrixTableAdapter taTDtmx; - public DS_DataMatrixTableAdapters.Linea2Dtx_IETableAdapter taL2D; - - /// - /// init dei table adapters - /// - protected void initTA() - { - taElencoDM = new GMW_data.DS_DataMatrixTableAdapters.ElencoDataMatrixTableAdapter(); - taDtMtxOrig = new GMW_data.DS_DataMatrixTableAdapters.v_trasfDataMatrixTableAdapter(); - taDtMtxOrig = new GMW_data.DS_DataMatrixTableAdapters.v_trasfDataMatrixTableAdapter(); - taVerifica = new DS_DataMatrixTableAdapters.stp_verificaDtxTableAdapter(); - taDecode = new DS_DataMatrixTableAdapters.stp_decodeDtxTableAdapter(); - taConteggio = new DS_DataMatrixTableAdapters.stp_conteggioDtxTableAdapter(); - taDtxAcq = new DS_DataMatrixTableAdapters.v_DtxAcquisitiTableAdapter(); - taDtx2UDC = new DS_DataMatrixTableAdapters.Dtx2UDCTableAdapter(); - taFirstLastUdc = new DS_DataMatrixTableAdapters.stp_getFirstLastDtxTableAdapter(); - taDtxAvailFree = new DS_DataMatrixTableAdapters.stp_DtxGetAvailFreeAnomTableAdapter(); - taDtxBlocked = new DS_DataMatrixTableAdapters.stp_DtxCheckBlockedTableAdapter(); - taAtt2Dtx = new DS_DataMatrixTableAdapters.Attr2DtxTableAdapter(); - taAnagFormDtx = new DS_DataMatrixTableAdapters.AnagFormatiDtmxTableAdapter(); - taDtxAcquisiti = new DS_DataMatrixTableAdapters.v_DtxAcquisitiTableAdapter(); - taVED = new DS_DataMatrixTableAdapters.v_ElencoDmtxTableAdapter(); - taSpecDtmx = new DS_DataMatrixTableAdapters.TabSpecDtxTableAdapter(); - taTPN = new DS_DataMatrixTableAdapters.TrascPartNumTableAdapter(); - taTDtmx = new DS_DataMatrixTableAdapters.TrascDatamatrixTableAdapter(); - taL2D = new DS_DataMatrixTableAdapters.Linea2Dtx_IETableAdapter(); - } - /// - /// effettua setup dei connection strings da web.config delal singola applicazione - /// - protected virtual void setupConnectionStringBase() - { - // connections strings del db verso GMW - string connString = memLayer.ML.confReadString("GMWConnectionString"); - taElencoDM.Connection.ConnectionString = connString; - taDtMtxOrig.Connection.ConnectionString = connString; - taVerifica.Connection.ConnectionString = connString; - taDecode.Connection.ConnectionString = connString; - taConteggio.Connection.ConnectionString = connString; - taDtxAcq.Connection.ConnectionString = connString; - taDtx2UDC.Connection.ConnectionString = connString; - taFirstLastUdc.Connection.ConnectionString = connString; - taDtxAvailFree.Connection.ConnectionString = connString; - taDtxBlocked.Connection.ConnectionString = connString; - taAtt2Dtx.Connection.ConnectionString = connString; - taAnagFormDtx.Connection.ConnectionString = connString; - taDtxAcquisiti.Connection.ConnectionString = connString; - taVED.Connection.ConnectionString = connString; - taSpecDtmx.Connection.ConnectionString = connString; - taTPN.Connection.ConnectionString = connString; - taTDtmx.Connection.ConnectionString = connString; - taL2D.Connection.ConnectionString = connString; - } - - #endregion - - public DataMatrix() - { - initTA(); - setupConnectionStringBase(); - } - - /// - /// singleton datamatrix - /// - public static DataMatrix mgr = new DataMatrix(); - /// - /// effettua import nuovi dati datamatrix/gitterbox - /// - /// - public bool importNuoviDati() - { - bool answ = false; - try - { - taElencoDM.stp_DtMtrx_import(memLayer.ML.cdv("CodCS"), memLayer.ML.cdvi("IdxPosizioneOdette"), MagClass.magazzino.CodSoggCurrUser); - answ = true; - } - catch - { } - return answ; - } - /// - /// restituisce codice gitterbox dato datamatrix - /// - /// - /// - public string gitterboxFromDataMatrix(decimal codDataMatrix) - { - string answ = ""; - try - { - answ = taElencoDM.getByCode(codDataMatrix)[0].CodGitterbox; - } - catch - { } - return answ; - } - /// - /// restituisce codice gitterbox ORIGINALE (pre import) dato datamatrix - /// - /// - /// - public string gitterboxOrigFromDataMatrix(decimal codDataMatrix) - { - string answ = ""; - try - { - answ = DataMatrix.mgr.taDtMtxOrig.getByDtMtx(codDataMatrix.ToString())[0].CodGitterbox; - } - catch - { } - return answ; - } - /// - /// verifica SE il codice datamatrix POSSA rappresentare un codice valido, ovvero - /// - lunghezza compatibile coi formati supportati - /// - decodifica datamatrix (da formato plausibile, 1 o +) con esito positivo - /// - /// - /// - public bool maybeDatamatrix(string DataMatrix) - { - bool answ = false; - // provo a verificare direttamente con score function... - DS_DataMatrix.AnagFormatiDtmxDataTable tab = taAnagFormDtx.getFormatiCompatibili(DataMatrix); - if (tab.Rows.Count > 0) - { - answ = true; - } - return answ; - } + taElencoDM = new GMW_data.DS_DataMatrixTableAdapters.ElencoDataMatrixTableAdapter(); + taDtMtxOrig = new GMW_data.DS_DataMatrixTableAdapters.v_trasfDataMatrixTableAdapter(); + taDtMtxOrig = new GMW_data.DS_DataMatrixTableAdapters.v_trasfDataMatrixTableAdapter(); + taVerifica = new DS_DataMatrixTableAdapters.stp_verificaDtxTableAdapter(); + taDecode = new DS_DataMatrixTableAdapters.stp_decodeDtxTableAdapter(); + taConteggio = new DS_DataMatrixTableAdapters.stp_conteggioDtxTableAdapter(); + taDtxAcq = new DS_DataMatrixTableAdapters.v_DtxAcquisitiTableAdapter(); + taDtx2UDC = new DS_DataMatrixTableAdapters.Dtx2UDCTableAdapter(); + taFirstLastUdc = new DS_DataMatrixTableAdapters.stp_getFirstLastDtxTableAdapter(); + taDtxAvailFree = new DS_DataMatrixTableAdapters.stp_DtxGetAvailFreeAnomTableAdapter(); + taDtxBlocked = new DS_DataMatrixTableAdapters.stp_DtxCheckBlockedTableAdapter(); + taAtt2Dtx = new DS_DataMatrixTableAdapters.Attr2DtxTableAdapter(); + taAnagFormDtx = new DS_DataMatrixTableAdapters.AnagFormatiDtmxTableAdapter(); + taDtxAcquisiti = new DS_DataMatrixTableAdapters.v_DtxAcquisitiTableAdapter(); + taVED = new DS_DataMatrixTableAdapters.v_ElencoDmtxTableAdapter(); + taSpecDtmx = new DS_DataMatrixTableAdapters.TabSpecDtxTableAdapter(); + taTPN = new DS_DataMatrixTableAdapters.TrascPartNumTableAdapter(); + taTDtmx = new DS_DataMatrixTableAdapters.TrascDatamatrixTableAdapter(); + taL2D = new DS_DataMatrixTableAdapters.Linea2Dtx_IETableAdapter(); } + /// + /// effettua setup dei connection strings da web.config delal singola applicazione + /// + protected virtual void setupConnectionStringBase() + { + // connections strings del db verso GMW + string connString = memLayer.ML.confReadString("GMWConnectionString"); + taElencoDM.Connection.ConnectionString = connString; + taDtMtxOrig.Connection.ConnectionString = connString; + taVerifica.Connection.ConnectionString = connString; + taDecode.Connection.ConnectionString = connString; + taConteggio.Connection.ConnectionString = connString; + taDtxAcq.Connection.ConnectionString = connString; + taDtx2UDC.Connection.ConnectionString = connString; + taFirstLastUdc.Connection.ConnectionString = connString; + taDtxAvailFree.Connection.ConnectionString = connString; + taDtxBlocked.Connection.ConnectionString = connString; + taAtt2Dtx.Connection.ConnectionString = connString; + taAnagFormDtx.Connection.ConnectionString = connString; + taDtxAcquisiti.Connection.ConnectionString = connString; + taVED.Connection.ConnectionString = connString; + taSpecDtmx.Connection.ConnectionString = connString; + taTPN.Connection.ConnectionString = connString; + taTDtmx.Connection.ConnectionString = connString; + taL2D.Connection.ConnectionString = connString; + } + + #endregion + + public DataMatrix() + { + initTA(); + setupConnectionStringBase(); + } + + /// + /// singleton datamatrix + /// + public static DataMatrix mgr = new DataMatrix(); + /// + /// effettua import nuovi dati datamatrix/gitterbox + /// + /// + public bool importNuoviDati() + { + bool answ = false; + try + { + taElencoDM.stp_DtMtrx_import(memLayer.ML.cdv("CodCS"), memLayer.ML.cdvi("IdxPosizioneOdette"), MagClass.magazzino.CodSoggCurrUser); + answ = true; + } + catch + { } + return answ; + } + /// + /// restituisce codice gitterbox dato datamatrix + /// + /// + /// + public string gitterboxFromDataMatrix(decimal codDataMatrix) + { + string answ = ""; + try + { + answ = taElencoDM.getByCode(codDataMatrix)[0].CodGitterbox; + } + catch + { } + return answ; + } + /// + /// restituisce codice gitterbox ORIGINALE (pre import) dato datamatrix + /// + /// + /// + public string gitterboxOrigFromDataMatrix(decimal codDataMatrix) + { + string answ = ""; + try + { + answ = taDtMtxOrig.getByDtMtx(codDataMatrix.ToString())[0].CodGitterbox; + } + catch + { } + return answ; + } + /// + /// verifica SE il codice datamatrix POSSA rappresentare un codice valido, ovvero + /// - lunghezza compatibile coi formati supportati + /// - decodifica datamatrix (da formato plausibile, 1 o +) con esito positivo + /// + /// + /// + public bool maybeDatamatrix(string DataMatrix) + { + bool answ = false; + // provo a verificare direttamente con score function... + DS_DataMatrix.AnagFormatiDtmxDataTable tab = taAnagFormDtx.getFormatiCompatibili(DataMatrix); + if (tab.Rows.Count > 0) + { + answ = true; + } + return answ; + } + } } diff --git a/GMW_data/MagClass.cs b/GMW_data/MagClass.cs index 855f5fc3..25436e6d 100644 --- a/GMW_data/MagClass.cs +++ b/GMW_data/MagClass.cs @@ -5,3386 +5,3386 @@ using System.Reflection; namespace GMW_data { + /// + /// classe gestione operazioni sul magazzino + /// + public class MagClass + { + #region area table adapters + + // variabile di tipo table adapter + public DS_magazzinoTableAdapters.AnagMagTableAdapter taAnagMag; + public DS_magazzinoTableAdapters.BlocchiTableAdapter taBlocchi; + public DS_magazzinoTableAdapters.CelleTableAdapter taCelle; + public DS_magazzinoTableAdapters.TipoCellaTableAdapter taTipoCella; + public DS_magazzinoTableAdapters.ElencoCartelliniTableAdapter taCartellini; + public DS_magazzinoTableAdapters.PosizioneUdcCorrenteTableAdapter taPosUdcCorr; + public DS_magazzinoTableAdapters.PosizioneUdcStoricoTableAdapter taPosUdcStorico; + public DS_magazzinoTableAdapters.V_MagazziniOverviewTableAdapter taMagOverw; + public DS_magazzinoTableAdapters.V_DettMagPartTableAdapter taDettMagPart; + public DS_magazzinoTableAdapters.v_UdcDetailTableAdapter taDettUDC; + public DS_magazzinoTableAdapters.ElencoListePrelievoTableAdapter taElencoListePrelievo; + public DS_magazzinoTableAdapters.RigheListePrelievoTableAdapter taRigheListePrelievo; + public DS_magazzinoTableAdapters.TipoListaPrelievoTableAdapter taTipoListaPrelievo; + public DS_magazzinoTableAdapters.V_ParticolariOverviewTableAdapter taVParticolariOverwiew; + public DS_magazzinoTableAdapters.v_particolariEsponenteFiguraTableAdapter taPartExpFig; + public DS_magazzinoTableAdapters.V_statoCelleCapienzaAssegnatiTableAdapter taStatoCelle; + public DS_magazzinoTableAdapters.RapQualTableAdapter taRapQual; + public DS_magazzinoTableAdapters.v_RapQualSuntoTableAdapter taRQ_sunto; + public DS_magazzinoTableAdapters.AnagLegheTableAdapter taAnagLeghe; + public DS_magazzinoTableAdapters.v_posizioniDelibereTableAdapter taPosizDelib; + public DS_magazzinoTableAdapters.AnagParticolariTableAdapter taAnagPart; + public DS_magazzinoTableAdapters.AnagPosizioniTableAdapter taAnagPos; + public DS_magazzinoTableAdapters.StoricoAzioniOperatoreTableAdapter taSAO; + public DS_magazzinoTableAdapters.AnagLineeTableAdapter taAL; + public DS_magazzinoTableAdapters.stp_ParticolareInOutOkTableAdapter taPartIO; + public DS_magazzinoTableAdapters.Attr2UDCTableAdapter taAtt2UDC; + public DS_magazzinoTableAdapters.ElencoAssiemiTableAdapter taEA; + public DS_magazzinoTableAdapters.AL2UDCTableAdapter taAL2UDC; + public DS_magazzinoTableAdapters.ElencoTrattamentiTableAdapter taET; + public DS_magazzinoTableAdapters.v_A2U2DTableAdapter taA2U2D; + public DS_magazzinoTableAdapters.UDC_check4deleteTableAdapter taUdcChk4Del; + + /// - /// classe gestione operazioni sul magazzino + /// init dei table adapters /// - public class MagClass + protected void initTA() { - #region area table adapters + // istanzio oggetto - // variabile di tipo table adapter - public DS_magazzinoTableAdapters.AnagMagTableAdapter taAnagMag; - public DS_magazzinoTableAdapters.BlocchiTableAdapter taBlocchi; - public DS_magazzinoTableAdapters.CelleTableAdapter taCelle; - public DS_magazzinoTableAdapters.TipoCellaTableAdapter taTipoCella; - public DS_magazzinoTableAdapters.ElencoCartelliniTableAdapter taCartellini; - public DS_magazzinoTableAdapters.PosizioneUdcCorrenteTableAdapter taPosUdcCorr; - public DS_magazzinoTableAdapters.PosizioneUdcStoricoTableAdapter taPosUdcStorico; - public DS_magazzinoTableAdapters.V_MagazziniOverviewTableAdapter taMagOverw; - public DS_magazzinoTableAdapters.V_DettMagPartTableAdapter taDettMagPart; - public DS_magazzinoTableAdapters.v_UdcDetailTableAdapter taDettUDC; - public DS_magazzinoTableAdapters.ElencoListePrelievoTableAdapter taElencoListePrelievo; - public DS_magazzinoTableAdapters.RigheListePrelievoTableAdapter taRigheListePrelievo; - public DS_magazzinoTableAdapters.TipoListaPrelievoTableAdapter taTipoListaPrelievo; - public DS_magazzinoTableAdapters.V_ParticolariOverviewTableAdapter taVParticolariOverwiew; - public DS_magazzinoTableAdapters.v_particolariEsponenteFiguraTableAdapter taPartExpFig; - public DS_magazzinoTableAdapters.V_statoCelleCapienzaAssegnatiTableAdapter taStatoCelle; - public DS_magazzinoTableAdapters.RapQualTableAdapter taRapQual; - public DS_magazzinoTableAdapters.v_RapQualSuntoTableAdapter taRQ_sunto; - public DS_magazzinoTableAdapters.AnagLegheTableAdapter taAnagLeghe; - public DS_magazzinoTableAdapters.v_posizioniDelibereTableAdapter taPosizDelib; - public DS_magazzinoTableAdapters.AnagParticolariTableAdapter taAnagPart; - public DS_magazzinoTableAdapters.AnagPosizioniTableAdapter taAnagPos; - public DS_magazzinoTableAdapters.StoricoAzioniOperatoreTableAdapter taSAO; - public DS_magazzinoTableAdapters.AnagLineeTableAdapter taAL; - public DS_magazzinoTableAdapters.stp_ParticolareInOutOkTableAdapter taPartIO; - public DS_magazzinoTableAdapters.Attr2UDCTableAdapter taAtt2UDC; - public DS_magazzinoTableAdapters.ElencoAssiemiTableAdapter taEA; - public DS_magazzinoTableAdapters.AL2UDCTableAdapter taAL2UDC; - public DS_magazzinoTableAdapters.ElencoTrattamentiTableAdapter taET; - public DS_magazzinoTableAdapters.v_A2U2DTableAdapter taA2U2D; - public DS_magazzinoTableAdapters.UDC_check4deleteTableAdapter taUdcChk4Del; + taAnagMag = new GMW_data.DS_magazzinoTableAdapters.AnagMagTableAdapter(); + taBlocchi = new GMW_data.DS_magazzinoTableAdapters.BlocchiTableAdapter(); + taCelle = new GMW_data.DS_magazzinoTableAdapters.CelleTableAdapter(); + taTipoCella = new GMW_data.DS_magazzinoTableAdapters.TipoCellaTableAdapter(); + taCartellini = new GMW_data.DS_magazzinoTableAdapters.ElencoCartelliniTableAdapter(); + taPosUdcCorr = new GMW_data.DS_magazzinoTableAdapters.PosizioneUdcCorrenteTableAdapter(); + taPosUdcStorico = new GMW_data.DS_magazzinoTableAdapters.PosizioneUdcStoricoTableAdapter(); + taMagOverw = new GMW_data.DS_magazzinoTableAdapters.V_MagazziniOverviewTableAdapter(); + taDettMagPart = new GMW_data.DS_magazzinoTableAdapters.V_DettMagPartTableAdapter(); + taDettUDC = new GMW_data.DS_magazzinoTableAdapters.v_UdcDetailTableAdapter(); + taElencoListePrelievo = new GMW_data.DS_magazzinoTableAdapters.ElencoListePrelievoTableAdapter(); + taRigheListePrelievo = new GMW_data.DS_magazzinoTableAdapters.RigheListePrelievoTableAdapter(); + taTipoListaPrelievo = new GMW_data.DS_magazzinoTableAdapters.TipoListaPrelievoTableAdapter(); + taVParticolariOverwiew = new GMW_data.DS_magazzinoTableAdapters.V_ParticolariOverviewTableAdapter(); + taPartExpFig = new GMW_data.DS_magazzinoTableAdapters.v_particolariEsponenteFiguraTableAdapter(); + taStatoCelle = new GMW_data.DS_magazzinoTableAdapters.V_statoCelleCapienzaAssegnatiTableAdapter(); + taRapQual = new GMW_data.DS_magazzinoTableAdapters.RapQualTableAdapter(); + taRQ_sunto = new GMW_data.DS_magazzinoTableAdapters.v_RapQualSuntoTableAdapter(); + taAnagLeghe = new GMW_data.DS_magazzinoTableAdapters.AnagLegheTableAdapter(); + taPosizDelib = new GMW_data.DS_magazzinoTableAdapters.v_posizioniDelibereTableAdapter(); + taAnagPart = new GMW_data.DS_magazzinoTableAdapters.AnagParticolariTableAdapter(); + taAnagPos = new GMW_data.DS_magazzinoTableAdapters.AnagPosizioniTableAdapter(); + taSAO = new DS_magazzinoTableAdapters.StoricoAzioniOperatoreTableAdapter(); + taAL = new DS_magazzinoTableAdapters.AnagLineeTableAdapter(); + taPartIO = new DS_magazzinoTableAdapters.stp_ParticolareInOutOkTableAdapter(); + taAtt2UDC = new DS_magazzinoTableAdapters.Attr2UDCTableAdapter(); + taEA = new DS_magazzinoTableAdapters.ElencoAssiemiTableAdapter(); + taAL2UDC = new DS_magazzinoTableAdapters.AL2UDCTableAdapter(); + taET = new DS_magazzinoTableAdapters.ElencoTrattamentiTableAdapter(); + taA2U2D = new DS_magazzinoTableAdapters.v_A2U2DTableAdapter(); + taUdcChk4Del = new DS_magazzinoTableAdapters.UDC_check4deleteTableAdapter(); + } + /// + /// effettua setup dei connection strings da web.config delal singola applicazione + /// + protected virtual void setupConnectionStringBase() + { + string connString = memLayer.ML.confReadString("GMWConnectionString"); + // connections del db + taAnagMag.Connection.ConnectionString = connString; + taBlocchi.Connection.ConnectionString = connString; + taCelle.Connection.ConnectionString = connString; + taTipoCella.Connection.ConnectionString = connString; + taCartellini.Connection.ConnectionString = connString; + taPosUdcCorr.Connection.ConnectionString = connString; + taPosUdcStorico.Connection.ConnectionString = connString; + taMagOverw.Connection.ConnectionString = connString; + taDettMagPart.Connection.ConnectionString = connString; + taDettUDC.Connection.ConnectionString = connString; + taElencoListePrelievo.Connection.ConnectionString = connString; + taRigheListePrelievo.Connection.ConnectionString = connString; + taTipoListaPrelievo.Connection.ConnectionString = connString; + taVParticolariOverwiew.Connection.ConnectionString = connString; + taPartExpFig.Connection.ConnectionString = connString; + taStatoCelle.Connection.ConnectionString = connString; + taRapQual.Connection.ConnectionString = connString; + taRQ_sunto.Connection.ConnectionString = connString; + taAnagLeghe.Connection.ConnectionString = connString; + taPosizDelib.Connection.ConnectionString = connString; + taAnagPart.Connection.ConnectionString = connString; + taAnagPos.Connection.ConnectionString = connString; + taSAO.Connection.ConnectionString = connString; + taAL.Connection.ConnectionString = connString; + taPartIO.Connection.ConnectionString = connString; + taAtt2UDC.Connection.ConnectionString = connString; + taEA.Connection.ConnectionString = connString; + taAL2UDC.Connection.ConnectionString = connString; + taET.Connection.ConnectionString = connString; + taA2U2D.Connection.ConnectionString = connString; + taUdcChk4Del.Connection.ConnectionString = connString; + } + #endregion - /// - /// init dei table adapters - /// - protected void initTA() - { - // istanzio oggetto + #region Inizializzazione - taAnagMag = new GMW_data.DS_magazzinoTableAdapters.AnagMagTableAdapter(); - taBlocchi = new GMW_data.DS_magazzinoTableAdapters.BlocchiTableAdapter(); - taCelle = new GMW_data.DS_magazzinoTableAdapters.CelleTableAdapter(); - taTipoCella = new GMW_data.DS_magazzinoTableAdapters.TipoCellaTableAdapter(); - taCartellini = new GMW_data.DS_magazzinoTableAdapters.ElencoCartelliniTableAdapter(); - taPosUdcCorr = new GMW_data.DS_magazzinoTableAdapters.PosizioneUdcCorrenteTableAdapter(); - taPosUdcStorico = new GMW_data.DS_magazzinoTableAdapters.PosizioneUdcStoricoTableAdapter(); - taMagOverw = new GMW_data.DS_magazzinoTableAdapters.V_MagazziniOverviewTableAdapter(); - taDettMagPart = new GMW_data.DS_magazzinoTableAdapters.V_DettMagPartTableAdapter(); - taDettUDC = new GMW_data.DS_magazzinoTableAdapters.v_UdcDetailTableAdapter(); - taElencoListePrelievo = new GMW_data.DS_magazzinoTableAdapters.ElencoListePrelievoTableAdapter(); - taRigheListePrelievo = new GMW_data.DS_magazzinoTableAdapters.RigheListePrelievoTableAdapter(); - taTipoListaPrelievo = new GMW_data.DS_magazzinoTableAdapters.TipoListaPrelievoTableAdapter(); - taVParticolariOverwiew = new GMW_data.DS_magazzinoTableAdapters.V_ParticolariOverviewTableAdapter(); - taPartExpFig = new GMW_data.DS_magazzinoTableAdapters.v_particolariEsponenteFiguraTableAdapter(); - taStatoCelle = new GMW_data.DS_magazzinoTableAdapters.V_statoCelleCapienzaAssegnatiTableAdapter(); - taRapQual = new GMW_data.DS_magazzinoTableAdapters.RapQualTableAdapter(); - taRQ_sunto = new GMW_data.DS_magazzinoTableAdapters.v_RapQualSuntoTableAdapter(); - taAnagLeghe = new GMW_data.DS_magazzinoTableAdapters.AnagLegheTableAdapter(); - taPosizDelib = new GMW_data.DS_magazzinoTableAdapters.v_posizioniDelibereTableAdapter(); - taAnagPart = new GMW_data.DS_magazzinoTableAdapters.AnagParticolariTableAdapter(); - taAnagPos = new GMW_data.DS_magazzinoTableAdapters.AnagPosizioniTableAdapter(); - taSAO = new DS_magazzinoTableAdapters.StoricoAzioniOperatoreTableAdapter(); - taAL = new DS_magazzinoTableAdapters.AnagLineeTableAdapter(); - taPartIO = new DS_magazzinoTableAdapters.stp_ParticolareInOutOkTableAdapter(); - taAtt2UDC = new DS_magazzinoTableAdapters.Attr2UDCTableAdapter(); - taEA = new DS_magazzinoTableAdapters.ElencoAssiemiTableAdapter(); - taAL2UDC = new DS_magazzinoTableAdapters.AL2UDCTableAdapter(); - taET = new DS_magazzinoTableAdapters.ElencoTrattamentiTableAdapter(); - taA2U2D = new DS_magazzinoTableAdapters.v_A2U2DTableAdapter(); - taUdcChk4Del = new DS_magazzinoTableAdapters.UDC_check4deleteTableAdapter(); - } - /// - /// effettua setup dei connection strings da web.config delal singola applicazione - /// - protected virtual void setupConnectionStringBase() - { - string connString = memLayer.ML.confReadString("GMWConnectionString"); - // connections del db - taAnagMag.Connection.ConnectionString = connString; - taBlocchi.Connection.ConnectionString = connString; - taCelle.Connection.ConnectionString = connString; - taTipoCella.Connection.ConnectionString = connString; - taCartellini.Connection.ConnectionString = connString; - taPosUdcCorr.Connection.ConnectionString = connString; - taPosUdcStorico.Connection.ConnectionString = connString; - taMagOverw.Connection.ConnectionString = connString; - taDettMagPart.Connection.ConnectionString = connString; - taDettUDC.Connection.ConnectionString = connString; - taElencoListePrelievo.Connection.ConnectionString = connString; - taRigheListePrelievo.Connection.ConnectionString = connString; - taTipoListaPrelievo.Connection.ConnectionString = connString; - taVParticolariOverwiew.Connection.ConnectionString = connString; - taPartExpFig.Connection.ConnectionString = connString; - taStatoCelle.Connection.ConnectionString = connString; - taRapQual.Connection.ConnectionString = connString; - taRQ_sunto.Connection.ConnectionString = connString; - taAnagLeghe.Connection.ConnectionString = connString; - taPosizDelib.Connection.ConnectionString = connString; - taAnagPart.Connection.ConnectionString = connString; - taAnagPos.Connection.ConnectionString = connString; - taSAO.Connection.ConnectionString = connString; - taAL.Connection.ConnectionString = connString; - taPartIO.Connection.ConnectionString = connString; - taAtt2UDC.Connection.ConnectionString = connString; - taEA.Connection.ConnectionString = connString; - taAL2UDC.Connection.ConnectionString = connString; - taET.Connection.ConnectionString = connString; - taA2U2D.Connection.ConnectionString = connString; - taUdcChk4Del.Connection.ConnectionString = connString; - } + public MagClass() + { + initTA(); + setupConnectionStringBase(); - #endregion + // aggiunta x gestione timeout esteso (ove necessario)! + fixCommandTimeout(); + } - #region Inizializzazione + /// + /// sistemazione timeout comandi nei tableadapter + /// + private void fixCommandTimeout() + { + SetAllCommandTimeouts(taCartellini, memLayer.ML.confReadInt("sqlLongCommandTimeout")); + SetAllCommandTimeouts(taPosUdcCorr, memLayer.ML.confReadInt("sqlLongCommandTimeout")); + SetAllCommandTimeouts(taElencoListePrelievo, memLayer.ML.confReadInt("sqlLongCommandTimeout")); + } + void SetAllCommandTimeouts(object adapter, int timeout) + { + var commands = adapter.GetType().InvokeMember( + "CommandCollection", + BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic, + null, adapter, new object[0]); + var sqlCommand = (SqlCommand[])commands; + foreach (var cmd in sqlCommand) + { + cmd.CommandTimeout = timeout; + } + } - public MagClass() - { - initTA(); - setupConnectionStringBase(); + /// + /// oggetto static per fare chiamate sul magazzino + /// + public static MagClass magazzino = new MagClass(); - // aggiunta x gestione timeout esteso (ove necessario)! - fixCommandTimeout(); - } + #endregion - /// - /// sistemazione timeout comandi nei tableadapter - /// - private void fixCommandTimeout() - { - SetAllCommandTimeouts(taCartellini, memLayer.ML.confReadInt("sqlLongCommandTimeout")); - SetAllCommandTimeouts(taPosUdcCorr, memLayer.ML.confReadInt("sqlLongCommandTimeout")); - SetAllCommandTimeouts(taElencoListePrelievo, memLayer.ML.confReadInt("sqlLongCommandTimeout")); - } - void SetAllCommandTimeouts(object adapter, int timeout) - { - var commands = adapter.GetType().InvokeMember( - "CommandCollection", - BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic, - null, adapter, new object[0]); - var sqlCommand = (SqlCommand[])commands; - foreach (var cmd in sqlCommand) + #region metodi protected + + /// + /// aggiunge le righe liste di prelievo necessarie a soddisfare la richiesta in logica FIFO dato un elenco di cartellini, la qta totale da allocare e la lista attuale + /// + /// + /// + /// + private void allocaRigheListaPrelievo(decimal QtaTot, string codListaAttuale, DS_magazzino.ElencoCartelliniDataTable tabellaElencoCartellini) + { + //ricavo il valore UDC della riga del più vecchio + string udcAttuale; + bool qtaOk = false; + bool dataFinished = false; + int progrUdc = 0; + int numUdcDisponibili = tabellaElencoCartellini.Rows.Count; + // contiene la quantità della riga attuale + decimal qtaRiga; + // somma progressiva della qta allocata - calcolo da db! + decimal qtaAllocata = taElencoListePrelievo.getByCodLista(codListaAttuale)[0].Prelevato; + //ciclo WHILE per lo riempimento FIFO con UDC secondo richiesta a partire da elenco fornito + while (!qtaOk && !dataFinished) + { + /* + * crea una riga in righelistaprelievo passando come valori + * il codlista attuale ricavato da sopr + * l'UDC dal primo della tabella getOlderUDC + * + * + * recupero quantità dalla riga corrente; + * + * imposto proposto a 1; + * imposto prelevato 0; + * taRighelistePreliveo.Insert; + * + * qtaAllocata = qtaAllocata + Qta di questa riga (riuso il valore della colonna QTA + * tabella[contatore]; contatore++; + * qtaOk = (qtaAllocata >= qtaRichiesta) + * dataFinished = (contatore >= numRighe); + * + * */ + // ricavo la riga più vecchia + qtaRiga = tabellaElencoCartellini[progrUdc].Qta; + udcAttuale = tabellaElencoCartellini[progrUdc].UDC; + // eseguo query di insert + taRigheListePrelievo.Insert(codListaAttuale, udcAttuale, qtaRiga, true, false); + + //incremento qta allocata + qtaAllocata = (qtaAllocata + qtaRiga); + //incremento contatore + progrUdc++; + + // verifico le condizioni, false se non cambia nulla true se cambia e si esce dal while + qtaOk = (qtaAllocata >= QtaTot); + dataFinished = (progrUdc >= numUdcDisponibili); + } + } + + #endregion + + #region Metodi esposti + + #region operazioni su AL + + /// + /// Fornisce un nuovo codice AL tipo completo a partire dalla richiesta e salva i dati + /// + /// tipologia dell'AL da generare + /// codice della cella contentente gli UDC da associare + /// codice dell'operatore + /// anno in cui intestare i cartellini, trimma a 2 cifre DX + /// codice cesta + /// note da associare agli UDC + /// AL del nuovo Assieme Logico e lo associa agli UDC della postazione/cella + public string creaAssociaAlRxNt(tipoAL tipologia, string CodCella, string CodSoggetto, int anno, string Cesta, string note) + { + // imposto valori default + string CodCS = memLayer.ML.cdv("CodCS"); + string PostFlux = ""; + string CodFlusso = ""; + string TipoAL = ""; + string CodEvento = ""; + string CodDtxStart = ""; + string CodDtxEnd = ""; + switch (tipologia) + { + case tipoAL.AL_RxDt: + PostFlux = "RxDt"; + CodFlusso = "AR"; + TipoAL = "R"; + CodEvento = "UDC_RX_DT"; + // calcolo primo/ultimo dtx OK + try + { + DS_DataMatrix.stp_getFirstLastDtxRow rigaFirstLast = DataMatrix.mgr.taFirstLastUdc.GetData(CodCella)[0]; + if (!rigaFirstLast.IsNull(0)) { - cmd.CommandTimeout = timeout; - } - } - - /// - /// oggetto static per fare chiamate sul magazzino - /// - public static MagClass magazzino = new MagClass(); - - #endregion - - #region metodi protected - - /// - /// aggiunge le righe liste di prelievo necessarie a soddisfare la richiesta in logica FIFO dato un elenco di cartellini, la qta totale da allocare e la lista attuale - /// - /// - /// - /// - private void allocaRigheListaPrelievo(decimal QtaTot, string codListaAttuale, DS_magazzino.ElencoCartelliniDataTable tabellaElencoCartellini) - { - //ricavo il valore UDC della riga del più vecchio - string udcAttuale; - bool qtaOk = false; - bool dataFinished = false; - int progrUdc = 0; - int numUdcDisponibili = tabellaElencoCartellini.Rows.Count; - // contiene la quantità della riga attuale - decimal qtaRiga; - // somma progressiva della qta allocata - calcolo da db! - decimal qtaAllocata = taElencoListePrelievo.getByCodLista(codListaAttuale)[0].Prelevato; - //ciclo WHILE per lo riempimento FIFO con UDC secondo richiesta a partire da elenco fornito - while (!qtaOk && !dataFinished) - { - /* - * crea una riga in righelistaprelievo passando come valori - * il codlista attuale ricavato da sopr - * l'UDC dal primo della tabella getOlderUDC - * - * - * recupero quantità dalla riga corrente; - * - * imposto proposto a 1; - * imposto prelevato 0; - * taRighelistePreliveo.Insert; - * - * qtaAllocata = qtaAllocata + Qta di questa riga (riuso il valore della colonna QTA - * tabella[contatore]; contatore++; - * qtaOk = (qtaAllocata >= qtaRichiesta) - * dataFinished = (contatore >= numRighe); - * - * */ - // ricavo la riga più vecchia - qtaRiga = tabellaElencoCartellini[progrUdc].Qta; - udcAttuale = tabellaElencoCartellini[progrUdc].UDC; - // eseguo query di insert - taRigheListePrelievo.Insert(codListaAttuale, udcAttuale, qtaRiga, true, false); - - //incremento qta allocata - qtaAllocata = (qtaAllocata + qtaRiga); - //incremento contatore - progrUdc++; - - // verifico le condizioni, false se non cambia nulla true se cambia e si esce dal while - qtaOk = (qtaAllocata >= QtaTot); - dataFinished = (progrUdc >= numUdcDisponibili); - } - } - - #endregion - - #region Metodi esposti - - #region operazioni su AL - - /// - /// Fornisce un nuovo codice AL tipo completo a partire dalla richiesta e salva i dati - /// - /// tipologia dell'AL da generare - /// codice della cella contentente gli UDC da associare - /// codice dell'operatore - /// anno in cui intestare i cartellini, trimma a 2 cifre DX - /// codice cesta - /// note da associare agli UDC - /// AL del nuovo Assieme Logico e lo associa agli UDC della postazione/cella - public string creaAssociaAlRxNt(tipoAL tipologia, string CodCella, string CodSoggetto, int anno, string Cesta, string note) - { - // imposto valori default - string CodCS = memLayer.ML.cdv("CodCS"); - string PostFlux = ""; - string CodFlusso = ""; - string TipoAL = ""; - string CodEvento = ""; - string CodDtxStart = ""; - string CodDtxEnd = ""; - switch (tipologia) - { - case tipoAL.AL_RxDt: - PostFlux = "RxDt"; - CodFlusso = "AR"; - TipoAL = "R"; - CodEvento = "UDC_RX_DT"; - // calcolo primo/ultimo dtx OK - try - { - DS_DataMatrix.stp_getFirstLastDtxRow rigaFirstLast = DataMatrix.mgr.taFirstLastUdc.GetData(CodCella)[0]; - if (!rigaFirstLast.IsNull(0)) - { - CodDtxStart = rigaFirstLast.DtxStart; - CodDtxEnd = rigaFirstLast.DtxEnd; - } - else - { - CodDtxStart = ""; - CodDtxEnd = ""; - } - } - catch - { - CodDtxStart = ""; - CodDtxEnd = ""; - } - break; - case tipoAL.AL_RxNt: - PostFlux = "RxNt"; - CodFlusso = "AR"; - TipoAL = "R"; - CodEvento = "UDC_RX"; - break; - default: - break; - } - DateTime DataRif = DateTime.Now; - // trim fix - string CodSoggettoTrim = CodSoggetto.Trim(); - string annoTrim = anno.ToString(); - if (annoTrim.Length > 2) - { - annoTrim = annoTrim.Substring(2, 2); - } - // out: codice AL... - string AL = "NA"; - // creo nuovo Assieme Logico ed associo UDC! - try - { - taEA.insertNewRX(CodCS, annoTrim, Cesta, PostFlux, CodFlusso, TipoAL, DataRif, CodSoggettoTrim, CodDtxStart, CodDtxEnd, CodCella, CodEvento, note, ref AL); - } - catch (Exception exc) - { - // loggo errore - logger.lg.scriviLog(string.Format("ERRORE CREAZIONE AL: {0} procedura stp_UAL_insertNewRX, parametri: {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11} | {12} | {13} {0} {14}", Environment.NewLine, CodCS, annoTrim, Cesta, PostFlux, CodFlusso, TipoAL, DataRif, CodSoggettoTrim, CodDtxStart, CodDtxEnd, CodCella, CodEvento, note, exc), tipoLog.EXCEPTION); - } - return AL; - } - - /// - /// Fornisce un nuovo codice AL tipo completo a partire dalla richiesta e salva i dati - /// - /// Codice Linea - /// Formato DataMatrix - /// CodEvento creazione UDC - /// CodEvento creazione UDC - /// tipologia dell'AL da generare - /// codice della cella contentente gli UDC da associare - /// codice dell'operatore - /// anno in cui intestare i cartellini, trimma a 2 cifre DX - /// codice cesta - /// note da associare agli UDC - /// AL del nuovo Assieme Logico e lo associa agli UDC della postazione/cella - public string creaAssociaAlUdcRxDt(string CodLinea, string FormatoDtmx, string CodEventoUdc, string CodStatoUdc, tipoAL tipologia, string CodCella, string CodSoggetto, int anno, string Cesta, string note) - { - // imposto valori default - string CodCS = memLayer.ML.cdv("CodCS"); - string PostFlux = ""; - string CodFlusso = ""; - string CodFlussoUdc = ""; - string TipoAL = ""; - string CodDtxStart = ""; - string CodDtxEnd = ""; - switch (tipologia) - { - case tipoAL.AL_RxDt: - PostFlux = "RxDt"; - CodFlusso = "AR"; - CodFlussoUdc = "RX"; - TipoAL = "R"; - // calcolo primo/ultimo dtx OK - try - { - DS_DataMatrix.stp_getFirstLastDtxRow rigaFirstLast = DataMatrix.mgr.taFirstLastUdc.GetData(CodCella)[0]; - if (!rigaFirstLast.IsNull(0)) - { - CodDtxStart = rigaFirstLast.DtxStart; - CodDtxEnd = rigaFirstLast.DtxEnd; - } - else - { - CodDtxStart = ""; - CodDtxEnd = ""; - } - } - catch - { - CodDtxStart = ""; - CodDtxEnd = ""; - } - break; - default: - break; - } - DateTime DataRif = DateTime.Now; - // trim fix - string CodSoggettoTrim = CodSoggetto.Trim(); - string annoTrim = anno.ToString(); - if (annoTrim.Length > 2) - { - annoTrim = annoTrim.Substring(2, 2); - } - // out: codice AL... - string AL = "NA"; - // creo nuovo Assieme Logico ed associo UDC! - try - { - - - DataMatrix.mgr.taL2D.createUdcAl(CodLinea, FormatoDtmx, CodFlusso, TipoAL, Cesta, CodCS, CodFlussoUdc, annoTrim, "", "", "", "", "", DataRif, 0, memLayer.ML.cdv("CodImballoRX"), CodSoggettoTrim, 0, memLayer.ML.cdvi("IdxPosizioneRxTemp"), "U", CodEventoUdc, 0, 0, CodStatoUdc, "", false, note); - // vado a leggere AL da riga corrente - AL = DataMatrix.mgr.taL2D.getByLineFormato(Postazione.currCodLinea, FormatoDtmx)[0].AL; - - } - catch (Exception exc) - { - // loggo errore - logger.lg.scriviLog(string.Format("ERRORE CREAZIONE AL: {0} procedura dmtx.stp_L2D_createUdc, parametri: {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11} | {12} | {13} {0} {14}", Environment.NewLine, CodCS, annoTrim, Cesta, PostFlux, CodFlusso, TipoAL, DataRif, CodSoggettoTrim, CodDtxStart, CodDtxEnd, CodCella, CodEventoUdc, note, exc), tipoLog.EXCEPTION); - } - return AL; - } - - /// - /// Crea un nuovo AL di tipo TT a partire da uno RX e sistema di conseguenza UDC ed eventuali Dtx - /// - /// Codice AL RX sorgente - /// tipologia (T) - /// Operatore - /// Note - /// Numero Trattamento - /// Durezza rilevata - /// Codice Punzone da utilizzare (se indicato) - /// - public string creaAssociaAlTT(string SourceAL, tipoAL tipologia, string CodSoggetto, string note, string NumTratt, int Durezza, string punzone) - { - // imposto valori default - string TipoAL = ""; - string CodEvento = ""; - DateTime DataRif = DateTime.Now; - // trim fix - string CodSoggettoTrim = CodSoggetto.Trim(); - // out: codice AL... - string AL = "NA"; - switch (tipologia) - { - case tipoAL.AL_TT: - TipoAL = "T"; - CodEvento = "UDC_TRATT"; - break; - default: - break; - } - // creo nuovo Assieme Logico ed associo UDC! - try - { - taEA.insertNewTT(SourceAL, TipoAL, DataRif, CodSoggetto, note, NumTratt, Durezza, punzone, ref AL); - } - catch (Exception exc) - { - // loggo errore - logger.lg.scriviLog(string.Format("ERRORE avanzamento AL TT: {0} procedura stp_UAL_insertNewTT, parametri: {1} | {2} | {3} | {4} | {5} | {6} | {0} {7}", Environment.NewLine, SourceAL, TipoAL, DataRif, CodSoggetto, CodEvento, note, exc), tipoLog.EXCEPTION); - } - return AL; - } - /// - /// Crea un nuovo AL di tipo TL a partire da uno TT e sistema di conseguenza UDC ed eventuali Dtx - /// - /// Codice AL TT sorgente - /// tipologia (L) - /// codice cella di destinazione - /// Operatore - /// - public string creaAssociaAlTL(string SourceAL, tipoAL tipologia, string CodSoggetto, string CodCella) - { - // imposto valori default - string TipoAL = ""; - DateTime DataRif = DateTime.Now; - // trim fix - string CodSoggettoTrim = CodSoggetto.Trim(); - // out: codice AL... - string AL = "NA"; - switch (tipologia) - { - case tipoAL.AL_LI: - TipoAL = "L"; - break; - default: - break; - } - // creo nuovo Assieme Logico ed associo UDC! - try - { - taEA.insertNewTL(SourceAL, TipoAL, DataRif, CodSoggetto, CodCella, ref AL); - } - catch (Exception exc) - { - // loggo errore - logger.lg.scriviLog(string.Format("ERRORE avanzamento AL TL: {0} procedura stp_UAL_insertNewTL, parametri: {1} | {2} | {3} | {4} | {0} {5}", Environment.NewLine, SourceAL, TipoAL, DataRif, CodSoggetto, exc), tipoLog.EXCEPTION); - } - return AL; - } - /// - /// elimina un AL che sia vuoto (da datamatrix) - /// - /// - /// - /// - public bool eliminaEmptyAL(string AL, string CodSoggetto) - { - bool answ = false; - try - { - taEA.eliminaEmpty(AL, DateTime.Now, CodSoggetto); - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Errore in eliminazione AL non vuoto: {0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); - } - return answ; - } - - /// - /// verifica se l'AL indicato sia valido, ovvero esistente - /// - /// - /// - public bool checkAL(string AL) - { - bool answ = false; - try - { - answ = (taEA.getByAL(AL).Rows.Count > 0); - } - catch - { } - return answ; - } - /// - /// travasa gli UDC / datamatrix tra 2 AL - /// - /// Codice AL sorgente - /// Codice AL destinazione - /// IP del chiamante - /// esito comando - public bool travasoAL(string ALFrom, string ALDest, string clientIp) - { - bool answ = false; - try - { - taAL2UDC.moveUdcDtx(ALFrom, ALDest, CodSoggCurrUser); - logger.lg.scriviLog(string.Format(" | {0} | travaso UDC: da {1} a {2} | soggetto {3}", clientIp, ALFrom, ALDest, CodSoggCurrUser), tipoLog.INFO); - answ = true; - } - catch - { } - return answ; - } - /// - /// effettua la stampa di un dato AL - /// - /// Codice AL - /// stampante specifica (da postazione o std da webconfig, a cura dell'utente) - /// IP del chiamante - /// - public bool stampaAL(string AL, string printer, string clientIp) - { - bool answ = false; - tipoCartellino tipoCart = tipoCartellino.cartAL; - // controllo se esista UDC - if (checkAL(AL)) - { - // in base al codice AL scelgo il tipo di cartellino... - switch (verificaTipoAl(AL)) - { - case tipoAL.AL_RX: - case tipoAL.AL_RxDt: - case tipoAL.AL_RxNt: - tipoCart = tipoCartellino.cartALRX; - break; - case tipoAL.AL_TT: - tipoCart = tipoCartellino.cartALTT; - break; - case tipoAL.AL_LI: - case tipoAL.ND: - default: - tipoCart = tipoCartellino.cartAL; - break; - } - answ = reportPrinter.obj.stampaCartellino(tipoCart, AL, printer); - logger.lg.scriviLog(string.Format(" | {0} | stampato AL {1} | stampante {2} | tipo {3}", clientIp, AL, printer, tipoCart), tipoLog.INFO); + CodDtxStart = rigaFirstLast.DtxStart; + CodDtxEnd = rigaFirstLast.DtxEnd; } else { - logger.lg.scriviLog(string.Format("ERRORE: non e' stato possibile stampare AL richiesto poiche' non trovato: | IP: {0} | AL {1} | stampante {2} | tipo {3}", clientIp, AL, printer, tipoCart), tipoLog.INFO); + CodDtxStart = ""; + CodDtxEnd = ""; } - return answ; - } - /// - /// verifica il tipo di AL dato il codice - /// - /// - /// - public tipoAL verificaTipoAl(string AL) - { - tipoAL answ = tipoAL.ND; - if (AL.StartsWith("ALR")) + } + catch + { + CodDtxStart = ""; + CodDtxEnd = ""; + } + break; + case tipoAL.AL_RxNt: + PostFlux = "RxNt"; + CodFlusso = "AR"; + TipoAL = "R"; + CodEvento = "UDC_RX"; + break; + default: + break; + } + DateTime DataRif = DateTime.Now; + // trim fix + string CodSoggettoTrim = CodSoggetto.Trim(); + string annoTrim = anno.ToString(); + if (annoTrim.Length > 2) + { + annoTrim = annoTrim.Substring(2, 2); + } + // out: codice AL... + string AL = "NA"; + // creo nuovo Assieme Logico ed associo UDC! + try + { + taEA.insertNewRX(CodCS, annoTrim, Cesta, PostFlux, CodFlusso, TipoAL, DataRif, CodSoggettoTrim, CodDtxStart, CodDtxEnd, CodCella, CodEvento, note, ref AL); + } + catch (Exception exc) + { + // loggo errore + logger.lg.scriviLog(string.Format("ERRORE CREAZIONE AL: {0} procedura stp_UAL_insertNewRX, parametri: {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11} | {12} | {13} {0} {14}", Environment.NewLine, CodCS, annoTrim, Cesta, PostFlux, CodFlusso, TipoAL, DataRif, CodSoggettoTrim, CodDtxStart, CodDtxEnd, CodCella, CodEvento, note, exc), tipoLog.EXCEPTION); + } + return AL; + } + + /// + /// Fornisce un nuovo codice AL tipo completo a partire dalla richiesta e salva i dati + /// + /// Codice Linea + /// Formato DataMatrix + /// CodEvento creazione UDC + /// CodEvento creazione UDC + /// tipologia dell'AL da generare + /// codice della cella contentente gli UDC da associare + /// codice dell'operatore + /// anno in cui intestare i cartellini, trimma a 2 cifre DX + /// codice cesta + /// note da associare agli UDC + /// AL del nuovo Assieme Logico e lo associa agli UDC della postazione/cella + public string creaAssociaAlUdcRxDt(string CodLinea, string FormatoDtmx, string CodEventoUdc, string CodStatoUdc, tipoAL tipologia, string CodCella, string CodSoggetto, int anno, string Cesta, string note) + { + // imposto valori default + string CodCS = memLayer.ML.cdv("CodCS"); + string PostFlux = ""; + string CodFlusso = ""; + string CodFlussoUdc = ""; + string TipoAL = ""; + string CodDtxStart = ""; + string CodDtxEnd = ""; + switch (tipologia) + { + case tipoAL.AL_RxDt: + PostFlux = "RxDt"; + CodFlusso = "AR"; + CodFlussoUdc = "RX"; + TipoAL = "R"; + // calcolo primo/ultimo dtx OK + try + { + DS_DataMatrix.stp_getFirstLastDtxRow rigaFirstLast = DataMatrix.mgr.taFirstLastUdc.GetData(CodCella)[0]; + if (!rigaFirstLast.IsNull(0)) { - answ = tipoAL.AL_RX; - } - else if (AL.StartsWith("ALT")) - { - answ = tipoAL.AL_TT; - } - else if (AL.StartsWith("ALL")) - { - answ = tipoAL.AL_LI; + CodDtxStart = rigaFirstLast.DtxStart; + CodDtxEnd = rigaFirstLast.DtxEnd; } else { - answ = tipoAL.ND; + CodDtxStart = ""; + CodDtxEnd = ""; } - return answ; + } + catch + { + CodDtxStart = ""; + CodDtxEnd = ""; + } + break; + default: + break; + } + DateTime DataRif = DateTime.Now; + // trim fix + string CodSoggettoTrim = CodSoggetto.Trim(); + string annoTrim = anno.ToString(); + if (annoTrim.Length > 2) + { + annoTrim = annoTrim.Substring(2, 2); + } + // out: codice AL... + string AL = "NA"; + // creo nuovo Assieme Logico ed associo UDC! + try + { + + + DataMatrix.mgr.taL2D.createUdcAl(CodLinea, FormatoDtmx, CodFlusso, TipoAL, Cesta, CodCS, CodFlussoUdc, annoTrim, "", "", "", "", "", DataRif, 0, memLayer.ML.cdv("CodImballoRX"), CodSoggettoTrim, 0, memLayer.ML.cdvi("IdxPosizioneRxTemp"), "U", CodEventoUdc, 0, 0, CodStatoUdc, "", false, note); + // vado a leggere AL da riga corrente + AL = DataMatrix.mgr.taL2D.getByLineFormato(Postazione.currCodLinea, FormatoDtmx)[0].AL; + + } + catch (Exception exc) + { + // loggo errore + logger.lg.scriviLog(string.Format("ERRORE CREAZIONE AL: {0} procedura dmtx.stp_L2D_createUdc, parametri: {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11} | {12} | {13} {0} {14}", Environment.NewLine, CodCS, annoTrim, Cesta, PostFlux, CodFlusso, TipoAL, DataRif, CodSoggettoTrim, CodDtxStart, CodDtxEnd, CodCella, CodEventoUdc, note, exc), tipoLog.EXCEPTION); + } + return AL; + } + + /// + /// Crea un nuovo AL di tipo TT a partire da uno RX e sistema di conseguenza UDC ed eventuali Dtx + /// + /// Codice AL RX sorgente + /// tipologia (T) + /// Operatore + /// Note + /// Numero Trattamento + /// Durezza rilevata + /// Codice Punzone da utilizzare (se indicato) + /// + public string creaAssociaAlTT(string SourceAL, tipoAL tipologia, string CodSoggetto, string note, string NumTratt, int Durezza, string punzone) + { + // imposto valori default + string TipoAL = ""; + string CodEvento = ""; + DateTime DataRif = DateTime.Now; + // trim fix + string CodSoggettoTrim = CodSoggetto.Trim(); + // out: codice AL... + string AL = "NA"; + switch (tipologia) + { + case tipoAL.AL_TT: + TipoAL = "T"; + CodEvento = "UDC_TRATT"; + break; + default: + break; + } + // creo nuovo Assieme Logico ed associo UDC! + try + { + taEA.insertNewTT(SourceAL, TipoAL, DataRif, CodSoggetto, note, NumTratt, Durezza, punzone, ref AL); + } + catch (Exception exc) + { + // loggo errore + logger.lg.scriviLog(string.Format("ERRORE avanzamento AL TT: {0} procedura stp_UAL_insertNewTT, parametri: {1} | {2} | {3} | {4} | {5} | {6} | {0} {7}", Environment.NewLine, SourceAL, TipoAL, DataRif, CodSoggetto, CodEvento, note, exc), tipoLog.EXCEPTION); + } + return AL; + } + /// + /// Crea un nuovo AL di tipo TL a partire da uno TT e sistema di conseguenza UDC ed eventuali Dtx + /// + /// Codice AL TT sorgente + /// tipologia (L) + /// codice cella di destinazione + /// Operatore + /// + public string creaAssociaAlTL(string SourceAL, tipoAL tipologia, string CodSoggetto, string CodCella) + { + // imposto valori default + string TipoAL = ""; + DateTime DataRif = DateTime.Now; + // trim fix + string CodSoggettoTrim = CodSoggetto.Trim(); + // out: codice AL... + string AL = "NA"; + switch (tipologia) + { + case tipoAL.AL_LI: + TipoAL = "L"; + break; + default: + break; + } + // creo nuovo Assieme Logico ed associo UDC! + try + { + taEA.insertNewTL(SourceAL, TipoAL, DataRif, CodSoggetto, CodCella, ref AL); + } + catch (Exception exc) + { + // loggo errore + logger.lg.scriviLog(string.Format("ERRORE avanzamento AL TL: {0} procedura stp_UAL_insertNewTL, parametri: {1} | {2} | {3} | {4} | {0} {5}", Environment.NewLine, SourceAL, TipoAL, DataRif, CodSoggetto, exc), tipoLog.EXCEPTION); + } + return AL; + } + /// + /// elimina un AL che sia vuoto (da datamatrix) + /// + /// + /// + /// + public bool eliminaEmptyAL(string AL, string CodSoggetto) + { + bool answ = false; + try + { + taEA.eliminaEmpty(AL, DateTime.Now, CodSoggetto); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in eliminazione AL non vuoto: {0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + } + return answ; + } + + /// + /// verifica se l'AL indicato sia valido, ovvero esistente + /// + /// + /// + public bool checkAL(string AL) + { + bool answ = false; + try + { + answ = (taEA.getByAL(AL).Rows.Count > 0); + } + catch + { } + return answ; + } + /// + /// travasa gli UDC / datamatrix tra 2 AL + /// + /// Codice AL sorgente + /// Codice AL destinazione + /// IP del chiamante + /// esito comando + public bool travasoAL(string ALFrom, string ALDest, string clientIp) + { + bool answ = false; + try + { + taAL2UDC.moveUdcDtx(ALFrom, ALDest, CodSoggCurrUser); + logger.lg.scriviLog(string.Format(" | {0} | travaso UDC: da {1} a {2} | soggetto {3}", clientIp, ALFrom, ALDest, CodSoggCurrUser), tipoLog.INFO); + answ = true; + } + catch + { } + return answ; + } + /// + /// effettua la stampa di un dato AL + /// + /// Codice AL + /// stampante specifica (da postazione o std da webconfig, a cura dell'utente) + /// IP del chiamante + /// + public bool stampaAL(string AL, string printer, string clientIp) + { + bool answ = false; + tipoCartellino tipoCart = tipoCartellino.cartAL; + // controllo se esista UDC + if (checkAL(AL)) + { + // in base al codice AL scelgo il tipo di cartellino... + switch (verificaTipoAl(AL)) + { + case tipoAL.AL_RX: + case tipoAL.AL_RxDt: + case tipoAL.AL_RxNt: + tipoCart = tipoCartellino.cartALRX; + break; + case tipoAL.AL_TT: + tipoCart = tipoCartellino.cartALTT; + break; + case tipoAL.AL_LI: + case tipoAL.ND: + default: + tipoCart = tipoCartellino.cartAL; + break; + } + answ = reportPrinter.obj.stampaCartellino(tipoCart, AL, printer); + logger.lg.scriviLog(string.Format(" | {0} | stampato AL {1} | stampante {2} | tipo {3}", clientIp, AL, printer, tipoCart), tipoLog.INFO); + } + else + { + logger.lg.scriviLog(string.Format("ERRORE: non e' stato possibile stampare AL richiesto poiche' non trovato: | IP: {0} | AL {1} | stampante {2} | tipo {3}", clientIp, AL, printer, tipoCart), tipoLog.INFO); + } + return answ; + } + /// + /// verifica il tipo di AL dato il codice + /// + /// + /// + public tipoAL verificaTipoAl(string AL) + { + tipoAL answ = tipoAL.ND; + if (AL.StartsWith("ALR")) + { + answ = tipoAL.AL_RX; + } + else if (AL.StartsWith("ALT")) + { + answ = tipoAL.AL_TT; + } + else if (AL.StartsWith("ALL")) + { + answ = tipoAL.AL_LI; + } + else + { + answ = tipoAL.ND; + } + return answ; + } + + #endregion + + #region operazioni su UDC + + /// + /// effettua lo spostamento di un UDC tra 2 posizioni indicate + /// + /// Codice company/sito + /// Codice UDC + /// Cella di destinazione + /// indica se sia richiesto resettare le Righe Liste Prelievo con lo spostsamento + /// IP del chiamante + /// esito comando + public bool spostaUDC(string CodCS, string UDC, int IdxCellaTo, bool resetRLP, string clientIp) + { + bool answ = false; + // procedo SOLO se la cella di dest è VUOTA... + if (!MagClass.magazzino.cellaPiena(CodCS, IdxCellaTo)) + { + try + { + taPosUdcCorr.stp_spostaUdc(CodCS, UDC, IdxCellaTo, resetRLP, CodSoggCurrUser); + // cerco nuova posizione... + if (taPosUdcCorr.getByCellaUdc(UDC, IdxCellaTo).Rows.Count > 0) + { + answ = true; + } + } + catch (Exception e) + { + logger.lg.scriviLog(string.Format(" | {1} | Errore durante spostamento cella: {0}", e, clientIp), tipoLog.EXCEPTION); + } + // solo se ha fatto spostamento posizione corrente verifico se fare spostamento in posizione LOGICA magazzino + if (answ) + { + try + { + // verifico tipo cella e se ci sia da fare spostamento in mag logico/contabile + int idxTipoCella = taCelle.getByIdxCella(IdxCellaTo)[0].IdxTipoCella; + bool needSetMag = taTipoCella.getByIdx(idxTipoCella)[0].SetMag; + if (needSetMag) + { + // cambio (eventualmente) la posizione "logica" dato lo spostamento (il codice magazzino...) + int idxBlocco = taCelle.getByIdxCella(IdxCellaTo)[0].IdxBlocco; + int IdxPosizione = Convert.ToInt32(taBlocchi.getByIdx(idxBlocco)[0].CodMag); + taCartellini.updateIdxPosizione(UDC, IdxPosizione, CodSoggCurrUser); + } + } + catch (Exception e) + { + logger.lg.scriviLog(string.Format(" | {1} | Errore durante indicazione posizione UDC: {0}", e, clientIp), tipoLog.EXCEPTION); + } + } + } + else + { + logger.lg.scriviLog(string.Format(" | {1} | Errore, cella {0} di destinazione piena!!!", IdxCellaTo, clientIp), tipoLog.ERROR); + } + return answ; + } + /// + /// effettua lo scaricamento di un UDC (x spedizione) + /// + /// Codice UDC + /// Codice posizione UDC finale + /// Codice evento associato allo scaricamento + /// IP del chiamante + /// esito comando + public bool scaricaUDC(string UDC, int IdxPosizUdc, string CodEvento, string clientIp) + { + bool answ = false; + try + { + taPosUdcCorr.stp_scaricaUdc(UDC, IdxPosizUdc, CodEvento, CodSoggCurrUser); + logger.lg.scriviLog(string.Format(" | {0} | Scaricato UDC {1} | posizione {2} | CodEvento {3} | soggetto {4}", clientIp, UDC, IdxPosizUdc, CodEvento, CodSoggCurrUser), tipoLog.INFO); + answ = true; + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format(" | {2} | Errore in scaricaUDC:{0}{1}", Environment.NewLine, exc, clientIp), tipoLog.EXCEPTION); + } + return answ; + } + /// + /// rettifica la qta di un UDC + /// + /// Codice UDC + /// Nuova quantita associata + /// IP del chiamante + /// esito comando + public bool rettificaQtaUDC(string UDC, decimal qta, string clientIp) + { + bool answ = false; + try + { + int fatti = 0; + fatti = taCartellini.updateQty(UDC, CodSoggCurrUser, "U", "UDC_QTY", qta).Rows.Count; + if (fatti > 0) + { + answ = true; + logger.lg.scriviLog(string.Format(" | {0} | Rettifica qta UDC {1} | qta {2} | soggetto {3}", clientIp, UDC, qta, CodSoggCurrUser), tipoLog.INFO); + } + } + catch + { } + return answ; + } + /// + /// rettifica la qta di un UDC + /// + /// Codice UDC sorgente + /// Codice UDC destinazione + /// Quantita da travasare + /// IP del chiamante + /// esito comando + public bool travasoQtaUDC(string UdcFrom, string UdcDest, decimal qta, string clientIp) + { + bool answ = false; + try + { + taCartellini.travasoQty(UdcFrom, UdcDest, CodSoggCurrUser, "U", "UDC_TraQTY", qta); + logger.lg.scriviLog(string.Format(" | {0} | travaso qta UDC: da {1} a {2} | qta {3} | soggetto {4}", clientIp, UdcFrom, UdcDest, qta, CodSoggCurrUser), tipoLog.INFO); + answ = true; + } + catch + { } + return answ; + } + /// + /// Sistema il cartellino finito liquidi per la stampa + /// + /// AL sorgente in postazione (ATL) + /// Tipo cart da legare (TT) + /// Cod UDC da processare + /// Cod Imballo + /// Note x cartellino + /// Cod soggetto + /// + public bool liquidiFullUpdate(string SourceAL, string TipoAlAnc, string UDC, string CodImb, string Note, string CodSoggetto) + { + bool answ = false; + try + { + DS_magazzino.ElencoCartelliniRow riga = taCartellini.UdcLiqFullUpdate(SourceAL, TipoAlAnc, UDC, CodImb, Note, DateTime.Now, CodSoggetto)[0]; + answ = true; + } + catch + { } + return answ; + } + /// + /// Riprende in carico alla postazione un cartellino liquidi FINITO valido + /// + /// Cod UDC da processare + /// Cod soggetto + /// AL (temporaneo) di destinazione + /// Cod cella di destinazione + /// + public bool liquidiRiprendiInCaricoUDC(string UDC, string CodSoggetto, string tempAL, int idxCella) + { + bool answ = false; + try + { + DS_magazzino.ElencoCartelliniRow riga = taCartellini.UdcLiqRicarica(UDC, idxCella, tempAL, DateTime.Now, CodSoggetto)[0]; + answ = true; + } + catch (Exception exc) + { + logger.lg.scriviLog(exc.ToString(), tipoLog.EXCEPTION); + } + return answ; + } + /// + /// Riprende in carico alla postazione un cartellino Finiti Rx valido + /// + /// Cod UDC da processare + /// Cod soggetto + /// AL (temporaneo) di destinazione + /// Cod cella di destinazione + /// + public bool finRxRiprendiInCaricoUDC(string UDC, string CodSoggetto, string tempAL, int idxCella) + { + bool answ = false; + try + { + DS_magazzino.ElencoCartelliniRow riga = taCartellini.UdcFinRxRicarica(UDC, idxCella, tempAL, DateTime.Now, CodSoggetto)[0]; + answ = true; + } + catch + { } + return answ; + } + /// + /// Sistema il cartellino Gitterbox Rx Finiti (B48) per la stampa + /// + /// Cod UDC da processare + /// Cod Imballo + /// Note x cartellino + /// Cod soggetto + /// + public bool Udc_B48_FullUpdate(string UDC, string CodImb, string Note, string CodSoggetto) + { + bool answ = false; + try + { + DS_magazzino.ElencoCartelliniRow riga = taCartellini.UdcRxFinLiqFullUpdate(UDC, CodImb, Note, DateTime.Now, CodSoggetto)[0]; + answ = true; + } + catch + { } + return answ; + } + /// + /// verifica se l'UDC indicato sia valido, ovvero esistente + /// + /// + /// + public bool checkUDC(string UDC) + { + bool answ = false; + try + { + answ = (taCartellini.getDetailsUdcByUdc(UDC).Rows.Count > 0); + } + catch + { } + return answ; + } + /// + /// verifica se l'UDC indicato sia ESENTE DA NC attive (ovvero senza deroga DC) + /// + /// + /// restituisce esito controllo + public checkUdcNc checkUDC_NC(string UDC) + { + /// default caso pessimo... + checkUdcNc answ = checkUdcNc.HasNc; + bool hasNc = false; + try + { + hasNc = (DataProxy.obj.taUDC2NC.getNcPending(UDC, "DC", "NC").Rows.Count != 0); + } + catch + { } + // se richiesto faccio verifica + if (memLayer.ML.CRB("checkUDC_NC")) + { + if (hasNc) + { + answ = checkUdcNc.HasNc; + } + else + { + answ = checkUdcNc.NoNc; + } + } + // altrimenti NON E' richiesta verifica + else + { + if (hasNc) + { + answ = checkUdcNc.ChkDis_HasNc; + } + else + { + answ = checkUdcNc.ChkDis_NoNc; + } + } + return answ; + } + /// + /// Fornisce elenco NC associate ad un UDC + /// + /// + /// + public DS_Applicazione.ElencoNCDataTable getNc2UDC(string UDC) + { + DS_Applicazione.ElencoNCDataTable answ = new DS_Applicazione.ElencoNCDataTable(); + // controllo se ci siano NC + checkUdcNc esito = checkUDC_NC(UDC); + // se ci sono recupero! + if (esito == checkUdcNc.HasNc || esito == checkUdcNc.ChkDis_HasNc) + { + answ = DataProxy.obj.taENC.getByUDC(UDC); + } + return answ; + } + /// + /// Restituisce stringa formattata dellal NC associata all'UDC + /// + /// + /// + public string getDescrNc2Udc(string UDC) + { + DS_Applicazione.ElencoNCDataTable tab = getNc2UDC(UDC); + string answ = ""; + if (tab.Rows.Count > 0) + { + DS_Applicazione.ElencoNCRow riga = null; + // recupero righe... + for (int i = 0; i < tab.Rows.Count; i++) + { + riga = (DS_Applicazione.ElencoNCRow)tab.Rows[i]; + answ += string.Format("
NC: {0}, {1}
", riga.CodNC, riga.DescrNC); + //answ += string.Format("
NC: {0}, {1}
{2} | {3} | {4} ({5:yyyy.MM.dd HH:mm} --> {6:yyyy.MM.dd HH:mm})
", riga.CodNC, riga.DescrNC, riga.TipoCart, riga.Particolare, riga.SearchNote, riga.DataFrom, riga.DataTo); + } + } + return answ; + } + + /// + /// verifica se l'UDC indicato POSSA ESSERE MOVIMENTATO (ovvero NON in LDP in stato "bloccato") + /// + /// + /// + public bool checkUDC_mov(string UDC) + { + bool answ = false; + try + { + answ = (taRigheListePrelievo.getBloccateMovByUdc(UDC).Rows.Count == 0); + } + catch + { } + return answ; + } + /// + /// verifica se l'UDC indicato POSSA ESSERE OGGETTO DI RETTIFICA QTA (ovvero NON in LDP in stato "bloccato") + /// + /// + /// + public bool checkUDC_qty(string UDC) + { + bool answ = false; + try + { + answ = (taRigheListePrelievo.getBloccateQtaByUdc(UDC).Rows.Count == 0); + } + catch + { } + return answ; + } + /// + /// effettua lo scaricamento (da db e da AS400) degli UDC di MP/WIP, registrando l'evento "UDC_CONS" + /// + /// Codice UDC + /// IP del chiamante + /// + public bool scaricaUdcMpWip(string UDC, string clientIp) + { + // inizializzo + bool answ = false; + int idxCellaFrom = 0; + int idxPosizUdcCorr = 0; + int idxPosizUdcDest = 0; + string CodEvento = "UDC_CONS"; + // calcolo posizione UDC corrente (se c'è...) + try + { + // mi serve per posizione udc corrente + DS_magazzino.PosizioneUdcCorrenteRow rigaUdcCorrente = taPosUdcCorr.getByUDC(UDC)[0]; + // il secondo idx che mi serve + idxCellaFrom = rigaUdcCorrente.IdxCella; + } + catch (Exception e) + { + logger.lg.scriviLog(string.Format(" | {3} | Errore in fase di recupero cella per l'UDC {0}: {1}{2}", UDC, Environment.NewLine, e, clientIp), tipoLog.EXCEPTION); + } + // ora calcolo gli altri dati dalla riga ElencoCartellini dell'UDC + try + { + // calcolo posizione destinazione da state machine... + idxPosizUdcCorr = taCartellini.getDetailsUdcByUdc(UDC)[0].IdxPosizione; + idxPosizUdcDest = StateMachine.SM.getIdxPostizioneTo(CodEvento, idxPosizUdcCorr); + } + catch (Exception e) + { + logger.lg.scriviLog(string.Format(" | {3} | Errore in fase di recupero dati posizioni from/to per l'UDC {0}: {1}{2}", UDC, Environment.NewLine, e, clientIp), tipoLog.EXCEPTION); + } + // ora provo ad eseguire! + try + { + if (idxPosizUdcDest != 0) // solo se c'è una posizione da cui poter fare lo scaricamento... + { + // sposto UDC + answ = scaricaUDC(UDC, idxPosizUdcDest, CodEvento, clientIp); + } + } + catch (Exception e) + { + logger.lg.scriviLog(string.Format(" | {3} | Errore in fase di scaricamento dell'UDC {0}: {1}{2}", UDC, Environment.NewLine, e, clientIp), tipoLog.EXCEPTION); + } + + return answ; + } + /// + /// riattiva un UDC (se permesso) da una posizione consumata ad una valida + /// + /// Codice UDC + /// Cod soggetto utente + /// IP del chiamante + /// + public bool riattivaUdc(string UDC, string CodSoggetto, string clientIp) + { + // init + bool answ = false; + try + { + // salvo dati cartellino PRE + DS_Applicazione.ElencoCartelliniRow rigaUdcPre = DataProxy.obj.taCartellini.stp_getByUdc(UDC)[0]; + GMW_data.DataProxy.obj.taCartellini.stp_riattivaUdc(UDC, CodSoggetto); + logger.lg.scriviLog(string.Format(" | {0} | riattivato UDC {1} | soggetto {2}", clientIp, UDC, CodSoggetto), tipoLog.INFO); + // salvo dati cartellino POST + DS_Applicazione.ElencoCartelliniRow rigaUdcPost = DataProxy.obj.taCartellini.stp_getByUdc(UDC)[0]; + answ = true; + } + catch (Exception e) + { + logger.lg.scriviLog(string.Format(" | {2} | Eccezione: {0}{1}", Environment.NewLine, e, clientIp), tipoLog.EXCEPTION); + } + + return answ; + } + /// + /// sblocca un UDC (se permesso) + /// + /// Codice UDC + /// Cod soggetto utente + /// IP del chiamante + /// + public bool sbloccaUdc(string UDC, string CodSoggetto, string clientIp) + { + // init + bool answ = false; + try + { + GMW_data.DataProxy.obj.taCartellini.stp_sbloccaUdc(UDC, CodSoggetto); + logger.lg.scriviLog(string.Format(" | {0} | sbloccato UDC {1} | soggetto {2}", clientIp, UDC, CodSoggetto), tipoLog.INFO); + answ = true; + } + catch (Exception e) + { + logger.lg.scriviLog(string.Format(" | {2} | Eccezione: {0}{1}", Environment.NewLine, e, clientIp), tipoLog.EXCEPTION); + } + return answ; + } + /// + /// controlla se l'udc della qualità indicato ha benestare qualità ("S") + /// + /// + /// + public bool udcMpHasBenesQual(string UDC) + { + bool answ = false; + try + { + DS_magazzino.RapQualRow rigaRapQual = taRapQual.getByUdc(UDC)[0]; + if (rigaRapQual.BenesQual == "S") + { + answ = true; + } + } + catch + { } + return answ; + } + /// + /// controlla se l'udc indicato è già stato consumato + /// + /// + /// + public bool udcMpIsConsumabile(string UDC) + { + bool answ = false; + try + { + DS_magazzino.ElencoCartelliniRow rigaUDC = taCartellini.getByUdc(UDC)[0]; + if (rigaUDC.IdxPosizione > 0) + { + answ = true; + } + } + catch + { } + return answ; + } + /// + /// fornisce IdxPosizione dell'UDC + /// + /// + /// + public int IdxPosizioneUdc(string UDC) + { + int answ = 0; + try + { + answ = taCartellini.getDetailsUdcByUdc(UDC)[0].IdxPosizione; + } + catch + { } + return answ; + } + /// + /// fornisce il CodStato dell'UDC + /// + /// + /// + public string CodStatoUdc(string UDC) + { + string answ = ""; + try + { + answ = taCartellini.getDetailsUdcByUdc(UDC)[0].CodStato; + } + catch + { } + return answ; + } + /// + /// fornisce cella in cui si trova l'UDC + /// + /// + /// + public string codCellaUdc(string UDC) + { + string answ = ""; + try + { + int idxCella = taPosUdcCorr.getByUDC(UDC)[0].IdxCella; + answ = taCelle.getByIdxCella(idxCella)[0].CodCella; + } + catch + { } + return answ; + } + /// + /// fornisce codBlocco in cui si trova l'UDC + /// + /// + /// + public string codBloccoUdc(string UDC) + { + string answ = ""; + try + { + int idxCella = taPosUdcCorr.getByUDC(UDC)[0].IdxCella; + int idxBlocco = taCelle.getByIdxCella(idxCella)[0].IdxBlocco; + answ = taBlocchi.getByIdx(idxBlocco)[0].CodBlocco; + } + catch + { } + return answ; + } + + /// + /// verifica se UDC sia ok x LDP secondo stored stp_getUdcDetailOkLP (LPA/LPX) + /// + /// + /// + public bool checkUdc_OkLPAX(string UDC) + { + bool answ = false; + try + { + answ = taDettUDC.getByUdcOkLp(UDC).Rows.Count > 0; + } + catch + { } + return answ; + } + /// + /// controlla se l'udc indicato sia in una LDP + /// + /// + /// + public bool udcInLdp(string UDC) + { + bool answ = false; + try + { + DS_magazzino.RigheListePrelievoDataTable tabRLDP = taRigheListePrelievo.getByUdc(UDC); + if (tabRLDP.Rows.Count > 0) + { + answ = true; + } + } + catch + { } + return answ; + } + /// + /// fornisce il codice UDC calcolato + /// + /// + /// + /// 2 cifre + /// + /// + public string getComposizioneUDC(string CodCS, string flusso, string anno, int numUDC) + { + string answ = ""; + try + { + answ = string.Format("U{0}{1}{2}{3}", CodCS, flusso, anno, numUDC.ToString().PadLeft(6, '0')); + } + catch + { } + return answ; + } + /// + /// fornisce il codice trattamento calcolato + /// + /// se > 2 cifre trim e tiene ultime 2.. + /// Numero trattamento + /// + public string getCompTrattamenti(string anno, string numTr) + { + string answ = ""; + try + { + answ = string.Format("{0}{1}", anno.Substring(anno.Length - 2, 2), numTr.PadLeft(6, '0')); + } + catch + { } + return answ; + }/// + /// Fornisce un nuovo codice UDC tipo completo (con pezzi e cod magazzino) a partire dalla richiesta e associa ad AL e mette nella cella richiesta + /// + /// AL da associare + /// AL Sorgente (da disattivare) + /// DataMatrix da spostare + /// + /// codice cella destinazione + /// codice anagrafico della bilanca che effettua la richiesta (codice della pesa) + /// codice anagrafico del cliente + /// codice del particolare (articolo) - da anagrafica! + /// Codice dell'impianto + /// Codice dello stampo + /// codice dell'esponente dello stampo + /// Codice figura + /// codice dell'UDC parent (UDC della tara) + /// peso in kg (0 se non noto) da associare all'UDC come tara del contenitore + /// codice dell'imballo (tipo cassone) - string LIBERO (non facciamo controlli in input) + /// tipo di dichiarazione (vedere relativa anagrafica consentita, es U=uomo, M=macchina...) + /// codice dell'operatore + /// numero pezzi associati all'UDC + /// Peso totale rilevato + /// Peso unitario rilevato + /// Data di rif per la dichiarazione + /// Turno di rif per la dichiarazione + /// Codice dello stato del pezzo (da anagrafica: sabbiato, ...) + /// Codice del magazzino in cui inserire l'UDC + /// NOME della posizione default in cui creare UDC + /// cod evento da associare al movimento mag + /// note (opzionali) + /// cod UDC pre-calcolato, se "" verrà calcolato dalla query + /// anno in cui intestare i cartellini, trimma a 2 cifre DX + /// Ip del client + /// UDC del nuovo cartellino per FINITI + public string creaUdcWithAlCella(string AL, string SourceAL, string DataMatrix, string CodStatoUdcOut, string CodCella, string CodBilancia, string CodCliente, string Particolare, string CodImpianto, string CodStampo, string Esponente, string Figura, string UDC_parent, double Tara, string CodImballo, string CodTipoDichiarazione, string CodSoggetto, int Quantita, float PesoTot, float PesoCad, DateTime DataRif, int TurnoRif, string CodStato, int CodMag, string defIdxPosiz, string codEvento, string note, string UDC, int anno, string clientIp) + { + // trim fix + string CodBilanciaTrim = CodBilancia.Trim(); + string CodClienteTrim = CodCliente.Trim(); + string ParticolareTrim = Particolare.Trim(); + string CodImpiantoTrim = CodImpianto.Trim(); + string CodStampoTrim = CodStampo.Trim(); + string EsponenteTrim = Esponente.Trim(); + string FiguraTrim = Figura.Trim(); + string UDC_parentTrim = UDC_parent.Trim(); + string CodImballoTrim = CodImballo.Trim(); + string CodTipoDichiarazioneTrim = CodTipoDichiarazione.Trim(); + string CodSoggettoTrim = CodSoggetto.Trim(); + string CodStatoTrim = CodStato.Trim(); + string defIdxPosizTrim = defIdxPosiz.Trim(); + string codEventoTrim = codEvento.Trim(); + string noteTrim = note.Trim(); + string annoTrim = anno.ToString(); + if (annoTrim.Length > 2) + { + annoTrim = annoTrim.Substring(2, 2); + } + // determino se cancellare udcTara + bool doDeleteUdcTara = false; // memLayer.ML.confReadBool("doDeleteUdcTara"); + // ricavo cod company... + string CodCS = "ND"; + string answ = "NA"; + try + { + CodCS = DataProxy.obj.taAnagBil.stp_getByCodBilancia(CodBilanciaTrim)[0].CodCS; + } + catch + { + CodCS = memLayer.ML.cdv("CodCS"); + } + int IdxPosizione = 0; + if (CodMag > 0) + { + IdxPosizione = CodMag; + } + else + { + IdxPosizione = memLayer.ML.confReadInt(defIdxPosizTrim); + } + // controllo di avere codice soggetto e particolare validi (!="") + if (ParticolareTrim != "" && CodSoggettoTrim != "") + { + // creo nuovo cartellino! + DS_Applicazione.ElencoCartelliniDataTable tabUdc = new DS_Applicazione.ElencoCartelliniDataTable(); + // insert nuovo UDC con codice impostato + try + { + tabUdc = DataProxy.obj.taCartellini.stp_insNewFullWithAL(AL, SourceAL, DataMatrix, CodStatoUdcOut, CodCella, CodCS, CodBilanciaTrim, annoTrim, CodClienteTrim, ParticolareTrim, CodImpiantoTrim, CodStampoTrim, EsponenteTrim, FiguraTrim, DataRif, TurnoRif, CodImballoTrim, CodSoggettoTrim, Tara, IdxPosizione, CodTipoDichiarazioneTrim, codEventoTrim, Quantita, PesoTot, PesoCad, CodStatoTrim, UDC_parentTrim, doDeleteUdcTara, noteTrim); + answ = UDC; + } + catch (Exception exc) + { + // loggo errore + logger.lg.scriviLog(string.Format("ERRORE CREAZIONE UDC: | {24} | procedura stp_insNewFull_fixUDC, parametri: {0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11} | {12} | {13} | {14} | {15} | {16} | {17} | {18} | {19} | {20} | {21} | {22} | {23} | {24}{25}{26}", answ, CodCS, CodBilanciaTrim, annoTrim, CodClienteTrim, ParticolareTrim, CodImpiantoTrim, CodStampoTrim, EsponenteTrim, FiguraTrim, DataRif, TurnoRif, CodImballoTrim, CodSoggettoTrim, Tara, IdxPosizione, CodTipoDichiarazioneTrim, codEventoTrim, Quantita, PesoTot, PesoCad, CodStatoTrim, UDC_parentTrim, noteTrim, clientIp, Environment.NewLine, exc), tipoLog.INFO); + } + // leggo la riga + answ = tabUdc[0].UDC; + // loggo tutto! + if (memLayer.ML.confReadInt("_logLevel") > 5) + { + try + { + logger.lg.scriviLog(string.Format(" | {24} | NUOVO cartellino da postazione: {0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11} | {12} | {13} | {14} | {15} | {16} | {17} | {18} | {19} | {20} | {21} | {22} | {23}", answ, CodCS, CodBilanciaTrim, annoTrim, CodClienteTrim, ParticolareTrim, CodImpiantoTrim, CodStampoTrim, EsponenteTrim, FiguraTrim, DataRif, TurnoRif, CodImballoTrim, CodSoggettoTrim, Tara, IdxPosizione, CodTipoDichiarazioneTrim, codEventoTrim, Quantita, PesoTot, PesoCad, CodStatoTrim, UDC_parentTrim, noteTrim, clientIp), tipoLog.INFO); + } + catch + { } + } + // solo se UDC parent != vuoto... + if (UDC_parentTrim != "") + { + try + { + // salvo associazione parent-child tra UDC! + DataProxy.obj.taRelazUDC.Insert(UDC_parentTrim, answ, DateTime.Now); + } + catch + { } + } + } + return answ; + } + /// + /// Fornisce un nuovo codice UDC tipo completo (con pezzi e cod magazzino) a partire dalla richiesta e salva i dati + /// + /// codice anagrafico della bilanca che effettua la richiesta (codice della pesa) + /// codice anagrafico del cliente + /// codice del particolare (articolo) - da anagrafica! + /// Codice dell'impianto + /// Codice dello stampo + /// codice dell'esponente dello stampo + /// Codice figura + /// codice dell'UDC parent (UDC della tara) + /// peso in kg (0 se non noto) da associare all'UDC come tara del contenitore + /// codice dell'imballo (tipo cassone) - string LIBERO (non facciamo controlli in input) + /// tipo di dichiarazione (vedere relativa anagrafica consentita, es U=uomo, M=macchina...) + /// codice dell'operatore + /// numero pezzi associati all'UDC + /// Peso totale rilevato + /// Peso unitario rilevato + /// Data di rif per la dichiarazione + /// Turno di rif per la dichiarazione + /// Codice dello stato del pezzo (da anagrafica: sabbiato, ...) + /// Codice del magazzino in cui inserire l'UDC + /// NOME della posizione default in cui creare UDC + /// cod evento da associare al movimento mag + /// note (opzionali) + /// cod UDC pre-calcolato, se "" verrà calcolato dalla query + /// anno in cui intestare i cartellini, trimma a 2 cifre DX + /// Ip del client + /// UDC del nuovo cartellino per FINITI + public string creaUdc(string CodBilancia, string CodCliente, string Particolare, string CodImpianto, string CodStampo, string Esponente, string Figura, string UDC_parent, double Tara, string CodImballo, string CodTipoDichiarazione, string CodSoggetto, int Quantita, float PesoTot, float PesoCad, DateTime DataRif, int TurnoRif, string CodStato, int CodMag, string defIdxPosiz, string codEvento, string note, string UDC, int anno, string clientIp) + { + // trim fix + string CodBilanciaTrim = CodBilancia.Trim(); + string CodClienteTrim = CodCliente.Trim(); + string ParticolareTrim = Particolare.Trim(); + string CodImpiantoTrim = CodImpianto.Trim(); + string CodStampoTrim = CodStampo.Trim(); + string EsponenteTrim = Esponente.Trim(); + string FiguraTrim = Figura.Trim(); + string UDC_parentTrim = UDC_parent.Trim(); + string CodImballoTrim = CodImballo.Trim(); + string CodTipoDichiarazioneTrim = CodTipoDichiarazione.Trim(); + string CodSoggettoTrim = CodSoggetto.Trim(); + string CodStatoTrim = CodStato.Trim(); + string defIdxPosizTrim = defIdxPosiz.Trim(); + string codEventoTrim = codEvento.Trim(); + string noteTrim = note.Trim(); + string annoTrim = anno.ToString(); + if (annoTrim.Length > 2) + { + annoTrim = annoTrim.Substring(2, 2); + } + // determino se cancellare udcTara + bool doDeleteUdcTara = false; // memLayer.ML.confReadBool("doDeleteUdcTara"); + // ricavo cod company... + string CodCS = "ND"; + string answ = "NA"; + try + { + CodCS = DataProxy.obj.taAnagBil.stp_getByCodBilancia(CodBilanciaTrim)[0].CodCS; + } + catch + { + CodCS = memLayer.ML.cdv("CodCS"); + } + int IdxPosizione = 0; + if (CodMag > 0) + { + IdxPosizione = CodMag; + } + else + { + IdxPosizione = memLayer.ML.confReadInt(defIdxPosizTrim); + } + //int IdxPosizione = memLayer.ML.confReadInt(defIdxPosizTrim); + // controllo di avere codice soggetto e particolare validi (!="") + if (ParticolareTrim != "" && CodSoggettoTrim != "") + { + // creo nuovo cartellino! + DS_Applicazione.ElencoCartelliniDataTable tabUdc = new DS_Applicazione.ElencoCartelliniDataTable(); + // controllo se UDC già definito o meno... + if (UDC != "") + { + // insert nuovo UDC con codice impostato + try + { + tabUdc = DataProxy.obj.taCartellini.stp_insNewFull_fixUDC(UDC, CodCS, CodBilanciaTrim, annoTrim, CodClienteTrim, ParticolareTrim, CodImpiantoTrim, CodStampoTrim, EsponenteTrim, FiguraTrim, DataRif, TurnoRif, CodImballoTrim, CodSoggettoTrim, Tara, IdxPosizione, CodTipoDichiarazioneTrim, codEventoTrim, Quantita, PesoTot, PesoCad, CodStatoTrim, UDC_parentTrim, doDeleteUdcTara, noteTrim); + answ = UDC; + } + catch + { + // loggo errore + logger.lg.scriviLog(string.Format("ERRORE CREAZIONE UDC: | {24} | procedura stp_insNewFull_fixUDC, parametri: {0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11} | {12} | {13} | {14} | {15} | {16} | {17} | {18} | {19} | {20} | {21} | {22} | {23}", answ, CodCS, CodBilanciaTrim, annoTrim, CodClienteTrim, ParticolareTrim, CodImpiantoTrim, CodStampoTrim, EsponenteTrim, FiguraTrim, DataRif, TurnoRif, CodImballoTrim, CodSoggettoTrim, Tara, IdxPosizione, CodTipoDichiarazioneTrim, codEventoTrim, Quantita, PesoTot, PesoCad, CodStatoTrim, UDC_parentTrim, noteTrim, clientIp), tipoLog.INFO); + } + } + else + { + // insert con calcolo UDC + try + { + tabUdc = DataProxy.obj.taCartellini.stp_insNewFull(CodCS, CodBilanciaTrim, annoTrim, CodClienteTrim, ParticolareTrim, CodImpiantoTrim, CodStampoTrim, EsponenteTrim, FiguraTrim, DataRif, TurnoRif, CodImballoTrim, CodSoggettoTrim, Tara, IdxPosizione, CodTipoDichiarazioneTrim, codEventoTrim, Quantita, PesoTot, PesoCad, CodStatoTrim, UDC_parentTrim, doDeleteUdcTara, noteTrim); + } + catch (Exception exc) + { + // loggo errore + logger.lg.scriviLog(string.Format("ERRORE CREAZIONE UDC: | {24} | procedura stp_insNewFull, parametri: {0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11} | {12} | {13} | {14} | {15} | {16} | {17} | {18} | {19} | {20} | {21} | {22} | {23}{25}{26}", answ, CodCS, CodBilanciaTrim, annoTrim, CodClienteTrim, ParticolareTrim, CodImpiantoTrim, CodStampoTrim, EsponenteTrim, FiguraTrim, DataRif, TurnoRif, CodImballoTrim, CodSoggettoTrim, Tara, IdxPosizione, CodTipoDichiarazioneTrim, codEventoTrim, Quantita, PesoTot, PesoCad, CodStatoTrim, UDC_parentTrim, noteTrim, clientIp, Environment.NewLine, exc), tipoLog.EXCEPTION); + } + } + // leggo la riga + answ = tabUdc[0].UDC; + // loggo tutto! + if (memLayer.ML.confReadInt("_logLevel") > 5) + { + try + { + logger.lg.scriviLog(string.Format(" | {24} | NUOVO cartellino da postazione: {0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11} | {12} | {13} | {14} | {15} | {16} | {17} | {18} | {19} | {20} | {21} | {22} | {23}", answ, CodCS, CodBilanciaTrim, annoTrim, CodClienteTrim, ParticolareTrim, CodImpiantoTrim, CodStampoTrim, EsponenteTrim, FiguraTrim, DataRif, TurnoRif, CodImballoTrim, CodSoggettoTrim, Tara, IdxPosizione, CodTipoDichiarazioneTrim, codEventoTrim, Quantita, PesoTot, PesoCad, CodStatoTrim, UDC_parentTrim, noteTrim, clientIp), tipoLog.INFO); + } + catch + { } + } + // solo se UDC parent != vuoto... + if (UDC_parentTrim != "") + { + try + { + // salvo associazione parent-child tra UDC! + DataProxy.obj.taRelazUDC.Insert(UDC_parentTrim, answ, DateTime.Now); + } + catch + { } + } + } + else + { + logger.lg.scriviLog(string.Format(" | {24} | CodSoggetto / particolare non validi! tentativo di creazione cartellino come {0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11} | {12} | {13} | {14} | {15} | {16} | {17} | {18} | {19} | {20} | {21} | {22}", CodCS, CodBilanciaTrim, annoTrim, CodClienteTrim, ParticolareTrim, CodImpiantoTrim, CodStampoTrim, EsponenteTrim, FiguraTrim, DataRif, TurnoRif, CodImballoTrim, CodSoggettoTrim, Tara, IdxPosizione, CodTipoDichiarazioneTrim, codEventoTrim, Quantita, PesoTot, PesoCad, CodStatoTrim, UDC_parentTrim, noteTrim, clientIp), tipoLog.ERROR); + } + return answ; + } + /// + /// associa udc all'UDCParent + /// + /// UDC destinazione + /// UDC parent + /// + public bool associaUdcParent(string codUdc, string codParent) + { + bool answ = false; + try + { + answ = associaUdcParent(codUdc, codParent, false); + } + catch + { } + return answ; + } + /// + /// VERIFICA se ci sia associazione tra udc e l'UDCParent e restituisce TRUE se sia già associato + /// + /// UDC destinazione + /// UDC parent + /// + public bool checkAssociazioneUdcParent(string codUdc, string codParent) + { + bool answ = false; + try + { + answ = DataProxy.obj.taRelazUDC.getByParentChild(codUdc, codParent).Rows.Count > 0; + } + catch + { } + return answ; + } + /// + /// calcola l'UDC Parent di quello fornito + /// + /// UDC destinazione + /// UDC parent + /// + public string getUdcParent(string codUdc) + { + string answ = ""; + try + { + answ = ((DS_Applicazione.RelazUDCRow)DataProxy.obj.taRelazUDC.stp_getParent(codUdc)[0]).UDC_parent; + } + catch + { } + return answ; + } + /// + /// calcola l'UDC Parent di quello fornito IN ORDINE DESCENDING + /// + /// UDC destinazione + /// UDC parent + /// + public string getUdcParentDesc(string codUdc) + { + string answ = ""; + try + { + answ = ((DS_Applicazione.RelazUDCRow)DataProxy.obj.taRelazUDC.stp_getParentDesc(codUdc)[0]).UDC_parent; + } + catch + { } + return answ; + } + /// + /// associa udc all'UDCParent + /// + /// UDC destinazione + /// UDC parent + /// copiare si/no attributi UDC da parent a child + /// + public bool associaUdcParent(string codUdc, string codParent, bool copyAttr) + { + bool answ = false; + try + { + DataProxy.obj.taCartellini.stp_UDC_associaParent(codUdc, codParent, CodSoggCurrUser, copyAttr); + answ = true; + } + catch + { } + return answ; + } + /// + /// effettua la stampa di un dato UDC + /// + /// Codice UDC + /// stampante specifica (da postazioen o std da webconfig, a cura dell'utente + /// IP del chiamante + /// + public bool stampaUdc(string UDC, string printer, tipoCartellino tipoCart, string clientIp) + { + bool answ = false; + // controllo se esista UDC + if (checkUDC(UDC)) + { + answ = reportPrinter.obj.stampaCartellino(tipoCart, UDC, printer); + logger.lg.scriviLog(string.Format(" | {0} | stampato UDC {1} | stampante {2} | tipo {3}", clientIp, UDC, printer, tipoCart), tipoLog.INFO); + } + return answ; + } + + /// + /// effettua la Ristampa di un dato UDC partendo dal primo tipo di cartellino stampato... + /// + /// Codice UDC + /// stampante specifica (da postazioen o std da webconfig, a cura dell'utente + /// IP del chiamante + /// + public bool ristampaUdc(string UDC, string printer, string clientIp) + { + bool answ = false; + tipoCartellino tipoCart = tipoCartellino.cartND; + try + { + tipoCart = (tipoCartellino)Enum.Parse(typeof(tipoCartellino), DataProxy.obj.taPJQ.getFirstByUdc(UDC)[0].TipoCart); + } + catch + { } + if (tipoCart != tipoCartellino.cartND) + { + // controllo se esista UDC + if (checkUDC(UDC)) + { + answ = reportPrinter.obj.stampaCartellino(tipoCart, UDC, printer); + logger.lg.scriviLog(string.Format(" | {0} | stampato UDC {1} | stampante {2} | tipo {3}", clientIp, UDC, printer, tipoCart), tipoLog.INFO); + } + } + return answ; + } + /// + /// restituisce particolare da UDC + /// + /// + /// + public string getParticolareByUDC(string UDC) + { + string answ = ""; + try + { + answ = (taCartellini.getDetailsUdcByUdc(UDC)[0].Particolare); + } + catch + { } + return answ; + } + /// + /// restituisce note dell'UDC + /// + /// + /// + public string getNoteByUDC(string UDC) + { + string answ = ""; + try + { + answ = (taCartellini.getDetailsUdcByUdc(UDC)[0].Note); + } + catch + { } + return answ; + } + /// + /// aggiorna note dell'UDC + /// + /// + /// + public void updateNoteUDC(string UDC, string note) + { + taCartellini.updateNote(UDC, note, CodSoggCurrUser); + } + /// + /// aggiorna posizione dell'UDC + /// + /// + /// + public void updatePosizioneUDC(string UDC, int idxPosizione) + { + taCartellini.updateIdxPosizione(UDC, idxPosizione, CodSoggCurrUser); + } + /// + /// aggiorna note e posizione dell'UDC + /// + /// + /// + /// + public void updateNotePosizioneUDC(string UDC, string note, int idxPosizione) + { + taCartellini.updateNotePosizione(UDC, idxPosizione, note, CodSoggCurrUser); + } + /// + /// aggiorna note, posizione e data fusione dell'UDC + /// + /// + /// + /// + /// + public void updateNotePosizioneDataUDC(string UDC, string note, int idxPosizione, DateTime DataFus) + { + taCartellini.updateNotePosizioneData(UDC, idxPosizione, note, CodSoggCurrUser, DataFus); + } + /// + /// aggiorna note, posizione e data fusione dell'UDC + /// + /// + /// + /// + /// + /// + public void updateNotePosizioneDataImballoUDC(string UDC, string note, int idxPosizione, DateTime DataFus, string CodImballo) + { + taCartellini.updateNotePosizioneDataImballo(UDC, idxPosizione, note, CodSoggCurrUser, DataFus, CodImballo); + } + /// + /// aggiorna note, posizione e data fusione dell'UDC + /// + /// + /// + /// + /// + /// + public void updateFinDtxFull(string UDC, string note, DateTime DataFus, string CodImballo, string AL) + { + taCartellini.finDatamatrixFullUpdate(AL, UDC, CodImballo, note, DataFus, CodSoggCurrUser); + } + /// + /// Verifica se UDC abbia attributo indicato + /// + /// + /// + /// + public bool udcHasAttr(string UDC, string CodAttr) + { + bool answ = false; + try + { + answ = MagClass.magazzino.taAtt2UDC.getByUdc(UDC).Select(string.Format("CodAttr = '{0}'", CodAttr)).Length > 0 ? true : false; + } + catch + { } + return answ; + } + + #endregion + + #region procedure di verifica e traduzione dati da anagrafiche + + /// + /// Verifica la corrispondenza dati tra RigheListePrelievo ed ElencoCartellini + /// + /// + /// + /// + public bool verificaDatiUdc(string CodLista, string UDC) + { + bool answ = false; + + try + { + DS_magazzino.ElencoListePrelievoDataTable tabellaElenco = taElencoListePrelievo.getByCodLista(CodLista); + DS_magazzino.ElencoListePrelievoRow rigaElenco = tabellaElenco[0]; + + DS_magazzino.ElencoCartelliniDataTable tabellaUDC = taCartellini.getDetailsUdcByUdc(UDC); + DS_magazzino.ElencoCartelliniRow rigaUDC = tabellaUDC[0]; + + // ricavo dati da confrontare - da Lista ricavo particolare/esponente/figura + string particolareLista = rigaElenco.Particolare.Trim(); + string esponenteLista = rigaElenco.Esponente.Trim(); + string figuraLista = rigaElenco.Figura.Trim(); + string CodImballoLista = rigaElenco.CodImballo.Trim(); + + //stessi dati da UDC + string particolareUDC = rigaUDC.Particolare.Trim(); + string esponenteUDC = rigaUDC.Esponente.Trim(); + string figuraUDC = rigaUDC.Figura.Trim(); + string CodImballoUDC = rigaUDC.CodImballo.Trim(); + + // condizioni di uguaglianza... + bool particolareOk = false; + bool esponenteOk = false; + bool figuraOk = false; + bool CodImballoOk = false; + // verifico le condizioni 1 ad 1... + particolareOk = (particolareLista == particolareUDC); + if (esponenteLista == "*") + { + esponenteOk = true; + } + else + { + esponenteOk = (esponenteLista == esponenteUDC); + } + if (figuraLista == "*") + { + figuraOk = true; + } + else + { + figuraOk = (figuraLista == figuraUDC); + } + if (CodImballoLista == "*") + { + CodImballoOk = true; + } + else + { + CodImballoOk = (CodImballoLista == CodImballoUDC); } - #endregion + // verifica finale del risultato uguaglianza... + answ = (particolareOk && esponenteOk && figuraOk && CodImballoOk); + } + catch + { + answ = false; + } - #region operazioni su UDC + return answ; + } + /// + /// restituisce codice soggetto dell'user corrente + /// + /// + public string CodSoggCurrUser + { + get + { + // ricavo da session... + string CodSoggetto = ""; + try + { + CodSoggetto = memLayer.ML.StringSessionObj("CodSoggetto"); + } + catch (Exception e) + { + logger.lg.scriviLog(string.Format("Non sono riuscito a recuperare il codice soggetto DALLA SESSIONE per l'utente loggato: {0}, errore {1}{2}", user_std.UtSn.userNameAD, Environment.NewLine, e), tipoLog.ERROR); + } + if (CodSoggetto == "") + { + // provo a recuperare da cookie... + CodSoggetto = memLayer.ML.getCookieVal("CodSoggetto"); + } + if (CodSoggetto == "") + { + try + { + CodSoggetto = DataProxy.obj.taSogg2Oper.getByUserDominio(user_std.UtSn.utente, user_std.UtSn.dominio)[0].CodSoggetto; + // salvo in sessione... + memLayer.ML.setSessionVal("CodSoggetto", CodSoggetto); + } + catch (Exception e) + { + logger.lg.scriviLog(string.Format("Non sono riuscito a recuperare il codice soggetto per l'utente loggato: {0}, errore {1}{2}", user_std.UtSn.userNameAD, Environment.NewLine, e), tipoLog.ERROR); + } + } + return CodSoggetto; + } + } + /// + /// restituisce l'IdxCella dato il CodCella + /// + /// Codice company/sito + /// + /// + public int IdxCellaByCodCella(string CodCS, string CodCella) + { + int answ = 0; + try + { + answ = taCelle.getByCodCella(CodCella)[0].IdxCella; // NON controllo il CodCS... + } + catch + { } + return answ; + } + /// + /// restituisce il CodCella dato l'IdxCella + /// + /// Codice company/sito + /// + /// + public string CodCellaByIdxCella(string CodCS, int IdxCella) + { + string answ = ""; + try + { + answ = taCelle.getByIdxCella(IdxCella)[0].CodCella; // NON controllo il CodCS... + } + catch + { } + return answ; + } + /// + /// verifica se la cella indicata sia attiva + /// + /// Codice company/sito + /// + /// + public bool cellaAttiva(string CodCS, int IdxCella) + { + bool answ = false; + try + { + answ = taCelle.getByIdxCella(IdxCella)[0].Attiva; // NON controllo il CodCS... + } + catch + { } + return answ; + } + /// + /// verifica se la cella indicata sia piena + /// + /// Codice company/sito + /// + /// + public bool cellaPiena(string CodCS, int IdxCella) + { + bool answ = false; //default non piena = permette caricamento + int idxTipoCella = 0; + bool checkPiena = true; + try + { + // controllo il tipo cella, se richiede check piena (altrimenti do ok...) + idxTipoCella = taCelle.getByIdxCella(IdxCella)[0].IdxTipoCella; + checkPiena = taTipoCella.getByIdx(idxTipoCella)[0].CheckPiena; + } + catch + { } + if (checkPiena) + { + try + { + // faccio controllo effettivo cella piena + answ = taCelle.getByIdxCella(IdxCella)[0].Piena; // NON controllo il CodCS... + } + catch + { } + } + return answ; + } + /// + /// restituisce cod UDC associato ad una cella + /// + /// Codice company/sito + /// + /// + public string udcInCella(string CodCS, int IdxCella) + { + string answ = ""; + try + { + answ = taPosUdcCorr.getByIdxCella(IdxCella)[0].UDC; + } + catch + { } + return answ; + } + /// + /// verifica la cella indicata sia valida, ovvero esistente + /// + /// + /// + public bool checkCella(string CodCella) + { + bool answ = false; + try + { + answ = (taCelle.getByCodCella(CodCella).Rows.Count > 0); + } + catch + { } + return answ; + } + /// + /// verifica se il particolare indicato sia valido, ovvero esistente + /// + /// Codice company/sito + /// + /// + public bool checkParticolare(string CodCS, string Particolare) + { + bool answ = false; + try + { + answ = (utils.obj.taSelParticolari.getByConditioValue(Particolare, "*").Rows.Count > 0); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in check particolare:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + } + return answ; + } + /// + /// restituisce il num di UDC che corrispondono alla richiesta indicata + /// + /// + /// + /// + /// + /// + /// + /// + public int numUdcDaPart(string CodCS, string Particolare, string codEsponente, string codFigura, string CodImballo, string codTipoLista) + { + int answ = 0; + try + { + answ = taVParticolariOverwiew.getByDatiListaPrelievo(Particolare, CodCS, codEsponente, codFigura, CodImballo, codTipoLista)[0].NumUDC; + } + catch + { } + return answ; + } + /// + /// verifica se l'UDC sia riattivabile, ovvero + /// - sia permesso da web.config + /// - l'UDC sia in un mag che permette riattivazione + /// + /// + /// + public bool udcIsRiattivabile(string UDC) + { + bool answ = false; + // se permesso da web config controllo + if (memLayer.ML.confReadBool("riattUdcPermessa")) + { + try + { + // recupero posizione attuale + int IdxPosizione = taCartellini.getDetailsUdcByUdc(UDC)[0].IdxPosizione; + // verifico se riattivabile + answ = taAnagPos.getByIdxPosizione(IdxPosizione)[0].IsRiattivaEnabled; + } + catch (Exception e) + { + logger.lg.scriviLog(string.Format("Errore nella riattivazione dell'UDC {0}:{1}{2}", UDC, Environment.NewLine, e), tipoLog.EXCEPTION); + } + } + return answ; + } - /// - /// effettua lo spostamento di un UDC tra 2 posizioni indicate - /// - /// Codice company/sito - /// Codice UDC - /// Cella di destinazione - /// indica se sia richiesto resettare le Righe Liste Prelievo con lo spostsamento - /// IP del chiamante - /// esito comando - public bool spostaUDC(string CodCS, string UDC, int IdxCellaTo, bool resetRLP, string clientIp) - { - bool answ = false; - // procedo SOLO se la cella di dest è VUOTA... - if (!MagClass.magazzino.cellaPiena(CodCS, IdxCellaTo)) - { - try - { - taPosUdcCorr.stp_spostaUdc(CodCS, UDC, IdxCellaTo, resetRLP, CodSoggCurrUser); - // cerco nuova posizione... - if (taPosUdcCorr.getByCellaUdc(UDC, IdxCellaTo).Rows.Count > 0) - { - answ = true; - } - } - catch (Exception e) - { - logger.lg.scriviLog(string.Format(" | {1} | Errore durante spostamento cella: {0}", e, clientIp), tipoLog.EXCEPTION); - } - // solo se ha fatto spostamento posizione corrente verifico se fare spostamento in posizione LOGICA magazzino - if (answ) - { - try - { - // verifico tipo cella e se ci sia da fare spostamento in mag logico/contabile - int idxTipoCella = taCelle.getByIdxCella(IdxCellaTo)[0].IdxTipoCella; - bool needSetMag = taTipoCella.getByIdx(idxTipoCella)[0].SetMag; - if (needSetMag) - { - // cambio (eventualmente) la posizione "logica" dato lo spostamento (il codice magazzino...) - int idxBlocco = taCelle.getByIdxCella(IdxCellaTo)[0].IdxBlocco; - int IdxPosizione = Convert.ToInt32(taBlocchi.getByIdx(idxBlocco)[0].CodMag); - taCartellini.updateIdxPosizione(UDC, IdxPosizione, CodSoggCurrUser); - } - } - catch (Exception e) - { - logger.lg.scriviLog(string.Format(" | {1} | Errore durante indicazione posizione UDC: {0}", e, clientIp), tipoLog.EXCEPTION); - } - } - } - else - { - logger.lg.scriviLog(string.Format(" | {1} | Errore, cella {0} di destinazione piena!!!", IdxCellaTo, clientIp), tipoLog.ERROR); - } - return answ; - } - /// - /// effettua lo scaricamento di un UDC (x spedizione) - /// - /// Codice UDC - /// Codice posizione UDC finale - /// Codice evento associato allo scaricamento - /// IP del chiamante - /// esito comando - public bool scaricaUDC(string UDC, int IdxPosizUdc, string CodEvento, string clientIp) - { - bool answ = false; - try - { - taPosUdcCorr.stp_scaricaUdc(UDC, IdxPosizUdc, CodEvento, CodSoggCurrUser); - logger.lg.scriviLog(string.Format(" | {0} | Scaricato UDC {1} | posizione {2} | CodEvento {3} | soggetto {4}", clientIp, UDC, IdxPosizUdc, CodEvento, CodSoggCurrUser), tipoLog.INFO); - answ = true; - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format(" | {2} | Errore in scaricaUDC:{0}{1}", Environment.NewLine, exc, clientIp), tipoLog.EXCEPTION); - } - return answ; - } - /// - /// rettifica la qta di un UDC - /// - /// Codice UDC - /// Nuova quantita associata - /// IP del chiamante - /// esito comando - public bool rettificaQtaUDC(string UDC, decimal qta, string clientIp) - { - bool answ = false; - try - { - int fatti = 0; - fatti = taCartellini.updateQty(UDC, CodSoggCurrUser, "U", "UDC_QTY", qta).Rows.Count; - if (fatti > 0) - { - answ = true; - logger.lg.scriviLog(string.Format(" | {0} | Rettifica qta UDC {1} | qta {2} | soggetto {3}", clientIp, UDC, qta, CodSoggCurrUser), tipoLog.INFO); - } - } - catch - { } - return answ; - } - /// - /// rettifica la qta di un UDC - /// - /// Codice UDC sorgente - /// Codice UDC destinazione - /// Quantita da travasare - /// IP del chiamante - /// esito comando - public bool travasoQtaUDC(string UdcFrom, string UdcDest, decimal qta, string clientIp) - { - bool answ = false; - try - { - taCartellini.travasoQty(UdcFrom, UdcDest, CodSoggCurrUser, "U", "UDC_TraQTY", qta); - logger.lg.scriviLog(string.Format(" | {0} | travaso qta UDC: da {1} a {2} | qta {3} | soggetto {4}", clientIp, UdcFrom, UdcDest, qta, CodSoggCurrUser), tipoLog.INFO); - answ = true; - } - catch - { } - return answ; - } - /// - /// Sistema il cartellino finito liquidi per la stampa - /// - /// AL sorgente in postazione (ATL) - /// Tipo cart da legare (TT) - /// Cod UDC da processare - /// Cod Imballo - /// Note x cartellino - /// Cod soggetto - /// - public bool liquidiFullUpdate(string SourceAL, string TipoAlAnc, string UDC, string CodImb, string Note, string CodSoggetto) - { - bool answ = false; - try - { - DS_magazzino.ElencoCartelliniRow riga = taCartellini.UdcLiqFullUpdate(SourceAL, TipoAlAnc, UDC, CodImb, Note, DateTime.Now, CodSoggetto)[0]; - answ = true; - } - catch - { } - return answ; - } - /// - /// Riprende in carico alla postazione un cartellino liquidi FINITO valido - /// - /// Cod UDC da processare - /// Cod soggetto - /// AL (temporaneo) di destinazione - /// Cod cella di destinazione - /// - public bool liquidiRiprendiInCaricoUDC(string UDC, string CodSoggetto, string tempAL, int idxCella) - { - bool answ = false; - try - { - DS_magazzino.ElencoCartelliniRow riga = taCartellini.UdcLiqRicarica(UDC, idxCella, tempAL, DateTime.Now, CodSoggetto)[0]; - answ = true; - } - catch (Exception exc) - { - logger.lg.scriviLog(exc.ToString(), tipoLog.EXCEPTION); - } - return answ; - } - /// - /// Riprende in carico alla postazione un cartellino Finiti Rx valido - /// - /// Cod UDC da processare - /// Cod soggetto - /// AL (temporaneo) di destinazione - /// Cod cella di destinazione - /// - public bool finRxRiprendiInCaricoUDC(string UDC, string CodSoggetto, string tempAL, int idxCella) - { - bool answ = false; - try - { - DS_magazzino.ElencoCartelliniRow riga = taCartellini.UdcFinRxRicarica(UDC, idxCella, tempAL, DateTime.Now, CodSoggetto)[0]; - answ = true; - } - catch - { } - return answ; - } - /// - /// Sistema il cartellino Gitterbox Rx Finiti (B48) per la stampa - /// - /// Cod UDC da processare - /// Cod Imballo - /// Note x cartellino - /// Cod soggetto - /// - public bool Udc_B48_FullUpdate(string UDC, string CodImb, string Note, string CodSoggetto) - { - bool answ = false; - try - { - DS_magazzino.ElencoCartelliniRow riga = taCartellini.UdcRxFinLiqFullUpdate(UDC, CodImb, Note, DateTime.Now, CodSoggetto)[0]; - answ = true; - } - catch - { } - return answ; - } - /// - /// verifica se l'UDC indicato sia valido, ovvero esistente - /// - /// - /// - public bool checkUDC(string UDC) - { - bool answ = false; - try - { - answ = (taCartellini.getDetailsUdcByUdc(UDC).Rows.Count > 0); - } - catch - { } - return answ; - } - /// - /// verifica se l'UDC indicato sia ESENTE DA NC attive (ovvero senza deroga DC) - /// - /// - /// restituisce esito controllo - public checkUdcNc checkUDC_NC(string UDC) - { - /// default caso pessimo... - checkUdcNc answ = checkUdcNc.HasNc; - bool hasNc = false; - try - { - hasNc = (DataProxy.obj.taUDC2NC.getNcPending(UDC, "DC", "NC").Rows.Count != 0); - } - catch - { } - // se richiesto faccio verifica - if (memLayer.ML.CRB("checkUDC_NC")) - { - if (hasNc) - { - answ = checkUdcNc.HasNc; - } - else - { - answ = checkUdcNc.NoNc; - } - } - // altrimenti NON E' richiesta verifica - else - { - if (hasNc) - { - answ = checkUdcNc.ChkDis_HasNc; - } - else - { - answ = checkUdcNc.ChkDis_NoNc; - } - } - return answ; - } - /// - /// Fornisce elenco NC associate ad un UDC - /// - /// - /// - public DS_Applicazione.ElencoNCDataTable getNc2UDC(string UDC) - { - DS_Applicazione.ElencoNCDataTable answ = new DS_Applicazione.ElencoNCDataTable(); - // controllo se ci siano NC - checkUdcNc esito = checkUDC_NC(UDC); - // se ci sono recupero! - if (esito == checkUdcNc.HasNc || esito == checkUdcNc.ChkDis_HasNc) - { - answ = DataProxy.obj.taENC.getByUDC(UDC); - } - return answ; - } - /// - /// Restituisce stringa formattata dellal NC associata all'UDC - /// - /// - /// - public string getDescrNc2Udc(string UDC) - { - DS_Applicazione.ElencoNCDataTable tab = getNc2UDC(UDC); - string answ = ""; - if (tab.Rows.Count > 0) - { - DS_Applicazione.ElencoNCRow riga = null; - // recupero righe... - for (int i = 0; i < tab.Rows.Count; i++) - { - riga = (DS_Applicazione.ElencoNCRow)tab.Rows[i]; - answ += string.Format("
NC: {0}, {1}
", riga.CodNC, riga.DescrNC); - //answ += string.Format("
NC: {0}, {1}
{2} | {3} | {4} ({5:yyyy.MM.dd HH:mm} --> {6:yyyy.MM.dd HH:mm})
", riga.CodNC, riga.DescrNC, riga.TipoCart, riga.Particolare, riga.SearchNote, riga.DataFrom, riga.DataTo); - } - } - return answ; - } + #endregion - /// - /// verifica se l'UDC indicato POSSA ESSERE MOVIMENTATO (ovvero NON in LDP in stato "bloccato") - /// - /// - /// - public bool checkUDC_mov(string UDC) + #region liste di prelievo + + /// + /// Crea una lista di prelievo andando a prenotare gli UDC del particolare richiesto in logica FIFO + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public string creaListaPrelievo(string CodCS, string TipoListaPrelievo, string Particolare, string Esponente, string Figura, decimal QtaTot, string CodImballo, string Destinatario, string DestinatarioDescrizione) + { + /* + * - ordini gli UDC per data dal + vecchio (data fusione? direi di si!) + * + * - prenda 1 ad 1 gli UDC, e crei dall'UDC un record in RigheListePrelievo con + * - CodLista (dal record appena generato) + * - UDC (il + vecchio trovato) + * - QTA (dell'UDC) + * - Proposto = 1 (vero) + * - Prelevato = 0 (falso) + * - questo loop di prelievo va eseguito fino a quanto la somam delle qty sia maggiore o uguale alla qty richiesta, o fino a quando siano finiti gli UDC + * + * - potrebbe esser cambiato approccio e si potrebbe fare una query ceh seleziona i + vecchi UDC in numero corretto fin dall'inizio da includere facendo una cosa del tipo + * - calcolo media qty degli UDC papabili x le condizioni dette prima + * - dato il totale ottengo quanti UDC mi servono arrotondando x eccesso (se ho 200 richiesti, media 70, CEIL(200/70) = 3) + * - faccio un SELECT TOP n (qui 3) * FROM ElencoCartellini WHERE ... + * - e questa select la uso x farci un INSERT INTO in RigheListePrelievo + * + * - terminati questi step si aggiorna la lista di prelievo emttendo come qty quella data dalla somma degli UDC davvero proposti + * + * - la stored deve restituire il codice della lista di prelievo e passarla qui, che a sua volta passerà al chiamante il codice della lista + * */ + + string answ = "K"; + + // variabile di tipo datetime per data corrente + DateTime adesso = DateTime.Now; + // non la valorizzo qui ma calcolo ... se non fa verificare + string RagioneSociale = ""; + + // ricavo da session... + string CodSoggetto = CodSoggCurrUser; + // proseguo SOLO se ho trovato cod soggetto... + if (CodSoggetto != "") + { + // li ricavo da db successivamente + string DisegnoGrezzo = ""; + string DescParticolare = ""; + string codCliente = ""; + + + // ricavo codCliente + try { - bool answ = false; - try - { - answ = (taRigheListePrelievo.getBloccateMovByUdc(UDC).Rows.Count == 0); - } - catch - { } - return answ; + codCliente = DataProxy.obj.taAnagParticolari.getByParticolare(Particolare)[0].CodCliente; } - /// - /// verifica se l'UDC indicato POSSA ESSERE OGGETTO DI RETTIFICA QTA (ovvero NON in LDP in stato "bloccato") - /// - /// - /// - public bool checkUDC_qty(string UDC) + catch { } + + // ricavo DisegnoGrezzo + try { - bool answ = false; - try - { - answ = (taRigheListePrelievo.getBloccateQtaByUdc(UDC).Rows.Count == 0); - } - catch - { } - return answ; + DisegnoGrezzo = DataProxy.obj.taAnagParticolari.getByParticolare(Particolare)[0].DisegnoGrezzo; } - /// - /// effettua lo scaricamento (da db e da AS400) degli UDC di MP/WIP, registrando l'evento "UDC_CONS" - /// - /// Codice UDC - /// IP del chiamante - /// - public bool scaricaUdcMpWip(string UDC, string clientIp) + catch { } + + try { - // inizializzo - bool answ = false; - int idxCellaFrom = 0; + DescParticolare = DataProxy.obj.taAnagParticolari.getByParticolare(Particolare)[0].DescParticolare; + } + catch { } + + // dato codcliente ricavo la ragione sociale + try + { + RagioneSociale = DataProxy.obj.taAnagClienti.getRagioneSocialeByCodCliente(codCliente)[0].RagSociale; + } + catch { } + + + string codListaAttuale = ""; + try + { + // eseguo soltanto la query (meglio con try catch così se non c'è non dà errore...) + DS_magazzino.ElencoListePrelievoDataTable tabellaElencoListe = taElencoListePrelievo.InsertQuery(string.Format("{0:yy}", adesso), string.Format("{0:MM}", adesso), TipoListaPrelievo, memLayer.ML.cdv("CodCS"), codCliente, RagioneSociale, CodSoggetto, Particolare, DescParticolare, DisegnoGrezzo, Esponente, Figura, CodImballo, QtaTot, Destinatario, DestinatarioDescrizione); + + // ricavo prima (e unica) riga dalla select + DS_magazzino.ElencoListePrelievoRow rigaElencoListe = tabellaElencoListe[0]; + + // ricavo valore del CodLista attuale appena inserito + codListaAttuale = rigaElencoListe.CodLista; + } + catch (Exception e) + { + logger.lg.scriviLog(string.Format("Eccezione creazione lista prelievo: {0}{1}", Environment.NewLine, e), tipoLog.ERROR); + } + if (codListaAttuale != "") + { + answ = codListaAttuale; + DS_magazzino.ElencoCartelliniDataTable tabellaElencoCartellini = taCartellini.getUdcUnusedOlder(codListaAttuale); + allocaRigheListaPrelievo(QtaTot, codListaAttuale, tabellaElencoCartellini); + } + } + return answ; + } + /// + /// Crea una lista di prelievo andando a prenotare gli UDC del particolare richiesto in logica FIFO + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public string creaListaPrelievoSmart(string CodCS, string TipoListaPrelievo, string Particolare, string Esponente, string Figura, decimal QtaTot, string CodImballo, string Destinatario, string DestinatarioDescrizione) + { + string answ = "K"; + + // variabile di tipo datetime per data corrente + DateTime adesso = DateTime.Now; + // non la valorizzo qui ma calcolo ... se non fa verificare + string RagioneSociale = ""; + + // ricavo da session... + string CodSoggetto = CodSoggCurrUser; + // proseguo SOLO se ho trovato cod soggetto... + if (CodSoggetto != "") + { + // li ricavo da db successivamente + string DisegnoGrezzo = ""; + string DescParticolare = ""; + string codCliente = ""; + + + // ricavo codCliente + try + { + codCliente = DataProxy.obj.taAnagParticolari.getByParticolare(Particolare)[0].CodCliente; + } + catch { } + + // ricavo DisegnoGrezzo + try + { + DisegnoGrezzo = DataProxy.obj.taAnagParticolari.getByParticolare(Particolare)[0].DisegnoGrezzo; + } + catch { } + + try + { + DescParticolare = DataProxy.obj.taAnagParticolari.getByParticolare(Particolare)[0].DescParticolare; + } + catch { } + + // dato codcliente ricavo la ragione sociale + try + { + RagioneSociale = DataProxy.obj.taAnagClienti.getRagioneSocialeByCodCliente(codCliente)[0].RagSociale; + } + catch { } + + + string codListaAttuale = ""; + try + { + // eseguo soltanto la query (meglio con try catch così se non c'è non dà errore...) + DS_magazzino.ElencoListePrelievoDataTable tabellaElencoListe = taElencoListePrelievo.InsertQuery(string.Format("{0:yy}", adesso), string.Format("{0:MM}", adesso), TipoListaPrelievo, memLayer.ML.cdv("CodCS"), codCliente, RagioneSociale, CodSoggetto, Particolare, DescParticolare, DisegnoGrezzo, Esponente, Figura, CodImballo, QtaTot, Destinatario, DestinatarioDescrizione); + + // ricavo prima (e unica) riga dalla select + DS_magazzino.ElencoListePrelievoRow rigaElencoListe = tabellaElencoListe[0]; + + // ricavo valore del CodLista attuale appena inserito + codListaAttuale = rigaElencoListe.CodLista; + } + catch (Exception e) + { + logger.lg.scriviLog(string.Format("Eccezione creazione lista prelievo: {0}{1}", Environment.NewLine, e), tipoLog.ERROR); + } + if (codListaAttuale != "") + { + answ = codListaAttuale; + } + } + return answ; + } + /// + /// indica come attivata in carico di una lista di prelievo + /// + /// Codice company/sito + /// codice della lista di prelievo + /// cod operatore carrellista + /// + public esitoOperazione attivaListaPrelievo(string CodCS, string CodLista, string CodSoggetto) + { + // da chiamare quando clicco e inizio lista prelievo .... vedi sopra + esitoOperazione answ = esitoOperazione.errore; + try + { + // la query recupera la lista in base al CodLista + DS_magazzino.ElencoListePrelievoDataTable tabella = taElencoListePrelievo.getByCodLista(CodLista); + DS_magazzino.ElencoListePrelievoRow riga = tabella[0]; + + // se la lista esiste... + if (tabella.Rows.Count > 0) + { + // se la lista è ancora non completata + if (riga.CodStatoLista == (int)statoLista.bozza) + { + taElencoListePrelievo.updateStato(CodSoggetto, CodLista, (int)statoLista.generata); + answ = esitoOperazione.ok; + } + // se è solo iniziata permetto di riportarla a generata... + else if (riga.CodStatoLista == (int)statoLista.iniziata) + { + taElencoListePrelievo.updateStato(CodSoggetto, CodLista, (int)statoLista.generata); + answ = esitoOperazione.ok; + } + // se è già completata dà errore + else + { + answ = esitoOperazione.errore_readOnly; + } + } + // se la lista non esiste dai errore + else + { + answ = esitoOperazione.errore; + } + } + catch + { } + return answ; + } + /// + /// indica presa in carico di una lista di prelievo + /// + /// Codice company/sito + /// codice della lista di prelievo + /// cod operatore carrellista + /// + public esitoOperazione iniziaListaPrelievo(string CodCS, string CodLista, string CodSoggetto) + { + memLayer.ML.setSessionVal("activeTask", string.Format("Lista Prelievo {0}", CodLista)); + memLayer.ML.setSessionVal("CodListaAttiva", CodLista, true); + // da chiamare quando clicco e inizio lista prelievo .... vedi sopra + esitoOperazione answ = esitoOperazione.errore; + + try + { + // la query recupera la lista in base al CodLista + DS_magazzino.ElencoListePrelievoDataTable tabella = taElencoListePrelievo.getByCodLista(CodLista); + DS_magazzino.ElencoListePrelievoRow riga = tabella[0]; + + // se la lista esiste... + if (tabella.Rows.Count > 0) + { + // se la lista è ancora non completata + if (riga.CodStatoLista == (int)statoLista.generata) + { + taElencoListePrelievo.updateStato(CodSoggetto, CodLista, (int)statoLista.iniziata); + answ = esitoOperazione.ok; + } + // se è già completata o iniziata dà errore + else + { + answ = esitoOperazione.errore_readOnly; + } + } + // se la lista non esiste dai errore + else + { + answ = esitoOperazione.errore; + } + } + catch + { } + return answ; + } + /// + /// indica come completata (da parte del magazziniere) una lista di prelievo + /// + /// Codice company/sito + /// codice della lista di prelievo + /// cod operatore carrellista + /// IP del client + /// + public esitoOperazione completaListaPrelievo(string CodCS, string CodLista, string CodSoggetto, string clientIp) + { + // da chiamare quando clicco e inizio lista prelievo .... vedi sopra + esitoOperazione answ = esitoOperazione.errore; + try + { + // la query recupera la lista in base al CodLista + DS_magazzino.ElencoListePrelievoDataTable tabella = taElencoListePrelievo.getByCodLista(CodLista); + DS_magazzino.ElencoListePrelievoRow riga = tabella[0]; + + // se la lista esiste... + if (tabella.Rows.Count > 0) + { + // se la lista è ancora non completata + if (riga.CodStatoLista == (int)statoLista.iniziata) + { + // controllo se ALMENO un UDC sia stsato prelevato + int numUdcPrelevati = taRigheListePrelievo.getByCodListaPrelevate(CodLista).Rows.Count; + if (numUdcPrelevati > 0) + { + // ricavo il codtipolista + string codTipoListaAttuale = riga.CodTipoLista; + + //leggo da tipoLista prelievo alcuni dati (es codcella di destinazione) + DS_magazzino.TipoListaPrelievoDataTable tabellaTipoLista = taTipoListaPrelievo.getByCodTipoLista(codTipoListaAttuale); + DS_magazzino.TipoListaPrelievoRow rigaTipoLista = tabellaTipoLista[0]; + + // leggo da righe lista prelievo il dato udc che mi serve + DS_magazzino.RigheListePrelievoDataTable tabellaRigheListaPrelievo = taRigheListePrelievo.getByCodListaPrelevate(CodLista); + DS_magazzino.RigheListePrelievoRow rigaListaPrelievo = tabellaRigheListaPrelievo[0]; + + // leggo il codice della cella... + string codCellaDestAttuale = rigaTipoLista.CodCella; + // lo trasformo x avere la cella di destinazione... + int idxCellaTo = taCelle.getByCodCella(codCellaDestAttuale)[0].IdxCella; + // sposto ("metto a terra") gli UDC + foreach (DS_magazzino.RigheListePrelievoRow row in tabellaRigheListaPrelievo.Rows) + { + // ricavo il codice UDC... + string _UDC = row.UDC; + // sposto UDC + spostaUDC(CodCS, _UDC, idxCellaTo, false, clientIp); + // dopo aver spostato UDC sistemo eventuali Righe di Prelievo x lo stesso UDC pending... + taRigheListePrelievo.stp_RLP_sbloccaNonPrelevate(CodLista, _UDC); + } + // libero le righe non prelevate... + taRigheListePrelievo.stp_RLP_eliminaNonPrelevate(CodLista); + // aggiorno stato lista + taElencoListePrelievo.updateStato(CodSoggetto, CodLista, (int)statoLista.completata); + answ = esitoOperazione.ok; + memLayer.ML.emptySessionVal("CodListaAttiva"); + memLayer.ML.emptySessionVal("activeTask"); + } + else //nessun UDC prelevato + { + answ = esitoOperazione.errore_noUdc; + } + } + // se è già completata o NON iniziata dà errore + else + { + answ = esitoOperazione.errore_readOnly; + } + } + // se la lista non esiste dai errore + else + { + answ = esitoOperazione.errore; + } + } + catch + { } + return answ; + } + /// + /// Effettua lo scaricamento della lista di prelievo indicata, ovvero + /// - toglie dalle posizioni di magazzino tutti gli UDC indicati come prelevati (liberando tali posizioni) + /// - assegna tutti gli UDC prelevati alla cella indicata per il tipo di lista di prelievo interessata + /// - elimina eventuali righe di prelievo della lista per UDC non effettivamente prelevate + /// - chiude la lista di prelievo (completata = 1) + /// + /// Modifica vers 2.5: check trattamenti (ove attributo sia trovato...) + /// + /// Codice company/sito + /// codice della lista di prelievo + /// cod operatore carrellista + /// IP del client + /// Slot PL AS400 prescelto + /// esito comando + public esitoOperazione scaricaListaPrelievo(string CodCS, string CodLista, string CodSoggetto, string clientIp, int SlotPL) + { + /* + * Questa funzione serve ALLA FINE delle operazioni di prelievo, x chiudere la lista di prelievo + * - controllo se la lista esiste, ed è ancora NON completata + * - se risulta già completata errore xché è "readOnly" la lista essendo già completata (vedere l'enum in fondo al codice) + * - se la lista è ok + * - leggo da tipoLista prelievo alcuni dati (es codcella di destinazione) + * - sposto TUTTI gli UDC delle righeListaPrelievo, da posizione attuale a posizione indicata da tipo lista + * (quindi da codCella --> IdxCella --> spostamento + * + * + * 2014.06.12: aggiunta x gestione PackList AS400 + * - verifico imballi, salvo su tab movimenti gli imballi eventuali da scaricare + * - chiamo stored x copia dati pack list su AS400 + * - chiamo stored che richiamerà SSIS e quindi CL di as400 + * + * + * indico la lista come completata = 1 (true) + * */ + // setup eventuali valori x rettifica + bool fatto = false; + + esitoOperazione answ = esitoOperazione.errore; + int trovate = 0; + DS_magazzino.ElencoListePrelievoDataTable tabella; + DS_magazzino.ElencoListePrelievoRow riga; + try + { + tabella = taElencoListePrelievo.getByCodLista(CodLista); + riga = tabella[0]; + trovate = tabella.Rows.Count; + + // se la lista esiste... + if (trovate > 0) + { + // se la lista è completata + if (riga.CodStatoLista == (int)statoLista.completata) + { + // ricavo il codtipolista + string codTipoListaAttuale = riga.CodTipoLista; + + // leggo da tipoLista prelievo alcuni dati (es codcella di destinazione) + DS_magazzino.TipoListaPrelievoDataTable tabellaTipoLista = taTipoListaPrelievo.getByCodTipoLista(codTipoListaAttuale); + DS_magazzino.TipoListaPrelievoRow rigaTipoLista = tabellaTipoLista[0]; + + // leggo da righe lista prelievo il dato udc che mi serve + DS_magazzino.RigheListePrelievoDataTable tabellaRigheListaPrelievo = taRigheListePrelievo.getByCodListaPrelevate(CodLista); + DS_magazzino.RigheListePrelievoRow rigaListaPrelievo = tabellaRigheListaPrelievo[0]; + + // leggo il codice della cella... + string CodEvento = rigaTipoLista.CodEvento; + // posizione che devono avere (uguale) tutti gli UDC + int idxPosizUdcAll = 0; + // posizione corrente dell'UDC int idxPosizUdcCorr = 0; + // posizione di destinazione per UDC corrente int idxPosizUdcDest = 0; - string CodEvento = "UDC_CONS"; - // calcolo posizione UDC corrente (se c'è...) - try + // cella di provenienza + int idxCellaFrom = 0; + // cella di destinazione + int idxCellaTo = 0; + /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + * ora controllo se la lista sia DAVVERO scaricabile, cioè + * - destinatario IMPOSTATO + * - TUTTE le righe hanno una posizione di destinazione valida, + * OVVERO tutte le righe hanno nella tab trans posiz eventi una riga valida + * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ + bool listaScaricabile = true; + if (riga.Destinatario == "") { + listaScaricabile = false; + } + else + { + foreach (DS_magazzino.RigheListePrelievoRow row in tabellaRigheListaPrelievo.Rows) + { + // ricavo il codice UDC... + string UDC = row.UDC; // mi serve per posizione udc corrente DS_magazzino.PosizioneUdcCorrenteRow rigaUdcCorrente = taPosUdcCorr.getByUDC(UDC)[0]; - // il secondo idx che mi serve - idxCellaFrom = rigaUdcCorrente.IdxCella; - } - catch (Exception e) - { - logger.lg.scriviLog(string.Format(" | {3} | Errore in fase di recupero cella per l'UDC {0}: {1}{2}", UDC, Environment.NewLine, e, clientIp), tipoLog.EXCEPTION); - } - // ora calcolo gli altri dati dalla riga ElencoCartellini dell'UDC - try - { // calcolo posizione destinazione da state machine... idxPosizUdcCorr = taCartellini.getDetailsUdcByUdc(UDC)[0].IdxPosizione; + if (idxPosizUdcAll == 0) + { + idxPosizUdcAll = idxPosizUdcCorr; + } idxPosizUdcDest = StateMachine.SM.getIdxPostizioneTo(CodEvento, idxPosizUdcCorr); - } - catch (Exception e) - { - logger.lg.scriviLog(string.Format(" | {3} | Errore in fase di recupero dati posizioni from/to per l'UDC {0}: {1}{2}", UDC, Environment.NewLine, e, clientIp), tipoLog.EXCEPTION); - } - // ora provo ad eseguire! - try - { - if (idxPosizUdcDest != 0) // solo se c'è una posizione da cui poter fare lo scaricamento... + if (idxPosizUdcDest == 0 || idxPosizUdcAll != idxPosizUdcCorr) { - // sposto UDC - answ = scaricaUDC(UDC, idxPosizUdcDest, CodEvento, clientIp); + listaScaricabile = false; } + } } - catch (Exception e) + // SE la lista è scaricabile procedo... + if (listaScaricabile) { - logger.lg.scriviLog(string.Format(" | {3} | Errore in fase di scaricamento dell'UDC {0}: {1}{2}", UDC, Environment.NewLine, e, clientIp), tipoLog.EXCEPTION); - } - - return answ; - } - /// - /// riattiva un UDC (se permesso) da una posizione consumata ad una valida - /// - /// Codice UDC - /// Cod soggetto utente - /// IP del chiamante - /// - public bool riattivaUdc(string UDC, string CodSoggetto, string clientIp) - { - // init - bool answ = false; - try - { - // salvo dati cartellino PRE - DS_Applicazione.ElencoCartelliniRow rigaUdcPre = DataProxy.obj.taCartellini.stp_getByUdc(UDC)[0]; - GMW_data.DataProxy.obj.taCartellini.stp_riattivaUdc(UDC, CodSoggetto); - logger.lg.scriviLog(string.Format(" | {0} | riattivato UDC {1} | soggetto {2}", clientIp, UDC, CodSoggetto), tipoLog.INFO); - // salvo dati cartellino POST - DS_Applicazione.ElencoCartelliniRow rigaUdcPost = DataProxy.obj.taCartellini.stp_getByUdc(UDC)[0]; - answ = true; - } - catch (Exception e) - { - logger.lg.scriviLog(string.Format(" | {2} | Eccezione: {0}{1}", Environment.NewLine, e, clientIp), tipoLog.EXCEPTION); - } - - return answ; - } - /// - /// sblocca un UDC (se permesso) - /// - /// Codice UDC - /// Cod soggetto utente - /// IP del chiamante - /// - public bool sbloccaUdc(string UDC, string CodSoggetto, string clientIp) - { - // init - bool answ = false; - try - { - GMW_data.DataProxy.obj.taCartellini.stp_sbloccaUdc(UDC, CodSoggetto); - logger.lg.scriviLog(string.Format(" | {0} | sbloccato UDC {1} | soggetto {2}", clientIp, UDC, CodSoggetto), tipoLog.INFO); - answ = true; - } - catch (Exception e) - { - logger.lg.scriviLog(string.Format(" | {2} | Eccezione: {0}{1}", Environment.NewLine, e, clientIp), tipoLog.EXCEPTION); - } - return answ; - } - /// - /// controlla se l'udc della qualità indicato ha benestare qualità ("S") - /// - /// - /// - public bool udcMpHasBenesQual(string UDC) - { - bool answ = false; - try - { - DS_magazzino.RapQualRow rigaRapQual = taRapQual.getByUdc(UDC)[0]; - if (rigaRapQual.BenesQual == "S") - { - answ = true; - } - } - catch - { } - return answ; - } - /// - /// controlla se l'udc indicato è già stato consumato - /// - /// - /// - public bool udcMpIsConsumabile(string UDC) - { - bool answ = false; - try - { - DS_magazzino.ElencoCartelliniRow rigaUDC = taCartellini.getByUdc(UDC)[0]; - if (rigaUDC.IdxPosizione > 0) - { - answ = true; - } - } - catch - { } - return answ; - } - /// - /// fornisce IdxPosizione dell'UDC - /// - /// - /// - public int IdxPosizioneUdc(string UDC) - { - int answ = 0; - try - { - answ = taCartellini.getDetailsUdcByUdc(UDC)[0].IdxPosizione; - } - catch - { } - return answ; - } - /// - /// fornisce il CodStato dell'UDC - /// - /// - /// - public string CodStatoUdc(string UDC) - { - string answ = ""; - try - { - answ = taCartellini.getDetailsUdcByUdc(UDC)[0].CodStato; - } - catch - { } - return answ; - } - /// - /// fornisce cella in cui si trova l'UDC - /// - /// - /// - public string codCellaUdc(string UDC) - { - string answ = ""; - try - { - int idxCella = taPosUdcCorr.getByUDC(UDC)[0].IdxCella; - answ = taCelle.getByIdxCella(idxCella)[0].CodCella; - } - catch - { } - return answ; - } - /// - /// fornisce codBlocco in cui si trova l'UDC - /// - /// - /// - public string codBloccoUdc(string UDC) - { - string answ = ""; - try - { - int idxCella = taPosUdcCorr.getByUDC(UDC)[0].IdxCella; - int idxBlocco = taCelle.getByIdxCella(idxCella)[0].IdxBlocco; - answ = taBlocchi.getByIdx(idxBlocco)[0].CodBlocco; - } - catch - { } - return answ; - } - - /// - /// verifica se UDC sia ok x LDP secondo stored stp_getUdcDetailOkLP (LPA/LPX) - /// - /// - /// - public bool checkUdc_OkLPAX(string UDC) - { - bool answ = false; - try - { - answ = taDettUDC.getByUdcOkLp(UDC).Rows.Count > 0; - } - catch - { } - return answ; - } - /// - /// controlla se l'udc indicato sia in una LDP - /// - /// - /// - public bool udcInLdp(string UDC) - { - bool answ = false; - try - { - DS_magazzino.RigheListePrelievoDataTable tabRLDP = taRigheListePrelievo.getByUdc(UDC); - if (tabRLDP.Rows.Count > 0) - { - answ = true; - } - } - catch - { } - return answ; - } - /// - /// fornisce il codice UDC calcolato - /// - /// - /// - /// 2 cifre - /// - /// - public string getComposizioneUDC(string CodCS, string flusso, string anno, int numUDC) - { - string answ = ""; - try - { - answ = string.Format("U{0}{1}{2}{3}", CodCS, flusso, anno, numUDC.ToString().PadLeft(6, '0')); - } - catch - { } - return answ; - } - /// - /// fornisce il codice trattamento calcolato - /// - /// se > 2 cifre trim e tiene ultime 2.. - /// Numero trattamento - /// - public string getCompTrattamenti(string anno, string numTr) - { - string answ = ""; - try - { - answ = string.Format("{0}{1}", anno.Substring(anno.Length - 2, 2), numTr.PadLeft(6, '0')); - } - catch - { } - return answ; - }/// - /// Fornisce un nuovo codice UDC tipo completo (con pezzi e cod magazzino) a partire dalla richiesta e associa ad AL e mette nella cella richiesta - /// - /// AL da associare - /// AL Sorgente (da disattivare) - /// DataMatrix da spostare - /// - /// codice cella destinazione - /// codice anagrafico della bilanca che effettua la richiesta (codice della pesa) - /// codice anagrafico del cliente - /// codice del particolare (articolo) - da anagrafica! - /// Codice dell'impianto - /// Codice dello stampo - /// codice dell'esponente dello stampo - /// Codice figura - /// codice dell'UDC parent (UDC della tara) - /// peso in kg (0 se non noto) da associare all'UDC come tara del contenitore - /// codice dell'imballo (tipo cassone) - string LIBERO (non facciamo controlli in input) - /// tipo di dichiarazione (vedere relativa anagrafica consentita, es U=uomo, M=macchina...) - /// codice dell'operatore - /// numero pezzi associati all'UDC - /// Peso totale rilevato - /// Peso unitario rilevato - /// Data di rif per la dichiarazione - /// Turno di rif per la dichiarazione - /// Codice dello stato del pezzo (da anagrafica: sabbiato, ...) - /// Codice del magazzino in cui inserire l'UDC - /// NOME della posizione default in cui creare UDC - /// cod evento da associare al movimento mag - /// note (opzionali) - /// cod UDC pre-calcolato, se "" verrà calcolato dalla query - /// anno in cui intestare i cartellini, trimma a 2 cifre DX - /// Ip del client - /// UDC del nuovo cartellino per FINITI - public string creaUdcWithAlCella(string AL, string SourceAL, string DataMatrix, string CodStatoUdcOut, string CodCella, string CodBilancia, string CodCliente, string Particolare, string CodImpianto, string CodStampo, string Esponente, string Figura, string UDC_parent, double Tara, string CodImballo, string CodTipoDichiarazione, string CodSoggetto, int Quantita, float PesoTot, float PesoCad, DateTime DataRif, int TurnoRif, string CodStato, int CodMag, string defIdxPosiz, string codEvento, string note, string UDC, int anno, string clientIp) - { - // trim fix - string CodBilanciaTrim = CodBilancia.Trim(); - string CodClienteTrim = CodCliente.Trim(); - string ParticolareTrim = Particolare.Trim(); - string CodImpiantoTrim = CodImpianto.Trim(); - string CodStampoTrim = CodStampo.Trim(); - string EsponenteTrim = Esponente.Trim(); - string FiguraTrim = Figura.Trim(); - string UDC_parentTrim = UDC_parent.Trim(); - string CodImballoTrim = CodImballo.Trim(); - string CodTipoDichiarazioneTrim = CodTipoDichiarazione.Trim(); - string CodSoggettoTrim = CodSoggetto.Trim(); - string CodStatoTrim = CodStato.Trim(); - string defIdxPosizTrim = defIdxPosiz.Trim(); - string codEventoTrim = codEvento.Trim(); - string noteTrim = note.Trim(); - string annoTrim = anno.ToString(); - if (annoTrim.Length > 2) - { - annoTrim = annoTrim.Substring(2, 2); - } - // determino se cancellare udcTara - bool doDeleteUdcTara = false; // memLayer.ML.confReadBool("doDeleteUdcTara"); - // ricavo cod company... - string CodCS = "ND"; - string answ = "NA"; - try - { - CodCS = DataProxy.obj.taAnagBil.stp_getByCodBilancia(CodBilanciaTrim)[0].CodCS; - } - catch - { - CodCS = memLayer.ML.cdv("CodCS"); - } - int IdxPosizione = 0; - if (CodMag > 0) - { - IdxPosizione = CodMag; - } - else - { - IdxPosizione = memLayer.ML.confReadInt(defIdxPosizTrim); - } - // controllo di avere codice soggetto e particolare validi (!="") - if (ParticolareTrim != "" && CodSoggettoTrim != "") - { - // creo nuovo cartellino! - DS_Applicazione.ElencoCartelliniDataTable tabUdc = new DS_Applicazione.ElencoCartelliniDataTable(); - // insert nuovo UDC con codice impostato - try - { - tabUdc = DataProxy.obj.taCartellini.stp_insNewFullWithAL(AL, SourceAL, DataMatrix, CodStatoUdcOut, CodCella, CodCS, CodBilanciaTrim, annoTrim, CodClienteTrim, ParticolareTrim, CodImpiantoTrim, CodStampoTrim, EsponenteTrim, FiguraTrim, DataRif, TurnoRif, CodImballoTrim, CodSoggettoTrim, Tara, IdxPosizione, CodTipoDichiarazioneTrim, codEventoTrim, Quantita, PesoTot, PesoCad, CodStatoTrim, UDC_parentTrim, doDeleteUdcTara, noteTrim); - answ = UDC; - } - catch (Exception exc) - { - // loggo errore - logger.lg.scriviLog(string.Format("ERRORE CREAZIONE UDC: | {24} | procedura stp_insNewFull_fixUDC, parametri: {0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11} | {12} | {13} | {14} | {15} | {16} | {17} | {18} | {19} | {20} | {21} | {22} | {23} | {24}{25}{26}", answ, CodCS, CodBilanciaTrim, annoTrim, CodClienteTrim, ParticolareTrim, CodImpiantoTrim, CodStampoTrim, EsponenteTrim, FiguraTrim, DataRif, TurnoRif, CodImballoTrim, CodSoggettoTrim, Tara, IdxPosizione, CodTipoDichiarazioneTrim, codEventoTrim, Quantita, PesoTot, PesoCad, CodStatoTrim, UDC_parentTrim, noteTrim, clientIp, Environment.NewLine, exc), tipoLog.INFO); - } - // leggo la riga - answ = tabUdc[0].UDC; - // loggo tutto! - if (memLayer.ML.confReadInt("_logLevel") > 5) + // 2015.09.18: aggiunto controllo che NON ci siano UDC con NC + if (taRigheListePrelievo.getUdcSenzaDelibPM(CodLista).Rows.Count == 0) + { + if (taRigheListePrelievo.getUdcConNC(CodLista).Rows.Count == 0) { + if (taRigheListePrelievo.getDmtxUdcConNc(CodLista).Rows.Count == 0) + { + // scarico i vari UDC dal magazzino (come posizione corrente) + foreach (DS_magazzino.RigheListePrelievoRow row in tabellaRigheListaPrelievo.Rows) + { + // ricavo il codice UDC... + string UDC = row.UDC; + // mi serve per posizione udc corrente + DS_magazzino.PosizioneUdcCorrenteRow rigaUdcCorrente = taPosUdcCorr.getByUDC(UDC)[0]; + // il secondo idx che mi serve + idxCellaFrom = rigaUdcCorrente.IdxCella; + // calcolo posizione destinazione da state machine... + idxPosizUdcCorr = taCartellini.getDetailsUdcByUdc(UDC)[0].IdxPosizione; + idxPosizUdcDest = StateMachine.SM.getIdxPostizioneTo(CodEvento, idxPosizUdcCorr); + // a questo punto mi calcolo se c'è una cella di destinazione associata + try + { + idxCellaTo = MagClass.magazzino.taCelle.getByCodMag(CodCS, idxPosizUdcDest.ToString())[0].IdxCella; + } + catch + { + idxCellaTo = 0; + } + // sposto UDC, e così facendo genero movimenti batch x AS400 + fatto = scaricaUDC(UDC, idxPosizUdcDest, CodEvento, clientIp); + // sposto nella PRIMA cella di destinazione associata l'UDC + if (idxCellaTo > 0) + { + spostaUDC(CodCS, UDC, idxCellaTo, false, clientIp); + } + if (fatto) + { + // dopo aver scaricato UDC sistemo eventuali Righe di Prelievo x lo stesso pending... + magazzino.taRigheListePrelievo.stp_RLP_sbloccaNonPrelevate(CodLista, UDC); + } + } + // ora step finali x LDP try { - logger.lg.scriviLog(string.Format(" | {24} | NUOVO cartellino da postazione: {0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11} | {12} | {13} | {14} | {15} | {16} | {17} | {18} | {19} | {20} | {21} | {22} | {23}", answ, CodCS, CodBilanciaTrim, annoTrim, CodClienteTrim, ParticolareTrim, CodImpiantoTrim, CodStampoTrim, EsponenteTrim, FiguraTrim, DataRif, TurnoRif, CodImballoTrim, CodSoggettoTrim, Tara, IdxPosizione, CodTipoDichiarazioneTrim, codEventoTrim, Quantita, PesoTot, PesoCad, CodStatoTrim, UDC_parentTrim, noteTrim, clientIp), tipoLog.INFO); - } - catch - { } - } - // solo se UDC parent != vuoto... - if (UDC_parentTrim != "") - { - try - { - // salvo associazione parent-child tra UDC! - DataProxy.obj.taRelazUDC.Insert(UDC_parentTrim, answ, DateTime.Now); - } - catch - { } - } - } - return answ; - } - /// - /// Fornisce un nuovo codice UDC tipo completo (con pezzi e cod magazzino) a partire dalla richiesta e salva i dati - /// - /// codice anagrafico della bilanca che effettua la richiesta (codice della pesa) - /// codice anagrafico del cliente - /// codice del particolare (articolo) - da anagrafica! - /// Codice dell'impianto - /// Codice dello stampo - /// codice dell'esponente dello stampo - /// Codice figura - /// codice dell'UDC parent (UDC della tara) - /// peso in kg (0 se non noto) da associare all'UDC come tara del contenitore - /// codice dell'imballo (tipo cassone) - string LIBERO (non facciamo controlli in input) - /// tipo di dichiarazione (vedere relativa anagrafica consentita, es U=uomo, M=macchina...) - /// codice dell'operatore - /// numero pezzi associati all'UDC - /// Peso totale rilevato - /// Peso unitario rilevato - /// Data di rif per la dichiarazione - /// Turno di rif per la dichiarazione - /// Codice dello stato del pezzo (da anagrafica: sabbiato, ...) - /// Codice del magazzino in cui inserire l'UDC - /// NOME della posizione default in cui creare UDC - /// cod evento da associare al movimento mag - /// note (opzionali) - /// cod UDC pre-calcolato, se "" verrà calcolato dalla query - /// anno in cui intestare i cartellini, trimma a 2 cifre DX - /// Ip del client - /// UDC del nuovo cartellino per FINITI - public string creaUdc(string CodBilancia, string CodCliente, string Particolare, string CodImpianto, string CodStampo, string Esponente, string Figura, string UDC_parent, double Tara, string CodImballo, string CodTipoDichiarazione, string CodSoggetto, int Quantita, float PesoTot, float PesoCad, DateTime DataRif, int TurnoRif, string CodStato, int CodMag, string defIdxPosiz, string codEvento, string note, string UDC, int anno, string clientIp) - { - // trim fix - string CodBilanciaTrim = CodBilancia.Trim(); - string CodClienteTrim = CodCliente.Trim(); - string ParticolareTrim = Particolare.Trim(); - string CodImpiantoTrim = CodImpianto.Trim(); - string CodStampoTrim = CodStampo.Trim(); - string EsponenteTrim = Esponente.Trim(); - string FiguraTrim = Figura.Trim(); - string UDC_parentTrim = UDC_parent.Trim(); - string CodImballoTrim = CodImballo.Trim(); - string CodTipoDichiarazioneTrim = CodTipoDichiarazione.Trim(); - string CodSoggettoTrim = CodSoggetto.Trim(); - string CodStatoTrim = CodStato.Trim(); - string defIdxPosizTrim = defIdxPosiz.Trim(); - string codEventoTrim = codEvento.Trim(); - string noteTrim = note.Trim(); - string annoTrim = anno.ToString(); - if (annoTrim.Length > 2) - { - annoTrim = annoTrim.Substring(2, 2); - } - // determino se cancellare udcTara - bool doDeleteUdcTara = false; // memLayer.ML.confReadBool("doDeleteUdcTara"); - // ricavo cod company... - string CodCS = "ND"; - string answ = "NA"; - try - { - CodCS = DataProxy.obj.taAnagBil.stp_getByCodBilancia(CodBilanciaTrim)[0].CodCS; - } - catch - { - CodCS = memLayer.ML.cdv("CodCS"); - } - int IdxPosizione = 0; - if (CodMag > 0) - { - IdxPosizione = CodMag; - } - else - { - IdxPosizione = memLayer.ML.confReadInt(defIdxPosizTrim); - } - //int IdxPosizione = memLayer.ML.confReadInt(defIdxPosizTrim); - // controllo di avere codice soggetto e particolare validi (!="") - if (ParticolareTrim != "" && CodSoggettoTrim != "") - { - // creo nuovo cartellino! - DS_Applicazione.ElencoCartelliniDataTable tabUdc = new DS_Applicazione.ElencoCartelliniDataTable(); - // controllo se UDC già definito o meno... - if (UDC != "") - { - // insert nuovo UDC con codice impostato - try - { - tabUdc = DataProxy.obj.taCartellini.stp_insNewFull_fixUDC(UDC, CodCS, CodBilanciaTrim, annoTrim, CodClienteTrim, ParticolareTrim, CodImpiantoTrim, CodStampoTrim, EsponenteTrim, FiguraTrim, DataRif, TurnoRif, CodImballoTrim, CodSoggettoTrim, Tara, IdxPosizione, CodTipoDichiarazioneTrim, codEventoTrim, Quantita, PesoTot, PesoCad, CodStatoTrim, UDC_parentTrim, doDeleteUdcTara, noteTrim); - answ = UDC; - } - catch - { - // loggo errore - logger.lg.scriviLog(string.Format("ERRORE CREAZIONE UDC: | {24} | procedura stp_insNewFull_fixUDC, parametri: {0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11} | {12} | {13} | {14} | {15} | {16} | {17} | {18} | {19} | {20} | {21} | {22} | {23}", answ, CodCS, CodBilanciaTrim, annoTrim, CodClienteTrim, ParticolareTrim, CodImpiantoTrim, CodStampoTrim, EsponenteTrim, FiguraTrim, DataRif, TurnoRif, CodImballoTrim, CodSoggettoTrim, Tara, IdxPosizione, CodTipoDichiarazioneTrim, codEventoTrim, Quantita, PesoTot, PesoCad, CodStatoTrim, UDC_parentTrim, noteTrim, clientIp), tipoLog.INFO); - } - } - else - { - // insert con calcolo UDC - try - { - tabUdc = DataProxy.obj.taCartellini.stp_insNewFull(CodCS, CodBilanciaTrim, annoTrim, CodClienteTrim, ParticolareTrim, CodImpiantoTrim, CodStampoTrim, EsponenteTrim, FiguraTrim, DataRif, TurnoRif, CodImballoTrim, CodSoggettoTrim, Tara, IdxPosizione, CodTipoDichiarazioneTrim, codEventoTrim, Quantita, PesoTot, PesoCad, CodStatoTrim, UDC_parentTrim, doDeleteUdcTara, noteTrim); + // STEP 1: segna come scaricata la lista prelievo + taElencoListePrelievo.updateStato(CodSoggetto, CodLista, (int)statoLista.scaricata); + // STEP 2: chiamo esportazione verso MovMag AS x imballi + copiare in altra tabella (quella per AS...) i dati della packing + taElencoListePrelievo.stp_LP_exportToAs400(CodLista, SlotPL, CodCS); + // STEP 3: chiamo stored x eseguire SSIS che a sua volta richiama la CL di AS400 x importazione MovMag + utils.obj.taAs400.stp_processaCodaMovimPackList(); + // restituisce ok + answ = esitoOperazione.ok; } catch (Exception exc) { - // loggo errore - logger.lg.scriviLog(string.Format("ERRORE CREAZIONE UDC: | {24} | procedura stp_insNewFull, parametri: {0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11} | {12} | {13} | {14} | {15} | {16} | {17} | {18} | {19} | {20} | {21} | {22} | {23}{25}{26}", answ, CodCS, CodBilanciaTrim, annoTrim, CodClienteTrim, ParticolareTrim, CodImpiantoTrim, CodStampoTrim, EsponenteTrim, FiguraTrim, DataRif, TurnoRif, CodImballoTrim, CodSoggettoTrim, Tara, IdxPosizione, CodTipoDichiarazioneTrim, codEventoTrim, Quantita, PesoTot, PesoCad, CodStatoTrim, UDC_parentTrim, noteTrim, clientIp, Environment.NewLine, exc), tipoLog.EXCEPTION); + logger.lg.scriviLog(string.Format("Errore in trasferimento dati LDP verso AS400: {0}", exc), tipoLog.EXCEPTION); } + } + else + { + answ = esitoOperazione.errore_DtmxNc; + } } - // leggo la riga - answ = tabUdc[0].UDC; - // loggo tutto! - if (memLayer.ML.confReadInt("_logLevel") > 5) + else { - try - { - logger.lg.scriviLog(string.Format(" | {24} | NUOVO cartellino da postazione: {0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11} | {12} | {13} | {14} | {15} | {16} | {17} | {18} | {19} | {20} | {21} | {22} | {23}", answ, CodCS, CodBilanciaTrim, annoTrim, CodClienteTrim, ParticolareTrim, CodImpiantoTrim, CodStampoTrim, EsponenteTrim, FiguraTrim, DataRif, TurnoRif, CodImballoTrim, CodSoggettoTrim, Tara, IdxPosizione, CodTipoDichiarazioneTrim, codEventoTrim, Quantita, PesoTot, PesoCad, CodStatoTrim, UDC_parentTrim, noteTrim, clientIp), tipoLog.INFO); - } - catch - { } - } - // solo se UDC parent != vuoto... - if (UDC_parentTrim != "") - { - try - { - // salvo associazione parent-child tra UDC! - DataProxy.obj.taRelazUDC.Insert(UDC_parentTrim, answ, DateTime.Now); - } - catch - { } + answ = esitoOperazione.errore_UdcNc; } + } + else + { + answ = esitoOperazione.errore_noDeliberPM; + } } else { - logger.lg.scriviLog(string.Format(" | {24} | CodSoggetto / particolare non validi! tentativo di creazione cartellino come {0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11} | {12} | {13} | {14} | {15} | {16} | {17} | {18} | {19} | {20} | {21} | {22}", CodCS, CodBilanciaTrim, annoTrim, CodClienteTrim, ParticolareTrim, CodImpiantoTrim, CodStampoTrim, EsponenteTrim, FiguraTrim, DataRif, TurnoRif, CodImballoTrim, CodSoggettoTrim, Tara, IdxPosizione, CodTipoDichiarazioneTrim, codEventoTrim, Quantita, PesoTot, PesoCad, CodStatoTrim, UDC_parentTrim, noteTrim, clientIp), tipoLog.ERROR); + answ = esitoOperazione.errore_nonScaricabile; } - return answ; + } + // se è già completata dà errore + else + { + answ = esitoOperazione.errore_readOnly; + } } - /// - /// associa udc all'UDCParent - /// - /// UDC destinazione - /// UDC parent - /// - public bool associaUdcParent(string codUdc, string codParent) + // se la lista non esiste dai errore + else { - bool answ = false; - try - { - answ = associaUdcParent(codUdc, codParent, false); - } - catch - { } - return answ; - } - /// - /// VERIFICA se ci sia associazione tra udc e l'UDCParent e restituisce TRUE se sia già associato - /// - /// UDC destinazione - /// UDC parent - /// - public bool checkAssociazioneUdcParent(string codUdc, string codParent) - { - bool answ = false; - try - { - answ = DataProxy.obj.taRelazUDC.getByParentChild(codUdc, codParent).Rows.Count > 0; - } - catch - { } - return answ; - } - /// - /// calcola l'UDC Parent di quello fornito - /// - /// UDC destinazione - /// UDC parent - /// - public string getUdcParent(string codUdc) - { - string answ = ""; - try - { - answ = ((DS_Applicazione.RelazUDCRow)DataProxy.obj.taRelazUDC.stp_getParent(codUdc)[0]).UDC_parent; - } - catch - { } - return answ; - } - /// - /// calcola l'UDC Parent di quello fornito IN ORDINE DESCENDING - /// - /// UDC destinazione - /// UDC parent - /// - public string getUdcParentDesc(string codUdc) - { - string answ = ""; - try - { - answ = ((DS_Applicazione.RelazUDCRow)DataProxy.obj.taRelazUDC.stp_getParentDesc(codUdc)[0]).UDC_parent; - } - catch - { } - return answ; - } - /// - /// associa udc all'UDCParent - /// - /// UDC destinazione - /// UDC parent - /// copiare si/no attributi UDC da parent a child - /// - public bool associaUdcParent(string codUdc, string codParent, bool copyAttr) - { - bool answ = false; - try - { - DataProxy.obj.taCartellini.stp_UDC_associaParent(codUdc, codParent, CodSoggCurrUser, copyAttr); - answ = true; - } - catch - { } - return answ; - } - /// - /// effettua la stampa di un dato UDC - /// - /// Codice UDC - /// stampante specifica (da postazioen o std da webconfig, a cura dell'utente - /// IP del chiamante - /// - public bool stampaUdc(string UDC, string printer, tipoCartellino tipoCart, string clientIp) - { - bool answ = false; - // controllo se esista UDC - if (checkUDC(UDC)) - { - answ = reportPrinter.obj.stampaCartellino(tipoCart, UDC, printer); - logger.lg.scriviLog(string.Format(" | {0} | stampato UDC {1} | stampante {2} | tipo {3}", clientIp, UDC, printer, tipoCart), tipoLog.INFO); - } - return answ; + answ = esitoOperazione.errore; } + } + catch + { } + return answ; + } + /// + /// resetta (riporta in bozza) una lista di prelievo, spostando gli UDC alla posizione standard precedente + /// + /// Codice company/sito + /// codice della lista di prelievo + /// cod operatore carrellista + /// IP del client + /// + public esitoOperazione resetListaPrelievo(string CodCS, string CodLista, string CodSoggetto, string clientIp) + { + memLayer.ML.emptySessionVal("CodListaAttiva"); + memLayer.ML.emptySessionVal("activeTask"); + // da chiamare quando clicco e inizio lista prelievo .... vedi sopra + esitoOperazione answ = esitoOperazione.errore; + // posizione corrente dell'UDC + int idxPosizUdcAll = 0; // posizione che devono avere (uguale) tutti gli UDC + int idxPosizUdcCorr = 0; + int IdxPosizioneTo = 0; + int idxPosizUdcDest = 0; + int idxCellaTo = 0; + try + { + // la query recupera la lista in base al CodLista + DS_magazzino.ElencoListePrelievoDataTable tabella = taElencoListePrelievo.getByCodLista(CodLista); + DS_magazzino.ElencoListePrelievoRow riga = tabella[0]; - /// - /// effettua la Ristampa di un dato UDC partendo dal primo tipo di cartellino stampato... - /// - /// Codice UDC - /// stampante specifica (da postazioen o std da webconfig, a cura dell'utente - /// IP del chiamante - /// - public bool ristampaUdc(string UDC, string printer, string clientIp) + // se la lista esiste... + if (tabella.Rows.Count > 0) { - bool answ = false; - tipoCartellino tipoCart = tipoCartellino.cartND; - try + // ricontrollo che la lista sia completata + if (riga.CodStatoLista >= (int)statoLista.completata) + { + // calcolo tipo lista di prelievo + string codTipoListaAttuale = riga.CodTipoLista; + // dal tipo lista determino l'evento + string codEvento = taTipoListaPrelievo.getByCodTipoLista(codTipoListaAttuale)[0].CodEvento; + // 2014.07.10 ATTENZIONE cablato evento reset come Pre --> Rst + codEvento = codEvento.Replace("Pre", "Rst"); + // leggo da righe lista prelievo il dato udc che mi serve + DS_magazzino.RigheListePrelievoDataTable tabellaRigheListaPrelievo = taRigheListePrelievo.getByCodListaPrelevate(CodLista); + DS_magazzino.RigheListePrelievoRow rigaListaPrelievo = tabellaRigheListaPrelievo[0]; + + /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + * ora controllo se la lista sia DAVVERO scaricabile, cioè + * - destinatario IMPOSTATO + * - TUTTE le righe hanno una posizione di destinazione valida, + * OVVERO tutte le righe hanno nella tab trans posiz eventi una riga valida + * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ + bool listaScaricabile = true; + if (riga.Destinatario == "") { - tipoCart = (tipoCartellino)Enum.Parse(typeof(tipoCartellino), DataProxy.obj.taPJQ.getFirstByUdc(UDC)[0].TipoCart); + listaScaricabile = false; } - catch - { } - if (tipoCart != tipoCartellino.cartND) + else { - // controllo se esista UDC - if (checkUDC(UDC)) + foreach (DS_magazzino.RigheListePrelievoRow row in tabellaRigheListaPrelievo.Rows) + { + // ricavo il codice UDC... + string UDC = row.UDC; + //// mi serve per posizione udc corrente + //DS_magazzino.PosizioneUdcCorrenteRow rigaUdcCorrente = taPosUdcCorr.getByUDC(UDC)[0]; + // calcolo posizione destinazione da state machine... + idxPosizUdcCorr = taCartellini.getDetailsUdcByUdc(UDC)[0].IdxPosizione; + if (idxPosizUdcAll == 0) { - answ = reportPrinter.obj.stampaCartellino(tipoCart, UDC, printer); - logger.lg.scriviLog(string.Format(" | {0} | stampato UDC {1} | stampante {2} | tipo {3}", clientIp, UDC, printer, tipoCart), tipoLog.INFO); + idxPosizUdcAll = idxPosizUdcCorr; } - } - return answ; - } - /// - /// restituisce particolare da UDC - /// - /// - /// - public string getParticolareByUDC(string UDC) - { - string answ = ""; - try - { - answ = (taCartellini.getDetailsUdcByUdc(UDC)[0].Particolare); - } - catch - { } - return answ; - } - /// - /// restituisce note dell'UDC - /// - /// - /// - public string getNoteByUDC(string UDC) - { - string answ = ""; - try - { - answ = (taCartellini.getDetailsUdcByUdc(UDC)[0].Note); - } - catch - { } - return answ; - } - /// - /// aggiorna note dell'UDC - /// - /// - /// - public void updateNoteUDC(string UDC, string note) - { - taCartellini.updateNote(UDC, note, CodSoggCurrUser); - } - /// - /// aggiorna posizione dell'UDC - /// - /// - /// - public void updatePosizioneUDC(string UDC, int idxPosizione) - { - taCartellini.updateIdxPosizione(UDC, idxPosizione, CodSoggCurrUser); - } - /// - /// aggiorna note e posizione dell'UDC - /// - /// - /// - /// - public void updateNotePosizioneUDC(string UDC, string note, int idxPosizione) - { - taCartellini.updateNotePosizione(UDC, idxPosizione, note, CodSoggCurrUser); - } - /// - /// aggiorna note, posizione e data fusione dell'UDC - /// - /// - /// - /// - /// - public void updateNotePosizioneDataUDC(string UDC, string note, int idxPosizione, DateTime DataFus) - { - taCartellini.updateNotePosizioneData(UDC, idxPosizione, note, CodSoggCurrUser, DataFus); - } - /// - /// aggiorna note, posizione e data fusione dell'UDC - /// - /// - /// - /// - /// - /// - public void updateNotePosizioneDataImballoUDC(string UDC, string note, int idxPosizione, DateTime DataFus, string CodImballo) - { - taCartellini.updateNotePosizioneDataImballo(UDC, idxPosizione, note, CodSoggCurrUser, DataFus, CodImballo); - } - /// - /// aggiorna note, posizione e data fusione dell'UDC - /// - /// - /// - /// - /// - /// - public void updateFinDtxFull(string UDC, string note, DateTime DataFus, string CodImballo, string AL) - { - taCartellini.finDatamatrixFullUpdate(AL, UDC, CodImballo, note, DataFus, CodSoggCurrUser); - } - /// - /// Verifica se UDC abbia attributo indicato - /// - /// - /// - /// - public bool udcHasAttr(string UDC, string CodAttr) - { - bool answ = false; - try - { - answ = MagClass.magazzino.taAtt2UDC.getByUdc(UDC).Select(string.Format("CodAttr = '{0}'", CodAttr)).Length > 0 ? true : false; - } - catch - { } - return answ; - } - - #endregion - - #region procedure di verifica e traduzione dati da anagrafiche - - /// - /// Verifica la corrispondenza dati tra RigheListePrelievo ed ElencoCartellini - /// - /// - /// - /// - public bool verificaDatiUdc(string CodLista, string UDC) - { - bool answ = false; - - try - { - DS_magazzino.ElencoListePrelievoDataTable tabellaElenco = taElencoListePrelievo.getByCodLista(CodLista); - DS_magazzino.ElencoListePrelievoRow rigaElenco = tabellaElenco[0]; - - DS_magazzino.ElencoCartelliniDataTable tabellaUDC = taCartellini.getDetailsUdcByUdc(UDC); - DS_magazzino.ElencoCartelliniRow rigaUDC = tabellaUDC[0]; - - // ricavo dati da confrontare - da Lista ricavo particolare/esponente/figura - string particolareLista = rigaElenco.Particolare.Trim(); - string esponenteLista = rigaElenco.Esponente.Trim(); - string figuraLista = rigaElenco.Figura.Trim(); - string CodImballoLista = rigaElenco.CodImballo.Trim(); - - //stessi dati da UDC - string particolareUDC = rigaUDC.Particolare.Trim(); - string esponenteUDC = rigaUDC.Esponente.Trim(); - string figuraUDC = rigaUDC.Figura.Trim(); - string CodImballoUDC = rigaUDC.CodImballo.Trim(); - - // condizioni di uguaglianza... - bool particolareOk = false; - bool esponenteOk = false; - bool figuraOk = false; - bool CodImballoOk = false; - // verifico le condizioni 1 ad 1... - particolareOk = (particolareLista == particolareUDC); - if (esponenteLista == "*") + idxPosizUdcDest = StateMachine.SM.getIdxPostizioneTo(codEvento, idxPosizUdcCorr); + if (idxPosizUdcDest == 0 || idxPosizUdcAll != idxPosizUdcCorr) { - esponenteOk = true; + listaScaricabile = false; } - else - { - esponenteOk = (esponenteLista == esponenteUDC); - } - if (figuraLista == "*") - { - figuraOk = true; - } - else - { - figuraOk = (figuraLista == figuraUDC); - } - if (CodImballoLista == "*") - { - CodImballoOk = true; - } - else - { - CodImballoOk = (CodImballoLista == CodImballoUDC); - } - - // verifica finale del risultato uguaglianza... - answ = (particolareOk && esponenteOk && figuraOk && CodImballoOk); + } } - catch + // procedo SOLO se lista scaricabile... + if (listaScaricabile) { - answ = false; - } - - return answ; - } - /// - /// restituisce codice soggetto dell'user corrente - /// - /// - public string CodSoggCurrUser - { - get - { - // ricavo da session... - string CodSoggetto = ""; + // Modifica x gestione "blocco " da stato LDP: PRIMA passo a bozza... + taElencoListePrelievo.updateStato(CodSoggetto, CodLista, (int)statoLista.bozza); + // sposto ("metto a terra") gli UDC + string _UDC = ""; + foreach (DS_magazzino.RigheListePrelievoRow row in tabellaRigheListaPrelievo.Rows) + { + // ricavo il codice UDC... + _UDC = row.UDC; + // posizione corrente + idxPosizUdcCorr = taCartellini.getDetailsUdcByUdc(_UDC)[0].IdxPosizione; + // calcolo posizione destinazione da state machine... try { - CodSoggetto = memLayer.ML.StringSessionObj("CodSoggetto"); + IdxPosizioneTo = StateMachine.SM.taTTPE.getByEventoPosizione(codEvento, idxPosizUdcCorr)[0].IdxPosizioneTo; } - catch (Exception e) + catch (Exception exc) { - logger.lg.scriviLog(string.Format("Non sono riuscito a recuperare il codice soggetto DALLA SESSIONE per l'utente loggato: {0}, errore {1}{2}", user_std.UtSn.userNameAD, Environment.NewLine, e), tipoLog.ERROR); + IdxPosizioneTo = 0; + logger.lg.scriviLog(string.Format(" | {1} | Errore in reset lista prelievo nel calcolo IdxPosizioneTo: {0}", exc, clientIp), tipoLog.EXCEPTION); } - if (CodSoggetto == "") - { - // provo a recuperare da cookie... - CodSoggetto = memLayer.ML.getCookieVal("CodSoggetto"); - } - if (CodSoggetto == "") + if (IdxPosizioneTo != 0) { + // lo trasformo x avere la cella di destinazione... + if (idxPosizUdcCorr < 0) + { + // se parto da cella negativa (consumato) calcolo destinazione da cella TO... + idxCellaTo = taCelle.getFirstByPosizione(IdxPosizioneTo.ToString())[0].IdxCella; + } + else + { try { - CodSoggetto = DataProxy.obj.taSogg2Oper.getByUserDominio(user_std.UtSn.utente, user_std.UtSn.dominio)[0].CodSoggetto; - // salvo in sessione... - memLayer.ML.setSessionVal("CodSoggetto", CodSoggetto); + // altrimenti uso la posizione corrente (NON faccio vero spostamento... + idxCellaTo = taCelle.getFirstByPosizione(idxPosizUdcCorr.ToString())[0].IdxCella; } - catch (Exception e) + catch { - logger.lg.scriviLog(string.Format("Non sono riuscito a recuperare il codice soggetto per l'utente loggato: {0}, errore {1}{2}", user_std.UtSn.userNameAD, Environment.NewLine, e), tipoLog.ERROR); + // se parto da cella negativa (consumato) calcolo destinazione da cella TO... + idxCellaTo = taCelle.getFirstByPosizione(IdxPosizioneTo.ToString())[0].IdxCella; } + } + // sposto UDC + spostaUDC(CodCS, _UDC, idxCellaTo, false, clientIp); + // 2014.07.09: modifica, per NON impostare da tab del magazzino con sposta fa update posizione esplicita + taCartellini.updateIdxPosizione(_UDC, IdxPosizioneTo, CodSoggCurrUser); } - return CodSoggetto; + } + // indico le righe come NON prelevate... + taRigheListePrelievo.stp_RLP_resetPrelevate(CodLista); + //// aggiorno stato lista che torna a BOZZA + //taElencoListePrelievo.updateStato(CodSoggetto, CodLista, (int)statoLista.bozza); + answ = esitoOperazione.ok; + logger.lg.scriviLog(string.Format(" | {0} | resettata lista di prelievo UDC {1} | utente {2} | tipo {2}", clientIp, CodLista, CodSoggetto), tipoLog.INFO); } + else + { + // loggo che c'è anomalia + answ = esitoOperazione.errore_readOnly; + logger.lg.scriviLog(string.Format(" | {0} | Errore in reset lista prelievo: non è stato possibile resettare per la posizione di almeno un UDC", clientIp), tipoLog.EXCEPTION); + } + } + // se è già completata o NON iniziata dà errore + else + { + answ = esitoOperazione.errore_readOnly; + } } - /// - /// restituisce l'IdxCella dato il CodCella - /// - /// Codice company/sito - /// - /// - public int IdxCellaByCodCella(string CodCS, string CodCella) + // se la lista non esiste dai errore + else { - int answ = 0; + answ = esitoOperazione.errore; + } + } + catch (Exception e) + { + logger.lg.scriviLog(string.Format(" | {1} | Errore in reset lista prelievo: {0}", e, clientIp), tipoLog.EXCEPTION); + } + return answ; + } + + + /// + /// Conferma che un dato UDC è stato prelevato per soddisfare la lista di prelievo ed aggiorna o aggiunge riga in RigheListePrelievo + /// + /// codice della lista di prelievo + /// Codice UDC + /// esito comando + public esitoOperazione confermaUdcPrelevatoPerLista(string CodLista, string UDC) + { + esitoOperazione answ = esitoOperazione.errore; + + // verifico che i dati corrispondano con il metodo relativo (vedi sopra) + bool datiUdcOk = verificaDatiUdc(CodLista, UDC); + + if (datiUdcOk) + { + // richiamo stored di upsert + taRigheListePrelievo.upsertPrelevato(CodLista, UDC); + // ...dò risposta positiva + answ = esitoOperazione.ok; + + } + else + { + // altrimenti dò errore mismatch e non proseguo + return answ = esitoOperazione.errore_mismatch; + } + + return answ; + } + /// + /// annulla il prelievo di un UDC, aggiornando RigheListePrelievo (solo preventivato...) + /// + /// codice della lista di prelievo + /// Codice UDC + /// esito comando + public esitoOperazione annullaUdcPrelevatoPerLista(string CodLista, string UDC) + { + esitoOperazione answ = esitoOperazione.errore; + + /* + * Questa funzione va chiamata da web o da terminalino ogni volta che si fa un annullamento di avvenuto prelievo, ovvero il carrellista ha ANNULLATO un prelievo di un UDC associato ad una lista + * + * - in primis controllo: esiste questa riga di prelievo udc/lista? + * - se i dati non corrispondono esco e mando falso --> vedere l'enum in fondo al codice ed + * usare esitoOperazione.errore_mismatch + * - se i dati corrispondono allora + * - cerco riga e tolgo check come prelevato + * - se tutto ok passo esito ok + * + * */ + try + { + // ricavo dati + DS_magazzino.RigheListePrelievoDataTable tabella = taRigheListePrelievo.getByCodLista(CodLista); + DS_magazzino.RigheListePrelievoRow riga = tabella[0]; + + // se i dati esistono procedo - eseguo stored che setta non prelevato = false per la riga selezionata + if (tabella.Rows.Count > 0) + { + taRigheListePrelievo.setAnnullaUdcPrelevato(CodLista, UDC); + answ = esitoOperazione.ok; + } + + else + { + answ = esitoOperazione.errore_mismatch; + } + } + catch + { } + return answ; + } + /// + /// Rigenera una Lista di prelievo togliendo gli UDC non ancora prelevati rimettendo in logica FIFO gli UDC "liberi" disponibili + /// + /// codice della lista di prelievo + /// esito comando + public esitoOperazione scambiaUdcPerLista(string CodLista) + { + esitoOperazione answ = esitoOperazione.errore; + + /* + * Questa funzione va chiamata da web o da terminalino ogni volta che si fa una richiesta di cambio per un UDC già prelevato, ovvero un altro carrellista prelevato un UDC associato alla mia lista corrente - rigenera UDC da prelevare + * */ + try + { + // ricavo dati + DS_magazzino.ElencoListePrelievoRow riga = taElencoListePrelievo.getByCodLista(CodLista)[0]; + // svuoto PRIMA gli UDC non prelevati + taRigheListePrelievo.stp_RigheListePrelievo_eliminaNonPrelevate(CodLista); + // rigenero righe UDC da prelevare + DS_magazzino.ElencoCartelliniDataTable tabellaElencoCartellini = taCartellini.getUdcUnusedOlder(CodLista); + allocaRigheListaPrelievo(riga.QtaTot, CodLista, tabellaElencoCartellini); + } + catch + { } + return answ; + } + /// + /// Aggiunge UN SOLO UDC in logica FIFO tra gli UDC "liberi" disponibili + /// + /// codice della lista di prelievo + /// esito comando + public esitoOperazione addUdcPerLista(string CodLista) + { + esitoOperazione answ = esitoOperazione.errore; + try + { + // ricavo dati + DS_magazzino.ElencoListePrelievoRow riga = taElencoListePrelievo.getByCodLista(CodLista)[0]; + // rigenero righe UDC da prelevare + DS_magazzino.ElencoCartelliniDataTable tabellaElencoCartellini = new DS_magazzino.ElencoCartelliniDataTable(); + // aggiungo l'UDC + vecchio (se c'è) + try + { + tabellaElencoCartellini.ImportRow(taCartellini.getUdcUnusedOlder(CodLista)[0]); + } + catch (Exception e) + { + logger.lg.scriviLog(String.Format("Errore in aggiunta UDC a lista prelievo: {0}", e), tipoLog.EXCEPTION); + } + allocaRigheListaPrelievo(riga.QtaTot, CodLista, tabellaElencoCartellini); + } + catch + { } + return answ; + } + /// + /// vero/falso che l'utent eha una lista di prelievo attiva + /// + public bool userHasActiveLP + { + get + { + bool answ = false; + try + { + answ = (MagClass.magazzino.taElencoListePrelievo.getByCodSogg(CodSoggCurrUser).Rows.Count > 0); + } + catch + { } + return answ; + } + } + /// + /// codice della lista di prelievo attiva + /// + public string codListaAttivaUtente + { + get + { + string answ = ""; + try + { + answ = MagClass.magazzino.taElencoListePrelievo.getByCodSogg(CodSoggCurrUser)[0].CodLista; + } + catch + { } + return answ; + } + } + /// + /// + /// + /// + /// + public bool listaPrelevabile(string CodLista) + { + bool answ = false; + try + { + answ = (MagClass.magazzino.taElencoListePrelievo.getByCodLista(CodLista).Select("CodStatoLista = 1").Length > 0); // filtro su stato = 1 (può esser presa in carico) + } + catch + { } + return answ; + } + + #endregion + + #region area rapporti qualità + + /// + /// Crea gli UDC da associare ai cartellini dei rapporti qualità deliberati, li associa e se richiesto lancia stampa + /// + /// identificativo rapp qualità + /// true/false se stampare + /// IP del client + /// + public bool creaUdcDaRappQualita(int numRapQual, string note, bool doPrint, string printerName, string clientIp) + { + bool answ = false; + string CodStato = ""; + // ottengo elenco righe dei cartellini del rapp qualità indicato SENZA righe UDC + DS_magazzino.RapQualDataTable tabRapQual = taRapQual.getByNumRapQualNoUdc(numRapQual); + // per prima cosa verifico che ci sia il rapporto di qualità in esame e che abbia righe da associare ad UDC + if (tabRapQual.Rows.Count > 0) + { + string UDC = ""; + foreach (DS_magazzino.RapQualRow rqRow in tabRapQual) + { + // se non ha già un UDC... e se NON E' stato già scaricato... + if (rqRow.UDC == "" && rqRow.LegaScaric.ToUpper() == "N") + { + answ = true; + // controllo se sia con benestare, se "N" imposto con stato Non accettata (da web.config) altrimenti con stato MP ok... + if (rqRow.BenesQual == "N") + { + CodStato = memLayer.ML.confReadString("CodStatoMP-NA"); + } + else + { + CodStato = memLayer.ML.confReadString("CodStatoMP"); + } + // per ogni riga creo un UDC + DS_Applicazione.ElencoCartelliniDataTable tabCartellini = DataProxy.obj.taCartellini.stp_insNewFull(memLayer.ML.cdv("CodCS"), memLayer.ML.confReadString("BilanciaMP"), string.Format("{0:yy}", DateTime.Now), rqRow.CodFor, rqRow.CodLega, "", "", "", "", DateTime.Now, 0, memLayer.ML.cdv("CodImballoMP"), CodSoggCurrUser, 0, memLayer.ML.cdvi("IdxPosizMP"), "M", "UDC_MP", rqRow.Qta, Convert.ToDouble(rqRow.Qta), 1, CodStato, rqRow.ProgUDC, false, note); // UDC_MP HARD CODED!!! try { - answ = taCelle.getByCodCella(CodCella)[0].IdxCella; // NON controllo il CodCS... - } - catch - { } - return answ; - } - /// - /// restituisce il CodCella dato l'IdxCella - /// - /// Codice company/sito - /// - /// - public string CodCellaByIdxCella(string CodCS, int IdxCella) - { - string answ = ""; - try - { - answ = taCelle.getByIdxCella(IdxCella)[0].CodCella; // NON controllo il CodCS... - } - catch - { } - return answ; - } - /// - /// verifica se la cella indicata sia attiva - /// - /// Codice company/sito - /// - /// - public bool cellaAttiva(string CodCS, int IdxCella) - { - bool answ = false; - try - { - answ = taCelle.getByIdxCella(IdxCella)[0].Attiva; // NON controllo il CodCS... - } - catch - { } - return answ; - } - /// - /// verifica se la cella indicata sia piena - /// - /// Codice company/sito - /// - /// - public bool cellaPiena(string CodCS, int IdxCella) - { - bool answ = false; //default non piena = permette caricamento - int idxTipoCella = 0; - bool checkPiena = true; - try - { - // controllo il tipo cella, se richiede check piena (altrimenti do ok...) - idxTipoCella = taCelle.getByIdxCella(IdxCella)[0].IdxTipoCella; - checkPiena = taTipoCella.getByIdx(idxTipoCella)[0].CheckPiena; - } - catch - { } - if (checkPiena) - { - try - { - // faccio controllo effettivo cella piena - answ = taCelle.getByIdxCella(IdxCella)[0].Piena; // NON controllo il CodCS... - } - catch - { } - } - return answ; - } - /// - /// restituisce cod UDC associato ad una cella - /// - /// Codice company/sito - /// - /// - public string udcInCella(string CodCS, int IdxCella) - { - string answ = ""; - try - { - answ = taPosUdcCorr.getByIdxCella(IdxCella)[0].UDC; - } - catch - { } - return answ; - } - /// - /// verifica la cella indicata sia valida, ovvero esistente - /// - /// - /// - public bool checkCella(string CodCella) - { - bool answ = false; - try - { - answ = (taCelle.getByCodCella(CodCella).Rows.Count > 0); - } - catch - { } - return answ; - } - /// - /// verifica se il particolare indicato sia valido, ovvero esistente - /// - /// Codice company/sito - /// - /// - public bool checkParticolare(string CodCS, string Particolare) - { - bool answ = false; - try - { - answ = (utils.obj.taSelParticolari.getByConditioValue(Particolare, "*").Rows.Count > 0); - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Errore in check particolare:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); - } - return answ; - } - /// - /// restituisce il num di UDC che corrispondono alla richiesta indicata - /// - /// - /// - /// - /// - /// - /// - /// - public int numUdcDaPart(string CodCS, string Particolare, string codEsponente, string codFigura, string CodImballo, string codTipoLista) - { - int answ = 0; - try - { - answ = taVParticolariOverwiew.getByDatiListaPrelievo(Particolare, CodCS, codEsponente, codFigura, CodImballo, codTipoLista)[0].NumUDC; - } - catch - { } - return answ; - } - /// - /// verifica se l'UDC sia riattivabile, ovvero - /// - sia permesso da web.config - /// - l'UDC sia in un mag che permette riattivazione - /// - /// - /// - public bool udcIsRiattivabile(string UDC) - { - bool answ = false; - // se permesso da web config controllo - if (memLayer.ML.confReadBool("riattUdcPermessa")) - { - try - { - // recupero posizione attuale - int IdxPosizione = taCartellini.getDetailsUdcByUdc(UDC)[0].IdxPosizione; - // verifico se riattivabile - answ = taAnagPos.getByIdxPosizione(IdxPosizione)[0].IsRiattivaEnabled; - } - catch (Exception e) - { - logger.lg.scriviLog(string.Format("Errore nella riattivazione dell'UDC {0}:{1}{2}", UDC, Environment.NewLine, e), tipoLog.EXCEPTION); - } - } - return answ; - } - - #endregion - - #region liste di prelievo - - /// - /// Crea una lista di prelievo andando a prenotare gli UDC del particolare richiesto in logica FIFO - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public string creaListaPrelievo(string CodCS, string TipoListaPrelievo, string Particolare, string Esponente, string Figura, decimal QtaTot, string CodImballo, string Destinatario, string DestinatarioDescrizione) - { - /* - * - ordini gli UDC per data dal + vecchio (data fusione? direi di si!) - * - * - prenda 1 ad 1 gli UDC, e crei dall'UDC un record in RigheListePrelievo con - * - CodLista (dal record appena generato) - * - UDC (il + vecchio trovato) - * - QTA (dell'UDC) - * - Proposto = 1 (vero) - * - Prelevato = 0 (falso) - * - questo loop di prelievo va eseguito fino a quanto la somam delle qty sia maggiore o uguale alla qty richiesta, o fino a quando siano finiti gli UDC - * - * - potrebbe esser cambiato approccio e si potrebbe fare una query ceh seleziona i + vecchi UDC in numero corretto fin dall'inizio da includere facendo una cosa del tipo - * - calcolo media qty degli UDC papabili x le condizioni dette prima - * - dato il totale ottengo quanti UDC mi servono arrotondando x eccesso (se ho 200 richiesti, media 70, CEIL(200/70) = 3) - * - faccio un SELECT TOP n (qui 3) * FROM ElencoCartellini WHERE ... - * - e questa select la uso x farci un INSERT INTO in RigheListePrelievo - * - * - terminati questi step si aggiorna la lista di prelievo emttendo come qty quella data dalla somma degli UDC davvero proposti - * - * - la stored deve restituire il codice della lista di prelievo e passarla qui, che a sua volta passerà al chiamante il codice della lista - * */ - - string answ = "K"; - - // variabile di tipo datetime per data corrente - DateTime adesso = DateTime.Now; - // non la valorizzo qui ma calcolo ... se non fa verificare - string RagioneSociale = ""; - - // ricavo da session... - string CodSoggetto = CodSoggCurrUser; - // proseguo SOLO se ho trovato cod soggetto... - if (CodSoggetto != "") - { - // li ricavo da db successivamente - string DisegnoGrezzo = ""; - string DescParticolare = ""; - string codCliente = ""; - - - // ricavo codCliente - try - { - codCliente = DataProxy.obj.taAnagParticolari.getByParticolare(Particolare)[0].CodCliente; - } - catch { } - - // ricavo DisegnoGrezzo - try - { - DisegnoGrezzo = DataProxy.obj.taAnagParticolari.getByParticolare(Particolare)[0].DisegnoGrezzo; - } - catch { } - - try - { - DescParticolare = DataProxy.obj.taAnagParticolari.getByParticolare(Particolare)[0].DescParticolare; - } - catch { } - - // dato codcliente ricavo la ragione sociale - try - { - RagioneSociale = DataProxy.obj.taAnagClienti.getRagioneSocialeByCodCliente(codCliente)[0].RagSociale; - } - catch { } - - - string codListaAttuale = ""; - try - { - // eseguo soltanto la query (meglio con try catch così se non c'è non dà errore...) - DS_magazzino.ElencoListePrelievoDataTable tabellaElencoListe = taElencoListePrelievo.InsertQuery(string.Format("{0:yy}", adesso), string.Format("{0:MM}", adesso), TipoListaPrelievo, memLayer.ML.cdv("CodCS"), codCliente, RagioneSociale, CodSoggetto, Particolare, DescParticolare, DisegnoGrezzo, Esponente, Figura, CodImballo, QtaTot, Destinatario, DestinatarioDescrizione); - - // ricavo prima (e unica) riga dalla select - DS_magazzino.ElencoListePrelievoRow rigaElencoListe = tabellaElencoListe[0]; - - // ricavo valore del CodLista attuale appena inserito - codListaAttuale = rigaElencoListe.CodLista; - } - catch (Exception e) - { - logger.lg.scriviLog(string.Format("Eccezione creazione lista prelievo: {0}{1}", Environment.NewLine, e), tipoLog.ERROR); - } - if (codListaAttuale != "") - { - answ = codListaAttuale; - DS_magazzino.ElencoCartelliniDataTable tabellaElencoCartellini = taCartellini.getUdcUnusedOlder(codListaAttuale); - allocaRigheListaPrelievo(QtaTot, codListaAttuale, tabellaElencoCartellini); - } - } - return answ; - } - /// - /// Crea una lista di prelievo andando a prenotare gli UDC del particolare richiesto in logica FIFO - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public string creaListaPrelievoSmart(string CodCS, string TipoListaPrelievo, string Particolare, string Esponente, string Figura, decimal QtaTot, string CodImballo, string Destinatario, string DestinatarioDescrizione) - { - string answ = "K"; - - // variabile di tipo datetime per data corrente - DateTime adesso = DateTime.Now; - // non la valorizzo qui ma calcolo ... se non fa verificare - string RagioneSociale = ""; - - // ricavo da session... - string CodSoggetto = CodSoggCurrUser; - // proseguo SOLO se ho trovato cod soggetto... - if (CodSoggetto != "") - { - // li ricavo da db successivamente - string DisegnoGrezzo = ""; - string DescParticolare = ""; - string codCliente = ""; - - - // ricavo codCliente - try - { - codCliente = DataProxy.obj.taAnagParticolari.getByParticolare(Particolare)[0].CodCliente; - } - catch { } - - // ricavo DisegnoGrezzo - try - { - DisegnoGrezzo = DataProxy.obj.taAnagParticolari.getByParticolare(Particolare)[0].DisegnoGrezzo; - } - catch { } - - try - { - DescParticolare = DataProxy.obj.taAnagParticolari.getByParticolare(Particolare)[0].DescParticolare; - } - catch { } - - // dato codcliente ricavo la ragione sociale - try - { - RagioneSociale = DataProxy.obj.taAnagClienti.getRagioneSocialeByCodCliente(codCliente)[0].RagSociale; - } - catch { } - - - string codListaAttuale = ""; - try - { - // eseguo soltanto la query (meglio con try catch così se non c'è non dà errore...) - DS_magazzino.ElencoListePrelievoDataTable tabellaElencoListe = taElencoListePrelievo.InsertQuery(string.Format("{0:yy}", adesso), string.Format("{0:MM}", adesso), TipoListaPrelievo, memLayer.ML.cdv("CodCS"), codCliente, RagioneSociale, CodSoggetto, Particolare, DescParticolare, DisegnoGrezzo, Esponente, Figura, CodImballo, QtaTot, Destinatario, DestinatarioDescrizione); - - // ricavo prima (e unica) riga dalla select - DS_magazzino.ElencoListePrelievoRow rigaElencoListe = tabellaElencoListe[0]; - - // ricavo valore del CodLista attuale appena inserito - codListaAttuale = rigaElencoListe.CodLista; - } - catch (Exception e) - { - logger.lg.scriviLog(string.Format("Eccezione creazione lista prelievo: {0}{1}", Environment.NewLine, e), tipoLog.ERROR); - } - if (codListaAttuale != "") - { - answ = codListaAttuale; - } - } - return answ; - } - /// - /// indica come attivata in carico di una lista di prelievo - /// - /// Codice company/sito - /// codice della lista di prelievo - /// cod operatore carrellista - /// - public esitoOperazione attivaListaPrelievo(string CodCS, string CodLista, string CodSoggetto) - { - // da chiamare quando clicco e inizio lista prelievo .... vedi sopra - esitoOperazione answ = esitoOperazione.errore; - try - { - // la query recupera la lista in base al CodLista - DS_magazzino.ElencoListePrelievoDataTable tabella = taElencoListePrelievo.getByCodLista(CodLista); - DS_magazzino.ElencoListePrelievoRow riga = tabella[0]; - - // se la lista esiste... - if (tabella.Rows.Count > 0) - { - // se la lista è ancora non completata - if (riga.CodStatoLista == (int)statoLista.bozza) - { - taElencoListePrelievo.updateStato(CodSoggetto, CodLista, (int)statoLista.generata); - answ = esitoOperazione.ok; - } - // se è solo iniziata permetto di riportarla a generata... - else if (riga.CodStatoLista == (int)statoLista.iniziata) - { - taElencoListePrelievo.updateStato(CodSoggetto, CodLista, (int)statoLista.generata); - answ = esitoOperazione.ok; - } - // se è già completata dà errore - else - { - answ = esitoOperazione.errore_readOnly; - } - } - // se la lista non esiste dai errore - else - { - answ = esitoOperazione.errore; - } - } - catch - { } - return answ; - } - /// - /// indica presa in carico di una lista di prelievo - /// - /// Codice company/sito - /// codice della lista di prelievo - /// cod operatore carrellista - /// - public esitoOperazione iniziaListaPrelievo(string CodCS, string CodLista, string CodSoggetto) - { - memLayer.ML.setSessionVal("activeTask", string.Format("Lista Prelievo {0}", CodLista)); - memLayer.ML.setSessionVal("CodListaAttiva", CodLista, true); - // da chiamare quando clicco e inizio lista prelievo .... vedi sopra - esitoOperazione answ = esitoOperazione.errore; - - try - { - // la query recupera la lista in base al CodLista - DS_magazzino.ElencoListePrelievoDataTable tabella = taElencoListePrelievo.getByCodLista(CodLista); - DS_magazzino.ElencoListePrelievoRow riga = tabella[0]; - - // se la lista esiste... - if (tabella.Rows.Count > 0) - { - // se la lista è ancora non completata - if (riga.CodStatoLista == (int)statoLista.generata) - { - taElencoListePrelievo.updateStato(CodSoggetto, CodLista, (int)statoLista.iniziata); - answ = esitoOperazione.ok; - } - // se è già completata o iniziata dà errore - else - { - answ = esitoOperazione.errore_readOnly; - } - } - // se la lista non esiste dai errore - else - { - answ = esitoOperazione.errore; - } - } - catch - { } - return answ; - } - /// - /// indica come completata (da parte del magazziniere) una lista di prelievo - /// - /// Codice company/sito - /// codice della lista di prelievo - /// cod operatore carrellista - /// IP del client - /// - public esitoOperazione completaListaPrelievo(string CodCS, string CodLista, string CodSoggetto, string clientIp) - { - // da chiamare quando clicco e inizio lista prelievo .... vedi sopra - esitoOperazione answ = esitoOperazione.errore; - try - { - // la query recupera la lista in base al CodLista - DS_magazzino.ElencoListePrelievoDataTable tabella = taElencoListePrelievo.getByCodLista(CodLista); - DS_magazzino.ElencoListePrelievoRow riga = tabella[0]; - - // se la lista esiste... - if (tabella.Rows.Count > 0) - { - // se la lista è ancora non completata - if (riga.CodStatoLista == (int)statoLista.iniziata) - { - // controllo se ALMENO un UDC sia stsato prelevato - int numUdcPrelevati = taRigheListePrelievo.getByCodListaPrelevate(CodLista).Rows.Count; - if (numUdcPrelevati > 0) - { - // ricavo il codtipolista - string codTipoListaAttuale = riga.CodTipoLista; - - //leggo da tipoLista prelievo alcuni dati (es codcella di destinazione) - DS_magazzino.TipoListaPrelievoDataTable tabellaTipoLista = taTipoListaPrelievo.getByCodTipoLista(codTipoListaAttuale); - DS_magazzino.TipoListaPrelievoRow rigaTipoLista = tabellaTipoLista[0]; - - // leggo da righe lista prelievo il dato udc che mi serve - DS_magazzino.RigheListePrelievoDataTable tabellaRigheListaPrelievo = taRigheListePrelievo.getByCodListaPrelevate(CodLista); - DS_magazzino.RigheListePrelievoRow rigaListaPrelievo = tabellaRigheListaPrelievo[0]; - - // leggo il codice della cella... - string codCellaDestAttuale = rigaTipoLista.CodCella; - // lo trasformo x avere la cella di destinazione... - int idxCellaTo = taCelle.getByCodCella(codCellaDestAttuale)[0].IdxCella; - // sposto ("metto a terra") gli UDC - foreach (DS_magazzino.RigheListePrelievoRow row in tabellaRigheListaPrelievo.Rows) - { - // ricavo il codice UDC... - string _UDC = row.UDC; - // sposto UDC - spostaUDC(CodCS, _UDC, idxCellaTo, false, clientIp); - // dopo aver spostato UDC sistemo eventuali Righe di Prelievo x lo stesso UDC pending... - taRigheListePrelievo.stp_RLP_sbloccaNonPrelevate(CodLista, _UDC); - } - // libero le righe non prelevate... - taRigheListePrelievo.stp_RLP_eliminaNonPrelevate(CodLista); - // aggiorno stato lista - taElencoListePrelievo.updateStato(CodSoggetto, CodLista, (int)statoLista.completata); - answ = esitoOperazione.ok; - memLayer.ML.emptySessionVal("CodListaAttiva"); - memLayer.ML.emptySessionVal("activeTask"); - } - else //nessun UDC prelevato - { - answ = esitoOperazione.errore_noUdc; - } - } - // se è già completata o NON iniziata dà errore - else - { - answ = esitoOperazione.errore_readOnly; - } - } - // se la lista non esiste dai errore - else - { - answ = esitoOperazione.errore; - } - } - catch - { } - return answ; - } - /// - /// Effettua lo scaricamento della lista di prelievo indicata, ovvero - /// - toglie dalle posizioni di magazzino tutti gli UDC indicati come prelevati (liberando tali posizioni) - /// - assegna tutti gli UDC prelevati alla cella indicata per il tipo di lista di prelievo interessata - /// - elimina eventuali righe di prelievo della lista per UDC non effettivamente prelevate - /// - chiude la lista di prelievo (completata = 1) - /// - /// Modifica vers 2.5: check trattamenti (ove attributo sia trovato...) - /// - /// Codice company/sito - /// codice della lista di prelievo - /// cod operatore carrellista - /// IP del client - /// Slot PL AS400 prescelto - /// esito comando - public esitoOperazione scaricaListaPrelievo(string CodCS, string CodLista, string CodSoggetto, string clientIp, int SlotPL) - { - /* - * Questa funzione serve ALLA FINE delle operazioni di prelievo, x chiudere la lista di prelievo - * - controllo se la lista esiste, ed è ancora NON completata - * - se risulta già completata errore xché è "readOnly" la lista essendo già completata (vedere l'enum in fondo al codice) - * - se la lista è ok - * - leggo da tipoLista prelievo alcuni dati (es codcella di destinazione) - * - sposto TUTTI gli UDC delle righeListaPrelievo, da posizione attuale a posizione indicata da tipo lista - * (quindi da codCella --> IdxCella --> spostamento - * - * - * 2014.06.12: aggiunta x gestione PackList AS400 - * - verifico imballi, salvo su tab movimenti gli imballi eventuali da scaricare - * - chiamo stored x copia dati pack list su AS400 - * - chiamo stored che richiamerà SSIS e quindi CL di as400 - * - * - * indico la lista come completata = 1 (true) - * */ - // setup eventuali valori x rettifica - bool fatto = false; - - esitoOperazione answ = esitoOperazione.errore; - int trovate = 0; - DS_magazzino.ElencoListePrelievoDataTable tabella; - DS_magazzino.ElencoListePrelievoRow riga; - try - { - tabella = taElencoListePrelievo.getByCodLista(CodLista); - riga = tabella[0]; - trovate = tabella.Rows.Count; - - // se la lista esiste... - if (trovate > 0) - { - // se la lista è completata - if (riga.CodStatoLista == (int)statoLista.completata) - { - // ricavo il codtipolista - string codTipoListaAttuale = riga.CodTipoLista; - - // leggo da tipoLista prelievo alcuni dati (es codcella di destinazione) - DS_magazzino.TipoListaPrelievoDataTable tabellaTipoLista = taTipoListaPrelievo.getByCodTipoLista(codTipoListaAttuale); - DS_magazzino.TipoListaPrelievoRow rigaTipoLista = tabellaTipoLista[0]; - - // leggo da righe lista prelievo il dato udc che mi serve - DS_magazzino.RigheListePrelievoDataTable tabellaRigheListaPrelievo = taRigheListePrelievo.getByCodListaPrelevate(CodLista); - DS_magazzino.RigheListePrelievoRow rigaListaPrelievo = tabellaRigheListaPrelievo[0]; - - // leggo il codice della cella... - string CodEvento = rigaTipoLista.CodEvento; - // posizione che devono avere (uguale) tutti gli UDC - int idxPosizUdcAll = 0; - // posizione corrente dell'UDC - int idxPosizUdcCorr = 0; - // posizione di destinazione per UDC corrente - int idxPosizUdcDest = 0; - // cella di provenienza - int idxCellaFrom = 0; - // cella di destinazione - int idxCellaTo = 0; - /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * ora controllo se la lista sia DAVVERO scaricabile, cioè - * - destinatario IMPOSTATO - * - TUTTE le righe hanno una posizione di destinazione valida, - * OVVERO tutte le righe hanno nella tab trans posiz eventi una riga valida - * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ - bool listaScaricabile = true; - if (riga.Destinatario == "") - { - listaScaricabile = false; - } - else - { - foreach (DS_magazzino.RigheListePrelievoRow row in tabellaRigheListaPrelievo.Rows) - { - // ricavo il codice UDC... - string UDC = row.UDC; - // mi serve per posizione udc corrente - DS_magazzino.PosizioneUdcCorrenteRow rigaUdcCorrente = taPosUdcCorr.getByUDC(UDC)[0]; - // calcolo posizione destinazione da state machine... - idxPosizUdcCorr = taCartellini.getDetailsUdcByUdc(UDC)[0].IdxPosizione; - if (idxPosizUdcAll == 0) - { - idxPosizUdcAll = idxPosizUdcCorr; - } - idxPosizUdcDest = StateMachine.SM.getIdxPostizioneTo(CodEvento, idxPosizUdcCorr); - if (idxPosizUdcDest == 0 || idxPosizUdcAll != idxPosizUdcCorr) - { - listaScaricabile = false; - } - } - } - // SE la lista è scaricabile procedo... - if (listaScaricabile) - { - // 2015.09.18: aggiunto controllo che NON ci siano UDC con NC - if (taRigheListePrelievo.getUdcSenzaDelibPM(CodLista).Rows.Count == 0) - { - if (taRigheListePrelievo.getUdcConNC(CodLista).Rows.Count == 0) - { - if (taRigheListePrelievo.getDmtxUdcConNc(CodLista).Rows.Count == 0) - { - // scarico i vari UDC dal magazzino (come posizione corrente) - foreach (DS_magazzino.RigheListePrelievoRow row in tabellaRigheListaPrelievo.Rows) - { - // ricavo il codice UDC... - string UDC = row.UDC; - // mi serve per posizione udc corrente - DS_magazzino.PosizioneUdcCorrenteRow rigaUdcCorrente = taPosUdcCorr.getByUDC(UDC)[0]; - // il secondo idx che mi serve - idxCellaFrom = rigaUdcCorrente.IdxCella; - // calcolo posizione destinazione da state machine... - idxPosizUdcCorr = taCartellini.getDetailsUdcByUdc(UDC)[0].IdxPosizione; - idxPosizUdcDest = StateMachine.SM.getIdxPostizioneTo(CodEvento, idxPosizUdcCorr); - // a questo punto mi calcolo se c'è una cella di destinazione associata - try - { - idxCellaTo = MagClass.magazzino.taCelle.getByCodMag(CodCS, idxPosizUdcDest.ToString())[0].IdxCella; - } - catch - { - idxCellaTo = 0; - } - // sposto UDC, e così facendo genero movimenti batch x AS400 - fatto = scaricaUDC(UDC, idxPosizUdcDest, CodEvento, clientIp); - // sposto nella PRIMA cella di destinazione associata l'UDC - if (idxCellaTo > 0) - { - spostaUDC(CodCS, UDC, idxCellaTo, false, clientIp); - } - if (fatto) - { - // dopo aver scaricato UDC sistemo eventuali Righe di Prelievo x lo stesso pending... - magazzino.taRigheListePrelievo.stp_RLP_sbloccaNonPrelevate(CodLista, UDC); - } - } - // ora step finali x LDP - try - { - // STEP 1: segna come scaricata la lista prelievo - taElencoListePrelievo.updateStato(CodSoggetto, CodLista, (int)statoLista.scaricata); - // STEP 2: chiamo esportazione verso MovMag AS x imballi + copiare in altra tabella (quella per AS...) i dati della packing - taElencoListePrelievo.stp_LP_exportToAs400(CodLista, SlotPL, CodCS); - // STEP 3: chiamo stored x eseguire SSIS che a sua volta richiama la CL di AS400 x importazione MovMag - utils.obj.taAs400.stp_processaCodaMovimPackList(); - // restituisce ok - answ = esitoOperazione.ok; - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Errore in trasferimento dati LDP verso AS400: {0}", exc), tipoLog.EXCEPTION); - } - } - else - { - answ = esitoOperazione.errore_DtmxNc; - } - } - else - { - answ = esitoOperazione.errore_UdcNc; - } - } - else - { - answ = esitoOperazione.errore_noDeliberPM; - } - } - else - { - answ = esitoOperazione.errore_nonScaricabile; - } - } - // se è già completata dà errore - else - { - answ = esitoOperazione.errore_readOnly; - } - } - // se la lista non esiste dai errore - else - { - answ = esitoOperazione.errore; - } - } - catch - { } - return answ; - } - /// - /// resetta (riporta in bozza) una lista di prelievo, spostando gli UDC alla posizione standard precedente - /// - /// Codice company/sito - /// codice della lista di prelievo - /// cod operatore carrellista - /// IP del client - /// - public esitoOperazione resetListaPrelievo(string CodCS, string CodLista, string CodSoggetto, string clientIp) - { - memLayer.ML.emptySessionVal("CodListaAttiva"); - memLayer.ML.emptySessionVal("activeTask"); - // da chiamare quando clicco e inizio lista prelievo .... vedi sopra - esitoOperazione answ = esitoOperazione.errore; - // posizione corrente dell'UDC - int idxPosizUdcAll = 0; // posizione che devono avere (uguale) tutti gli UDC - int idxPosizUdcCorr = 0; - int IdxPosizioneTo = 0; - int idxPosizUdcDest = 0; - int idxCellaTo = 0; - try - { - // la query recupera la lista in base al CodLista - DS_magazzino.ElencoListePrelievoDataTable tabella = taElencoListePrelievo.getByCodLista(CodLista); - DS_magazzino.ElencoListePrelievoRow riga = tabella[0]; - - // se la lista esiste... - if (tabella.Rows.Count > 0) - { - // ricontrollo che la lista sia completata - if (riga.CodStatoLista >= (int)statoLista.completata) - { - // calcolo tipo lista di prelievo - string codTipoListaAttuale = riga.CodTipoLista; - // dal tipo lista determino l'evento - string codEvento = taTipoListaPrelievo.getByCodTipoLista(codTipoListaAttuale)[0].CodEvento; - // 2014.07.10 ATTENZIONE cablato evento reset come Pre --> Rst - codEvento = codEvento.Replace("Pre", "Rst"); - // leggo da righe lista prelievo il dato udc che mi serve - DS_magazzino.RigheListePrelievoDataTable tabellaRigheListaPrelievo = taRigheListePrelievo.getByCodListaPrelevate(CodLista); - DS_magazzino.RigheListePrelievoRow rigaListaPrelievo = tabellaRigheListaPrelievo[0]; - - /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * ora controllo se la lista sia DAVVERO scaricabile, cioè - * - destinatario IMPOSTATO - * - TUTTE le righe hanno una posizione di destinazione valida, - * OVVERO tutte le righe hanno nella tab trans posiz eventi una riga valida - * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ - bool listaScaricabile = true; - if (riga.Destinatario == "") - { - listaScaricabile = false; - } - else - { - foreach (DS_magazzino.RigheListePrelievoRow row in tabellaRigheListaPrelievo.Rows) - { - // ricavo il codice UDC... - string UDC = row.UDC; - //// mi serve per posizione udc corrente - //DS_magazzino.PosizioneUdcCorrenteRow rigaUdcCorrente = taPosUdcCorr.getByUDC(UDC)[0]; - // calcolo posizione destinazione da state machine... - idxPosizUdcCorr = taCartellini.getDetailsUdcByUdc(UDC)[0].IdxPosizione; - if (idxPosizUdcAll == 0) - { - idxPosizUdcAll = idxPosizUdcCorr; - } - idxPosizUdcDest = StateMachine.SM.getIdxPostizioneTo(codEvento, idxPosizUdcCorr); - if (idxPosizUdcDest == 0 || idxPosizUdcAll != idxPosizUdcCorr) - { - listaScaricabile = false; - } - } - } - // procedo SOLO se lista scaricabile... - if (listaScaricabile) - { - // Modifica x gestione "blocco " da stato LDP: PRIMA passo a bozza... - taElencoListePrelievo.updateStato(CodSoggetto, CodLista, (int)statoLista.bozza); - // sposto ("metto a terra") gli UDC - string _UDC = ""; - foreach (DS_magazzino.RigheListePrelievoRow row in tabellaRigheListaPrelievo.Rows) - { - // ricavo il codice UDC... - _UDC = row.UDC; - // posizione corrente - idxPosizUdcCorr = taCartellini.getDetailsUdcByUdc(_UDC)[0].IdxPosizione; - // calcolo posizione destinazione da state machine... - try - { - IdxPosizioneTo = StateMachine.SM.taTTPE.getByEventoPosizione(codEvento, idxPosizUdcCorr)[0].IdxPosizioneTo; - } - catch (Exception exc) - { - IdxPosizioneTo = 0; - logger.lg.scriviLog(string.Format(" | {1} | Errore in reset lista prelievo nel calcolo IdxPosizioneTo: {0}", exc, clientIp), tipoLog.EXCEPTION); - } - if (IdxPosizioneTo != 0) - { - // lo trasformo x avere la cella di destinazione... - if (idxPosizUdcCorr < 0) - { - // se parto da cella negativa (consumato) calcolo destinazione da cella TO... - idxCellaTo = taCelle.getFirstByPosizione(IdxPosizioneTo.ToString())[0].IdxCella; - } - else - { - try - { - // altrimenti uso la posizione corrente (NON faccio vero spostamento... - idxCellaTo = taCelle.getFirstByPosizione(idxPosizUdcCorr.ToString())[0].IdxCella; - } - catch - { - // se parto da cella negativa (consumato) calcolo destinazione da cella TO... - idxCellaTo = taCelle.getFirstByPosizione(IdxPosizioneTo.ToString())[0].IdxCella; - } - } - // sposto UDC - spostaUDC(CodCS, _UDC, idxCellaTo, false, clientIp); - // 2014.07.09: modifica, per NON impostare da tab del magazzino con sposta fa update posizione esplicita - taCartellini.updateIdxPosizione(_UDC, IdxPosizioneTo, CodSoggCurrUser); - } - } - // indico le righe come NON prelevate... - taRigheListePrelievo.stp_RLP_resetPrelevate(CodLista); - //// aggiorno stato lista che torna a BOZZA - //taElencoListePrelievo.updateStato(CodSoggetto, CodLista, (int)statoLista.bozza); - answ = esitoOperazione.ok; - logger.lg.scriviLog(string.Format(" | {0} | resettata lista di prelievo UDC {1} | utente {2} | tipo {2}", clientIp, CodLista, CodSoggetto), tipoLog.INFO); - } - else - { - // loggo che c'è anomalia - answ = esitoOperazione.errore_readOnly; - logger.lg.scriviLog(string.Format(" | {0} | Errore in reset lista prelievo: non è stato possibile resettare per la posizione di almeno un UDC", clientIp), tipoLog.EXCEPTION); - } - } - // se è già completata o NON iniziata dà errore - else - { - answ = esitoOperazione.errore_readOnly; - } - } - // se la lista non esiste dai errore - else - { - answ = esitoOperazione.errore; - } + UDC = tabCartellini[0].UDC; + // lo associo! + taRapQual.stp_associaUDC(rqRow.ProgUDC, UDC); } catch (Exception e) { - logger.lg.scriviLog(string.Format(" | {1} | Errore in reset lista prelievo: {0}", e, clientIp), tipoLog.EXCEPTION); + logger.lg.scriviLog(string.Format(" | {3} | Non sono riuscito a creare associazione UDC / rapp qual: UDC creato: {0}, progRappQual: {1}, eccezione: {2}", UDC, rqRow.ProgUDC, e, clientIp), tipoLog.EXCEPTION); } - return answ; - } - - - /// - /// Conferma che un dato UDC è stato prelevato per soddisfare la lista di prelievo ed aggiorna o aggiunge riga in RigheListePrelievo - /// - /// codice della lista di prelievo - /// Codice UDC - /// esito comando - public esitoOperazione confermaUdcPrelevatoPerLista(string CodLista, string UDC) - { - esitoOperazione answ = esitoOperazione.errore; - - // verifico che i dati corrispondano con il metodo relativo (vedi sopra) - bool datiUdcOk = verificaDatiUdc(CodLista, UDC); - - if (datiUdcOk) - { - // richiamo stored di upsert - taRigheListePrelievo.upsertPrelevato(CodLista, UDC); - // ...dò risposta positiva - answ = esitoOperazione.ok; - - } - else - { - // altrimenti dò errore mismatch e non proseguo - return answ = esitoOperazione.errore_mismatch; - } - - return answ; - } - /// - /// annulla il prelievo di un UDC, aggiornando RigheListePrelievo (solo preventivato...) - /// - /// codice della lista di prelievo - /// Codice UDC - /// esito comando - public esitoOperazione annullaUdcPrelevatoPerLista(string CodLista, string UDC) - { - esitoOperazione answ = esitoOperazione.errore; - - /* - * Questa funzione va chiamata da web o da terminalino ogni volta che si fa un annullamento di avvenuto prelievo, ovvero il carrellista ha ANNULLATO un prelievo di un UDC associato ad una lista - * - * - in primis controllo: esiste questa riga di prelievo udc/lista? - * - se i dati non corrispondono esco e mando falso --> vedere l'enum in fondo al codice ed - * usare esitoOperazione.errore_mismatch - * - se i dati corrispondono allora - * - cerco riga e tolgo check come prelevato - * - se tutto ok passo esito ok - * - * */ try { - // ricavo dati - DS_magazzino.RigheListePrelievoDataTable tabella = taRigheListePrelievo.getByCodLista(CodLista); - DS_magazzino.RigheListePrelievoRow riga = tabella[0]; - - // se i dati esistono procedo - eseguo stored che setta non prelevato = false per la riga selezionata - if (tabella.Rows.Count > 0) - { - taRigheListePrelievo.setAnnullaUdcPrelevato(CodLista, UDC); - answ = esitoOperazione.ok; - } - - else - { - answ = esitoOperazione.errore_mismatch; - } + if (rqRow.BenesQual == "N") + { + // se non c'è benestare cambio posizione ad un altra cella, la prima (terra) del cod blocco MP - N.C. + int idxPosizTo = taCelle.getByCodMag(memLayer.ML.cdv("CodCS"), memLayer.ML.confReadString("CodMagMP_NA"))[0].IdxCella; + spostaUDC(memLayer.ML.cdv("CodCS"), UDC, idxPosizTo, true, clientIp); + } } - catch - { } - return answ; + catch (Exception e) + { + logger.lg.scriviLog(string.Format(" | {3} | Non sono riuscito a spostare UDC non conforme: UDC creato: {0}, progRappQual: {1}, eccezione: {2}", UDC, rqRow.ProgUDC, e, clientIp), tipoLog.EXCEPTION); + } + } } - /// - /// Rigenera una Lista di prelievo togliendo gli UDC non ancora prelevati rimettendo in logica FIFO gli UDC "liberi" disponibili - /// - /// codice della lista di prelievo - /// esito comando - public esitoOperazione scambiaUdcPerLista(string CodLista) + + // se devo stampare lancio stampa... + if (doPrint) { - esitoOperazione answ = esitoOperazione.errore; - - /* - * Questa funzione va chiamata da web o da terminalino ogni volta che si fa una richiesta di cambio per un UDC già prelevato, ovvero un altro carrellista prelevato un UDC associato alla mia lista corrente - rigenera UDC da prelevare - * */ - try - { - // ricavo dati - DS_magazzino.ElencoListePrelievoRow riga = taElencoListePrelievo.getByCodLista(CodLista)[0]; - // svuoto PRIMA gli UDC non prelevati - taRigheListePrelievo.stp_RigheListePrelievo_eliminaNonPrelevate(CodLista); - // rigenero righe UDC da prelevare - DS_magazzino.ElencoCartelliniDataTable tabellaElencoCartellini = taCartellini.getUdcUnusedOlder(CodLista); - allocaRigheListaPrelievo(riga.QtaTot, CodLista, tabellaElencoCartellini); - } - catch - { } - return answ; + stampaUdcDaRappQualita(numRapQual, printerName); } - /// - /// Aggiunge UN SOLO UDC in logica FIFO tra gli UDC "liberi" disponibili - /// - /// codice della lista di prelievo - /// esito comando - public esitoOperazione addUdcPerLista(string CodLista) - { - esitoOperazione answ = esitoOperazione.errore; - try - { - // ricavo dati - DS_magazzino.ElencoListePrelievoRow riga = taElencoListePrelievo.getByCodLista(CodLista)[0]; - // rigenero righe UDC da prelevare - DS_magazzino.ElencoCartelliniDataTable tabellaElencoCartellini = new DS_magazzino.ElencoCartelliniDataTable(); - // aggiungo l'UDC + vecchio (se c'è) - try - { - tabellaElencoCartellini.ImportRow(taCartellini.getUdcUnusedOlder(CodLista)[0]); - } - catch (Exception e) - { - logger.lg.scriviLog(String.Format("Errore in aggiunta UDC a lista prelievo: {0}", e), tipoLog.EXCEPTION); - } - allocaRigheListaPrelievo(riga.QtaTot, CodLista, tabellaElencoCartellini); - } - catch - { } - return answ; - } - /// - /// vero/falso che l'utent eha una lista di prelievo attiva - /// - public bool userHasActiveLP - { - get - { - bool answ = false; - try - { - answ = (MagClass.magazzino.taElencoListePrelievo.getByCodSogg(CodSoggCurrUser).Rows.Count > 0); - } - catch - { } - return answ; - } - } - /// - /// codice della lista di prelievo attiva - /// - public string codListaAttivaUtente - { - get - { - string answ = ""; - try - { - answ = MagClass.magazzino.taElencoListePrelievo.getByCodSogg(CodSoggCurrUser)[0].CodLista; - } - catch - { } - return answ; - } - } - /// - /// - /// - /// - /// - public bool listaPrelevabile(string CodLista) - { - bool answ = false; - try - { - answ = (MagClass.magazzino.taElencoListePrelievo.getByCodLista(CodLista).Select("CodStatoLista = 1").Length > 0); // filtro su stato = 1 (può esser presa in carico) - } - catch - { } - return answ; - } - - #endregion - - #region area rapporti qualità - - /// - /// Crea gli UDC da associare ai cartellini dei rapporti qualità deliberati, li associa e se richiesto lancia stampa - /// - /// identificativo rapp qualità - /// true/false se stampare - /// IP del client - /// - public bool creaUdcDaRappQualita(int numRapQual, string note, bool doPrint, string printerName, string clientIp) - { - bool answ = false; - string CodStato = ""; - // ottengo elenco righe dei cartellini del rapp qualità indicato SENZA righe UDC - DS_magazzino.RapQualDataTable tabRapQual = taRapQual.getByNumRapQualNoUdc(numRapQual); - // per prima cosa verifico che ci sia il rapporto di qualità in esame e che abbia righe da associare ad UDC - if (tabRapQual.Rows.Count > 0) - { - string UDC = ""; - foreach (DS_magazzino.RapQualRow rqRow in tabRapQual) - { - // se non ha già un UDC... e se NON E' stato già scaricato... - if (rqRow.UDC == "" && rqRow.LegaScaric.ToUpper() == "N") - { - answ = true; - // controllo se sia con benestare, se "N" imposto con stato Non accettata (da web.config) altrimenti con stato MP ok... - if (rqRow.BenesQual == "N") - { - CodStato = memLayer.ML.confReadString("CodStatoMP-NA"); - } - else - { - CodStato = memLayer.ML.confReadString("CodStatoMP"); - } - // per ogni riga creo un UDC - DS_Applicazione.ElencoCartelliniDataTable tabCartellini = DataProxy.obj.taCartellini.stp_insNewFull(memLayer.ML.cdv("CodCS"), memLayer.ML.confReadString("BilanciaMP"), string.Format("{0:yy}", DateTime.Now), rqRow.CodFor, rqRow.CodLega, "", "", "", "", DateTime.Now, 0, memLayer.ML.cdv("CodImballoMP"), CodSoggCurrUser, 0, memLayer.ML.cdvi("IdxPosizMP"), "M", "UDC_MP", rqRow.Qta, Convert.ToDouble(rqRow.Qta), 1, CodStato, rqRow.ProgUDC, false, note); // UDC_MP HARD CODED!!! - try - { - UDC = tabCartellini[0].UDC; - // lo associo! - taRapQual.stp_associaUDC(rqRow.ProgUDC, UDC); - } - catch (Exception e) - { - logger.lg.scriviLog(string.Format(" | {3} | Non sono riuscito a creare associazione UDC / rapp qual: UDC creato: {0}, progRappQual: {1}, eccezione: {2}", UDC, rqRow.ProgUDC, e, clientIp), tipoLog.EXCEPTION); - } - try - { - if (rqRow.BenesQual == "N") - { - // se non c'è benestare cambio posizione ad un altra cella, la prima (terra) del cod blocco MP - N.C. - int idxPosizTo = taCelle.getByCodMag(memLayer.ML.cdv("CodCS"), memLayer.ML.confReadString("CodMagMP_NA"))[0].IdxCella; - spostaUDC(memLayer.ML.cdv("CodCS"), UDC, idxPosizTo, true, clientIp); - } - } - catch (Exception e) - { - logger.lg.scriviLog(string.Format(" | {3} | Non sono riuscito a spostare UDC non conforme: UDC creato: {0}, progRappQual: {1}, eccezione: {2}", UDC, rqRow.ProgUDC, e, clientIp), tipoLog.EXCEPTION); - } - } - } - - // se devo stampare lancio stampa... - if (doPrint) - { - stampaUdcDaRappQualita(numRapQual, printerName); - } - } - return answ; - } - /// - /// aggiorna le note di un RDQ - /// - /// - /// - public bool updateNoteRDQ(int numRapQual, string note) - { - bool answ = false; - try - { - DataProxy.obj.taRQN.stp_UDC_updateNoteByRQ(numRapQual, note, CodSoggCurrUser); - answ = true; - } - catch - { } - return answ; - } - /// - /// effettua la (ri)stampa di TUTTI gli UDC dato un rapporto di qualità - /// - /// identificativo rapp qualità - /// - public bool stampaUdcDaRappQualita(int numRapQual, string printerName) - { - bool answ = false; - // ottengo elenco righe dei cartellini del rapp qualità indicato SENZA righe UDC - DS_magazzino.RapQualDataTable tabRapQual = taRapQual.getByNumRapQual(numRapQual); - // per prima cosa verifico che ci sia il rapporto di qualità in esame e che abbia righe da associare ad UDC - if (tabRapQual.Rows.Count > 0) - { - answ = true; - foreach (DS_magazzino.RapQualRow rqRow in tabRapQual) - { - answ = reportPrinter.obj.stampaCartellino(tipoCartellino.cartMP, rqRow.UDC, printerName); - } - } - return answ; - } - - - #endregion - - #region area utility - - /// - /// Decodifica il tipo barcode acquisito sino L5 - /// L1: comandi/matricole/DT e BCD - /// L2: Particolari/Imballi - /// L3: UDC - /// L4: AL - /// L5: DataMatrix - /// - public static tipoCodiceBarcode tipoBCode_L5(string valore) - { - tipoCodiceBarcode answ = tipoCodiceBarcode.ND; - int trovati = 0; - int matricola = -1; - // provo a convertire in intero barcode x verifica eventuale matricola... - try - { - matricola = Convert.ToInt32(valore); - } - catch - { } - // controllo non si tratti di un comando... - string preCmd = memLayer.ML.AppConf["prefComandi"]; - string preDT = memLayer.ML.AppConf["prefDateTime"]; - string preBCD = memLayer.ML.AppConf["prefBCode"]; - string preCodSogg = memLayer.ML.AppConf["prefCodSogg"]; - string statoDtx = ""; - string formatoDtx = ""; - // cerco di decodificare il Datamatrix... - try - { - DS_DataMatrix.stp_verificaDtxRow rowVerifica = DataMatrix.mgr.taVerifica.GetData(valore)[0]; - statoDtx = rowVerifica.StatoDtx; - formatoDtx = rowVerifica.FormatoDtmx; - } - catch - { } - if (valore.StartsWith(preCmd)) - { - answ = tipoCodiceBarcode.Comando; - } - else if (valore.StartsWith(preBCD)) - { - answ = tipoCodiceBarcode.BarCodeCMD; - } - else if (valore.StartsWith(preDT)) - { - // se lungh = 2+10 (DT+yyMMddHHmm) è SOLO datetime, altrimenti è DateTimeLine - if (valore.Length > 12) - { - answ = tipoCodiceBarcode.DateTimeLine; - } - else - { - answ = tipoCodiceBarcode.DateTime; - } - } - // cerco se c'è assieme logico - else if (MagClass.magazzino.checkAL(valore)) - { - answ = tipoCodiceBarcode.AL; - } - else if ((TermClass.Ter.riconosciBarcode(valore) == tipoCodiceBarcode.Particolare)) // è un particolare... - { - answ = tipoCodiceBarcode.Particolare; - } - else if (((statoDtx == "OK") || (statoDtx == "KO")) && formatoDtx != "") - { - answ = tipoCodiceBarcode.DataMatrixTrovato; - } - // controllo se sia un codice IMBALLO - else if (utils.obj.taSelImballi.getByImballo(valore).Rows.Count > 0) - { - // è imballo! - answ = tipoCodiceBarcode.Imballo; - } - else if (valore.StartsWith(preCodSogg)) - { - // cerco cod soggetto... - if (DataProxy.obj.taTrascSogg.getByKey(valore, 0).Rows.Count == 1) - { - answ = tipoCodiceBarcode.Operatore; - } - } - else if (matricola >= 0) - { - if (DataProxy.obj.taTrascSogg.getByKey("", matricola).Rows.Count == 1) - { - answ = tipoCodiceBarcode.Operatore; - } - } - else if ((statoDtx == "ND") && DataMatrix.mgr.maybeDatamatrix(valore)) // controllo se sia un POSSIBILE datamatrix poiché riesco a ricavare un partnumber noto... - { - answ = tipoCodiceBarcode.DataMatrixDecodificato; - } - else if (magazzino.taET.getByTratt(valore).Rows.Count > 0) - { - answ = tipoCodiceBarcode.TT; - } - else - { - try - { - // cerco tra UDC... - trovati = MagClass.magazzino.taCartellini.getByUdc(valore).Rows.Count; - if (trovati > 0) - { - answ = tipoCodiceBarcode.UDC; - } - } - catch - { - } - } - return answ; - } - - /// - /// Decodifica il tipo barcode acquisito sino L4 - /// L1: comandi/matricole/DT e BCD - /// L2: Particolari/Imballi - /// L3: UDC - /// L4: AL - /// - public static tipoCodiceBarcode tipoBCode_L4(string valore) - { - tipoCodiceBarcode answ = tipoCodiceBarcode.ND; - int trovati = 0; - int matricola = -1; - // provo a convertire in intero barcode x verifica eventuale matricola... - try - { - matricola = Convert.ToInt32(valore); - } - catch - { } - // controllo non si tratti di un comando... - string preCmd = memLayer.ML.AppConf["prefComandi"]; - string preDT = memLayer.ML.AppConf["prefDateTime"]; - string preBCD = memLayer.ML.AppConf["prefBCode"]; - string preCodSogg = memLayer.ML.AppConf["prefCodSogg"]; - if (valore.StartsWith(preCmd)) - { - answ = tipoCodiceBarcode.Comando; - } - else if (valore.StartsWith(preBCD)) - { - answ = tipoCodiceBarcode.BarCodeCMD; - } - else if (valore.StartsWith(preDT)) - { - // se lungh = 2+10 (DT+yyMMddHHmm) è SOLO datetime, altrimenti è DateTimeLine - if (valore.Length > 12) - { - answ = tipoCodiceBarcode.DateTimeLine; - } - else - { - answ = tipoCodiceBarcode.DateTime; - } - } - // cerco se c'è assieme logico - else if (MagClass.magazzino.checkAL(valore)) - { - answ = tipoCodiceBarcode.AL; - } - else if ((TermClass.Ter.riconosciBarcode(valore) == tipoCodiceBarcode.Particolare)) // è un particolare... - { - answ = tipoCodiceBarcode.Particolare; - } - // controllo se sia un codice IMBALLO - else if (utils.obj.taSelImballi.getByImballo(valore).Rows.Count > 0) - { - // è imballo! - answ = tipoCodiceBarcode.Imballo; - } - else if (valore.StartsWith(preCodSogg)) - { - // cerco cod soggetto... - if (DataProxy.obj.taTrascSogg.getByKey(valore, 0).Rows.Count == 1) - { - answ = tipoCodiceBarcode.Operatore; - } - } - else if (matricola >= 0) - { - if (DataProxy.obj.taTrascSogg.getByKey("", matricola).Rows.Count == 1) - { - answ = tipoCodiceBarcode.Operatore; - } - } - else if (magazzino.taET.getByTratt(valore).Rows.Count > 0) - { - answ = tipoCodiceBarcode.TT; - } - else - { - try - { - // cerco tra UDC... - trovati = MagClass.magazzino.taCartellini.getByUdc(valore).Rows.Count; - if (trovati > 0) - { - answ = tipoCodiceBarcode.UDC; - } - } - catch - { - } - } - return answ; - } - - /// - /// Decodifica il tipo barcode acquisito - /// checkL3 = verifica i livelli sino L3 - /// L1: comandi/matricole/DT e BCD - /// L2: Particolari/Imballi - /// L3: UDC - /// - public static tipoCodiceBarcode tipoBCode_L3(string valore) - { - tipoCodiceBarcode answ = tipoCodiceBarcode.ND; - int trovati = 0; - int matricola = -1; - // provo a convertire in intero barcode x verifica eventuale matricola... - try - { - matricola = Convert.ToInt32(valore); - } - catch - { } - // controllo non si tratti di un comando... - string preCmd = memLayer.ML.AppConf["prefComandi"]; - string preDT = memLayer.ML.AppConf["prefDateTime"]; - string preBCD = memLayer.ML.AppConf["prefBCode"]; - string preCodSogg = memLayer.ML.AppConf["prefCodSogg"]; - if (valore.StartsWith(preCmd)) - { - answ = tipoCodiceBarcode.Comando; - } - else if (valore.StartsWith(preBCD)) - { - answ = tipoCodiceBarcode.BarCodeCMD; - } - else if (valore.StartsWith(preDT)) - { - // se lungh = 2+10 (DT+yyMMddHHmm) è SOLO datetime, altrimenti è DateTimeLine - if (valore.Length > 12) - { - answ = tipoCodiceBarcode.DateTimeLine; - } - else - { - answ = tipoCodiceBarcode.DateTime; - } - } - else if ((TermClass.Ter.riconosciBarcode(valore) == tipoCodiceBarcode.Particolare)) // è un particolare... - { - answ = tipoCodiceBarcode.Particolare; - } - // controllo se sia un codice IMBALLO - else if (utils.obj.taSelImballi.getByImballo(valore).Rows.Count > 0) - { - // è imballo! - answ = tipoCodiceBarcode.Imballo; - } - else if (valore.StartsWith(preCodSogg)) - { - // cerco cod soggetto... - if (DataProxy.obj.taTrascSogg.getByKey(valore, 0).Rows.Count == 1) - { - answ = tipoCodiceBarcode.Operatore; - } - } - else if (matricola >= 0) - { - if (DataProxy.obj.taTrascSogg.getByKey("", matricola).Rows.Count == 1) - { - answ = tipoCodiceBarcode.Operatore; - } - } - else - { - try - { - // cerco tra UDC... - trovati = MagClass.magazzino.taCartellini.getByUdc(valore).Rows.Count; - if (trovati > 0) - { - answ = tipoCodiceBarcode.UDC; - } - } - catch - { - } - } - return answ; - } - - #endregion - - #region area utenti - - /// - /// recupera CognomeNome da CodSogg - /// - /// - /// - public string cognomeNomeFromCodSogg(object CodSogg) - { - string answ = ""; - try - { - DS_Applicazione.AnagOperatoriRow riga = DataProxy.obj.taAnagOperatore.getByCodSoggetto(CodSogg.ToString())[0]; - answ = string.Format("{0} {1}", riga.Cognome, riga.Nome); - } - catch - { } - return answ; - } - - #endregion - - #endregion - + } + return answ; } + /// + /// aggiorna le note di un RDQ + /// + /// + /// + public bool updateNoteRDQ(int numRapQual, string note) + { + bool answ = false; + try + { + DataProxy.obj.taRQN.stp_UDC_updateNoteByRQ(numRapQual, note, CodSoggCurrUser); + answ = true; + } + catch + { } + return answ; + } + /// + /// effettua la (ri)stampa di TUTTI gli UDC dato un rapporto di qualità + /// + /// identificativo rapp qualità + /// + public bool stampaUdcDaRappQualita(int numRapQual, string printerName) + { + bool answ = false; + // ottengo elenco righe dei cartellini del rapp qualità indicato SENZA righe UDC + DS_magazzino.RapQualDataTable tabRapQual = taRapQual.getByNumRapQual(numRapQual); + // per prima cosa verifico che ci sia il rapporto di qualità in esame e che abbia righe da associare ad UDC + if (tabRapQual.Rows.Count > 0) + { + answ = true; + foreach (DS_magazzino.RapQualRow rqRow in tabRapQual) + { + answ = reportPrinter.obj.stampaCartellino(tipoCartellino.cartMP, rqRow.UDC, printerName); + } + } + return answ; + } + + + #endregion + + #region area utility + + /// + /// Decodifica il tipo barcode acquisito sino L5 + /// L1: comandi/matricole/DT e BCD + /// L2: Particolari/Imballi + /// L3: UDC + /// L4: AL + /// L5: DataMatrix + /// + public static tipoCodiceBarcode tipoBCode_L5(string valore) + { + tipoCodiceBarcode answ = tipoCodiceBarcode.ND; + int trovati = 0; + int matricola = -1; + // provo a convertire in intero barcode x verifica eventuale matricola... + try + { + matricola = Convert.ToInt32(valore); + } + catch + { } + // controllo non si tratti di un comando... + string preCmd = memLayer.ML.AppConf["prefComandi"]; + string preDT = memLayer.ML.AppConf["prefDateTime"]; + string preBCD = memLayer.ML.AppConf["prefBCode"]; + string preCodSogg = memLayer.ML.AppConf["prefCodSogg"]; + string statoDtx = ""; + string formatoDtx = ""; + // cerco di decodificare il Datamatrix... + try + { + DS_DataMatrix.stp_verificaDtxRow rowVerifica = DataMatrix.mgr.taVerifica.GetData(valore)[0]; + statoDtx = rowVerifica.StatoDtx; + formatoDtx = rowVerifica.FormatoDtmx; + } + catch + { } + if (valore.StartsWith(preCmd)) + { + answ = tipoCodiceBarcode.Comando; + } + else if (valore.StartsWith(preBCD)) + { + answ = tipoCodiceBarcode.BarCodeCMD; + } + else if (valore.StartsWith(preDT)) + { + // se lungh = 2+10 (DT+yyMMddHHmm) è SOLO datetime, altrimenti è DateTimeLine + if (valore.Length > 12) + { + answ = tipoCodiceBarcode.DateTimeLine; + } + else + { + answ = tipoCodiceBarcode.DateTime; + } + } + // cerco se c'è assieme logico + else if (MagClass.magazzino.checkAL(valore)) + { + answ = tipoCodiceBarcode.AL; + } + else if ((TermClass.Ter.riconosciBarcode(valore) == tipoCodiceBarcode.Particolare)) // è un particolare... + { + answ = tipoCodiceBarcode.Particolare; + } + else if (((statoDtx == "OK") || (statoDtx == "KO")) && formatoDtx != "") + { + answ = tipoCodiceBarcode.DataMatrixTrovato; + } + // controllo se sia un codice IMBALLO + else if (utils.obj.taSelImballi.getByImballo(valore).Rows.Count > 0) + { + // è imballo! + answ = tipoCodiceBarcode.Imballo; + } + else if (valore.StartsWith(preCodSogg)) + { + // cerco cod soggetto... + if (DataProxy.obj.taTrascSogg.getByKey(valore, 0).Rows.Count == 1) + { + answ = tipoCodiceBarcode.Operatore; + } + } + else if (matricola >= 0) + { + if (DataProxy.obj.taTrascSogg.getByKey("", matricola).Rows.Count == 1) + { + answ = tipoCodiceBarcode.Operatore; + } + } + else if ((statoDtx == "ND") && DataMatrix.mgr.maybeDatamatrix(valore)) // controllo se sia un POSSIBILE datamatrix poiché riesco a ricavare un partnumber noto... + { + answ = tipoCodiceBarcode.DataMatrixDecodificato; + } + else if (magazzino.taET.getByTratt(valore).Rows.Count > 0) + { + answ = tipoCodiceBarcode.TT; + } + else + { + try + { + // cerco tra UDC... + trovati = MagClass.magazzino.taCartellini.getByUdc(valore).Rows.Count; + if (trovati > 0) + { + answ = tipoCodiceBarcode.UDC; + } + } + catch + { + } + } + return answ; + } + + /// + /// Decodifica il tipo barcode acquisito sino L4 + /// L1: comandi/matricole/DT e BCD + /// L2: Particolari/Imballi + /// L3: UDC + /// L4: AL + /// + public static tipoCodiceBarcode tipoBCode_L4(string valore) + { + tipoCodiceBarcode answ = tipoCodiceBarcode.ND; + int trovati = 0; + int matricola = -1; + // provo a convertire in intero barcode x verifica eventuale matricola... + try + { + matricola = Convert.ToInt32(valore); + } + catch + { } + // controllo non si tratti di un comando... + string preCmd = memLayer.ML.AppConf["prefComandi"]; + string preDT = memLayer.ML.AppConf["prefDateTime"]; + string preBCD = memLayer.ML.AppConf["prefBCode"]; + string preCodSogg = memLayer.ML.AppConf["prefCodSogg"]; + if (valore.StartsWith(preCmd)) + { + answ = tipoCodiceBarcode.Comando; + } + else if (valore.StartsWith(preBCD)) + { + answ = tipoCodiceBarcode.BarCodeCMD; + } + else if (valore.StartsWith(preDT)) + { + // se lungh = 2+10 (DT+yyMMddHHmm) è SOLO datetime, altrimenti è DateTimeLine + if (valore.Length > 12) + { + answ = tipoCodiceBarcode.DateTimeLine; + } + else + { + answ = tipoCodiceBarcode.DateTime; + } + } + // cerco se c'è assieme logico + else if (MagClass.magazzino.checkAL(valore)) + { + answ = tipoCodiceBarcode.AL; + } + else if ((TermClass.Ter.riconosciBarcode(valore) == tipoCodiceBarcode.Particolare)) // è un particolare... + { + answ = tipoCodiceBarcode.Particolare; + } + // controllo se sia un codice IMBALLO + else if (utils.obj.taSelImballi.getByImballo(valore).Rows.Count > 0) + { + // è imballo! + answ = tipoCodiceBarcode.Imballo; + } + else if (valore.StartsWith(preCodSogg)) + { + // cerco cod soggetto... + if (DataProxy.obj.taTrascSogg.getByKey(valore, 0).Rows.Count == 1) + { + answ = tipoCodiceBarcode.Operatore; + } + } + else if (matricola >= 0) + { + if (DataProxy.obj.taTrascSogg.getByKey("", matricola).Rows.Count == 1) + { + answ = tipoCodiceBarcode.Operatore; + } + } + else if (magazzino.taET.getByTratt(valore).Rows.Count > 0) + { + answ = tipoCodiceBarcode.TT; + } + else + { + try + { + // cerco tra UDC... + trovati = MagClass.magazzino.taCartellini.getByUdc(valore).Rows.Count; + if (trovati > 0) + { + answ = tipoCodiceBarcode.UDC; + } + } + catch + { + } + } + return answ; + } + + /// + /// Decodifica il tipo barcode acquisito + /// checkL3 = verifica i livelli sino L3 + /// L1: comandi/matricole/DT e BCD + /// L2: Particolari/Imballi + /// L3: UDC + /// + public static tipoCodiceBarcode tipoBCode_L3(string valore) + { + tipoCodiceBarcode answ = tipoCodiceBarcode.ND; + int trovati = 0; + int matricola = -1; + // provo a convertire in intero barcode x verifica eventuale matricola... + try + { + matricola = Convert.ToInt32(valore); + } + catch + { } + // controllo non si tratti di un comando... + string preCmd = memLayer.ML.AppConf["prefComandi"]; + string preDT = memLayer.ML.AppConf["prefDateTime"]; + string preBCD = memLayer.ML.AppConf["prefBCode"]; + string preCodSogg = memLayer.ML.AppConf["prefCodSogg"]; + if (valore.StartsWith(preCmd)) + { + answ = tipoCodiceBarcode.Comando; + } + else if (valore.StartsWith(preBCD)) + { + answ = tipoCodiceBarcode.BarCodeCMD; + } + else if (valore.StartsWith(preDT)) + { + // se lungh = 2+10 (DT+yyMMddHHmm) è SOLO datetime, altrimenti è DateTimeLine + if (valore.Length > 12) + { + answ = tipoCodiceBarcode.DateTimeLine; + } + else + { + answ = tipoCodiceBarcode.DateTime; + } + } + else if ((TermClass.Ter.riconosciBarcode(valore) == tipoCodiceBarcode.Particolare)) // è un particolare... + { + answ = tipoCodiceBarcode.Particolare; + } + // controllo se sia un codice IMBALLO + else if (utils.obj.taSelImballi.getByImballo(valore).Rows.Count > 0) + { + // è imballo! + answ = tipoCodiceBarcode.Imballo; + } + else if (valore.StartsWith(preCodSogg)) + { + // cerco cod soggetto... + if (DataProxy.obj.taTrascSogg.getByKey(valore, 0).Rows.Count == 1) + { + answ = tipoCodiceBarcode.Operatore; + } + } + else if (matricola >= 0) + { + if (DataProxy.obj.taTrascSogg.getByKey("", matricola).Rows.Count == 1) + { + answ = tipoCodiceBarcode.Operatore; + } + } + else + { + try + { + // cerco tra UDC... + trovati = MagClass.magazzino.taCartellini.getByUdc(valore).Rows.Count; + if (trovati > 0) + { + answ = tipoCodiceBarcode.UDC; + } + } + catch + { + } + } + return answ; + } + + #endregion + + #region area utenti + + /// + /// recupera CognomeNome da CodSogg + /// + /// + /// + public string cognomeNomeFromCodSogg(object CodSogg) + { + string answ = ""; + try + { + DS_Applicazione.AnagOperatoriRow riga = DataProxy.obj.taAnagOperatore.getByCodSoggetto(CodSogg.ToString())[0]; + answ = string.Format("{0} {1}", riga.Cognome, riga.Nome); + } + catch + { } + return answ; + } + + #endregion + + #endregion + + } } public enum esitoOperazione { - ok // tutto ok, come true + ok // tutto ok, come true , errore // non è andata errore generico , errore_mismatch // errore x mancanza corrispondenza tra dati (particolare-esponente-figura di lista ed UDC ad esempio) , errore_readOnly // errore xché il dato è read only o bloccato (es lista di prelievo già completata NON posso riprenderla in carico) @@ -3398,33 +3398,33 @@ public enum esitoOperazione public enum statoLista { - bozza = 0, - generata, - iniziata, - completata, - scaricata + bozza = 0, + generata, + iniziata, + completata, + scaricata } /// /// esito verifica NC su UDC /// public enum checkUdcNc { - /// - /// NESSUNA NC - /// - NoNc, - /// - /// controllo disabilitato/non bloccate, NC NON presenti - /// - ChkDis_NoNc, - /// - /// controllo disabilitato/non bloccate, NC presenti - /// - ChkDis_HasNc, - /// - /// ci sono NC, bloccante - /// - HasNc + /// + /// NESSUNA NC + /// + NoNc, + /// + /// controllo disabilitato/non bloccate, NC NON presenti + /// + ChkDis_NoNc, + /// + /// controllo disabilitato/non bloccate, NC presenti + /// + ChkDis_HasNc, + /// + /// ci sono NC, bloccante + /// + HasNc } /// @@ -3432,28 +3432,28 @@ public enum checkUdcNc /// public enum tipoAL { - /// - /// non definito - /// - ND, - /// - /// Assieme RX - /// - AL_RX, - /// - /// Assieme RX Datamatrix - /// - AL_RxDt, - /// - /// Assieme RX NON Datamatrix - /// - AL_RxNt, - /// - /// Assieme TT Datamatrix - /// - AL_TT, - /// - /// Assieme TT NON Datamatrix - /// - AL_LI + /// + /// non definito + /// + ND, + /// + /// Assieme RX + /// + AL_RX, + /// + /// Assieme RX Datamatrix + /// + AL_RxDt, + /// + /// Assieme RX NON Datamatrix + /// + AL_RxNt, + /// + /// Assieme TT Datamatrix + /// + AL_TT, + /// + /// Assieme TT NON Datamatrix + /// + AL_LI } \ No newline at end of file diff --git a/GMW_data/Odette.cs b/GMW_data/Odette.cs index e18ece56..c488c5af 100644 --- a/GMW_data/Odette.cs +++ b/GMW_data/Odette.cs @@ -4,118 +4,122 @@ using System; namespace GMW_data { + /// + /// fa da proxy singleton x gli oggetti legati ai cartellini ODETTE + /// + public class Odette + { /// - /// fa da proxy singleton x gli oggetti legati ai cartellini ODETTE + /// Oggetto locale gestione classe datamatrix... /// - public class Odette + protected DataMatrix DataMatrix_mgr = new DataMatrix(); + #region area table adapters + + public DS_OdetteTableAdapters.OdetteTableAdapter taOdette; + public DS_OdetteTableAdapters.BORI202JTableAdapter taBORI; + public DS_OdetteTableAdapters.stp_OdetteStatoCreateTableAdapter taOdCreate; + + /// + /// init dei table adapters + /// + protected void initTA() { - #region area table adapters + taOdette = new GMW_data.DS_OdetteTableAdapters.OdetteTableAdapter(); + taBORI = new GMW_data.DS_OdetteTableAdapters.BORI202JTableAdapter(); + taOdCreate = new GMW_data.DS_OdetteTableAdapters.stp_OdetteStatoCreateTableAdapter(); + } + /// + /// effettua setup dei connection strings da web.config delal singola applicazione + /// + protected virtual void setupConnectionStringBase() + { + string connString = memLayer.ML.confReadString("GMWConnectionString"); + // connections strings del db + taOdette.Connection.ConnectionString = connString; + taBORI.Connection.ConnectionString = connString; + taOdCreate.Connection.ConnectionString = connString; + } + #endregion - public DS_OdetteTableAdapters.OdetteTableAdapter taOdette; - public DS_OdetteTableAdapters.BORI202JTableAdapter taBORI; - public DS_OdetteTableAdapters.stp_OdetteStatoCreateTableAdapter taOdCreate; + protected Odette() + { + initTA(); + setupConnectionStringBase(); + } - /// - /// init dei table adapters - /// - protected void initTA() - { - taOdette = new GMW_data.DS_OdetteTableAdapters.OdetteTableAdapter(); - taBORI = new GMW_data.DS_OdetteTableAdapters.BORI202JTableAdapter(); - taOdCreate = new GMW_data.DS_OdetteTableAdapters.stp_OdetteStatoCreateTableAdapter(); - } - /// - /// effettua setup dei connection strings da web.config delal singola applicazione - /// - protected virtual void setupConnectionStringBase() - { - string connString = memLayer.ML.confReadString("GMWConnectionString"); - // connections strings del db - taOdette.Connection.ConnectionString = connString; - taBORI.Connection.ConnectionString = connString; - taOdCreate.Connection.ConnectionString = connString; - } - #endregion + #region area protected - protected Odette() - { - initTA(); - setupConnectionStringBase(); - } - - #region area protected - - /// - /// carica le label di lingua su un etichetta odette (che deve già esistere) - /// - /// - /// - /// - protected bool caricaEtichetteLinguaPerOdette(string UDC, string lingua) - { - bool answ = false; - // controllo se etichetta odette esiste... - if (taOdette.getByUdc(UDC).Rows.Count > 0) - { - // carico le mie labels tradotte... - string Campo1_1 = traduci("Campo1_1", lingua); - string Campo2_1 = traduci("Campo2_1", lingua); - string Campo3_1 = traduci("Campo3_1", lingua); - string Campo4_1 = traduci("Campo4_1", lingua); - string Campo5_1 = traduci("Campo5_1", lingua); - string Campo6_1 = traduci("Campo6_1", lingua); - string Campo7_1 = traduci("Campo7_1", lingua); - string Campo8_1 = traduci("Campo8_1", lingua); - string Campo9_1 = traduci("Campo9_1", lingua); - string Campo10_1 = traduci("Campo10_1", lingua); - string Campo11_1_1 = traduci("Campo11_1_1", lingua); - string Campo11_2_1 = traduci("Campo11_2_1", lingua); - string Campo12_1 = traduci("Campo12_1", lingua); - string Campo13_1 = traduci("Campo13_1", lingua); - string Campo14_1 = traduci("Campo14_1", lingua); - string Campo15_1 = traduci("Campo15_1", lingua); - string Campo16_1 = traduci("Campo16_1", lingua); - // effettuo update! - taOdette.updateLingua(UDC, Campo1_1, Campo2_1, Campo3_1, Campo4_1, Campo5_1, Campo6_1, Campo7_1, Campo8_1, Campo9_1, Campo10_1, Campo11_1_1, Campo11_2_1, Campo12_1, Campo13_1, Campo14_1, Campo15_1, Campo16_1); - } - else - { - logger.lg.scriviLog(string.Format("Attenzione! etichetta odette non trovata per l'UDC {0}", UDC), tipoLog.ERROR); - } - return answ; - } - /// - /// verifica una etichetta odette e salva in db il valore di check x consistenza dei dati - /// - /// - /// - protected bool updateStatoOdette(string UDC) - { - bool answ = false; - try - { - // effettuo verifiche sulla riga odette... - // !!!FARE!!! - answ = true; - taOdette.setStato(UDC, answ); - } - catch - { } - return answ; - } - /// - /// carica i dati per l'etichetta Odette provenienti dalla bolla indicata - /// - /// - /// - /// - /// codice bolla - /// data bolla formato YYYYMMDD - /// - /// - protected bool caricaDatiBollaEtichettaOdette(string UDC, string RaggMag, string GrpBolla, decimal numBolla, decimal dataBolla, string particolare) - { - // versione vecchia: ora faccio tutto con stored! + /// + /// carica le label di lingua su un etichetta odette (che deve già esistere) + /// + /// + /// + /// + protected bool caricaEtichetteLinguaPerOdette(string UDC, string lingua) + { + bool answ = false; + // controllo se etichetta odette esiste... + if (taOdette.getByUdc(UDC).Rows.Count > 0) + { + // carico le mie labels tradotte... + string Campo1_1 = traduci("Campo1_1", lingua); + string Campo2_1 = traduci("Campo2_1", lingua); + string Campo3_1 = traduci("Campo3_1", lingua); + string Campo4_1 = traduci("Campo4_1", lingua); + string Campo5_1 = traduci("Campo5_1", lingua); + string Campo6_1 = traduci("Campo6_1", lingua); + string Campo7_1 = traduci("Campo7_1", lingua); + string Campo8_1 = traduci("Campo8_1", lingua); + string Campo9_1 = traduci("Campo9_1", lingua); + string Campo10_1 = traduci("Campo10_1", lingua); + string Campo11_1_1 = traduci("Campo11_1_1", lingua); + string Campo11_2_1 = traduci("Campo11_2_1", lingua); + string Campo12_1 = traduci("Campo12_1", lingua); + string Campo13_1 = traduci("Campo13_1", lingua); + string Campo14_1 = traduci("Campo14_1", lingua); + string Campo15_1 = traduci("Campo15_1", lingua); + string Campo16_1 = traduci("Campo16_1", lingua); + // effettuo update! + taOdette.updateLingua(UDC, Campo1_1, Campo2_1, Campo3_1, Campo4_1, Campo5_1, Campo6_1, Campo7_1, Campo8_1, Campo9_1, Campo10_1, Campo11_1_1, Campo11_2_1, Campo12_1, Campo13_1, Campo14_1, Campo15_1, Campo16_1); + } + else + { + logger.lg.scriviLog(string.Format("Attenzione! etichetta odette non trovata per l'UDC {0}", UDC), tipoLog.ERROR); + } + return answ; + } + /// + /// verifica una etichetta odette e salva in db il valore di check x consistenza dei dati + /// + /// + /// + protected bool updateStatoOdette(string UDC) + { + bool answ = false; + try + { + // effettuo verifiche sulla riga odette... + // !!!FARE!!! + answ = true; + taOdette.setStato(UDC, answ); + } + catch + { } + return answ; + } + /// + /// carica i dati per l'etichetta Odette provenienti dalla bolla indicata + /// + /// + /// + /// + /// codice bolla + /// data bolla formato YYYYMMDD + /// + /// + protected bool caricaDatiBollaEtichettaOdette(string UDC, string RaggMag, string GrpBolla, decimal numBolla, decimal dataBolla, string particolare) + { + // versione vecchia: ora faccio tutto con stored! #if false bool answ = false; string ragSocCli = ""; @@ -371,343 +375,343 @@ namespace GMW_data } } #endif - bool answ = false; - try - { - taOdette.caricaDatiBollaEtichettaOdette(memLayer.ML.cdv("CodCS"), UDC, numBolla.ToString(), dataBolla.ToString(), RaggMag, GrpBolla, particolare); - answ = true; - } - catch - { - answ = false; - } - return answ; - } - - #endregion - - #region area public - - /// - /// singleton - /// - public static Odette mgr = new Odette(); - /// - /// wrapper traduzione - /// - /// - /// - /// - public string traduci(string lemma, string lingua) - { - return user_std.UtSn.Traduci(lemma, lingua); - } - - /// - /// verifica l'esistenza di una bolla dato il suo codice + data - /// - /// cod raggr magazzino - /// gruppo bolla - /// codice bolla NUMERICO - /// data bolla formato numerico YYYYMMDD - /// codice particolare - /// - public bool checkCodBolla(string RaggMag, string GrpBolla, decimal numBolla, decimal dataBolla, string particolare) - { - bool answ = false; - int righeBolla = 0; - // controllo che la bolla esista... - try - { - // provo a caricarle con stored... - taBORI.caricaDatiBolla(RaggMag, GrpBolla, numBolla.ToString(), dataBolla.ToString(), particolare); - // rileggo se presenti... - righeBolla = taBORI.getByKeyFull(RaggMag, GrpBolla, Convert.ToDecimal(numBolla), Convert.ToDecimal(dataBolla), particolare).Rows.Count; - answ = (righeBolla >= 1); - } - catch(Exception exc) - { - logger.lg.scriviLog(string.Format("Errore in checkCodBolla:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); - } - // controllo che la bolla non sia già associata... ovvero SENZA NESSUNA etichetta odette associata x quel particolare... - if (answ) - { - // controllo se trovo odette associate a tale bolla... - answ = (taOdette.getByBolla(RaggMag, GrpBolla, numBolla, dataBolla, particolare).Rows.Count == 0); - } - return answ; - } - /// - /// conteggia il num di colli x una data bolla - /// - /// cod raggr magazzino - /// gruppo bolla - /// codice bolla NUMERICO - /// data bolla formato numerico YYYYMMDD - /// codice particolare - /// - public int totColliBolla(string RaggMag, string GrpBolla, decimal numBolla, decimal dataBolla, string particolare) - { - int answ = 0; - try - { - // calcolo il totale dei pezzi: ogni riga contiene il totale colli della bolla... - //answ = (int)taBORI.getByKeyFull(RaggMag, GrpBolla, Convert.ToDecimal(numBolla), Convert.ToDecimal(dataBolla), particolare)[0].NRC1B; - answ = Convert.ToInt32(taBORI.getByKeyFull(RaggMag, GrpBolla, Convert.ToDecimal(numBolla), Convert.ToDecimal(dataBolla), particolare).Compute("SUM(NRC1B)", "")); - } - catch - { } - return answ; - } - /// - /// conteggia il num di pezzi x una data bolla - /// - /// cod raggr magazzino - /// gruppo bolla - /// codice bolla NUMERICO - /// data bolla formato numerico YYYYMMDD - /// codice particolare - /// - public int totPezziBolla(string RaggMag, string GrpBolla, decimal numBolla, decimal dataBolla, string particolare) - { - int answ = 0; - try - { - // rileggo se presenti... - answ = Convert.ToInt32(taBORI.getByKeyFull(RaggMag, GrpBolla, Convert.ToDecimal(numBolla), Convert.ToDecimal(dataBolla), particolare).Compute("SUM(QTCNS)", "")); - //answ = (int)taBORI.getByKeyFull(RaggMag, GrpBolla, Convert.ToDecimal(numBolla), Convert.ToDecimal(dataBolla), particolare)[0].QTCNS; - } - catch - { } - return answ; - } - - /// - /// crea tutte le righe encessarie alal stampa dei cartellini Odette dati lista di prelievo, bolla da associare - /// - /// codice lista di prelievo - /// cod raggr magazzino - /// gruppo bolla - /// codice bolla NUMERICO - /// data bolla formato numerico YYYYMMDD - /// codice particolare - /// IT/EN/... - /// in caso di errore e ritorno false, salva in sessione il messaggio di errore relativo in errCreazOdette - public bool creaOdetteByBollaPackList(string CodLista, string RaggMag, string GrpBolla, decimal numBolla, decimal dataBolla, string particolare, string lingua) - { - bool answ = false; - string errCreazOdette = ""; - int totUdc = 0; - int totPz = 0; - int udcOk = 0; - DS_magazzino.RigheListePrelievoDataTable ElencoUdc = new DS_magazzino.RigheListePrelievoDataTable(); - // conto totale etichette da creare - try - { - ElencoUdc = MagClass.magazzino.taRigheListePrelievo.getByCodLista(CodLista); - totUdc = ElencoUdc.Rows.Count; - totPz = (int)MagClass.magazzino.taElencoListePrelievo.getByCodLista(CodLista)[0].Prelevato; - } - catch - { - errCreazOdette = string.Format("Errore: non ci sono UDC da creare per la PackList {0}", CodLista); - logger.lg.scriviLog(errCreazOdette, tipoLog.ERROR); - } - // in primis comunque verifico che la bolla ci sia altrimenti non procedo (anche se avrebbe già dovuto controllare...) - if (checkCodBolla(RaggMag, GrpBolla, numBolla, dataBolla, particolare) && totUdc > 0) - { - // controllo se il totale colli corrisponde al totale UDC.. - if (totColliBolla(RaggMag, GrpBolla, numBolla, dataBolla, particolare) == totUdc || true) // controllo disattivato 2013.03.22 perché i colli riga sono i colli totali bolla - { - // controllo se il totale pezzi corrisponde al totale qta... - if (totPezziBolla(RaggMag, GrpBolla, numBolla, dataBolla, particolare) == totPz) - { - // leggo elenco UDC da packing list - foreach (DS_magazzino.RigheListePrelievoRow rigaUdc in ElencoUdc) - { - // per ogni UDC creo una riga - taOdette.upsertUdc(rigaUdc.UDC, memLayer.ML.cdv("CodCS"), numBolla.ToString(), dataBolla.ToString(), RaggMag, GrpBolla, particolare, CodLista, memLayer.ML.confReadString("indStabFrom"), rigaUdc.Qta.ToString()); - udcOk++; - // per ogni riga inserisco traduzione nella lingua richiesta - caricaEtichetteLinguaPerOdette(rigaUdc.UDC, lingua); - // vado a caricare i dati dalla tab dei dati bolle - caricaDatiBollaEtichettaOdette(rigaUdc.UDC, RaggMag, GrpBolla, numBolla, dataBolla, particolare); - // effettuo check della riga odette e determino se sia conforme - updateStatoOdette(rigaUdc.UDC); - } - } - else - { - errCreazOdette = string.Format("Errore assegnazione bolle/odette, il num di pezzi non corrisponde: num bolla {0} del {1}, lista prelievo {2}", numBolla, dataBolla, CodLista); - logger.lg.scriviLog(errCreazOdette, tipoLog.ERROR); - } - } - else - { - errCreazOdette = string.Format("Errore assegnazione bolle/odette, il num di colli non corrisponde: num bolla {0} del {1}, lista prelievo {2}", numBolla, dataBolla, CodLista); - logger.lg.scriviLog(errCreazOdette, tipoLog.ERROR); - } - } - else - { - errCreazOdette = string.Format("Tentativo di generazione etichette odette da bolla inesistente/già impiegata: codice {0} del {1}", numBolla, dataBolla); - logger.lg.scriviLog(errCreazOdette, tipoLog.ERROR); - } - // controllo se tutte le etichette sono sstate create - if (totUdc == udcOk) - { - answ = true; - } - memLayer.ML.setSessionVal("errCreazOdette", errCreazOdette); - return answ; - } - /// - /// Stampa tutte le etichette odette di una lista di prelievo - /// - /// - /// - /// - public bool stampaOdettePackingList(string CodLista, string printerName) - { - bool answ = false; - int totOdette = 0; - DS_Odette.OdetteDataTable ElencoOdette = new DS_Odette.OdetteDataTable(); - // conto totale etichette Odette con StatusOK=1 corrispondenti a lista prelievo - try - { - ElencoOdette = taOdette.getByCodLista(CodLista); - totOdette = ElencoOdette.Rows.Count; - } - catch - { - logger.lg.scriviLog(string.Format("Errore: non ci sono UDC da creare per la PackList {0}", CodLista), tipoLog.ERROR); - } - // in primis comunque verifico che la bolla ci sia altrimenti non procedo (anche se avrebbe già dovuto controllare...) - if (totOdette > 0) - { - // processo elenco Odette - foreach (DS_Odette.OdetteRow rigaOdette in ElencoOdette) - { - stampaEtichettaOdette(rigaOdette.CampoUDC, printerName); - } - } - else - { - logger.lg.scriviLog(string.Format("Attenzione: non ho trovaot etichette odette valide per la lista di prelievo {0}", CodLista), tipoLog.ERROR); - } - return answ; - } - /// - /// stampa una singola etichetta odette - /// - /// - /// - /// - public bool stampaEtichettaOdette(string UDC, string printerName) - { - bool answ = false; - // chiamo il report... - try - { - answ = reportPrinter.obj.stampaCartellino(tipoCartellino.cartOdette, UDC, printerName); - } - catch - { - logger.lg.scriviLog(String.Format("Errore nella stmapa del cartellino per l'UDC {0}", UDC), tipoLog.ERROR); - } - return answ; - } - /// - /// determina se ci siano odette x la lista di prelievo - /// - /// - /// - public bool listaHasOdette(string codLista) - { - bool answ = false; - try - { - DS_Odette.stp_OdetteStatoCreateRow rigaCreate = taOdCreate.GetData(codLista)[0]; - answ = rigaCreate.OdetteCreate > 0; - } - catch - { } - return answ; - } - /// - /// restituisce info se un gitterbox abbia una etichetta odette associata - /// - /// - public bool gitterboxInOdette(string codGitterbox) - { - bool answ = false; - try - { - answ = taOdette.getByUdc(codGitterbox).Rows.Count > 0; - } - catch - { } - return answ; - } - /// - /// restituisce info se un datamatrix faccia parte di un gitterbox con una etichetta odette associata - /// - public bool datamatrixInOdette(decimal codDataMatrix) - { - bool answ = false; - string codGitterbox = DataMatrix.mgr.gitterboxFromDataMatrix(codDataMatrix); - answ = gitterboxInOdette(codGitterbox); - return answ; - } - /// - /// Restituisce info se un datamatrix possa essere spostato tra 2 gitterbox (il suo d'origine e quello indicato), - /// mantenendo l'omogeneità dei prodotti nel gitterbox. - /// Verifiche: - /// - se il datamatrix ha un gitterbox associato --> le prime 2 cifre dei gitterbox devono coincidere - /// - se il datamatrix non ha un gitterbox associato --> rileggo gitterbox originale pre importazione e faccio verifica dei primi 2 char - /// - /// - /// - public bool dtMtxGtboxCompatibili(decimal codDataMatrix, string codGitterboxTo) - { - bool answ = false; - string codGitterboxFrom = ""; - try - { - codGitterboxFrom = DataMatrix.mgr.gitterboxFromDataMatrix(codDataMatrix); - if (codGitterboxFrom != "EmptyGBox") - { - answ = (codGitterboxFrom.Substring(0, 2) == codGitterboxTo.Substring(0, 2)); - } - else - { - // cerco gitterbox originale... - codGitterboxFrom = DataMatrix.mgr.gitterboxOrigFromDataMatrix(codDataMatrix); - answ = (codGitterboxFrom.Substring(0, 2) == codGitterboxTo.Substring(0, 2)); - } - } - catch - { } - return answ; - } - /// - /// restituisce info se un datamatrix esista - /// - /// - public bool datamatrixEsiste(decimal codDataMatrix) - { - bool answ = false; - try - { - answ = DataMatrix.mgr.taElencoDM.getByCode(codDataMatrix).Rows.Count > 0; - } - catch - { } - return answ; - } - - - #endregion - + bool answ = false; + try + { + taOdette.caricaDatiBollaEtichettaOdette(memLayer.ML.cdv("CodCS"), UDC, numBolla.ToString(), dataBolla.ToString(), RaggMag, GrpBolla, particolare); + answ = true; + } + catch + { + answ = false; + } + return answ; } + + #endregion + + #region area public + + /// + /// singleton + /// + public static Odette mgr = new Odette(); + /// + /// wrapper traduzione + /// + /// + /// + /// + public string traduci(string lemma, string lingua) + { + return user_std.UtSn.Traduci(lemma, lingua); + } + + /// + /// verifica l'esistenza di una bolla dato il suo codice + data + /// + /// cod raggr magazzino + /// gruppo bolla + /// codice bolla NUMERICO + /// data bolla formato numerico YYYYMMDD + /// codice particolare + /// + public bool checkCodBolla(string RaggMag, string GrpBolla, decimal numBolla, decimal dataBolla, string particolare) + { + bool answ = false; + int righeBolla = 0; + // controllo che la bolla esista... + try + { + // provo a caricarle con stored... + taBORI.caricaDatiBolla(RaggMag, GrpBolla, numBolla.ToString(), dataBolla.ToString(), particolare); + // rileggo se presenti... + righeBolla = taBORI.getByKeyFull(RaggMag, GrpBolla, Convert.ToDecimal(numBolla), Convert.ToDecimal(dataBolla), particolare).Rows.Count; + answ = (righeBolla >= 1); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in checkCodBolla:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + } + // controllo che la bolla non sia già associata... ovvero SENZA NESSUNA etichetta odette associata x quel particolare... + if (answ) + { + // controllo se trovo odette associate a tale bolla... + answ = (taOdette.getByBolla(RaggMag, GrpBolla, numBolla, dataBolla, particolare).Rows.Count == 0); + } + return answ; + } + /// + /// conteggia il num di colli x una data bolla + /// + /// cod raggr magazzino + /// gruppo bolla + /// codice bolla NUMERICO + /// data bolla formato numerico YYYYMMDD + /// codice particolare + /// + public int totColliBolla(string RaggMag, string GrpBolla, decimal numBolla, decimal dataBolla, string particolare) + { + int answ = 0; + try + { + // calcolo il totale dei pezzi: ogni riga contiene il totale colli della bolla... + //answ = (int)taBORI.getByKeyFull(RaggMag, GrpBolla, Convert.ToDecimal(numBolla), Convert.ToDecimal(dataBolla), particolare)[0].NRC1B; + answ = Convert.ToInt32(taBORI.getByKeyFull(RaggMag, GrpBolla, Convert.ToDecimal(numBolla), Convert.ToDecimal(dataBolla), particolare).Compute("SUM(NRC1B)", "")); + } + catch + { } + return answ; + } + /// + /// conteggia il num di pezzi x una data bolla + /// + /// cod raggr magazzino + /// gruppo bolla + /// codice bolla NUMERICO + /// data bolla formato numerico YYYYMMDD + /// codice particolare + /// + public int totPezziBolla(string RaggMag, string GrpBolla, decimal numBolla, decimal dataBolla, string particolare) + { + int answ = 0; + try + { + // rileggo se presenti... + answ = Convert.ToInt32(taBORI.getByKeyFull(RaggMag, GrpBolla, Convert.ToDecimal(numBolla), Convert.ToDecimal(dataBolla), particolare).Compute("SUM(QTCNS)", "")); + //answ = (int)taBORI.getByKeyFull(RaggMag, GrpBolla, Convert.ToDecimal(numBolla), Convert.ToDecimal(dataBolla), particolare)[0].QTCNS; + } + catch + { } + return answ; + } + + /// + /// crea tutte le righe encessarie alal stampa dei cartellini Odette dati lista di prelievo, bolla da associare + /// + /// codice lista di prelievo + /// cod raggr magazzino + /// gruppo bolla + /// codice bolla NUMERICO + /// data bolla formato numerico YYYYMMDD + /// codice particolare + /// IT/EN/... + /// in caso di errore e ritorno false, salva in sessione il messaggio di errore relativo in errCreazOdette + public bool creaOdetteByBollaPackList(string CodLista, string RaggMag, string GrpBolla, decimal numBolla, decimal dataBolla, string particolare, string lingua) + { + bool answ = false; + string errCreazOdette = ""; + int totUdc = 0; + int totPz = 0; + int udcOk = 0; + DS_magazzino.RigheListePrelievoDataTable ElencoUdc = new DS_magazzino.RigheListePrelievoDataTable(); + // conto totale etichette da creare + try + { + ElencoUdc = MagClass.magazzino.taRigheListePrelievo.getByCodLista(CodLista); + totUdc = ElencoUdc.Rows.Count; + totPz = (int)MagClass.magazzino.taElencoListePrelievo.getByCodLista(CodLista)[0].Prelevato; + } + catch + { + errCreazOdette = string.Format("Errore: non ci sono UDC da creare per la PackList {0}", CodLista); + logger.lg.scriviLog(errCreazOdette, tipoLog.ERROR); + } + // in primis comunque verifico che la bolla ci sia altrimenti non procedo (anche se avrebbe già dovuto controllare...) + if (checkCodBolla(RaggMag, GrpBolla, numBolla, dataBolla, particolare) && totUdc > 0) + { + // controllo se il totale colli corrisponde al totale UDC.. + if (totColliBolla(RaggMag, GrpBolla, numBolla, dataBolla, particolare) == totUdc || true) // controllo disattivato 2013.03.22 perché i colli riga sono i colli totali bolla + { + // controllo se il totale pezzi corrisponde al totale qta... + if (totPezziBolla(RaggMag, GrpBolla, numBolla, dataBolla, particolare) == totPz) + { + // leggo elenco UDC da packing list + foreach (DS_magazzino.RigheListePrelievoRow rigaUdc in ElencoUdc) + { + // per ogni UDC creo una riga + taOdette.upsertUdc(rigaUdc.UDC, memLayer.ML.cdv("CodCS"), numBolla.ToString(), dataBolla.ToString(), RaggMag, GrpBolla, particolare, CodLista, memLayer.ML.confReadString("indStabFrom"), rigaUdc.Qta.ToString()); + udcOk++; + // per ogni riga inserisco traduzione nella lingua richiesta + caricaEtichetteLinguaPerOdette(rigaUdc.UDC, lingua); + // vado a caricare i dati dalla tab dei dati bolle + caricaDatiBollaEtichettaOdette(rigaUdc.UDC, RaggMag, GrpBolla, numBolla, dataBolla, particolare); + // effettuo check della riga odette e determino se sia conforme + updateStatoOdette(rigaUdc.UDC); + } + } + else + { + errCreazOdette = string.Format("Errore assegnazione bolle/odette, il num di pezzi non corrisponde: num bolla {0} del {1}, lista prelievo {2}", numBolla, dataBolla, CodLista); + logger.lg.scriviLog(errCreazOdette, tipoLog.ERROR); + } + } + else + { + errCreazOdette = string.Format("Errore assegnazione bolle/odette, il num di colli non corrisponde: num bolla {0} del {1}, lista prelievo {2}", numBolla, dataBolla, CodLista); + logger.lg.scriviLog(errCreazOdette, tipoLog.ERROR); + } + } + else + { + errCreazOdette = string.Format("Tentativo di generazione etichette odette da bolla inesistente/già impiegata: codice {0} del {1}", numBolla, dataBolla); + logger.lg.scriviLog(errCreazOdette, tipoLog.ERROR); + } + // controllo se tutte le etichette sono sstate create + if (totUdc == udcOk) + { + answ = true; + } + memLayer.ML.setSessionVal("errCreazOdette", errCreazOdette); + return answ; + } + /// + /// Stampa tutte le etichette odette di una lista di prelievo + /// + /// + /// + /// + public bool stampaOdettePackingList(string CodLista, string printerName) + { + bool answ = false; + int totOdette = 0; + DS_Odette.OdetteDataTable ElencoOdette = new DS_Odette.OdetteDataTable(); + // conto totale etichette Odette con StatusOK=1 corrispondenti a lista prelievo + try + { + ElencoOdette = taOdette.getByCodLista(CodLista); + totOdette = ElencoOdette.Rows.Count; + } + catch + { + logger.lg.scriviLog(string.Format("Errore: non ci sono UDC da creare per la PackList {0}", CodLista), tipoLog.ERROR); + } + // in primis comunque verifico che la bolla ci sia altrimenti non procedo (anche se avrebbe già dovuto controllare...) + if (totOdette > 0) + { + // processo elenco Odette + foreach (DS_Odette.OdetteRow rigaOdette in ElencoOdette) + { + stampaEtichettaOdette(rigaOdette.CampoUDC, printerName); + } + } + else + { + logger.lg.scriviLog(string.Format("Attenzione: non ho trovaot etichette odette valide per la lista di prelievo {0}", CodLista), tipoLog.ERROR); + } + return answ; + } + /// + /// stampa una singola etichetta odette + /// + /// + /// + /// + public bool stampaEtichettaOdette(string UDC, string printerName) + { + bool answ = false; + // chiamo il report... + try + { + answ = reportPrinter.obj.stampaCartellino(tipoCartellino.cartOdette, UDC, printerName); + } + catch + { + logger.lg.scriviLog(String.Format("Errore nella stmapa del cartellino per l'UDC {0}", UDC), tipoLog.ERROR); + } + return answ; + } + /// + /// determina se ci siano odette x la lista di prelievo + /// + /// + /// + public bool listaHasOdette(string codLista) + { + bool answ = false; + try + { + DS_Odette.stp_OdetteStatoCreateRow rigaCreate = taOdCreate.GetData(codLista)[0]; + answ = rigaCreate.OdetteCreate > 0; + } + catch + { } + return answ; + } + /// + /// restituisce info se un gitterbox abbia una etichetta odette associata + /// + /// + public bool gitterboxInOdette(string codGitterbox) + { + bool answ = false; + try + { + answ = taOdette.getByUdc(codGitterbox).Rows.Count > 0; + } + catch + { } + return answ; + } + /// + /// restituisce info se un datamatrix faccia parte di un gitterbox con una etichetta odette associata + /// + public bool datamatrixInOdette(decimal codDataMatrix) + { + bool answ = false; + string codGitterbox = DataMatrix_mgr.gitterboxFromDataMatrix(codDataMatrix); + answ = gitterboxInOdette(codGitterbox); + return answ; + } + /// + /// Restituisce info se un datamatrix possa essere spostato tra 2 gitterbox (il suo d'origine e quello indicato), + /// mantenendo l'omogeneità dei prodotti nel gitterbox. + /// Verifiche: + /// - se il datamatrix ha un gitterbox associato --> le prime 2 cifre dei gitterbox devono coincidere + /// - se il datamatrix non ha un gitterbox associato --> rileggo gitterbox originale pre importazione e faccio verifica dei primi 2 char + /// + /// + /// + public bool dtMtxGtboxCompatibili(decimal codDataMatrix, string codGitterboxTo) + { + bool answ = false; + string codGitterboxFrom = ""; + try + { + codGitterboxFrom = DataMatrix_mgr.gitterboxFromDataMatrix(codDataMatrix); + if (codGitterboxFrom != "EmptyGBox") + { + answ = (codGitterboxFrom.Substring(0, 2) == codGitterboxTo.Substring(0, 2)); + } + else + { + // cerco gitterbox originale... + codGitterboxFrom = DataMatrix_mgr.gitterboxOrigFromDataMatrix(codDataMatrix); + answ = (codGitterboxFrom.Substring(0, 2) == codGitterboxTo.Substring(0, 2)); + } + } + catch + { } + return answ; + } + /// + /// restituisce info se un datamatrix esista + /// + /// + public bool datamatrixEsiste(decimal codDataMatrix) + { + bool answ = false; + try + { + answ = DataMatrix_mgr.taElencoDM.getByCode(codDataMatrix).Rows.Count > 0; + } + catch + { } + return answ; + } + + + #endregion + + } } \ No newline at end of file diff --git a/GMW_data/UserControlBCodeMan.cs b/GMW_data/UserControlBCodeMan.cs index e82f20d7..2593ed82 100644 --- a/GMW_data/UserControlBCodeMan.cs +++ b/GMW_data/UserControlBCodeMan.cs @@ -5,7 +5,10 @@ namespace GMW_data { public class UserControlBCodeMan : GMW_data.UserControl { - + /// + /// Oggetto locale gestione classe datamatrix... + /// + protected DataMatrix DataMatrix_mgr = new DataMatrix(); #region Conf stili css /// @@ -283,7 +286,7 @@ namespace GMW_data string answ = ""; try { - answ = DataMatrix.mgr.taVerifica.GetData(datamatrix)[0].FormatoDtmx; + answ = DataMatrix_mgr.taVerifica.GetData(datamatrix)[0].FormatoDtmx; } catch { } @@ -297,7 +300,7 @@ namespace GMW_data string answ = ""; try { - answ = DataMatrix.mgr.taTDtmx.getByParticolare(Particolare)[0].FormatoDtmx; + answ = DataMatrix_mgr.taTDtmx.getByParticolare(Particolare)[0].FormatoDtmx; } catch { } @@ -315,11 +318,11 @@ namespace GMW_data string answ = ""; if (byTable) { - answ = DataMatrix.mgr.taDtxAcquisiti.getByKey(barcodeIn)[0].Particolare; + answ = DataMatrix_mgr.taDtxAcquisiti.getByKey(barcodeIn)[0].Particolare; } else { - answ = DataMatrix.mgr.taDecode.GetData(barcodeIn, FormatoDtmxLinea)[0].Particolare; + answ = DataMatrix_mgr.taDecode.GetData(barcodeIn, FormatoDtmxLinea)[0].Particolare; } return answ; }