Ejemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
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.º 6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string      maXuatKho = txtMaXuatKho.Text.TrimStart().TrimEnd();
            ApiResponse res       = new ApiResponse();

            res.Status = false;

            var listPackage = listCodeFromListObject(listScanned);

            try
            {
                string url = "allocateXuatKho";
                if (this._checkOther == 1)
                {
                    url = "allocateXuatKhoOther";
                }
                var paras = new
                {
                    ma_xuat_kho  = maXuatKho,
                    list_package = listPackage
                };
                res = HTTP.Post(url, paras);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Xay ra loi trong qua trinh allocate!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }

            if (res.Status && Util.IsJson(res.RawText))
            {
                try
                {
                    //Get list save fail
                    List <string> _listFail = JsonConvert.DeserializeObject <List <string> >(res.RawText, new JsonSerializerSettings
                    {
                        NullValueHandling = NullValueHandling.Ignore
                    });

                    if (_listFail.Count > 0)
                    {
                        foreach (string _id in _listFail)
                        {
                            PackageInfo result = this.listScanned.SingleOrDefault(s => s.id_cuon == _id);
                            //add listSaveFail
                            if (result != null)
                            {
                                result.status = "Loi";
                                this.listSaveFail.Add(result);
                            }
                            //else
                            //{
                            //    PackageInfo _package_fail = new PackageInfo();
                            //    _package_fail.id_cuon = _id;
                            //    _package_fail.status = "Loi";
                            //    _package_fail.type = 0;
                            //    this.listSaveFail.Add(_package_fail);
                            //}
                        }
                        if (listScanned.Count > listSaveFail.Count)
                        {
                            MessageBox.Show("Da luu duoc " + (listScanned.Count - listSaveFail.Count).ToString() + " thung/cuon. Con " + listSaveFail.Count.ToString() + " thung/cuon da quet khong chinh xac!");
                        }
                        else
                        {
                            MessageBox.Show("Allocate khong thanh cong! Thung/cuon duoc quet khong chinh xac!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Luu thanh cong!");
                    }
                    _sl_thung_quet  = 0;
                    _sl_cuon_quet   = 0;
                    lblDaQuet.Text  = _sl_thung_quet.ToString() + " thùng/" + _sl_cuon_quet.ToString() + " cuon";
                    btnSave.Enabled = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Xay ra loi trong qua trinh luu!");
                }
            }
            else
            {
                MessageBox.Show(res.RawText);
            }

            //Done
            this.listScanned.Clear();

            //refresh data
            LoadData(maXuatKho);
        }
Ejemplo n.º 7
0
        private void LoadData(string maXuatKho)
        {
            ApiResponse res = new ApiResponse();

            res.Status = false;
            //Load danh sach linh kien
            try
            {
                string url = "getInfoXuatKho";
                if (this._checkOther == 1)
                {
                    url = "getInfoXuatKhoOther";
                }
                var paras = new
                {
                    ma_xuat_kho = maXuatKho
                };
                res = HTTP.Post(url, paras);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Loi tai du lieu xuat kho", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }

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

                    _sl_thung_xuat      = Convert.ToInt32(Util.ReflectPropertyValue(RootObject, "sl_thung"));
                    _sl_cuon_xuat       = Convert.ToInt32(Util.ReflectPropertyValue(RootObject, "sl_cuon"));
                    this.lblDaXuat.Text = _sl_thung_xuat.ToString() + " thùng/" + _sl_cuon_xuat.ToString() + " cuon";

                    object        details    = Util.ReflectPropertyValue(RootObject, "detail");
                    List <Detail> ListDetail = details as List <Detail>;

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

                    dtList.Columns.Add(COL_SCANNED);
                    foreach (DataRow row in dtList.Rows)
                    {
                        row[COL_SCANNED] = 0;
                    }

                    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 "vnpt_pn":
                        {
                            tbcName.MappingName = item.ColumnName;
                            tbcName.HeaderText  = "VNPT P/N";
                            tbcName.Width       = 100;
                        } break;

                        case "total_export":
                        {
                            tbcName.MappingName = item.ColumnName;
                            tbcName.HeaderText  = "Đã xuất";
                            tbcName.Width       = 40;
                        } break;

                        case "total_request":
                        {
                            tbcName.MappingName = item.ColumnName;
                            tbcName.HeaderText  = "Tổng";
                            tbcName.Width       = 40;
                        } break;

                        case COL_SCANNED:
                        {
                            tbcName.MappingName = item.ColumnName;
                            tbcName.HeaderText  = "Đã quét";
                            tbcName.Width       = 40;
                        } break;

                        case "part_id":
                        {
                            tbcName.Width = -1;
                        } break;

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

                        if (tbcName.MappingName != "")
                        {
                            tbcName.MappingName = item.ColumnName;
                            tbcName.HeaderText  = item.ColumnName;
                        }

                        tableStyle.GridColumnStyles.Add(tbcName);
                    }

                    dgCuonList.TableStyles.Add(tableStyle);

                    dgCuonList.Refresh();
                    btnReset.Enabled = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Khong lay duoc du lieu");
                    txtMaXuatKho.Text = DEFAULT_TXT_MAXK;
                    _exp_code         = "";
                }
            }
            else
            {
                //if (Util.CleanStr(res.RawText) != "") MessageBox.Show(Util.CleanStr(res.RawText));
                MessageBox.Show(res.RawText);
                txtMaXuatKho.Text = DEFAULT_TXT_MAXK;
                _exp_code         = "";
            }
        }
