Example #1
0
 private int DajInvPregled(int _skip, int _take)
 {
     string šifra = null;
     string barkod = null;
     string kaj = F.RazriješiŠifruIliBarkod(txtRoba.Text);
     if (kaj == "š")
     {
         šifra = txtRoba.Text.Trim().ToUpper();
     }
     else if (kaj == "b")
     {
         barkod = txtRoba.Text.Trim().ToUpper();
     }
     MTrenisClient c = new MTrenisClient();
     try
     {
         InvHistoriat h = c.DohvatiInvHistoriat(this.inventura.skladiste, this.inventura.godina.ToString(), this.inventura.rBr, this.inventura.kontrola, šifra, barkod, String.IsNullOrEmpty(txtLokacija.Text) ? null : txtLokacija.Text.Trim().ToUpper(), null, null, _skip, _take, this.terminal.skladištar.mBr);
         if (h.straniceneInvStavke.Length == 0)
         {
             MessageBox.Show(P.INVPREGLED_NEMA_STAVKI, String.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
             return 0;
         }
         List<KInvStavka> lista = new List<KInvStavka>();
         foreach (var r in h.straniceneInvStavke)
         {
             lista.Add(new KInvStavka(r.id, r.vremUpisa, r.roba, r.kolicina, r.lokOznaka));
         }
         dgvInvPregled.DataSource = lista;
         int count = h.ukupnoInvStavki;
         int rowEnd = 0;
         if (_skip + _take < count)
         {
             rowEnd = _skip + _take;
         }
         else
         {
             rowEnd = count;
         }
         lblStr.Text = _skip + 1 + " - " + rowEnd + @" / " + count;
         if (rowEnd < count)
         {
             btnNext.Enabled = true;
         }
         else
         {
             btnNext.Enabled = false;
         }
         if (_skip == 0)
         {
             btnPrev.Enabled = false;
         }
         else
         {
             btnPrev.Enabled = true;
         }
         if (h.ukupnoInvRobe.HasValue)
         {
             lblPoruka.Text = P.INVPREGLED_TOBA_UKUPNO + h.ukupnoInvRobe.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();
         }
     }
     return _skip + _take;
 }