Example #1
0
 private void btnTraži_Click(object sender, EventArgs e)
 {
     MTrenisClient c = null;
     if (btnTraži.Tag.ToString() == "potvrda")
     {
         txtDok.Text = txtDok.Text.ToUpper();
         if (txtDok.Text.Length != 15 && txtDok.Text.Length != 19)
         {
             MessageBox.Show(String.Format(P.DOKBARKOD_KRIVA_DULJINA, txtDok.Text.Length), P.MSGBOX_ERR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         DokBarkod skladok = F.RazriješiDokBarkod(txtDok.Text);
         string msg;
         if (!F.DokBarkodOK(skladok, this.katalog, out msg))
         {
             MessageBox.Show(msg, P.MSGBOX_ERR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         try
         {
             c = new MTrenisClient();
             if (skladok.dokVrsta == "PSS")
             {
                 CoreScannerProxy.Instance.BarcodeEvent -= new BarcodeEventHandler(OnBarcode);
                 ModalPSS modal = new ModalPSS();
                 modal.ShowDialog(this);
                 modal.Dispose();
                 CoreScannerProxy.Instance.BarcodeEvent += new BarcodeEventHandler(OnBarcode);
                 if (String.IsNullOrEmpty(smjerPSS))
                 {
                     MessageBox.Show(P.NALOGPSS_KAJ_SE_DELA, P.MSGBOX_ERR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                     return;
                 }
                 if (smjerPSS == "U" && !c.MozeUlazPSS(skladok.sklaOznaka, skladok.dokBr))
                 {
                     MessageBox.Show(P.NALOGPSS_NEMRE_ULAZ, P.MSGBOX_ERR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                     return;
                 }
             }
             PrikažiNalog(
                 skladok.sklaOznaka,
                 skladok.sklaOznakaPSS,
                 skladok.dokVrsta,
                 skladok.dokBr,
                 skladok.dokVrsta == "PSS" ? smjerPSS : (from r in this.katalog.dokumenti where r.vrsta == skladok.dokVrsta select r).Single().smjer.ToUpper());
         }
         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();
             }
         }
     }
     else if (btnTraži.Tag.ToString() == "izmjena")
     {
         FormNalog form = new FormNalog(this.terminal, this.katalog, this.Location, this.Width, this.Height, this.WindowState, null);
         form.Show();
         this.Close();
     }
 }