Ejemplo n.º 1
0
        private bool getTransferById()
        {
            if (_transferId > 0)
            {
                ApiResponse res = new ApiResponse();
                res.Status = false;

                try
                {
                    string url = "transfers/search?query=id==" + _transferId.ToString();
                    res = HTTP.GetJson(url);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Get transfer error: " + ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    return(false);
                }

                if (res.Status && Util.IsJson(res.RawText))
                {
                    try
                    {
                        List <TransferInfo> RootObject = JsonConvert.DeserializeObject <List <TransferInfo> >(res.RawText, new JsonSerializerSettings
                        {
                            NullValueHandling = NullValueHandling.Ignore
                        });

                        if (RootObject.Count > 0)
                        {
                            TransferInfo = RootObject[0];
                            _transferId  = TransferInfo.id;
                            if (!getListTransferItem(_transferId))
                            {
                                clearData(true); return(false);
                            }
                            txtTransferNumber.Text = TransferInfo.transferNumber;
                            //alertStateTransfer(TransferInfo.state);
                        }
                        else
                        {
                            clearData(true);
                            MessageBox.Show("Not exists transfer number !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                            return(false);
                        }
                    }
                    catch (Exception ex)
                    {
                        clearData(true);
                        MessageBox.Show(ex.Message.ToString());
                        return(false);
                    }
                }
                else
                {
                    clearData(true);
                    MessageBox.Show(res.RawText);
                    return(false);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        private void ScanCode(string dcdData)
        {
            #region scan transfer
            try
            {
                string _transferNumber = dcdData.Trim();
                if (_transferNumber.Length > 0)
                {
                    clearData(true);
                    ApiResponse res = new ApiResponse();
                    res.Status = false;

                    try
                    {
                        string url = "transfers/search?query=transferNumber=='" + _transferNumber + "'";
                        res = HTTP.GetJson(url);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Get transfer error: " + ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        return;
                    }

                    if (res.Status && Util.IsJson(res.RawText))
                    {
                        try
                        {
                            List <TransferInfo> RootObject = JsonConvert.DeserializeObject <List <TransferInfo> >(res.RawText, new JsonSerializerSettings
                            {
                                NullValueHandling = NullValueHandling.Ignore
                            });

                            if (RootObject.Count > 0)
                            {
                                TransferInfo = RootObject[0];
                                _transferId  = TransferInfo.id;
                                if (!getListTransferItem(_transferId))
                                {
                                    clearData(true); return;
                                }
                                txtTransferNumber.Text = dcdData.Trim();
                            }
                            else
                            {
                                clearData(true);
                                MessageBox.Show("Not exists transfer number !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                            }
                        }
                        catch (Exception ex)
                        {
                            clearData(true);
                            MessageBox.Show(ex.Message.ToString());
                        }
                    }
                    else
                    {
                        clearData(true);
                        MessageBox.Show(res.RawText);
                    }
                }
                else
                {
                    clearData(true);
                }
            }
            catch (Exception ex)
            {
                clearData(true);
                MessageBox.Show("Transfer number wrong format !");
            }
            #endregion
        }