public CertixDS.USR_PRD_FASIRow EstraiFaseGalvanicaDaODL(CertixDS.USR_PRD_MOVFASIRow movFase, CertixDS ds) { using (CertixWSBusiness bCertix = new CertixWSBusiness()) { bCertix.FillUSR_PRD_FASI(ds, new List <string>(new string[] { movFase.IDPRDFASE })); CertixDS.USR_PRD_FASIRow fase = ds.USR_PRD_FASI.Where(x => x.IDPRDFASE == movFase.IDPRDFASE).FirstOrDefault(); if (fase == null) { string messaggio = string.Format("Nessuna fase trovata per IDPRDFASE: {0} ", movFase.IDPRDFASE); throw new ArgumentException(messaggio); } if (fase.IsIDPRDFASEPADRENull()) { string messaggio = "Impossibile risalire alla fase di galvanica"; throw new ArgumentException(messaggio); } bCertix.FillUSR_PRD_FASI(ds, new List <string>(new string[] { fase.IDPRDFASEPADRE })); CertixDS.USR_PRD_FASIRow faseGalvanica = ds.USR_PRD_FASI.Where(x => x.IDPRDFASE == fase.IDPRDFASEPADRE).FirstOrDefault(); if (faseGalvanica == null) { string messaggio = "Nessuna fase galvanica non trovata per IDPRDFASE: " + fase.IDPRDFASEPADRE; throw new ArgumentException(messaggio); } return(faseGalvanica); } }
private void VerificaMuasures(int IdMeasure, List <UploadMeasuresElementRequest> UploadMeasuresElements, CertixDS ds) { bool esito = true; StringBuilder sb = new StringBuilder(); CertixDS.AP_CERTIXRow misura = ds.AP_CERTIX.Where(x => x.IDMISURECERTIX == IdMeasure).FirstOrDefault(); using (CertixWSBusiness bCertix = new CertixWSBusiness()) { bCertix.FillAP_GALVANICA_SPESSORI(ds, misura.IDMAGAZZ, misura.IDMAGAZZ_WIP); } decimal aux; foreach (UploadMeasuresElementRequest m in UploadMeasuresElements) { if (m.Material.Length > 10) { esito = false; sb.AppendLine(string.Format("Materiale: {0} lunghezza etichetta non valida", m.Material)); } if (!ds.AP_GALVANICA_SPESSORI.Select(x => x.ETICHETTA).ToList().Contains(m.Material)) { esito = false; sb.AppendLine(string.Format("Materiale: {0} inatteso.", m.Material)); } } if (!esito) { throw new ArgumentException(sb.ToString()); } }
public CertixDS.USR_PRD_MOVFASIRow VerificaBarcodeODL(string barcode, CertixDS ds) { using (CertixWSBusiness bCertix = new CertixWSBusiness()) { bCertix.FillUSR_PRD_MOVFASIByBarcode(ds, barcode); } return(ds.USR_PRD_MOVFASI.Where(x => x.BARCODE == barcode).FirstOrDefault()); }
private bool VerificaDuplicati(int IdMeasure, CertixDS ds) { using (CertixWSBusiness bCertix = new CertixWSBusiness()) { bCertix.FillAP_CERTIX_DETTAGLIO(ds, IdMeasure); return(ds.AP_CERTIX_DETTAGLIO.Any(x => x.IDMISURECERTIX == IdMeasure)); } }
private void SalvaMuasures(int IdMeasure, List <UploadMeasuresElementRequest> UploadMeasuresElements, CertixDS ds) { int sequenza = 0; using (CertixWSBusiness bCertix = new CertixWSBusiness()) { foreach (UploadMeasuresElementRequest m in UploadMeasuresElements) { CertixDS.AP_CERTIX_DETTAGLIORow dettaglio = ds.AP_CERTIX_DETTAGLIO.NewAP_CERTIX_DETTAGLIORow(); dettaglio.DATAINSERIMENTO = DateTime.Now; dettaglio.ETICHETTA = m.Material; dettaglio.IDMISURECERTIX = IdMeasure; dettaglio.IDMISURECERTIXDET = bCertix.GetID(); dettaglio.SEQUENZA = sequenza; sequenza++; dettaglio.VALORE = m.Measure; ds.AP_CERTIX_DETTAGLIO.AddAP_CERTIX_DETTAGLIORow(dettaglio); } bCertix.UpdateTable(ds.AP_CERTIX_DETTAGLIO.TableName, ds); } }
public int CreateIdMeasureFromCodeAndIdLine(int IdLine, string Code, bool IsTest, out List <string> Measures) { Measures = new List <string>(); if (IsTest) { if (IdLine < 0) { string m = string.Format("Codice IdLine: {0} non valido", IdLine); throw new ArgumentException(m); } if (Code == "12345678912345") { Measures = new List <string>(new string[] { "Au", "Ni", "Pd" }); } if (Code == "12345678912345") { return(DateTime.Now.Minute); } string messaggio = string.Format("Codice Code: {0} non valido", Code); throw new ArgumentException(messaggio); } //********* PRODUZIONE ****** CertixDS ds = new CertixDS(); CertixDS.USR_PRD_MOVFASIRow movFase = VerificaBarcodeODL(Code, ds); if (movFase == null) { string messaggio = string.Format("Codice Code: {0} non valido", Code); throw new ArgumentException(messaggio); } CertixDS.USR_PRD_FASIRow faseGalvanica = EstraiFaseGalvanicaDaODL(movFase, ds); if (faseGalvanica == null) { string messaggio = string.Format("Codice Code: {0} fase galvanica non trovata", Code); throw new ArgumentException(messaggio); } if (faseGalvanica.IsIDMAGAZZNull()) { string messaggio = string.Format("Codice Code: {0} articolo galvanica non trovato", Code); throw new ArgumentException(messaggio); } int idMeasure = -1; using (CertixWSBusiness bCertix = new CertixWSBusiness()) { bCertix.FillAP_GALVANICA_SPESSORI(ds, movFase.IDMAGAZZ, faseGalvanica.IDMAGAZZ); if (ds.AP_GALVANICA_SPESSORI.Count == 0) { string messaggio = string.Format("Codice Code: {0} articolo galvanica dati incompleti", Code); throw new ArgumentException(messaggio); } CertixDS.AP_CERTIXRow certixRow = ds.AP_CERTIX.NewAP_CERTIXRow(); certixRow.IDMISURECERTIX = bCertix.GetID(); idMeasure = (int)certixRow.IDMISURECERTIX; certixRow.IDLINE = IdLine; certixRow.BARCODE = Code; certixRow.IDMAGAZZ = movFase.IDMAGAZZ; certixRow.IDMAGAZZ_WIP = faseGalvanica.IDMAGAZZ; certixRow.DATAMISURA = DateTime.Now; ds.AP_CERTIX.AddAP_CERTIXRow(certixRow); bCertix.UpdateTable(ds.AP_CERTIX.TableName, ds); } Measures = ds.AP_GALVANICA_SPESSORI.OrderBy(x => x.SEQUENZA).Select(x => x.ETICHETTA).ToList(); return(idMeasure); }
private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string barcode = textBox1.Text; using (CertixWSBusiness bCertix = new CertixWSBusiness()) { CertixBLL bll = new CertixBLL(); CertixDS.USR_PRD_MOVFASIRow movFase = bll.VerificaBarcodeODL(barcode, _ds); if (movFase == null) { string messaggio = string.Format("Codice Code: {0} non valido", barcode); throw new ArgumentException(messaggio); } txtIdmagazz.Text = movFase.IsIDMAGAZZNull() ? string.Empty : movFase.IDMAGAZZ; if (!movFase.IsIDMAGAZZNull()) { bCertix.FillMAGAZZ(_ds, movFase.IDMAGAZZ); CertixDS.MAGAZZRow magazz = _ds.MAGAZZ.Where(x => x.IDMAGAZZ == movFase.IDMAGAZZ).FirstOrDefault(); if (magazz != null) { txtModelloMagazz.Text = magazz.MODELLO; } } CertixDS.USR_PRD_FASIRow faseGalvanica = bll.EstraiFaseGalvanicaDaODL(movFase, _ds); if (faseGalvanica == null) { string messaggio = string.Format("Codice Code: {0} fase galvanica non trovata", barcode); throw new ArgumentException(messaggio); } if (faseGalvanica.IsIDMAGAZZNull()) { string messaggio = string.Format("Codice Code: {0} articolo galvanica non trovato", barcode); throw new ArgumentException(messaggio); } else { bCertix.FillMAGAZZ(_ds, faseGalvanica.IDMAGAZZ); CertixDS.MAGAZZRow magazz = _ds.MAGAZZ.Where(x => x.IDMAGAZZ == faseGalvanica.IDMAGAZZ).FirstOrDefault(); if (magazz != null) { txtModelloMagazzWip.Text = magazz.MODELLO; } } txtIdmagazzWip.Text = faseGalvanica.IsIDMAGAZZNull() ? string.Empty : faseGalvanica.IDMAGAZZ; bCertix.FillAP_GALVANICA_MODELLO(_ds, movFase.IDMAGAZZ, faseGalvanica.IDMAGAZZ); if (_ds.AP_GALVANICA_MODELLO.Count != 0) { CertixDS.AP_GALVANICA_MODELLORow modello = _ds.AP_GALVANICA_MODELLO.Where(x => x.IDMAGAZZ == txtIdmagazz.Text && x.IDMAGAZZ_WIP == txtIdmagazzWip.Text).FirstOrDefault(); if (modello != null) { ddlBrand.Text = modello.IsBRANDNull() ? string.Empty : modello.BRAND; txtFinitura.Text = modello.IsFINITURANull() ? string.Empty : modello.FINITURA; bCertix.FillAP_GALVANICA_SPESSORI(ddlBrand.Text, txtFinitura.Text, _ds); List <string> etichette = _ds.AP_GALVANICA_SPESSORI.OrderBy(x => x.SEQUENZA).Select(x => x.ETICHETTA).ToList(); foreach (string etichetta in _ds.AP_GALVANICA_SPESSORI.OrderBy(x => x.SEQUENZA).Select(x => x.ETICHETTA).ToList()) { dgvEtichette.Rows.Add(etichetta); } } } } } }
private void btnSalva_Click(object sender, EventArgs e) { string brand = (string)ddlBrand.SelectedItem; if (string.IsNullOrEmpty(brand)) { lblMessaggio.Text = "Brand non valorizzato"; return; } if (string.IsNullOrEmpty(txtFinitura.Text)) { lblMessaggio.Text = "Finitura non valorizzata"; return; } if (dgvEtichette.Rows.Count == 0) { lblMessaggio.Text = "Etichette non inserite"; return; } using (CertixWSBusiness bCertix = new CertixWSBusiness()) { CertixDS.AP_GALVANICA_MODELLORow modello = _ds.AP_GALVANICA_MODELLO.Where(x => x.IDMAGAZZ == txtIdmagazz.Text && x.IDMAGAZZ_WIP == txtIdmagazzWip.Text).FirstOrDefault(); if (modello == null) { CertixDS.AP_GALVANICA_MODELLORow galvanicaModello = _ds.AP_GALVANICA_MODELLO.NewAP_GALVANICA_MODELLORow(); galvanicaModello.IDGALVAMODEL = bCertix.GetID(); galvanicaModello.IDMAGAZZ = txtIdmagazz.Text; galvanicaModello.IDMAGAZZ_WIP = txtIdmagazzWip.Text; galvanicaModello.MODELLO = txtModelloMagazz.Text; galvanicaModello.COMPONENTE = txtModelloMagazzWip.Text; galvanicaModello.BRAND = brand; galvanicaModello.FINITURA = txtFinitura.Text; _ds.AP_GALVANICA_MODELLO.AddAP_GALVANICA_MODELLORow(galvanicaModello); } List <CertixDS.AP_GALVANICA_SPESSORIRow> elementi = _ds.AP_GALVANICA_SPESSORI.Where(x => x.BRAND == brand && x.FINITURA == txtFinitura.Text).ToList(); foreach (CertixDS.AP_GALVANICA_SPESSORIRow elemento in elementi) { elemento.Delete(); } int sequenza = 0; foreach (DataGridViewRow dr in dgvEtichette.Rows) { if (dr.IsNewRow) { continue; } CertixDS.AP_GALVANICA_SPESSORIRow spessore = _ds.AP_GALVANICA_SPESSORI.NewAP_GALVANICA_SPESSORIRow(); spessore.IDGALVASPESSORI = bCertix.GetID(); spessore.BRAND = brand; spessore.FINITURA = txtFinitura.Text; spessore.SEQUENZA = sequenza; sequenza++; spessore.ETICHETTA = (string)dr.Cells[0].Value; _ds.AP_GALVANICA_SPESSORI.AddAP_GALVANICA_SPESSORIRow(spessore); } bCertix.UpdateTable(_ds.AP_GALVANICA_MODELLO.TableName, _ds); bCertix.UpdateTable(_ds.AP_GALVANICA_SPESSORI.TableName, _ds); } }