Ejemplo n.º 8
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.º 9
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.º 10
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.º 11
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.º 12
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.º 13
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.º 14
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.º 15
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);
            }
        }
Ejemplo n.º 16
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.º 17
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.dtList.Rows.Count > 0)
            {
                ApiResponse res = new ApiResponse();
                res.Status = false;

                try
                {
                    string url = "smart-devices/move-packages";

                    string param = "{ \"destPackageNumber\": \"" + DestPackageNumber.Trim() + "\", \"lotNumbers\": [";
                    foreach (DataRow row in dtList.Rows)
                    {
                        param += "\"" + row[COL_LOT_ID] + "\",";
                    }
                    param = param.Replace(System.Environment.NewLine, "").Trim();
                    param = param.Substring(0, param.Length - 1);

                    //string end_char = param.Substring(param.Length - 2, 1);
                    //while (end_char != ",")
                    //{
                    //    param = param.Substring(0, param.Length - 2);
                    //    end_char = param.Substring(param.Length - 2, 1);
                    //}
                    //if (end_char == ",") param = param.Substring(0, param.Length - 2);

                    if (dtList.Rows[0][COL_PACK_ID] != null && dtList.Rows[0][COL_PACK_ID].ToString().Trim().Length > 0)
                    {
                        param += "], \"srcPackageNumber\": \"" + dtList.Rows[0][COL_PACK_ID] + "\" }";
                    }
                    else
                    {
                        param += "], \"srcPackageNumber\": null }";
                    }

                    param = param.Replace(System.Environment.NewLine, "").Trim();

                    res = HTTP.PostJson(url, param);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    //MessageBox.Show(ex.InnerException.ToString());
                }

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

                        PackagingResponse Response = RootObject as PackagingResponse;
                        if (Response.invalidLotNumbers.Count > 0)
                        {
                            string message = "Error occurred with unit ID: ";
                            foreach (string item in Response.invalidLotNumbers)
                            {
                                message += item + ",";
                            }
                            string end_char = message.Substring(message.Length - 1, 1);
                            if (end_char == ",")
                            {
                                message = message.Substring(0, message.Length - 1);
                            }
                            MessageBox.Show(message);
                        }
                        else
                        {
                            MessageBox.Show("Move unit ID to package successfully!");
                        }
                    }
                    catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }
                }
                else
                {
                    //MessageBox.Show(res.RawText);
                }

                //btnSave.Enabled = false;
                //btnClear.Enabled = true;
            }
            else
            {
                MessageBox.Show("Request scanned package before saving !");
            }
        }
Ejemplo n.º 18
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);
            }
        }
