Exemplo n.º 1
0
        public static StockQuants getStockUid(string lotNumber)
        {
            Lots Lot = LotBusiness.getInfo(lotNumber);

            if (Lot == null)
            {
                return(null);
            }

            ApiResponse res = new ApiResponse();

            res.Status = false;
            string url = "quants/search?query=lotId==" + Lot.id.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);
            }
        }
Exemplo n.º 2
0
        private void addPackageFromStock(int _id, string _packageId, bool isPackage, string _productName, string _locationBarcode, string type, double realDefault)
        {
            List <Quant> ListQuant = new List <Quant>();

            if (!isPackage)
            {
                Lots lotInfo = LotBusiness.getFullInfo(_id);
                if (lotInfo.quants == null)
                {
                    addPackageToList(null, _packageId, realDefault, _productName, _locationBarcode, type);
                    return;
                }
                else
                {
                    ListQuant.Add(lotInfo.quants[0]);
                }
            }
            else
            {
                Packages packageInfo = PackageBusiness.getFullInfo(_id);
                if (packageInfo.quants == null)
                {
                    addPackageToList(_packageId, null, realDefault, _productName, _locationBarcode, type);
                    return;
                }
                else
                {
                    ListQuant = packageInfo.quants;
                }
            }

            try
            {
                if (!isPackage)
                {
                    addPackageToList(null, _packageId, ListQuant[0].onHand, _productName, _locationBarcode, type);
                }
                else if (ListQuant.Count == 1 && ListQuant[0].lotId == null)
                {
                    addPackageToList(_packageId, null, ListQuant[0].onHand, _productName, _locationBarcode, type);
                }
                else
                {
                    foreach (Quant item in ListQuant)
                    {
                        if (item.lotId != null)
                        {
                            Lots Lot = LotBusiness.getFullInfo(Convert.ToInt32(item.lotId));
                            addPackageToList(_packageId, Lot.lotNumber, item.onHand, Lot.internalReference, _locationBarcode, type);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Add package from stock to list: " + ex.Message.ToString(), "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return;
            }
        }
Exemplo n.º 3
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);
        }