private void OnBarcode(CSBarcode barcode) { if (btnTraži.Tag.ToString() == "potvrda") { if (barcode.Symbology == Symbology.CODE_39) { txtDok.Text = barcode.Data; } else { MessageBox.Show(P.DOKBARKOD_NIJE_NALOG, P.MSGBOX_ERR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (btnTraži.Tag.ToString() == "izmjena") { MTrenisClient c = new MTrenisClient(); try { Roba r = c.DohvatiRobu(barcode.Data); foreach (DataGridViewRow row in dgvNalog.Rows) { if (row.Cells["colSifra"].Value.ToString() == r.sifra) { //dgvSkladok.FirstDisplayedScrollingRowIndex = dgvSkladok.Rows[ix].Index; dgvNalog.ClearSelection(); dgvNalog.Rows[row.Index].Selected = true; dgvNalog.CurrentCell = dgvNalog.Rows[row.Index].Cells[0]; break; } } } catch (FaultException<MTrenisKvar> ex) { MessageBox.Show(ex.Detail.opis, ex.Detail.oznaka.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message, P.MSGBOX_ERR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (c != null && c.State != CommunicationState.Closed) { c.Close(); } } } }
private void OnBarcode(CSBarcode barcode) { if ("potvrda" == btnLok.Tag.ToString()) { if (barcode.Symbology == Symbology.CODE_128) { txtLokacija.Text = barcode.Data; } else { MessageBox.Show(P.LOK_KRIVI_BARKOD, P.MSGBOX_ERR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { txtBarkod.Text = String.Empty; txtKoličina.Text = String.Empty; lblRoba.Text = String.Empty; MTrenisClient c = new MTrenisClient(); try { Roba r = c.DohvatiRobu(barcode.Data); StringBuilder sb = new StringBuilder(); sb.Append(r.sifra); sb.Append(Environment.NewLine); sb.Append(r.naziv); sb.Append(Environment.NewLine); sb.Append(r.dobavljac); txtBarkod.Text = barcode.Data; txtKoličina.Focus(); lblRoba.Text = sb.ToString(); } catch (FaultException<MTrenisKvar> ex) { MessageBox.Show(ex.Detail.opis, ex.Detail.oznaka.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message, P.MSGBOX_ERR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (c != null && c.State != CommunicationState.Closed) { c.Close(); } } } }