Ejemplo n.º 19
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            string maXuatKho = txtMaXuatKho.Text.TrimStart().TrimEnd();

            _exp_code = txtMaXuatKho.Text;

            btnLoad.Enabled  = false;
            btnReset.Enabled = false;
            listScanned.Clear();
            dtListCuon.Rows.Clear();

            if (maXuatKho != "")
            {
                ApiResponse res = new ApiResponse();
                res.Status = false;
                //Load danh sach linh kien
                try
                {
                    //string url = "getListThungXuatKho";
                    string url   = "getListCuonXuatKho";
                    var    paras = new
                    {
                        ma_xuat_kho = maXuatKho
                    };
                    res = HTTP.Post(url, paras);
                }
                catch (Exception ex) {
                    MessageBox.Show("Loi tai du lieu xuat kho", "Loi mang", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }

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

                        btnReset.Enabled = true;

                        //lblChuaQuet.Text = chuaQuet.ToString();

                        dtListCuon = Util.ToDataTable <CuonModel>(listCuon);

                        dtListCuon.Columns.Add(COL_STATUS);
                        dtListCuon.Columns.Add(COL_ACTION);

                        foreach (DataRow row in dtListCuon.Rows)
                        {
                            if (row["Scanned"].ToString() == "1")
                            {
                                row[COL_STATUS] = "DX";
                            }
                            else
                            {
                                row[COL_STATUS] = "";
                            }
                            row[COL_ACTION] = "";
                        }

                        dgCuonList.DataSource = dtListCuon;
                        dgCuonList.TableStyles.Clear();
                        DataGridTableStyle tableStyle = new DataGridTableStyle();
                        tableStyle.MappingName = dtListCuon.TableName;
                        foreach (DataColumn item in dtListCuon.Columns)
                        {
                            DataGridTextBoxColumn tbcName = new DataGridTextBoxColumn();

                            switch (item.ColumnName)
                            {
                            case "vnpt_pn":
                            {
                                tbcName.MappingName = item.ColumnName;
                                tbcName.HeaderText  = "VNPT P/N";
                                tbcName.Width       = 100;
                            } break;

                            case "Code":
                            {
                                tbcName.MappingName = item.ColumnName;
                                tbcName.HeaderText  = "Id Cuon";
                                tbcName.Width       = 65;
                            } break;

                            case "Quantity":
                            {
                                tbcName.Width = -1;
                            } break;

                            case "Thung":
                            {
                                tbcName.Width = 65;
                            } break;

                            case "Scanned":
                            {
                                tbcName.Width = -1;
                            } break;

                            case "ThungType":
                            {
                                tbcName.Width = -1;
                            } break;

                            case COL_STATUS:
                            {
                                tbcName.MappingName = item.ColumnName;
                                tbcName.HeaderText  = "Trang thai";
                                tbcName.Width       = 30;
                            } break;

                            case COL_ACTION:
                            {
                                tbcName.MappingName = item.ColumnName;
                                tbcName.HeaderText  = "Huy";
                                tbcName.Width       = 25;
                            } break;

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

                            if (tbcName.MappingName != "")
                            {
                                tbcName.MappingName = item.ColumnName;
                                tbcName.HeaderText  = item.ColumnName;
                            }

                            tableStyle.GridColumnStyles.Add(tbcName);

                            dangQuet = true;
                        }

                        dgCuonList.TableStyles.Add(tableStyle);

                        dgCuonList.Refresh();

                        ScanInfo();
                    }
                    catch (Exception ex)
                    {
                        //btnLoad.Enabled = true;
                        MessageBox.Show("Khong lay duoc du lieu");
                        txtMaXuatKho.Text = DEFAULT_TXT_MAXK;
                        _exp_code         = "";
                    }
                }
                else
                {
                    //btnLoad.Enabled = true;
                    if (Util.CleanStr(res.RawText) != "")
                    {
                        MessageBox.Show(Util.CleanStr(res.RawText));
                    }
                    txtMaXuatKho.Text = DEFAULT_TXT_MAXK;
                    _exp_code         = "";
                }
            }
            else
            {
                txtMaXuatKho.Focus();
            }
        }
