716 lines
29 KiB
C#
716 lines
29 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using SteamWare;
|
|
|
|
|
|
namespace GMW_data
|
|
{
|
|
/// <summary>
|
|
/// fa da proxy singleton x gli oggetti legati ai cartellini ODETTE
|
|
/// </summary>
|
|
public class Odette
|
|
{
|
|
#region area table adapters
|
|
|
|
public DS_OdetteTableAdapters.OdetteTableAdapter taOdette;
|
|
public DS_OdetteTableAdapters.BORI202JTableAdapter taBORI;
|
|
public DS_OdetteTableAdapters.stp_OdetteStatoCreateTableAdapter taOdCreate;
|
|
|
|
/// <summary>
|
|
/// init dei table adapters
|
|
/// </summary>
|
|
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();
|
|
}
|
|
/// <summary>
|
|
/// effettua setup dei connection strings da web.config delal singola applicazione
|
|
/// </summary>
|
|
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
|
|
|
|
protected Odette()
|
|
{
|
|
initTA();
|
|
setupConnectionStringBase();
|
|
}
|
|
|
|
#region area protected
|
|
|
|
/// <summary>
|
|
/// carica le label di lingua su un etichetta odette (che deve già esistere)
|
|
/// </summary>
|
|
/// <param name="UDC"></param>
|
|
/// <param name="lingua"></param>
|
|
/// <returns></returns>
|
|
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;
|
|
}
|
|
/// <summary>
|
|
/// verifica una etichetta odette e salva in db il valore di check x consistenza dei dati
|
|
/// </summary>
|
|
/// <param name="UDC"></param>
|
|
/// <returns></returns>
|
|
protected bool updateStatoOdette(string UDC)
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
// effettuo verifiche sulla riga odette...
|
|
// !!!FARE!!!
|
|
answ = true;
|
|
taOdette.setStato(UDC, answ);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// carica i dati per l'etichetta Odette provenienti dalla bolla indicata
|
|
/// </summary>
|
|
/// <param name="UDC"></param>
|
|
/// <param name="RaggMag"></param>
|
|
/// <param name="GrpBolla"></param>
|
|
/// <param name="numBolla">codice bolla</param>
|
|
/// <param name="dataBolla">data bolla formato YYYYMMDD</param>
|
|
/// <param name="particolare"></param>
|
|
/// <returns></returns>
|
|
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 = "";
|
|
string indirCli = "";
|
|
string capCittCli = "";
|
|
string destP1 = "";
|
|
string destP2 = "";
|
|
string destP3 = "";
|
|
string destinatario = "";
|
|
decimal peso = 0;
|
|
string pesoNetto = "";
|
|
string pesoLordo = "";
|
|
string numColli = "";
|
|
string disPart = "";
|
|
string descPart = "";
|
|
string codPart = "";
|
|
string codImb = "";
|
|
string codMaz = "";
|
|
string codNael = "";
|
|
string codNaelP1 = "";
|
|
string codNaelP2 = "";
|
|
string codNaelP3 = "";
|
|
string codAQP = "";
|
|
// in primis recupero la riga di dati da AS400...
|
|
int trovati = 0;
|
|
DS_Odette.BORI202JDataTable tabAs400 = new DS_Odette.BORI202JDataTable();
|
|
DS_magazzino.ElencoCartelliniRow rigaUdc = null;
|
|
decimal qtaUdc = 1;
|
|
try
|
|
{
|
|
tabAs400 = taBORI.getByKeyFull(RaggMag, GrpBolla, numBolla, dataBolla, particolare);
|
|
trovati = tabAs400.Rows.Count;
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog(string.Format("Non trovati dati per {0}-{1}-{2}-{3}-{4}", RaggMag, GrpBolla, numBolla, dataBolla, particolare), tipoLog.EXCEPTION);
|
|
}
|
|
// carico dati udc
|
|
try
|
|
{
|
|
rigaUdc = MagClass.magazzino.taCartellini.getByUdc(UDC)[0];
|
|
qtaUdc = rigaUdc.Qta;
|
|
}
|
|
catch
|
|
{
|
|
qtaUdc = 1;
|
|
logger.lg.scriviLog(string.Format("Non trovati dati per UDC {0} (qta)", UDC), tipoLog.EXCEPTION);
|
|
}
|
|
if (trovati >= 1)
|
|
{
|
|
DS_Odette.BORI202JRow rigaAs = tabAs400[0];
|
|
// in base al valore di CDINB definisco i campi...
|
|
if (rigaAs.CDINB.Trim() != "")
|
|
{
|
|
// campo1
|
|
try
|
|
{
|
|
ragSocCli = rigaAs.RA1ND.Trim();
|
|
indirCli = rigaAs.RA2ND.Trim();
|
|
capCittCli = string.Format("{0} {1}", rigaAs.CAPND.Trim(), rigaAs.CITND.Trim());
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog("Errore campo1 (101)", tipoLog.ERROR);
|
|
}
|
|
// campo2
|
|
try
|
|
{
|
|
destP2 = rigaAs.INEND.Substring(0, 15).Trim();
|
|
destP1 = rigaAs.INEND.Substring(15, 15).Trim();
|
|
if (rigaAs.CRAGCL.Trim() == "13" || rigaAs.TELND.Substring(18, 2) == "13")
|
|
{
|
|
destP3 = "/S";
|
|
}
|
|
destinatario = string.Format("{0}/{1}{2}", destP1, destP2, destP3);
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog("Errore campo2 (102)", tipoLog.ERROR);
|
|
}
|
|
// campo12
|
|
try
|
|
{
|
|
if (rigaAs.CRAGCL.Trim() == "13" || rigaAs.TELND.Substring(18, 2) == "13")
|
|
{
|
|
codMaz = rigaAs.PERND.Trim();
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog("Errore campo12 (112)", tipoLog.ERROR);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// campo1
|
|
try
|
|
{
|
|
ragSocCli = rigaAs.RASCL.Trim();
|
|
indirCli = rigaAs.INDCL.Trim();
|
|
capCittCli = string.Format("{0} {1} {2}", rigaAs.CAPCL.Trim(), rigaAs.LOCCL.Trim(), rigaAs.PROCL.Trim());
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog("Errore campo1 (201)", tipoLog.ERROR);
|
|
}
|
|
// campo2
|
|
try
|
|
{
|
|
destP1 = rigaAs.CCDMOL.Trim();
|
|
destP2 = rigaAs.CCDPTR.Trim();
|
|
if (rigaAs.CRAGCL.Trim() == "13")
|
|
{
|
|
destP3 = "/S";
|
|
}
|
|
destinatario = string.Format("{0}/{1}{2}", destP1, destP2, destP3);
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog("Errore campo2 (202)", tipoLog.ERROR);
|
|
}
|
|
// campo12
|
|
try
|
|
{
|
|
if (rigaAs.CRAGCL.Trim() == "13" || rigaAs.TELND.Substring(18, 2) == "13")
|
|
{
|
|
codMaz = rigaAs.CCDET1.Trim();
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog("Errore campo12 (212)", tipoLog.ERROR);
|
|
}
|
|
}
|
|
// campo5
|
|
try
|
|
{
|
|
// se EPLAVO = 0 --> si mette EPLNETT
|
|
if (rigaAs.EPLAVO <= 0)
|
|
{
|
|
peso = rigaAs.EPNETT;
|
|
}
|
|
else
|
|
{
|
|
// modifica 2013.05.03
|
|
//peso = Math.Round(rigaAs.EPLAVO * memLayer.ML.confReadInt("qtaOdette"), 2);
|
|
peso = rigaAs.EPLAVO;
|
|
}
|
|
pesoNetto = Math.Round(peso * qtaUdc, 2).ToString();
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog("Errore campo5 (005)", tipoLog.ERROR);
|
|
}
|
|
// campo6
|
|
try
|
|
{
|
|
pesoLordo = Math.Round(rigaAs.PELDB / rigaAs.NRC1B, 2).ToString();
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog("Errore campo6 (006)", tipoLog.ERROR);
|
|
}
|
|
// campo7
|
|
try
|
|
{
|
|
numColli = rigaAs.NRC1B.ToString();
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog("Errore campo7 (007)", tipoLog.ERROR);
|
|
}
|
|
// campo8
|
|
try
|
|
{
|
|
disPart = rigaAs.ECMM01.Trim();
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog("Errore campo8 (008)", tipoLog.ERROR);
|
|
}
|
|
// campo10
|
|
try
|
|
{
|
|
descPart = rigaAs.DEPAR.Trim();
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog("Errore campo10 (010)", tipoLog.ERROR);
|
|
}
|
|
// campo 11_1
|
|
try
|
|
{
|
|
codPart = rigaAs.CDARS.Trim();
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog("Errore campo11_1 (011_1)", tipoLog.ERROR);
|
|
}
|
|
// campo 11_2
|
|
try
|
|
{
|
|
// modifica 2013.05.02
|
|
codImb = rigaAs.FCDI01.Trim();
|
|
//codImb = rigaAs.RCARTC.Trim();
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog("Errore campo11_2 (011_2)", tipoLog.ERROR);
|
|
}
|
|
// campo14
|
|
try
|
|
{
|
|
// controlla se debba configurare come BMW da accodamento dati o leggendo in nuova tabella...
|
|
if (rigaAs.CRAGCL.Trim() == "13" || rigaAs.TELND.Substring(18, 2) == "13")
|
|
{
|
|
codNaelP1 = rigaAs.ECDNAE.Trim();
|
|
codNaelP2 = rigaAs.ECDNA1.Trim();
|
|
codNaelP3 = rigaAs.EESPMD.Trim();
|
|
codNael = string.Format("ZI:{0} {1} AI:{2}", codNaelP1, codNaelP2, codNaelP3);
|
|
}
|
|
else
|
|
{
|
|
// leggo record...
|
|
codNael = rigaAs.OCDODM;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog("Errore campo14 (014)", tipoLog.ERROR);
|
|
}
|
|
// campo16_5
|
|
try
|
|
{
|
|
// sistema codAQP
|
|
codAQP = rigaAs.ECLAQP;
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog("Errore campo16 (016)", tipoLog.ERROR);
|
|
}
|
|
}
|
|
if (trovati >= 1)
|
|
{
|
|
try
|
|
{
|
|
taOdette.updateValAs400(UDC, ragSocCli, indirCli, capCittCli, destinatario, "", "", pesoNetto, pesoLordo, numColli, disPart, descPart, codPart, codImb, codMaz, codNael, codAQP);
|
|
answ = true;
|
|
}
|
|
catch
|
|
{
|
|
answ = false;
|
|
}
|
|
}
|
|
#endif
|
|
bool answ = false;
|
|
try
|
|
{
|
|
taOdette.caricaDatiBollaEtichettaOdette(memLayer.ML.confReadString("CodCS"), UDC, numBolla.ToString(), dataBolla.ToString(), RaggMag, GrpBolla, particolare);
|
|
answ = true;
|
|
}
|
|
catch
|
|
{
|
|
answ = false;
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region area public
|
|
|
|
/// <summary>
|
|
/// singleton
|
|
/// </summary>
|
|
public static Odette mgr = new Odette();
|
|
/// <summary>
|
|
/// wrapper traduzione
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <param name="lingua"></param>
|
|
/// <returns></returns>
|
|
public string traduci(string lemma, string lingua)
|
|
{
|
|
return user_std.UtSn.Traduci(lemma, lingua);
|
|
}
|
|
|
|
/// <summary>
|
|
/// verifica l'esistenza di una bolla dato il suo codice + data
|
|
/// </summary>
|
|
/// <param name="RaggMag">cod raggr magazzino</param>
|
|
/// <param name="GrpBolla">gruppo bolla</param>
|
|
/// <param name="numBolla">codice bolla NUMERICO</param>
|
|
/// <param name="dataBolla">data bolla formato numerico YYYYMMDD</param>
|
|
/// <param name="particolare">codice particolare</param>
|
|
/// <returns></returns>
|
|
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;
|
|
}
|
|
/// <summary>
|
|
/// conteggia il num di colli x una data bolla
|
|
/// </summary>
|
|
/// <param name="RaggMag">cod raggr magazzino</param>
|
|
/// <param name="GrpBolla">gruppo bolla</param>
|
|
/// <param name="numBolla">codice bolla NUMERICO</param>
|
|
/// <param name="dataBolla">data bolla formato numerico YYYYMMDD</param>
|
|
/// <param name="particolare">codice particolare</param>
|
|
/// <returns></returns>
|
|
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;
|
|
}
|
|
/// <summary>
|
|
/// conteggia il num di pezzi x una data bolla
|
|
/// </summary>
|
|
/// <param name="RaggMag">cod raggr magazzino</param>
|
|
/// <param name="GrpBolla">gruppo bolla</param>
|
|
/// <param name="numBolla">codice bolla NUMERICO</param>
|
|
/// <param name="dataBolla">data bolla formato numerico YYYYMMDD</param>
|
|
/// <param name="particolare">codice particolare</param>
|
|
/// <returns></returns>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// crea tutte le righe encessarie alal stampa dei cartellini Odette dati lista di prelievo, bolla da associare
|
|
/// </summary>
|
|
/// <param name="CodLista">codice lista di prelievo</param>
|
|
/// <param name="RaggMag">cod raggr magazzino</param>
|
|
/// <param name="GrpBolla">gruppo bolla</param>
|
|
/// <param name="numBolla">codice bolla NUMERICO</param>
|
|
/// <param name="dataBolla">data bolla formato numerico YYYYMMDD</param>
|
|
/// <param name="particolare">codice particolare</param>
|
|
/// <param name="Lingua">IT/EN/...</param>
|
|
/// <returns>in caso di errore e ritorno false, salva in sessione il messaggio di errore relativo in errCreazOdette</returns>
|
|
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.confReadString("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;
|
|
}
|
|
/// <summary>
|
|
/// Stampa tutte le etichette odette di una lista di prelievo
|
|
/// </summary>
|
|
/// <param name="CodLista"></param>
|
|
/// <param name="printerName"></param>
|
|
/// <returns></returns>
|
|
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;
|
|
}
|
|
/// <summary>
|
|
/// stampa una singola etichetta odette
|
|
/// </summary>
|
|
/// <param name="UDC"></param>
|
|
/// <param name="printerName"></param>
|
|
/// <returns></returns>
|
|
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;
|
|
}
|
|
/// <summary>
|
|
/// determina se ci siano odette x la lista di prelievo
|
|
/// </summary>
|
|
/// <param name="codLista"></param>
|
|
/// <returns></returns>
|
|
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;
|
|
}
|
|
/// <summary>
|
|
/// restituisce info se un gitterbox abbia una etichetta odette associata
|
|
/// <param name="codGitterbox"></param>
|
|
/// </summary>
|
|
public bool gitterboxInOdette(string codGitterbox)
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
answ = taOdette.getByUdc(codGitterbox).Rows.Count > 0;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// restituisce info se un datamatrix faccia parte di un gitterbox con una etichetta odette associata
|
|
/// </summary>
|
|
public bool datamatrixInOdette(decimal codDataMatrix)
|
|
{
|
|
bool answ = false;
|
|
string codGitterbox = DataMatrix.mgr.gitterboxFromDataMatrix(codDataMatrix);
|
|
answ = gitterboxInOdette(codGitterbox);
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// 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
|
|
/// <param name="codDataMatrix"></param>
|
|
/// <param name="codGitterbox"></param>
|
|
/// </summary>
|
|
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;
|
|
}
|
|
/// <summary>
|
|
/// restituisce info se un datamatrix esista
|
|
/// <param name="codDataMatrix"></param>
|
|
/// </summary>
|
|
public bool datamatrixEsiste(decimal codDataMatrix)
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
answ = DataMatrix.mgr.taElencoDM.getByCode(codDataMatrix).Rows.Count > 0;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
} |