Ejemplo n.º 1
0
        public static StockQuants getStockUid(int lotId)
        {
            ApiResponse res = new ApiResponse();

            res.Status = false;
            string url = "quants/search?query=lotId==" + lotId.ToString() + ";onHand>0";

            res = HTTP.GetJson(url);
            if (res.Status && Util.IsJson(res.RawText))
            {
                List <StockQuants> RootObject = JsonConvert.DeserializeObject <List <StockQuants> >(res.RawText, new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore
                });
                if (RootObject.Count > 0)
                {
                    return(RootObject[0]);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        public static double getStockQuantPackage(string PackageNumber)
        {
            double             total     = 0;
            List <StockQuants> ListStock = new List <StockQuants>();
            Packages           Package   = PackageBusiness.getInfo(PackageNumber);

            if (Package == null)
            {
                return(total);
            }

            ApiResponse res = new ApiResponse();

            res.Status = false;
            string url = "quants/search?query=packageId==" + Package.id.ToString() + ";onHand>0";

            res = HTTP.GetJson(url);
            if (res.Status && Util.IsJson(res.RawText))
            {
                ListStock = JsonConvert.DeserializeObject <List <StockQuants> >(res.RawText, new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore
                });
            }
            foreach (StockQuants item in ListStock)
            {
                total += item.onHand;
            }
            return(total);
        }
Ejemplo n.º 3
0
        public static List <TransferInfo> getListTransfer(string api)
        {
            ApiResponse res = new ApiResponse();

            res.Status = false;
            List <TransferInfo> ListTransfer = new List <TransferInfo>();

            try
            {
                string url = "transfers/" + api;
                res = HTTP.GetJson(url);

                if (res.Status && Util.IsJson(res.RawText))
                {
                    List <TransferInfo> RootObject = JsonConvert.DeserializeObject <List <TransferInfo> >(res.RawText, new JsonSerializerSettings
                    {
                        NullValueHandling = NullValueHandling.Ignore
                    });
                    ListTransfer = RootObject as List <TransferInfo>;
                }
            }
            catch (Exception ex)
            {
            }
            return(ListTransfer);
        }
Ejemplo n.º 4
0
        public static TransferInfo getTransferInfo(int transferId)
        {
            ApiResponse res = new ApiResponse();

            res.Status = false;
            TransferInfo TransferInfo = new TransferInfo();

            try
            {
                string url = "transfers/" + transferId.ToString().Trim();
                res = HTTP.GetJson(url);

                if (res.Status && Util.IsJson(res.RawText))
                {
                    TransferInfo RootObject = JsonConvert.DeserializeObject <TransferInfo>(res.RawText, new JsonSerializerSettings
                    {
                        NullValueHandling = NullValueHandling.Ignore
                    });
                    TransferInfo = RootObject as TransferInfo;
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
            return(TransferInfo);
        }
Ejemplo n.º 5
0
        public static Lots getInfo(string lotNumber)
        {
            ApiResponse res = new ApiResponse();

            res.Status = false;
            string url = "lots/search?query=lotNumber==\"" + lotNumber + "\"";

            res = HTTP.GetJson(url);
            if (res.Status && Util.IsJson(res.RawText))
            {
                List <Lots> RootObject = JsonConvert.DeserializeObject <List <Lots> >(res.RawText, new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore
                });
                if (RootObject.Count > 0)
                {
                    return(RootObject[0]);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
        public Packages getInfo(int packageId)
        {
            ApiResponse res = new ApiResponse();

            res.Status = false;
            string url = "packages/search?query=id==" + packageId.ToString();

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

                if (RootObject.Count > 0)
                {
                    return(RootObject[0]);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 7
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;
                            }
                            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());
                }
            }
        }
Ejemplo n.º 8
0
        private bool getTransferById()
        {
            if (_transferId > 0)
            {
                ApiResponse res = new ApiResponse();
                res.Status = false;

                try
                {
                    string url = "transfers/" + _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
                    {
                        TransferInfo RootObject = JsonConvert.DeserializeObject <TransferInfo>(res.RawText, new JsonSerializerSettings
                        {
                            NullValueHandling = NullValueHandling.Ignore
                        });

                        TransferInfo = RootObject;
                        _transferId  = TransferInfo.id;
                        if (!getListTransferItem(_transferId))
                        {
                            clearData(true); return(false);
                        }
                        txtTransferNumber.Text = TransferInfo.transferNumber;
                        //alertStateTransfer(TransferInfo.state);
                    }
                    catch (Exception ex)
                    {
                        clearData(true);
                        MessageBox.Show("Exception: " + ex.Message.ToString());
                        return(false);
                    }
                }
                else
                {
                    clearData(true);
                    MessageBox.Show("Not exists transfer number !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    return(false);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 9
0
        private bool getListTransferItem(int transferId)
        {
            ApiResponse res = new ApiResponse();

            res.Status = false;

            try
            {
                string url = "transfer-items/search?query=transferId==" + transferId.ToString() + ";((optionOf!=null),(optionOf==null;level==null))&size=150";
                res = HTTP.GetJson(url);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Get transfer items error: " + ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return(false);
            }
            try
            {
                if (res.Status && Util.IsJson(res.RawText))
                {
                    this.ListTransferItem = JsonConvert.DeserializeObject <List <TransferItem> >(res.RawText, new JsonSerializerSettings
                    {
                        NullValueHandling = NullValueHandling.Ignore
                    });
                    dtList      = Util.ToDataTable <TransferItem>(ListTransferItem);
                    this.dtList = buildTable(dtList);
                    foreach (DataRow dr in this.dtList.Rows)
                    {
                        if (dr[COL_INTERNAL_REFERENCE] == null || dr[COL_INTERNAL_REFERENCE].ToString().Length == 0)
                        {
                            dr[COL_INTERNAL_REFERENCE] = dr["productName"].ToString();
                        }
                    }

                    loadList(dgList, dtList, Color.White);
                }
                else
                {
                    MessageBox.Show(res.RawText);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Load transfer items error: " + ex.Message.ToString());
                return(false);
            }
            return(true);
        }
Ejemplo n.º 10
0
        private LocationInfo getLocationInfo(string locationBarcode)
        {
            ApiResponse res = new ApiResponse();

            res.Status = false;
            try
            {
                string url = "locations/search?query=barcode==\"" + locationBarcode + "\"";
                res = HTTP.GetJson(url);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
                return(null);
            }

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

                    List <LocationInfo> ListLocations = RootObject as List <LocationInfo>;
                    if (ListLocations.Count > 0)
                    {
                        return(ListLocations[0]);
                    }
                    else
                    {
                        MessageBox.Show("Location is not exists in inventory!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        return(null);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                    return(null);
                }
            }
            else
            {
                MessageBox.Show("Error during load information location !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return(null);
            }
        }
Ejemplo n.º 11
0
        public static List <StockQuants> getStockPackage(int PackageId)
        {
            List <StockQuants> ListStock = new List <StockQuants>();
            ApiResponse        res       = new ApiResponse();

            res.Status = false;
            string url = "quants/search?query=packageId==" + PackageId.ToString() + ";onHand>0";

            res = HTTP.GetJson(url);
            if (res.Status && Util.IsJson(res.RawText))
            {
                ListStock = JsonConvert.DeserializeObject <List <StockQuants> >(res.RawText, new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore
                });
            }
            return(ListStock);
        }
Ejemplo n.º 12
0
        private DataTable getListTransfer(string api)
        {
            ApiResponse res = new ApiResponse();

            res.Status = false;
            DataTable dtList = new DataTable();

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

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

                    List <TransferInfo> ListTransfer = RootObject as List <TransferInfo>;
                    dtList = Util.ToDataTable <TransferInfo>(ListTransfer);
                }
                else
                {
                    MessageBox.Show("Get transfer info error: " + res.RawText);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception : " + ex.Message.ToString());
            }
            return(dtList);
        }
Ejemplo n.º 13
0
        public static Lots getFullInfo(int lotId)
        {
            ApiResponse res = new ApiResponse();

            res.Status = false;
            string url = "lots/" + lotId.ToString();

            res = HTTP.GetJson(url);
            if (res.Status && Util.IsJson(res.RawText))
            {
                Lots RootObject = JsonConvert.DeserializeObject <Lots>(res.RawText, new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore
                });
                return(RootObject);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 14
0
        private bool checkReservedInOtherList(string _packageId, bool _isPackage)
        {
            string url = "";

            if (_isPackage)
            {
                url = "transfer-details/search?query=srcPackageNumber=='" + _packageId + "';state!='done'";
            }
            else
            {
                url = "transfer-details/search?query=traceNumber=='" + _packageId + "';state!='done'";
            }
            ApiResponse res = new ApiResponse();

            res.Status = false;
            List <TransferDetail> ListTransferDetail = new List <TransferDetail>();

            try
            {
                res = HTTP.GetJson(url);

                if (res.Status && Util.IsJson(res.RawText))
                {
                    List <TransferDetail> RootObject = JsonConvert.DeserializeObject <List <TransferDetail> >(res.RawText, new JsonSerializerSettings
                    {
                        NullValueHandling = NullValueHandling.Ignore
                    });
                    ListTransferDetail = RootObject as List <TransferDetail>;
                    if (ListTransferDetail.Count == 0)
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 15
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
        }
Ejemplo n.º 16
0
        private void loadProductsManually(int _adjustmentId)
        {
            dtList.Rows.Clear();

            ApiResponse res = new ApiResponse();

            res.Status = false;
            //Load danh sach linh kien
            try
            {
                string url = "adjustment-inputs/search?query=adjustmentId==" + _adjustmentId + "&page=0&size=1000&sort=,asc";
                res = HTTP.GetJson(url);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Load adjustment input data Fail !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }

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

                    ListDetail = RootObject as List <AdjustmentInput>;

                    foreach (AdjustmentInput item in ListDetail)
                    {
                        if (item.internalReference == null && item.productId != null)
                        {
                            Product product     = new Product();
                            Product productInfo = product.getInfo(item.productId);
                            if (productInfo != null)
                            {
                                item.internalReference = productInfo.name;
                            }
                        }
                    }

                    dtList = Util.ToDataTable <AdjustmentInput>(ListDetail);

                    dgCuonList.DataSource = dtList;
                    dgCuonList.TableStyles.Clear();

                    DataGridTableStyle tableStyle = new DataGridTableStyle();
                    tableStyle.MappingName = dtList.TableName;
                    foreach (DataColumn item in dtList.Columns)
                    {
                        DataGridTextBoxColumn tbcName = new DataGridTextBoxColumn();

                        switch (item.ColumnName)
                        {
                        case "internalReference":
                        {
                            tbcName.MappingName = item.ColumnName;
                            tbcName.HeaderText  = "Product";
                            tbcName.Width       = 100;
                        } break;

                        case "packageNumber":
                        {
                            tbcName.MappingName = item.ColumnName;
                            tbcName.HeaderText  = "Package";
                            tbcName.Width       = 60;
                        } break;

                        case "traceNumber":
                        {
                            tbcName.MappingName = item.ColumnName;
                            tbcName.HeaderText  = "Unit ID";
                            tbcName.Width       = 60;
                        } break;

                        default:
                        {
                            tbcName.Width = 20;
                        } break;
                        }

                        tableStyle.GridColumnStyles.Add(tbcName);
                    }

                    dgCuonList.TableStyles.Add(tableStyle);
                    dgCuonList.Refresh();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    //MessageBox.Show("Error during loading information !");
                }
            }
            else
            {
                //MessageBox.Show(res.RawText);
            }
        }
Ejemplo n.º 17
0
        private void ScanCode(string dcdData)
        {
            if (dcdData.StartsWith("["))
            {
                #region Scan Package/Unit ID new
                try
                {
                    LabelPackage labelPackage = new LabelPackage(dcdData.Trim());
                    DataRow[]    rs_package   = null;

                    bool _exists_package = false;

                    if (labelPackage.PackageId != null && labelPackage.PackageId != "")
                    {
                        rs_package = dtList.Select(COL_ID + " = '" + labelPackage.PackageId + "'");
                        if (rs_package.Length > 0)
                        {
                            _exists_package = true;
                        }

                        //DialogResult mgb = new DialogResult();
                        if (_exists_package)
                        {
                            //mgb = MessageBox.Show("Package not exists in list !", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                            //if (mgb == DialogResult.Yes)
                            //{
                            //    dr = dtList.Select("internalReference = '" + labelPackage.ProductName + "' AND " + COL_ID + " = '" + labelPackage.PackageId + "'").FirstOrDefault();
                            //    if(dr == null)
                            //        addPackageNotInList(labelPackage.ProductName, labelPackage.PackageId);
                            //}
                            MessageBox.Show("Package already exists in the list !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        }
                        else
                        {
                            addPackageToList(labelPackage.ProductName, labelPackage.PackageId);

                            if (BarcodeLocation != null && BarcodeLocation.Trim().Length > 0 && !btnSave.Enabled)
                            {
                                //enable button save
                                btnSave.Enabled  = true;
                                btnClear.Enabled = true;
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Error scan!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Wrong Package/Unit ID QRCode format !");
                    //MessageBox.Show(ex.InnerException.ToString());
                    //MessageBox.Show("Error during loading information !", "Chu y", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }
                #endregion
            }
            else if (dcdData.Trim().StartsWith("PN:"))
            {
                #region Scan Package/Unit ID old
                try
                {
                    TemCuon   temCuon    = new TemCuon(dcdData.Trim());
                    DataRow[] rs_package = null;

                    bool _exists_package = false;

                    if (temCuon.IdCuon != null && temCuon.IdCuon != "")
                    {
                        rs_package = dtList.Select(COL_ID + " = '" + temCuon.IdCuon + "'");
                        if (rs_package.Length > 0)
                        {
                            _exists_package = true;
                        }

                        //DialogResult mgb = new DialogResult();
                        if (_exists_package)
                        {
                            //mgb = MessageBox.Show("Package not exists in list !", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                            //if (mgb == DialogResult.Yes)
                            //{
                            //    dr = dtList.Select("internalReference = '" + labelPackage.ProductName + "' AND " + COL_ID + " = '" + labelPackage.PackageId + "'").FirstOrDefault();
                            //    if(dr == null)
                            //        addPackageNotInList(labelPackage.ProductName, labelPackage.PackageId);
                            //}
                            MessageBox.Show("Package already exists in the list !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        }
                        else
                        {
                            addPackageToList(temCuon.VnptPn, temCuon.IdCuon, Convert.ToInt32(temCuon.Type));

                            if (BarcodeLocation != null && BarcodeLocation.Trim().Length > 0 && !btnSave.Enabled)
                            {
                                //enable button save
                                btnSave.Enabled  = true;
                                btnClear.Enabled = true;
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Error scan!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Wrong Package/Unit ID QRCode format !");
                }
                #endregion
            }
            else if (Util.OnlyHexInString(dcdData.Trim()))
            {
                #region Scan Serial number
                try
                {
                    string    SerialNumber    = dcdData.Trim();
                    DataRow[] rs_package      = null;
                    bool      _exists_package = false;

                    if (SerialNumber != null && SerialNumber != "")
                    {
                        rs_package = dtList.Select(COL_ID + " = '" + SerialNumber + "'");
                        if (rs_package.Length > 0)
                        {
                            _exists_package = true;
                        }

                        //DialogResult mgb = new DialogResult();
                        if (_exists_package)
                        {
                            //mgb = MessageBox.Show("Package not exists in list !", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                            //if (mgb == DialogResult.Yes)
                            //{
                            //    dr = dtList.Select("internalReference = '" + labelPackage.ProductName + "' AND " + COL_ID + " = '" + labelPackage.PackageId + "'").FirstOrDefault();
                            //    if(dr == null)
                            //        addPackageNotInList(labelPackage.ProductName, labelPackage.PackageId);
                            //}
                            MessageBox.Show("Package/Serial number already exists in the list !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        }
                        else
                        {
                            addPackageToList(null, SerialNumber);

                            if (BarcodeLocation != null && BarcodeLocation.Trim().Length > 0 && !btnSave.Enabled)
                            {
                                //enable button save
                                btnSave.Enabled  = true;
                                btnClear.Enabled = true;
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Error scan!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Wrong Package/Unit ID QRCode format !");
                    //MessageBox.Show(ex.InnerException.ToString());
                    //MessageBox.Show("Error during loading information !", "Chu y", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }
                #endregion
            }
            else
            {
                #region Scan location

                ApiResponse res = new ApiResponse();
                res.Status = false;
                try
                {
                    string url = "locations/search?query=barcode==\"" + dcdData.Trim() + "\"";
                    res = HTTP.GetJson(url);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error during load location information !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }

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

                        List <LocationInfo> ListLocations = RootObject as List <LocationInfo>;
                        this.lblLocationBarcode.Text = ListLocations[0].name;
                        BarcodeLocation = dcdData;

                        if (this.dtList.Rows.Count > 0 && !btnSave.Enabled)
                        {
                            //enable button save
                            btnSave.Enabled  = true;
                            btnClear.Enabled = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error during load location information !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    }
                }
                #endregion
            }
        }
Ejemplo n.º 18
0
        private void txtTransferNumber_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                string      _inventoryName = txtInventoryName.Text.Trim();
                ApiResponse res            = new ApiResponse();
                res.Status = false;

                try
                {
                    string url = "inventories/search?query=reference=='" + _inventoryName + "'";
                    res = HTTP.GetJson(url);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Not exists inventory name !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }
                try
                {
                    if (res.Status && Util.IsJson(res.RawText))
                    {
                        List <Adjustment> RootObject = JsonConvert.DeserializeObject <List <Adjustment> >(res.RawText, new JsonSerializerSettings
                        {
                            NullValueHandling = NullValueHandling.Ignore
                        });

                        if (RootObject.Count > 0)
                        {
                            _Adjustment   = RootObject[0];
                            _adjustmentId = _Adjustment.id;
                            this.lblInventoryOfValue.Text       = _Adjustment.inventoryOf;
                            this.lblInventoryLocationValue.Text = _Adjustment.locationName;
                            this.ListSpace.Clear();

                            checkScan(_Adjustment);

                            if (_adjustmentId != 0)
                            {
                                LoadData(_Adjustment);
                            }
                            else
                            {
                                txtInventoryName.Focus();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Not exists inventory name !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        }
                    }
                    else
                    {
                        MessageBox.Show(res.RawText);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error during loading information !");
                }
            }
        }
Ejemplo n.º 19
0
        private bool checkScan(string _productName, string _packageId, string type)
        {
            if (_LocationInfo == null)
            {
                MessageBox.Show("Request scan location before scan the package!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return(false);
            }

            //Check package exists in inventory
            ApiResponse res = new ApiResponse();

            res.Status = false;
            string url = "";
            int    _id = 0; bool isPackage = true;

            if (Util.getTypePackage(_packageId, type) % 2 == 0)
            {
                isPackage = false;
                Lots lotInfo = LotBusiness.getInfo(_packageId);
                if (lotInfo == null)
                {
                    DialogResult mgb = new DialogResult();
                    mgb = MessageBox.Show("Uid is not exists in inventory! Do you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    //if (mgb != DialogResult.Yes) return false;
                    return(false);
                }
                url = "adjustment-details/search?query=adjustmentId==" + _Adjustment.id.ToString() + ";lotId==" + lotInfo.id.ToString();
                _id = lotInfo.id;
            }
            else //if (Util.getTypePackage(_packageId, type) % 2 != 0)
            {
                isPackage = true;
                Packages packageInfo = PackageBusiness.getInfo(_packageId);
                if (packageInfo == null)
                {
                    DialogResult mgb = new DialogResult();
                    mgb = MessageBox.Show("Package is not exists in inventory! Do you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    //if (mgb != DialogResult.Yes) return false;
                    return(false);
                }
                url = "adjustment-details/search?query=adjustmentId==" + _Adjustment.id.ToString() + ";packageId==" + packageInfo.id.ToString();
                _id = packageInfo.id;
            }
            if (url.Length == 0)
            {
                MessageBox.Show("Wrong Package/Unit ID QRCode format !"); return(false);
            }

            try
            {
                res = HTTP.GetJson(url);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Server error: " + ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return(false);
            }
            List <AdjustmentDetail> ListDetail;

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

                ListDetail = RootObject as List <AdjustmentDetail>;

                if (checkExistsInTable(_packageId, Convert.ToInt32(type)))
                {
                    return(false);
                }
                else
                {
                    if (ListDetail.Count == 0)
                    {
                        DialogResult mgb = new DialogResult();
                        mgb = MessageBox.Show("Package/UnitID is not exists in inventory adjustment! Do you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        if (mgb != DialogResult.Yes)
                        {
                            return(false);
                        }

                        addPackageFromStock(_id, _packageId, isPackage, _productName, _LocationInfo.barcode, null, 1);

                        //enable button save
                        if (_LocationInfo != null && !btnSave.Enabled)
                        {
                            btnSave.Enabled = true;
                        }
                    }
                    else
                    {
                        if (Util.getTypePackage(_packageId, type) % 2 == 0 || ListDetail.Count == 1)
                        {
                            addPackageToList(ListDetail[0]);
                        }
                        else //Util.getTypePackage(_packageId, type) % 2 != 0
                        {
                            foreach (AdjustmentDetail item in ListDetail)
                            {
                                addPackageToList(item);
                            }
                        }

                        //enable button save
                        if (_LocationInfo != null && !btnSave.Enabled)
                        {
                            btnSave.Enabled = true;
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Server error !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 20
0
        private void ScanCode(string dcdData)
        {
            if (dcdData.StartsWith("["))
            {
                #region Scan Package/Unit ID new
                if (this._LocationInfo == null)
                {
                    MessageBox.Show("Request scan location before scan the package!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    return;
                }

                try
                {
                    string       scanValue    = dcdData.Replace(System.Environment.NewLine, "").Trim();
                    LabelPackage labelPackage = new LabelPackage(scanValue);

                    //Util.Logs(labelPackage.PackageId);

                    if (labelPackage.PackageId != null && labelPackage.PackageId != "")
                    {
                        //Check package exists in inventory
                        ApiResponse res = new ApiResponse();
                        res.Status = false;
                        string url = "";
                        int    _id = 0; bool isPackage = true;
                        if (Util.getTypePackage(labelPackage.PackageId, null) % 2 == 0)
                        {
                            isPackage = false;
                            Lots lot     = new Lots();
                            Lots lotInfo = lot.getInfo(labelPackage.PackageId);
                            if (lotInfo == null)
                            {
                                MessageBox.Show("Unit ID is not exists in inventory !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                                return;
                            }
                            else
                            {
                                url = "adjustment-details/search?query=adjustmentId==" + _Adjustment.id.ToString() + ";lotId==" + lotInfo.id.ToString();
                                _id = lotInfo.id;
                            }
                        }
                        else if (Util.getTypePackage(labelPackage.PackageId, null) % 2 != 0)
                        {
                            isPackage = true;
                            Packages package     = new Packages();
                            Packages packageInfo = package.getInfo(labelPackage.PackageId);
                            if (packageInfo == null)
                            {
                                MessageBox.Show("Package is not exists in inventory !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                                return;
                            }
                            else
                            {
                                url = "adjustment-details/search?query=adjustmentId==" + _Adjustment.id.ToString() + ";packageId==" + packageInfo.id.ToString();
                                _id = packageInfo.id;
                            }
                        }
                        if (url.Length == 0)
                        {
                            MessageBox.Show("Wrong Package/Unit ID QRCode format !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                            return;
                        }

                        try
                        {
                            res = HTTP.GetJson(url);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Server error !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                            return;
                        }
                        List <AdjustmentDetail> ListDetail;
                        if (res.Status && Util.IsJson(res.RawText))
                        {
                            List <AdjustmentDetail> RootObject = JsonConvert.DeserializeObject <List <AdjustmentDetail> >(res.RawText, new JsonSerializerSettings
                            {
                                NullValueHandling = NullValueHandling.Ignore
                            });

                            ListDetail = RootObject as List <AdjustmentDetail>;

                            if (checkExistsInTable(labelPackage.PackageId))
                            {
                                return;
                            }
                            else
                            {
                                if (ListDetail.Count == 0)
                                {
                                    DialogResult mgb = new DialogResult();
                                    mgb = MessageBox.Show("Package/Unit ID is not exists in inventory adjustment! Do you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                                    if (mgb != DialogResult.Yes)
                                    {
                                        return;
                                    }

                                    addPackageFromStock(_id, labelPackage.PackageId, isPackage, labelPackage.ProductName, _LocationInfo.barcode, null, 0);
                                    //addPackageToList(labelPackage.PackageId, 0, labelPackage.ProductName, _LocationInfo.barcode);

                                    //enable button save
                                    if (_LocationInfo != null && !btnSave.Enabled)
                                    {
                                        btnSave.Enabled = true;
                                    }
                                }
                                else
                                {
                                    if (labelPackage.PackageId.StartsWith(PREFIX_LOT) || ListDetail.Count == 1)
                                    {
                                        addPackageToList(ListDetail[0]);
                                    }
                                    else if (labelPackage.PackageId.StartsWith(PREFIX_PACK))
                                    {
                                        foreach (AdjustmentDetail item in ListDetail)
                                        {
                                            addPackageToList(item);
                                        }
                                    }

                                    //enable button save
                                    if (_LocationInfo != null && !btnSave.Enabled)
                                    {
                                        btnSave.Enabled = true;
                                    }
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("Server error !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Wrong Package/Unit ID QRCode format !");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error scan!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }
                #endregion
            }
            else if (dcdData.Trim().StartsWith("PN:"))
            {
                #region Scan Package/Unit ID old
                if (_LocationInfo == null)
                {
                    MessageBox.Show("Request scan location before scan the package!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    return;
                }

                try
                {
                    string  scanValue = dcdData.Replace(System.Environment.NewLine, "").Trim();
                    TemCuon temCuon   = new TemCuon(scanValue);

                    if (temCuon.IdCuon != null && temCuon.IdCuon != "")
                    {
                        //Check package exists in inventory
                        ApiResponse res = new ApiResponse();
                        res.Status = false;
                        string url = "";
                        int    _id = 0; bool isPackage = true;

                        if (Convert.ToInt32(temCuon.Type) == 0)
                        {
                            isPackage = false;
                            Lots lot     = new Lots();
                            Lots lotInfo = lot.getInfo(temCuon.IdCuon);
                            if (lotInfo == null)
                            {
                                DialogResult mgb = new DialogResult();
                                mgb = MessageBox.Show("Uid is not exists in inventory! Do you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                                if (mgb != DialogResult.Yes)
                                {
                                    return;
                                }
                                if (checkExistsInTable(temCuon.IdCuon, Convert.ToInt32(temCuon.Type)))
                                {
                                    return;
                                }
                                addPackageToList(null, temCuon.IdCuon, Convert.ToDouble(temCuon.SoLuong), temCuon.VnptPn, _LocationInfo.barcode, temCuon.Type);
                            }
                            url = "adjustment-details/search?query=adjustmentId==" + _Adjustment.id.ToString() + ";lotId==" + lotInfo.id.ToString();
                            _id = lotInfo.id;
                        }
                        else if (Convert.ToInt32(temCuon.Type) == 1)
                        {
                            isPackage = true;
                            Packages package     = new Packages();
                            Packages packageInfo = package.getInfo(temCuon.IdCuon);
                            if (packageInfo == null)
                            {
                                DialogResult mgb = new DialogResult();
                                mgb = MessageBox.Show("Package is not exists in inventory! Do you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                                if (mgb != DialogResult.Yes)
                                {
                                    return;
                                }
                                if (checkExistsInTable(temCuon.IdCuon, Convert.ToInt32(temCuon.Type)))
                                {
                                    return;
                                }
                                addPackageToList(temCuon.IdCuon, null, Convert.ToDouble(temCuon.SoLuong), temCuon.VnptPn, _LocationInfo.barcode, temCuon.Type);
                            }
                            url = "adjustment-details/search?query=adjustmentId==" + _Adjustment.id.ToString() + ";packageId==" + packageInfo.id.ToString();
                            _id = packageInfo.id;
                        }
                        if (url.Length == 0)
                        {
                            MessageBox.Show("Wrong Package/Unit ID QRCode format !"); return;
                        }

                        try
                        {
                            res = HTTP.GetJson(url);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Server error !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                            return;
                        }
                        List <AdjustmentDetail> ListDetail;
                        if (res.Status && Util.IsJson(res.RawText))
                        {
                            List <AdjustmentDetail> RootObject = JsonConvert.DeserializeObject <List <AdjustmentDetail> >(res.RawText, new JsonSerializerSettings
                            {
                                NullValueHandling = NullValueHandling.Ignore
                            });

                            ListDetail = RootObject as List <AdjustmentDetail>;

                            if (checkExistsInTable(temCuon.IdCuon, Convert.ToInt32(temCuon.Type)))
                            {
                                return;
                            }
                            else
                            {
                                if (ListDetail.Count == 0)
                                {
                                    DialogResult mgb = new DialogResult();
                                    mgb = MessageBox.Show("Package/Unit ID is not exists in inventory adjustment! Do you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                                    if (mgb != DialogResult.Yes)
                                    {
                                        return;
                                    }

                                    addPackageFromStock(_id, temCuon.IdCuon, isPackage, temCuon.VnptPn, _LocationInfo.barcode, temCuon.Type, Convert.ToDouble(temCuon.SoLuong));
                                    //addPackageToList(temCuon.IdCuon, 0, temCuon.VnptPn, _LocationInfo.barcode, Convert.ToInt32(temCuon.Type));

                                    //enable button save
                                    if (_LocationInfo != null && !btnSave.Enabled)
                                    {
                                        btnSave.Enabled = true;
                                    }
                                }
                                else
                                {
                                    if (Convert.ToInt32(temCuon.Type) == 0 || ListDetail.Count == 1)
                                    {
                                        addPackageToList(ListDetail[0]);
                                    }
                                    else if (Convert.ToInt32(temCuon.Type) == 1)
                                    {
                                        foreach (AdjustmentDetail item in ListDetail)
                                        {
                                            addPackageToList(item);
                                        }
                                    }

                                    //enable button save
                                    if (_LocationInfo != null && !btnSave.Enabled)
                                    {
                                        btnSave.Enabled = true;
                                    }
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("Server error !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Wrong Package/Unit ID QRCode format !");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error scan!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }
                #endregion
            }
            else if (Util.OnlyHexInString(dcdData.Trim()))
            {
                #region scan serial number

                string SerialNumber = dcdData.Trim();
                checkScan(null, SerialNumber, null);

                #endregion
            }
            else
            {
                #region Scan location
                locationBarcode = dcdData.Replace(System.Environment.NewLine, "").Trim();
                try
                {
                    ApiResponse res = new ApiResponse();
                    res.Status = false;

                    string url   = "locations/check-child";
                    var    param = new
                    {
                        locationId = this._Adjustment.locationId,
                        barcode    = locationBarcode
                    };
                    res = HTTP.Post(url, param);
                    if (res.Status)
                    {
                        if (Convert.ToBoolean(res.RawText))
                        {
                            if (_LocationInfo != null)
                            {
                                DialogResult mgb = new DialogResult();
                                mgb = MessageBox.Show("Are you sure you want to update new scan location?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                                if (mgb != DialogResult.Yes)
                                {
                                    return;
                                }
                            }

                            _LocationInfo = getLocationInfo(locationBarcode);
                            if (_LocationInfo == null)
                            {
                                return;
                            }

                            this.lblLocationBarcode.Text = _LocationInfo.name;

                            //enable button save
                            if (this.dtList.Rows.Count > 0 && !btnSave.Enabled)
                            {
                                btnSave.Enabled = true;
                            }
                        }
                        else
                        {
                            MessageBox.Show("Location is not exists in adjustment name!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                            //btnSave.Enabled = false;
                            //this.dtList.Rows.Clear();
                            //this.dgCuonList.Refresh();
                            this.locationBarcode = null;
                            //this.lblLocationBarcode.Text = null;
                        }
                    }
                    else
                    {
                        //btnSave.Enabled = false;
                        //this.dtList.Rows.Clear();
                        //this.dgCuonList.Refresh();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error during load location information !");
                }
                #endregion
            }
        }
Ejemplo n.º 21
0
        private string getListOperations(int type)
        {
            string url;

            if (type == 0)
            {
                url = "operation-types/search?query=type=in=(\"incoming\")";
            }
            else
            {
                //url = "operation-types/search?query=type=in=(\"outcoming\",\"internal\",\"manufacturing\")";
                url = "operation-types/search?query=type=in=(\"outcoming\")";
            }

            ApiResponse res = new ApiResponse();

            res.Status = false;
            string result = "";

            try
            {
                res = HTTP.GetJson(url);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Get list operations error: " + ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return(result);
            }

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

                    List <Operation> ListOperation = RootObject as List <Operation>;
                    foreach (Operation item in ListOperation)
                    {
                        if (result.Length > 0)
                        {
                            result += "," + item.id.ToString();
                        }
                        else
                        {
                            result += item.id.ToString();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Load list operations error: " + res.RawText);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Parse operation error : " + ex.Message.ToString());
            }
            return(result);
        }
Ejemplo n.º 22
0
        private void ScanCode(string dcdData)
        {
            //dtList.Rows.Clear();

            try
            {
                if (dcdData.Trim().Length > 0)
                {
                    ApiResponse res = new ApiResponse();
                    res.Status = false;

                    try
                    {
                        string url = "inventories/search?query=reference==\"" + dcdData.Trim() + "\"";
                        res = HTTP.GetJson(url);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    }

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

                            if (RootObject.Count > 0)
                            {
                                _Adjustment = RootObject[0];
                                this.lblInventoryOfValue.Text       = _Adjustment.inventoryOf;
                                this.lblInventoryLocationValue.Text = _Adjustment.locationName;

                                _adjustmentId         = _Adjustment.id;
                                txtInventoryName.Text = _Adjustment.reference;
                                this.ListSpace.Clear();

                                checkScan(_Adjustment);

                                LoadData(_Adjustment);
                            }
                            else
                            {
                                MessageBox.Show("Not exists inventory name !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Error during loading information !");
                        }
                    }
                    else
                    {
                        MessageBox.Show(res.RawText);
                    }
                }
                else
                {
                    txtInventoryName.Focus();
                }
            }
            catch (Exception ex)
            {
                txtInventoryName.Text = null;
                dtList.Rows.Clear();
                _adjustmentId = 0;
                MessageBox.Show("Inventory name wrong format !");
            }
        }
Ejemplo n.º 23
0
        private Packages validateLot(int lotId)
        {
            ApiResponse res = new ApiResponse();

            res.Status = false;

            try
            {
                string url = "quants/search?query=lotId==" + lotId.ToString() + ";onHand>0&sort=created,desc";
                res = HTTP.GetJson(url);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Not exists unit ID number in inventory !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return(null);
            }

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

                    List <StockQuants> ListStock = RootObject as List <StockQuants>;

                    if (ListStock.Count == 0)
                    {
                        MessageBox.Show("Not exists unit ID number in inventory !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        return(null);
                    }
                    else
                    {
                        if (ListStock[0].packageId == null)
                        {
                            return(new Packages());
                        }
                        else
                        {
                            Packages package     = new Packages();
                            Packages packageInfo = package.getInfo(Convert.ToInt32(ListStock[0].packageId));
                            if (packageInfo == null)
                            {
                                return(null);
                            }
                            else
                            {
                                return(packageInfo);
                            }
                        }
                    }
                }
                catch (Exception ex) { return(null); }
            }
            else
            {
                return(null);
            }
        }