Ejemplo n.º 20
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.dtList.Rows.Count > 0)
            {
                ApiResponse res = new ApiResponse();
                res.Status = false;

                try
                {
                    string url = "smart-devices/update-locations";

                    string param = "[";
                    foreach (DataRow row in dtList.Rows)
                    {
                        param += "{";
                        if (BarcodeLocation != null && BarcodeLocation.Length > 0)
                        {
                            param += "\"locationCode\": \"" + BarcodeLocation + "\", ";
                        }
                        if (Util.getTypePackage(row[COL_ID].ToString().Trim(), row[COL_TYPE].ToString()) % 2 == 0)
                        {
                            param += "\"lotNumber\": \"" + row[COL_ID] + "\"";
                        }
                        else
                        {
                            param += "\"packageNumber\": \"" + row[COL_ID] + "\"";
                        }
                        param += "}, ";
                    }
                    string end_char = param.Substring(param.Length - 2, 1);
                    if (end_char == ",")
                    {
                        param = param.Substring(0, param.Length - 2);
                    }
                    param += " ]";

                    param = param.Replace(System.Environment.NewLine, "").Trim();

                    //Util.Logs(param);

                    res = HTTP.PostJson(url, param);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    //MessageBox.Show(ex.InnerException.ToString());
                }

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

                        List <LocationUpdate> ListDetail = RootObject as List <LocationUpdate>;
                        //dtList.Rows.Clear();

                        foreach (LocationUpdate item in ListDetail)
                        {
                            string    packIdResponse = item.lotNumber != null && item.lotNumber.Length > 0 ? item.lotNumber : item.packageNumber;
                            DataRow[] rs_package     = dtList.Select(COL_ID + " = '" + packIdResponse.Trim() + "'");
                            if (rs_package.Length > 0)
                            {
                                rs_package[0][COL_STATUS]     = item.errorCode != null && item.errorCode.Length > 0 ? "error" : "";
                                rs_package[0][COL_ERROR_CODE] = item.errorCode != null && item.errorCode.Length > 0 ? item.errorCode : "";
                            }
                        }

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

                        this.dgCuonList.DataSource = this.dtList;
                        this.dgCuonList.Refresh();
                    }
                    catch { }

                    MessageBox.Show("Update location done !");
                }
                else
                {
                    //MessageBox.Show(res.RawText);
                }

                btnSave.Enabled  = false;
                btnClear.Enabled = true;
            }
            else
            {
                MessageBox.Show("Request scanned package before saving !");
            }
        }
Ejemplo n.º 21
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //check vi tri
            if (temViTri == null)
            {
                MessageBox.Show("Hãy quét vào tem vị trí", "Chu y", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }
            else if (listTemThungThanhPham.Count == 0)
            {
                MessageBox.Show("Hãy quét vào tem thùng thành phẩm", "Chu y", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }
            else
            {
                try
                {
                    btnSave.Enabled    = false;
                    btnReset.Enabled   = false;
                    dgListCuon.Enabled = false;

                    string url = "update_location_by_code";

                    var temCuons = listCodeFromListObject(listTemThungThanhPham);

                    var paras = new
                    {
                        code = temCuons,
                        inventory_location_id = temViTri.ID
                    };

                    ApiResponse res = HTTP.Post(url, paras);

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

                        if (resApi.code == 200)
                        {
                            MessageBox.Show("Lưu thành công");
                            ResetForm();
                        }
                        else
                        {
                            //MessageBox.Show(resApi.message, "Co loi xay ra", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                            MessageBox.Show(resApi.message);
                            btnSave.Enabled    = true;
                            btnReset.Enabled   = true;
                            dgListCuon.Enabled = true;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Co loi xay ra, hay thu lai");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Không có kết nối mạng", "Loi mang", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    btnSave.Enabled    = true;
                    btnReset.Enabled   = true;
                    dgListCuon.Enabled = true;
                }
            }
        }
Ejemplo n.º 22
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());
                }
            }
        }
Ejemplo n.º 23
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);
            }
        }