コード例 #1
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;
                                }
                                if (TransferInfo.srcLocationId != null)
                                {
                                    LocationInfo _srcLocationInfo = LocationBusiness.getInfo(Convert.ToInt32(TransferInfo.srcLocationId));
                                    if (_srcLocationInfo != null)
                                    {
                                        TransferInfo.srcLocationName = _srcLocationInfo.completeName;
                                    }
                                }
                                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
        }
コード例 #2
0
        private void txtTransferNumber_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                clearData(false);

                string      _transferNumber = txtTransferNumber.Text.Trim();
                ApiResponse res             = new ApiResponse();

                try
                {
                    string url = "transfers/search?query=transferNumber=='" + _transferNumber + "'";
                    res = HTTP.GetJson(url);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Not exists transfer number !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }
                try
                {
                    if (res.Status && Util.IsJson(res.RawText))
                    {
                        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(false); return;
                            }
                            if (TransferInfo.srcLocationId != null)
                            {
                                LocationInfo _srcLocationInfo = LocationBusiness.getInfo(Convert.ToInt32(TransferInfo.srcLocationId));
                                if (_srcLocationInfo != null)
                                {
                                    TransferInfo.srcLocationName = _srcLocationInfo.completeName;
                                }
                            }
                            alertStateTransfer(TransferInfo.state);
                        }
                        else
                        {
                            clearData(false);
                            MessageBox.Show("Not exists transfer number !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        }
                    }
                    else
                    {
                        clearData(false);
                        MessageBox.Show("res.RawText: " + res.RawText);
                    }
                }
                catch (Exception ex)
                {
                    clearData(false);
                    MessageBox.Show("Load data error: " + ex.Message.ToString());
                }
            }
        }
コード例 #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            LocationInfo locationInfo = LocationBusiness.getInfo(_LocationInfo.id);

            if (locationInfo == null)
            {
                MessageBox.Show("Location is not exists in inventory!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return;
            }

            //_action = "save";
            string param = "";

            try
            {
                _Adjustment.adjustmentDetails = this._ListSpace;//Util.DataTableToList<AdjustmentDetail>(this.dtList);
                param = JsonConvert.SerializeObject(_Adjustment);
                param = param.Replace(System.Environment.NewLine, "").Trim();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Client error: " + ex.ToString());
                return;
            }

            ApiResponse res = new ApiResponse();

            res.Status = false;
            string url = "inventories/gen-details";

            //string url = "inventories/" + this.Adjustment.id.ToString();

            //Util.Logs(param);

            try
            {
                //res = HTTP.Put(url, param);
                res = HTTP.PostJson(url, param);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }

            if (res.Status)
            {
                try
                {
                    Adjustment RootObject = JsonConvert.DeserializeObject <Adjustment>(res.RawText, new JsonSerializerSettings
                    {
                        NullValueHandling = NullValueHandling.Ignore
                    });

                    Adjustment AdjustmentResponse     = RootObject as Adjustment;
                    List <AdjustmentDetail> ListError = AdjustmentResponse.errorDetails;
                    foreach (AdjustmentDetail item in ListError)
                    {
                        if (item.id != null)
                        {
                            DataRow[] rs_package = dtList.Select("id" + " = " + item.id.ToString());
                            if (rs_package.Length > 0)
                            {
                                rs_package[0][COL_STATUS] = "error";
                            }
                        }
                        else
                        {
                            DataRow[] rs_package;
                            if (item.packageNumber != null && item.traceNumber != null)
                            {
                                rs_package = dtList.Select(COL_PACK + " = '" + item.packageNumber + "' AND " + COL_LOT + " = '" + item.traceNumber + "'");
                            }
                            else if (item.packageNumber != null)
                            {
                                rs_package = dtList.Select(COL_PACK + " = '" + item.packageNumber + "'");
                            }
                            else //if (item.traceNumber != null)
                            {
                                rs_package = dtList.Select(COL_LOT + " = '" + item.traceNumber + "'");
                            }
                            if (rs_package.Length > 0)
                            {
                                rs_package[0][COL_STATUS] = "error";
                            }
                        }
                    }

                    this.dtList.DefaultView.Sort = COL_STATUS + " DESC";
                    this.dtList = this.dtList.DefaultView.ToTable();

                    this.dgCuonList.DataSource = this.dtList;
                    this.dgCuonList.Refresh();
                }
                catch (Exception ex) { MessageBox.Show("View error: " + ex.Message.ToString()); }

                MessageBox.Show("Success !");
                btnSave.Enabled = false;
                //btnClear.Enabled = false;
                //this.dtList.Rows.Clear();
                //this.dgCuonList.Refresh();
                //this._ListSpace.Clear();
                this.locationBarcode = null;
                //this.lblLocationBarcode.Text = null;
            }
            else
            {
                //Util.Logs("res.Message: " + res.Message + " --- res.RawText: " + res.RawText);
            }
        }