示例#1
0
        private void AddKey(ConnectionInfo connectionInfo, List <KeyInfo> listKeyInfo)
        {
            using (VRArcadeDataAccessModel m = new VRArcadeDataAccessModel())
            {
                BarcodeInfo bInfo = new BarcodeInfo();

                if (listKeyInfo != null)
                {
                    foreach (KeyInfo keyInfo in listKeyInfo)
                    {
                        VRTicketType vrTicketType = m.VRTicketTypes.Where(x => x.ID == keyInfo.KeyTypeID).FirstOrDefault();

                        if (vrTicketType != null)
                        {
                            BarcodeItem barcodeItem = new BarcodeItem()
                            {
                                IsPrintingKey = true,
                                KeyName       = vrTicketType.Type,
                                Minutes       = keyInfo.Minutes
                            };

                            bInfo.BarcodeItems.Add(barcodeItem);
                        }
                    }

                    GenerateBarcode(connectionInfo, bInfo);
                    GetKey(connectionInfo);
                }
            }
        }
 /// <summary>
 /// OutputDetailInfo -> BarcodeInfo
 /// </summary>
 /// <param name="outputDetailInfo"></param>
 /// <param name="barcodeInfo"></param>
 public static void GetBarcodeInfo(OutputDetailInfo outputDetailInfo, ref BarcodeInfo barcodeInfo)
 {
     if (outputDetailInfo == null)
     {
         return;
     }
     barcodeInfo.PartNo                = outputDetailInfo.PartNo;
     barcodeInfo.PartCname             = outputDetailInfo.PartCname;
     barcodeInfo.PackageModel          = outputDetailInfo.PackageModel;
     barcodeInfo.Package               = outputDetailInfo.Package;
     barcodeInfo.IdentifyPartNo        = outputDetailInfo.IdentifyPartNo;
     barcodeInfo.MeasuringUnitNo       = outputDetailInfo.MeasuringUnitNo;
     barcodeInfo.SupplierNum           = outputDetailInfo.SupplierNum;
     barcodeInfo.Plant                 = outputDetailInfo.Plant;
     barcodeInfo.AssemblyLine          = outputDetailInfo.AssemblyLine;
     barcodeInfo.Dock                  = outputDetailInfo.Dock;
     barcodeInfo.WmNo                  = outputDetailInfo.WmNo;
     barcodeInfo.ZoneNo                = outputDetailInfo.ZoneNo;
     barcodeInfo.Dloc                  = outputDetailInfo.Dloc;
     barcodeInfo.BoxParts              = outputDetailInfo.BoxParts;
     barcodeInfo.RunsheetNo            = outputDetailInfo.RunsheetNo;
     barcodeInfo.AsnRunsheetNo         = outputDetailInfo.TranNo;
     barcodeInfo.PickupSeqNo           = outputDetailInfo.PickupSeqNo;
     barcodeInfo.RdcDloc               = outputDetailInfo.RdcDloc;
     barcodeInfo.Comments              = outputDetailInfo.Comments;
     barcodeInfo.PackageLength         = outputDetailInfo.PackageLength;
     barcodeInfo.PackageWidth          = outputDetailInfo.PackageWidth;
     barcodeInfo.PackageHeight         = outputDetailInfo.PackageHeight;
     barcodeInfo.PerpackageGrossWeight = outputDetailInfo.PerpackageGrossWeight;
     barcodeInfo.CreateSourceFid       = outputDetailInfo.Fid;
     barcodeInfo.PackageVolume         = outputDetailInfo.PackageVolume;
 }
示例#3
0
        public string CreateBarcode(BarcodeInfo model, string name, bool isOldDelete)
        {
            EncodingOptions options = null;

            options = new EncodingOptions
            {
                Width  = model.Width,
                Height = model.Height,
                Margin = model.Margin
            };

            var writer = new BarcodeWriter();

            writer.Options = options;
            writer.Format  = (BarcodeFormat)Enum.Parse(typeof(BarcodeFormat), model.BarcodeFormat);
            var bitmap = writer.Write(model.Barcode);

            var filePath = string.Format("{0}/{1}.jpg", GetFileRootByBarcode(), string.IsNullOrEmpty(name) ? model.Barcode : name);
            var fullPath = FilesHelper.GetFullPathByWcf(filePath);

            if (File.Exists(fullPath))
            {
                if (isOldDelete)
                {
                    File.Delete(fullPath);
                }
                else
                {
                    return(VirtualPathUtility.ToAbsolute(filePath));
                }
            }

            bitmap.Save(fullPath);
            return(VirtualPathUtility.ToAbsolute(filePath));
        }
示例#4
0
        public string CreateBarcodeBrowser(BarcodeInfo model)
        {
            EncodingOptions options = null;

            options = new EncodingOptions
            {
                Width  = model.Width,
                Height = model.Height,
                Margin = model.Margin
            };

            BarcodeWriter writer = new BarcodeWriter();

            writer.Options = options;
            writer.Format  = (BarcodeFormat)Enum.Parse(typeof(BarcodeFormat), model.BarcodeFormat);
            var bitmap = writer.Write(model.Barcode);

            var filePath = new TempFolder().GetTempUrl(string.Format("{0}.jpg", model.Barcode));
            var fullPath = FilesHelper.GetFullPathByWcf(filePath);

            if (File.Exists(fullPath))
            {
                return(VirtualPathUtility.ToAbsolute(filePath));
            }

            bitmap.Save(fullPath);
            return(VirtualPathUtility.ToAbsolute(filePath));
        }
 /// <summary>
 /// SrmBarcodeInfo -> BarcodeInfo
 /// </summary>
 /// <param name="srmBarcodeInfo"></param>
 /// <param name="barcodeInfo"></param>
 public static void GetBarcodeInfo(SrmBarcodeInfo srmBarcodeInfo, ref BarcodeInfo barcodeInfo)
 {
     if (srmBarcodeInfo == null)
     {
         return;
     }
     ///BARCODE_DATA
     barcodeInfo.BarcodeData = srmBarcodeInfo.PackageBarcode;
     ///ASN_RUNSHEET_NO
     barcodeInfo.AsnRunsheetNo = srmBarcodeInfo.SourceOrderCode;
     ///PART_NO
     barcodeInfo.PartNo = srmBarcodeInfo.PartNo;
     ///PART_CNAME
     barcodeInfo.PartCname = srmBarcodeInfo.PartCname;
     ///CURRENT_QTY
     barcodeInfo.CurrentQty = srmBarcodeInfo.PartQty;
     ///DLOC
     barcodeInfo.Dloc = srmBarcodeInfo.TargetSlcode;
     ///PACKAGE_MODEL
     barcodeInfo.PackageModel = srmBarcodeInfo.PackageCode;
     ///PACKAGE
     barcodeInfo.Package = srmBarcodeInfo.Snp;
     ///COMMENTS
     barcodeInfo.Comments = srmBarcodeInfo.Remark;
 }
示例#6
0
        private void Scanner_BarcodeEvent(short eventType, ref string pscanData)
        {
            string      data = string.Empty;
            XmlDocument doc  = new XmlDocument();

            doc.LoadXml(pscanData);
            string code        = doc.DocumentElement.GetElementsByTagName("datalabel").Item(0).InnerText;
            string symbology   = doc.DocumentElement.GetElementsByTagName("datatype").Item(0).InnerText;
            string modelnumber = doc.DocumentElement.GetElementsByTagName("modelnumber").Item(0).InnerText;

            string[] items = code.Split(' ');
            foreach (string item in items)
            {
                if (string.IsNullOrEmpty(item))
                {
                    break;
                }

                data += ((char)Convert.ToInt32(item, 16)).ToString();
            }

            BarcodeInfo info = new BarcodeInfo();

            info.Code          = data;
            info.ModelNumber   = modelnumber.Trim();
            info.SymbologyCode = symbology.Trim();

            IMessage msg = this.CreateMessage(info);

            this.Send(msg);
        }
示例#7
0
        /// <summary>
        /// Sets the barcode parameter.
        /// </summary>
        private void SetBarcodeParameter()
        {
            _barcodeInfo = StandardBarcodes.GetBarcodeInfo(_code);

            // license
            // put in your license code here
            //_myBarcode.License("<Your Licensee Name>", LicenseType.DeveloperOrWeb, 1, "<Your License Key>", TBarCodeProduct.Barcode2D);

            // --- BAR CODE TYPE ---

            SetBarCodeType();
            SetAdvancedParams();

            // --- BARCODE DATA ---

            SetBarcodeData();

            SetBarodeHRT();

            // --- BAR CODE SIZE ---

            SetDPI();

            SetModuleWidth();

            SetBarcodeSize();

            SetRotation();
        }
        private Bitmap GetQRCodeBitmap(BarcodeInfo barcode)
        {
            var qrCodeGenerator = new QRCodeGenerator();
            var qrCodeData      = qrCodeGenerator.CreateQrCode(JsonConvert.SerializeObject(barcode), QRCodeGenerator.ECCLevel.Q);
            var qrCode          = new QRCode(qrCodeData);

            return(qrCode.GetGraphic(10));
        }
示例#9
0
 public FAProductInfo()
 {
     SerialBarcodeInfo = new BarcodeInfo();
     PPIDBarcodeInfo = new BarcodeInfo();
     WWNBarcodeInfo = new BarcodeInfo();
     CSerialBarcodeInfo = new BarcodeInfo();
     PSIDBarcodeInfo = new BarcodeInfo();
     ECInfo = new FAECInfo();
     ECInfo.Clear();
     IsEmptyBox = false;
 }
示例#10
0
        private void NetworkFunction_OnIncommingBarcodeInfo(object sender, EventArgs e)
        {
            BarcodeInfo bInfo = ((BarcodeInfoEvent)e).BarcodeInfo;

            Utility.DoPrintBarcode(bInfo.BarcodeItems);

            this.InvokeUI(() =>
            {
                this.ShowAlertBox("Barcode Generation", "Ticket is send to the printer.");
            });
        }
 /// <summary>
 /// SupplierInfo -> BarcodeInfo
 /// </summary>
 /// <param name="supplierInfo"></param>
 /// <param name="barcodeInfo"></param>
 public static void GetBarcodeInfo(SupplierInfo supplierInfo, ref BarcodeInfo barcodeInfo)
 {
     if (supplierInfo == null)
     {
         return;
     }
     ///SUPPLIER_NUM
     barcodeInfo.SupplierNum = supplierInfo.SupplierNum;
     ///SUPPLIER_NAME
     barcodeInfo.SupplierName = supplierInfo.SupplierName;
     ///SUPPLIER_SNAME
     barcodeInfo.SupplierSname = supplierInfo.SupplierSname;
 }
示例#12
0
 /// <summary>
 /// BarcodeInfo -> BarcodeStatusInfo
 /// </summary>
 /// <param name="barcodeInfo"></param>
 /// <param name="barcodeStatusInfo"></param>
 public static void GetBarcodeStatusInfo(BarcodeInfo barcodeInfo, ref BarcodeStatusInfo barcodeStatusInfo)
 {
     if (barcodeInfo == null)
     {
         return;
     }
     ///BARCODE_FID
     barcodeStatusInfo.BarcodeFid = barcodeInfo.Fid;
     ///PART_NO
     barcodeStatusInfo.PartNo = barcodeInfo.PartNo;
     ///PART_CNAME
     barcodeStatusInfo.PartCname = barcodeInfo.PartCname;
     ///BARCODE_DATA
     barcodeStatusInfo.BarcodeData = barcodeInfo.BarcodeData;
     ///BARCODE_STATUS
     barcodeStatusInfo.BarcodeStatus = barcodeInfo.BarcodeStatus;
     ///PACKAGE_MODEL
     barcodeStatusInfo.PackageModel = barcodeInfo.PackageModel;
     ///PACKAGE
     barcodeStatusInfo.Package = barcodeInfo.Package;
     ///CURRENT_QTY
     barcodeStatusInfo.CurrentQty = barcodeInfo.CurrentQty;
     ///MEASURING_UNIT_NO
     barcodeStatusInfo.MeasuringUnitNo = barcodeInfo.MeasuringUnitNo;
     ///SUPPLIER_NUM
     barcodeStatusInfo.SupplierNum = barcodeInfo.SupplierNum;
     ///PLANT
     barcodeStatusInfo.Plant = barcodeInfo.Plant;
     ///ASSEMBLY_LINE
     barcodeStatusInfo.AssemblyLine = barcodeInfo.AssemblyLine;
     ///LOCATION
     barcodeStatusInfo.Location = barcodeInfo.Location;
     ///DOCK
     barcodeStatusInfo.Dock = barcodeInfo.Dock;
     ///WM_NO
     barcodeStatusInfo.WmNo = barcodeInfo.WmNo;
     ///ZONE_NO
     barcodeStatusInfo.ZoneNo = barcodeInfo.ZoneNo;
     ///DLOC
     barcodeStatusInfo.Dloc = barcodeInfo.Dloc;
     ///BATTH_NO
     barcodeStatusInfo.BatthNo = barcodeInfo.BatthNo;
     ///RFID_NO
     barcodeStatusInfo.RfidNo = barcodeInfo.RfidNo;
     ///ASN_RUNSHEET_NO
     barcodeStatusInfo.AsnRunsheetNo = barcodeInfo.AsnRunsheetNo;
     ///COMMENTS
     barcodeStatusInfo.Comments = barcodeInfo.Comments;
 }
示例#13
0
        public void shouldSuccessInstantiate()
        {
            ProductSKUModel product = new ProductSKUModel("Code", "Name", 1, 1, "Description")
            {
                Id = 1,
            };

            UnitOfMeasurementModel uom = new UnitOfMeasurementModel()
            {
                Id = 1
            };

            CategoryModel category = new CategoryModel("Name", "Code")
            {
            };

            ProductSKUDto productSKUDto = new ProductSKUDto(product, uom, category)
            {
                Category = new CategoryDto(new CategoryModel("Name", "Code"))
            };


            ProductPackingModel productPackingModel = new ProductPackingModel(1, 1, 1, "Code", "Name", "description")
            {
            };

            ProductSKUModel productSKUModel = new ProductSKUModel("Code", "Name", 1, 1, "Description")
            {
            };

            UnitOfMeasurementModel uomModel = new UnitOfMeasurementModel("Unit")
            {
            };
            UnitOfMeasurementModel skuUOM            = new UnitOfMeasurementModel();
            CategoryModel          skuCategory       = new CategoryModel();
            ProductPackingDto      productPackingDto = new ProductPackingDto(productPackingModel, productSKUModel, uomModel, skuUOM, skuCategory);


            BarcodeInfo barcode = new BarcodeInfo(productSKUDto, productPackingDto);

            Assert.NotNull(barcode);
            Assert.Equal("Code", barcode.SKUCode);
            Assert.Equal("Name", barcode.SKUName);
            Assert.Equal("Code", barcode.PackingCode);
            Assert.Equal(1, barcode.PackingSize);
            Assert.Equal("Unit", barcode.PackingType);
        }
示例#14
0
        public static BarcodeInfo SelectVoucherInfo(int iso, int voucherId)
        {
            #region SQL

            const string SQL = @"select * from Voucher where v_iso_id = @iso and v_number = @voucher";

            #endregion

            using (var conn = new SqlConnection(ConnectionString))
                using (var comm = new SqlCommand(SQL, conn))
                {
                    comm.Parameters.AddWithValue("@iso", iso);
                    comm.Parameters.AddWithValue("@voucher", voucherId);
                    conn.Open();
                    using (var reader = comm.ExecuteReader(CommandBehavior.CloseConnection))
                        return(BarcodeInfo.ReadFromReader(reader));
                }
        }
 /// <summary>
 /// PartsStockInfo -> BarcodeInfo
 /// </summary>
 /// <param name="partsStockInfo"></param>
 /// <param name="barcodeInfo"></param>
 public static void GetBarcodeInfo(PartsStockInfo partsStockInfo, ref BarcodeInfo barcodeInfo)
 {
     if (partsStockInfo == null)
     {
         return;
     }
     ///PART_NICKNAME
     barcodeInfo.PartNickname = partsStockInfo.PartNickname;
     ///MEASURING_UNIT_NO
     barcodeInfo.MeasuringUnitNo = partsStockInfo.PartUnits;
     ///WM_NO
     barcodeInfo.WmNo = partsStockInfo.WmNo;
     ///ZONE_NO
     barcodeInfo.ZoneNo = partsStockInfo.ZoneNo;
     ///LINE_POSITION
     barcodeInfo.LinePosition = partsStockInfo.LineSiteDloc;
     ///SUPERMARKET_ADDRESS
     barcodeInfo.SupermarketAddress = partsStockInfo.SupperZoneDloc;
 }
 /// <summary>
 /// PackageApplianceInfo -> BarcodeInfo
 /// </summary>
 /// <param name="packageApplianceInfo"></param>
 /// <param name="barcodeInfo"></param>
 public static void GetBarcodeInfo(PackageApplianceInfo packageApplianceInfo, ref BarcodeInfo barcodeInfo)
 {
     if (packageApplianceInfo == null)
     {
         return;
     }
     ///PACKAGE_LENGTH
     barcodeInfo.PackageLength = packageApplianceInfo.PackageLength;
     ///PACKAGE_WIDTH
     barcodeInfo.PackageWidth = packageApplianceInfo.PackageWidth;
     ///PACKAGE_HEIGHT
     barcodeInfo.PackageHeight = packageApplianceInfo.PackageHeight;
     ///PERPACKAGE_GROSS_WEIGHT
     barcodeInfo.PerpackageGrossWeight = packageApplianceInfo.MaxWeight;
     ///PACKAGE_VOLUME
     barcodeInfo.PackageVolume = packageApplianceInfo.PackageLength.GetValueOrDefault() * packageApplianceInfo.PackageWidth.GetValueOrDefault() * packageApplianceInfo.PackageHeight.GetValueOrDefault();
     ///NET_WEIGHT
     barcodeInfo.NetWeight = packageApplianceInfo.MaxLoadWeight;
 }
示例#17
0
        public static BarcodeInfo SelectVoucherInfo(int iso, int voucherId)
        {
            #region SQL

            const string SQL = @"select * from Voucher where v_iso_id = @iso and v_number = @voucher";

            #endregion

            using (var comm = new SqlCommand(SQL))
            {
                comm.Parameters.AddWithValue("@iso", iso);
                comm.Parameters.AddWithValue("@voucher", voucherId);
                var data = comm.CreateSerializationData().ToList().ToArray();
                DataServiceClient client = new DataServiceClient();
                var result = client.TRSExecuteReader(data);
                using (DataTableReader reader = new DataTableReader(result.Data.ToDataTable()))
                    if (reader.Read())
                    {
                        return(BarcodeInfo.ReadFromReader(reader));
                    }
            }
            return(new BarcodeInfo());
        }
示例#18
0
        public static void DoPrintBarcode(List <BarcodeItem> barcodeItems)
        {
            TextWriter writeFileStream = null;
            string     fName           = Path.GetTempFileName();

            BarcodeInfo bInfo = new BarcodeInfo();

            bInfo.BarcodeItems = barcodeItems;

            try
            {
                XmlSerializer SerializerObj = new XmlSerializer(typeof(BarcodeInfo));
                writeFileStream = new StreamWriter(fName);
                SerializerObj.Serialize(writeFileStream, bInfo);

                logger.Debug("DO PRINT BARCODE. File Name: " + fName);

                Process proc = Utility.IsProcessOpenByName("BarcodePrintHelper");

                if (proc == null)
                {
                    RunCommand(AppDomain.CurrentDomain.BaseDirectory + "BarcodePrintHelper.exe", fName, AppDomain.CurrentDomain.BaseDirectory, ProcessWindowStyle.Hidden);
                }
            }
            catch (Exception ex)
            {
                logger.Error("DoPrintBarcode: " + ex.ToString());
            }
            finally
            {
                if (writeFileStream != null)
                {
                    writeFileStream.Close();
                }
            }
        }
示例#19
0
        public string WaiverBarcodeGen(int waiverID)
        {
            using (VRArcadeDataAccessModel m = new VRArcadeDataAccessModel())
            {
                VRWaiverLog vrWaiverLog = m.VRWaiverLogs.Where(x => x.ID == waiverID).FirstOrDefault();

                if (vrWaiverLog != null)
                {
                    int    minutes    = 0;
                    string bookingRef = "";
                    if (vrWaiverLog.BookingReference != null && vrWaiverLog.BookingReference.IsTimedTiming)
                    {
                        minutes    = vrWaiverLog.BookingReference.Duration;
                        bookingRef = vrWaiverLog.BookingReference.Reference;
                    }


                    BarcodeItem bItem = new BarcodeItem()
                    {
                        IsPrintingTicket = true,
                        Minutes          = minutes,
                        CustomerName     = vrWaiverLog.FirstName + " " + vrWaiverLog.LastName,
                        BookingReference = bookingRef,
                        WaiverLogID      = vrWaiverLog.ID
                    };

                    BarcodeInfo bInfo = new BarcodeInfo();
                    bInfo.BarcodeItems.Add(bItem);

                    GenerateBarcode(null, bInfo);
                }
            }


            return("");
        }
示例#20
0
        private void radButtonPrintNow_Click(object sender, EventArgs e)
        {
            string question = "Are you sure you want to print (" + radSpinEditorNumPrint.Value.ToString() + ") "
                              + (radRadioButtonTimed.CheckState == CheckState.Checked ? "TIMED" : "NON-TIMED")
                              + " session ticket?";

            if (radRadioButtonTimed.CheckState == radRadioButtonNonTimed.CheckState || radSpinEditorNumPrint.Value == 0)
            {
                this.ShowAlertBox("Barcode Generation", "Please make your choice!");
            }
            else
            {
                DialogResult dr = RadMessageBox.Show(this, string.Format(question), "Confirm", MessageBoxButtons.YesNo, RadMessageIcon.Question);

                if (dr == DialogResult.Yes)
                {
                    BarcodeInfo bInfo = new BarcodeInfo();

                    for (int i = 0; i < radSpinEditorNumPrint.Value; i++)
                    {
                        BarcodeItem bItem = new BarcodeItem()
                        {
                            IsPrintingTicket = true,
                            Minutes          = (radRadioButtonTimed.CheckState == CheckState.Checked ? (int)radSpinEditorSessionTime.Value : 0),
                            CustomerName     = ""
                        };

                        bInfo.BarcodeItems.Add(bItem);
                    }

                    NetworkFunction.GenerateBarcode(bInfo);

                    Close();
                }
            }
        }
示例#21
0
        private void GenerateBarcode(ConnectionInfo connectionInfo, BarcodeInfo barcodeInfo)
        {
            using (VRArcadeDataAccessModel m = new VRArcadeDataAccessModel())
            {
                if (barcodeInfo.BarcodeItems.Count > 0)
                {
                    foreach (BarcodeItem bi in barcodeInfo.BarcodeItems)
                    {
                        VRTicketType vrTT       = null;
                        string       ticketType = "";
                        Guid         guid       = Utility.CreateGuid();

                        bi.DateStampCreate = DateTime.Now;

                        if (bi.IsPrintingTicket)
                        {
                            ticketType = "TICKET";
                        }
                        else if (bi.IsPrintingKey)
                        {
                            ticketType = bi.KeyName;
                        }

                        vrTT = m.VRTicketTypes.Where(x => x.Type == ticketType).FirstOrDefault();


                        VRTicket vrt = new VRTicket()
                        {
                            GUID            = guid.ToString(),
                            Minutes         = bi.Minutes,
                            TimeStampCreate = bi.DateStampCreate,
                            VRTicketTypeID  = (vrTT != null) ? (int?)vrTT.ID : null,
                            WaiverLogID     = bi.WaiverLogID
                        };

                        //string t = Convert.ToBase64String(guid.ToByteArray()).Replace("=", "");

                        //byte[] b = Convert.FromBase64String(t + "==");

                        //var g = new Guid(b);

                        m.Add(vrt);
                        bi.GUID = guid;
                    }

                    m.SaveChanges();
                    //m.Cache.Release(m.VRTickets);

                    VRCommandServer vcs = new VRCommandServer(VRGameSelectorServerDTO.Enums.ControlMessage.GENERATE_BARCODE, barcodeInfo);

                    if (connectionInfo != null)
                    {
                        SendCommandToPeer(connectionInfo, vcs);
                    }
                    else
                    {
                        foreach (ConnectionInfo managingSysConn in _targetManagingSystemConnection)
                        {
                            SendCommandToPeer(managingSysConn, vcs);
                        }
                    }
                }
            }
        }
        public static void GenerateBarcode(BarcodeInfo barcodeInfo)
        {
            VRCommandServer cmd = new VRCommandServer(Enums.ControlMessage.GENERATE_BARCODE, barcodeInfo);

            SendCommandToServer(cmd);
        }
示例#23
0
        private void radButtonPrintTicket_Click(object sender, EventArgs e)
        {
            DialogResult dr = DialogResult.None;

            if (radListViewClientList.CheckedItems.Count > 0)
            {
                if (OptionSelectedValidate())
                {
                    if (!OptionTimeValidate())
                    {
                        dr = RadMessageBox.Show(this, string.Format("One or more check-ins failed appointment time validation. Is the customer late or too early (e.g. Earlier than 60 minutes to game start)? " + Environment.NewLine + Environment.NewLine + " Do you want to override this error?", radListViewClientList.CheckedItems.Count), "Confirm", MessageBoxButtons.YesNo, RadMessageIcon.Question);
                    }

                    if (dr == DialogResult.None || dr == DialogResult.Yes)
                    {
                        dr = RadMessageBox.Show(this, string.Format("Are you sure you want to print ({0}) tickets?", radListViewClientList.CheckedItems.Count), "Confirm", MessageBoxButtons.YesNo, RadMessageIcon.Question);

                        if (dr == DialogResult.Yes)
                        {
                            BarcodeInfo bInfo = new BarcodeInfo();
                            //List<WaiverInfo> listWaiverInfo = new List<WaiverInfo>();

                            foreach (ListViewDataItem item in radListViewClientList.CheckedItems)
                            {
                                ClientActionType cat = ((DataRowView)item.DataBoundItem)["Data"] as ClientActionType;

                                string clientName = ((DataRowView)item.DataBoundItem)["ClientName"].ToString();

                                BarcodeItem bItem = new BarcodeItem()
                                {
                                    IsPrintingTicket = true,
                                    Minutes          = (cat.StartType == ClientActionType.ClientStartType.TIMED_START ? cat.Duration : 0),
                                    CustomerName     = clientName,
                                    BookingReference = (string)((DataRowView)item.DataBoundItem)["Reference"],
                                    WaiverLogID      = (int)((DataRowView)item.DataBoundItem)["ID"]
                                };

                                bInfo.BarcodeItems.Add(bItem);

                                /*listWaiverInfo.Add(new WaiverInfo()
                                 * {
                                 *  ID = (int)((DataRowView)item.DataBoundItem)["ID"],
                                 *  BookingReference = new BookingReference()
                                 *  {
                                 *      Reference = (string)((DataRowView)item.DataBoundItem)["Reference"]
                                 *  }
                                 *
                                 * });*/
                            }

                            //NetworkFunction.MarkWaiverReceived(listWaiverInfo);

                            NetworkFunction.GenerateBarcode(bInfo);

                            Close();
                        }
                    }
                }
                else
                {
                    this.ShowAlertBox("Waiver Process", "One or more selected item does not have option picked! Booking reference not found!");
                }
            }
            else
            {
                this.ShowAlertBox("Waiver Process", "Please select at least one client to continue!");
            }
        }
        /// <summary>
        /// Hàm xử lý click vào nút đăng ký xn
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnTestTypeClick(object sender, EventArgs e)
        {
            try
            {
                int count;
                var btn         = (UIButton)sender;
                int vTestTypeId = Utility.Int32Dbnull(btn.Tag);

                count = TTestInfo.CreateQuery().WHERE(TTestInfo.Columns.PatientId, patientId).
                        WHERE(TTestInfo.Columns.TestTypeId, vTestTypeId).GetRecordCount();
                if (count > 0)
                {
                    //Utility.ShowMsg("Loại Xét Nghiệm đã được đăng ký");
                    //Todo: focus vào test đã đăng ký
                    for (int i = 0; i < grdTestInfo.RowCount; i++)
                    {
                        if (Utility.sDbnull(grdTestInfo.GetRow(i).Cells["TestType_ID"].Value) == (string)btn.Tag)
                        {
                            grdTestInfo.MoveTo(i);
                            break;
                        }
                    }
                    return;
                }

                string  vBarcode   = "";
                DataRow drTestType = Utility.GetDataRow(dtTestTypeList, TTestTypeList.Columns.TestTypeId, btn.Tag);

                if (SysPara.AutoGenerateBarcode == 2 | (SysPara.AutoGenerateBarcode == 0 & dtTestInfo.Rows.Count == 0))
                {
                    frmInput_Update_Barcode oForm = new frmInput_Update_Barcode();
                    if (dtTestInfo.Rows.Count > 0)
                    {
                        oForm.txtBarcode.Text = Utility.sDbnull(grdTestInfo.GetValue("Barcode"));
                        oForm.txtBarcode.SelectAll();
                    }
                    oForm.vTestType_ID          = vTestTypeId;
                    oForm.txtTestType_Name.Text = Utility.sDbnull(drTestType["TestType_Name"]);
                    oForm.ShowDialog();
                    if (string.IsNullOrEmpty(oForm.txtBarcode.Text))
                    {
                        return;
                    }
                    vBarcode = oForm.txtBarcode.Text;
                }
                else if (dtTestInfo.Rows.Count > 0)
                {
                    vBarcode = Utility.sDbnull(grdTestInfo.GetValue("Barcode")).Trim();
                    //count = new Select().From(TTestInfo.Schema).Where(TTestInfo.Columns.TestTypeId).IsEqualTo(vTestTypeId).
                    //                And(TTestInfo.Columns.Barcode).IsEqualTo(vBarcode).GetRecordCount();
                    //if (count > 0)
                    //{
                    //    Utility.ShowMsg("Barcode tồn tại. Mời nhập lại.");
                    //    return;
                    //}
                }
                else
                {
                    vBarcode = BarcodeInfo.GetBarcodeForPatient(patientId, vTestTypeId, drTestType[TTestTypeList.Columns.IntOrder].ToString());
                    if (vBarcode == "-1")
                    {
                        Utility.ShowMsg("Không tìm được Barcode");
                        return;
                    }
                }
                string       canlamsangid;
                LPatientInfo lPatientInfo = new Select().From(LPatientInfo.Schema.Name).Where(LPatientInfo.Columns.PatientId).IsEqualTo(patientId).ExecuteSingle <LPatientInfo>();
                canlamsangid = lPatientInfo.CanLamSangId;
                var obj = new TTestInfo();
                obj.TestTypeId   = vTestTypeId;
                obj.Barcode      = vBarcode;
                obj.PatientId    = patientId;
                obj.TestDate     = DateTime.Now;
                obj.RequireDate  = DateTime.Now;
                obj.AssignId     = Utility.Int32Dbnull(cboAssignDoctor.SelectedValue);
                obj.CanLamSangId = "OO" + DateTime.Now.ToString("yyMMdd") + "." + canlamsangid;
                obj.IsNew        = true;
                obj.Save();

                DataRow dr = dtTestInfo.NewRow();
                dr[TTestInfo.Columns.TestId] = TTestInfo.CreateQuery().WHERE(TTestInfo.Columns.PatientId, patientId).
                                               WHERE(TTestInfo.Columns.TestTypeId, vTestTypeId).GetMax(TTestInfo.Columns.TestId);
                dr[TTestInfo.Columns.TestDate]         = obj.TestDate;
                dr[TTestInfo.Columns.Barcode]          = obj.Barcode;
                dr[TTestInfo.Columns.PatientId]        = obj.PatientId;
                dr[TTestInfo.Columns.TestTypeId]       = obj.TestTypeId;
                dr[TTestTypeList.Columns.TestTypeName] = drTestType[TTestTypeList.Columns.TestTypeName].ToString();
                dr[TTestInfo.Columns.AssignId]         = obj.AssignId;
                dr["AssignDoctor_Name"] = Utility.Int32Dbnull(cboAssignDoctor.SelectedValue) == -1
                                              ? ""
                                              : cboAssignDoctor.Text;


                dtTestInfo.Rows.InsertAt(dr, 0);
                grdTestInfo.SelectionChanged -= grdTestInfo_SelectionChanged;
                dtTestInfo.AcceptChanges();
                grdTestInfo.SelectionChanged += grdTestInfo_SelectionChanged;
                grdTestInfo.MoveFirst();

                // Todo: xử lý sau khi nhấn nút đăng ký
                //Nếu ô đăng ký test có dl thì chuyển sang
                //if (flpTestGroup.Controls.Count > 0) flpTestGroup.Focus();
                //else flpStandardTest.Focus();
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
            finally { FocusButtonDetail(); }
        }
示例#25
0
        public void SaveEAN13Info()
        {
            using (ProductContext ctx = new ProductContext())
            {
                var data1 = from entity in ctx.BarcodeInfo
                            where entity.product_id == this.m_id
                            select entity;

                foreach ( var obj in data1)
                {
                    ctx.BarcodeInfo.Remove(obj);
                }

                ctx.SaveChanges();
            }

            foreach(EAN13DataInfo info in this.m_ean13_data_list )
            {
                using (ProductContext ctx = new ProductContext())
                {
                    BarcodeInfo entity = new BarcodeInfo();

                    entity.product_id = this.m_id;
                    entity.size_name = info.SizeName;
                    entity.barcode = info.BarcodeType;
                    entity.memo = info.Memo;
                    entity.lastamp = System.Guid.NewGuid();

                    ctx.BarcodeInfo.Add(entity);

                    ctx.SaveChanges();
                }
            }
        }
示例#26
0
        private void CaptureCameraCallback()
        {
            TmpBarcodeInfo = new BarcodeInfo();
            _frame         = new Mat();
            _capture       = new VideoCapture
            {
                FrameWidth  = 960,
                FrameHeight = 720
            };
            //  _capture.Set(VideoCaptureProperties.FrameHeight, 200.0);
            //   _capture.Set(VideoCaptureProperties.FrameWidth , .0);
            _capture.Open(_selCameraIndex);
            //  var wb = new WriteableBitmap(_capture.FrameWidth, _capture.FrameHeight, 96, 96, PixelFormats.Bgr24, null);
            if (!_capture.IsOpened())
            {
                return;
            }

            while (_isCameraRunning)
            {
                _capture.Read(_frame);
                _image = _frame;
                // Cv2.ImShow("camera", _frame);
                // StreamImg?.Dispose();
                //StreamSource = _image.ToBitmapSource();

                if (IsAutoSubmit | waitpic)
                {
                    if (delaycount2 >= _switchdelay)
                    {
                        delaycount2    = 0;
                        TmpBarcodeInfo = DetectBarcode(_capture.RetrieveMat(), _threshold);
                    }
                    delaycount2 = delaycount2 + 1;
                }

                if (IsAutoSubmit)
                {
                    // BarcodeImg = _cropimgMat.ToBitmapSource();
                    BarcodeText   = TmpBarcodeInfo.Text;
                    BarcodeFormat = TmpBarcodeInfo.Format;
                    if (!string.IsNullOrWhiteSpace(TmpBarcodeInfo.Text))
                    {
                        var saveFile = @"{MasterPara.LocalDb}\Picture\{BarcodeText}.jpg";
                        _cropimgMat.ImWrite(saveFile);
                        TmpBarcodeInfo = new BarcodeInfo()
                        {
                            Text = string.Empty, Format = "submitted"
                        };
                    }
                }
                else
                {
                    if (waitpic)
                    {
                        if (!string.IsNullOrWhiteSpace(TmpBarcodeInfo.Text))
                        {
                            // BarcodeImg = _cropimgMat.ToBitmapSource();
                            BarcodeText   = TmpBarcodeInfo.Text;
                            BarcodeFormat = TmpBarcodeInfo.Format;
                            waitpic       = false;
                        }
                    }

                    if (isSubmit)
                    {
                        var saveFile = $@"{MasterPara.LocalDataDir}LocalData\Picture\{BarcodeText}.jpg";
                        _cropimgMat.ImWrite(saveFile);
                        isSubmit       = false;
                        waitpic        = true;
                        TmpBarcodeInfo = new BarcodeInfo()
                        {
                            Text = string.Empty, Format = "submitted"
                        };
                    }
                }
                MemoryStream ms          = new MemoryStream();
                BitmapImage  bitmapImage = new BitmapImage();
                bitmapImage.BeginInit();
                bitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                bitmapImage.StreamSource = _frame.ToMemoryStream(".bmp");
                bitmapImage.EndInit();
                bitmapImage.Freeze();
                StreamSource = bitmapImage;

                MemoryStream ms2          = new MemoryStream();
                BitmapImage  bitmapImage2 = new BitmapImage();

                if (_cropimgMat != null)
                {
                    bitmapImage2.BeginInit();
                    bitmapImage2.CacheOption  = BitmapCacheOption.OnLoad;
                    bitmapImage2.StreamSource = _cropimgMat.ToMemoryStream(".bmp");
                    bitmapImage2.EndInit();
                    bitmapImage2.Freeze();
                    BarcodeImg = bitmapImage2;
                }
            }
        }
示例#27
0
        /// <summary>
        /// hàm thực hiện việc xử lý thông tin in phiếu
        /// </summary>
        /// <param name="DT"></param>
        private void ProcessData(ref DataTable DT)
        {
            try
            {
                foreach (DataRow drv in DT.Rows)
                {
                    if (Utility.sDbnull(drv["PID"], "-1") == "-1")
                    {
                        drv["PID"] = Utility.sDbnull(drv["Barcode"], "");
                    }
                }
                DT.AcceptChanges();

                Utility.AddColumToDataTable(ref DT, "BarcodeImg", typeof(byte[]));
                Utility.AddColumToDataTable(ref DT, "sTitleReport", typeof(string));
                Utility.AddColumToDataTable(ref DT, "sSex", typeof(string));
                Utility.AddColumToDataTable(ref DT, "Nguoidung", typeof(string));
                Utility.AddColumToDataTable(ref DT, "logo", typeof(byte[]));
                string path = "";
                if (System.IO.File.Exists(@"logo\logo.bmp"))
                {
                    path = @"logo\logo.bmp";
                }
                if (System.IO.File.Exists(@"logo\logo.jpg"))
                {
                    path = @"logo\logo.jpg";
                }
                if (System.IO.File.Exists(@"logo\logo.png"))
                {
                    path = @"logo\logo.png";
                }
                byte[] logoBytes = new byte[] {};
                if (path != "")
                {
                    logoBytes = Utility.bytGetImage(path);
                }
                var    arrayList    = new ArrayList();
                string sTitleReport = "";
                foreach (DataRow dr in DT.Rows)
                {
                    dr["BarcodeImg"] =
                        Utility.GenerateBarCode(
                            BarcodeInfo.CreateNewBarcode(Utility.sDbnull(dr["Barcode"], "0000000000")));
                    dr["logo"]          = logoBytes;
                    dr["TESTTYPE_NAME"] = Utility.sDbnull(dr["TESTTYPE_NAME"], "").ToUpper();

                    if (dr["Sex"] == DBNull.Value)
                    {
                        dr["sSex"] = "";
                    }
                    else if (Utility.Int32Dbnull(dr["Sex"]) == 1)
                    {
                        //  dr["Normal_Level"] = dr["Normal_Level"];
                        dr["sSex"] = "Nam";
                    }
                    else
                    {
                        //dr["Normal_Level"] = dr["Normal_LevelW"];
                        dr["sSex"] = "Nữ";
                    }

                    arrayList.Add(dr[TResultDetail.Columns.TestDetailId].ToString());
                    string sql = string.Format("SELECT Sys_Users.sFullName \n"
                                               + "FROM   Sys_Users  WITH (NOLOCK)  \n"
                                               + "WHERE  Sys_Users.PK_sUID = '{0}'", globalVariables.UserName);

                    var userName = new InlineQuery().ExecuteScalar <string>(sql);

                    if (radGopChung.Checked)
                    {
                        //if (Utility.sDbnull(drv["PID"], "-1") == "-1") drv["PID"] = Utility.sDbnull(drv["Barcode"], "");
                        if (grdTestType.GetCheckedRows().Length == 1)
                        {
                            GridEXRow[] gridExRows = grdTestType.GetCheckedRows();
                            sTitleReport =
                                gridExRows[0].Cells[TTestTypeList.Columns.TestTypeName].Value.ToString().ToUpper();
                            sTitleReport       = sTitleReport.Replace("XÉT NGHIỆM", "");
                            dr["sTitleReport"] = sTitleReport;
                            dr["Nguoidung"]    = userName;
                        }
                    }
                    else
                    {
                        dr["PID"]          = Utility.sDbnull(dr["PID"]) + Utility.sDbnull(dr[TTestInfo.Columns.TestTypeId], "-1");
                        sTitleReport       = dr[TTestTypeList.Columns.TestTypeName].ToString().ToUpper();
                        sTitleReport       = sTitleReport.Replace("XÉT NGHIỆM", "");
                        dr["sTitleReport"] = sTitleReport;
                        dr["Nguoidung"]    = userName;
                    }
                }
                DT.AcceptChanges();

                new Update(TResultDetail.Schema)
                .Set(TResultDetail.Columns.ParaStatus).EqualTo(1)
                .Where(TResultDetail.Columns.TestDetailId).In(arrayList).Execute();
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
示例#28
0
        /*public void ImageInitalize()
         * {
         *  if (_isImageRunning)
         *  { return;}
         *  CaptureCamera();
         *  _isImageRunning = true;
         * }
         *
         * private void CaptureImage()
         * {
         *  _imageThread = new Thread(BarcodeTask);
         *  //CaptureCameraCallback();
         *  _imageThread.Start();
         * }
         *
         *
         * private void BarcodeTask()
         * {
         *
         *  BarcodeFormat = tmp.Format;
         *  BarcodeText = tmp.Text;
         *
         * }*/


        private BarcodeInfo DetectBarcode(Mat source, double thresh, bool debug = false)
        {
            //  Console.WriteLine("\nProcessing: {0}", fileName);
            // load the image and convert it to grayscale
            // var image = new Mat(fileName);
            // var image = StreamImg.ToMat();
            var barcoderesult = new BarcodeInfo();
            var image         = source;

            if (debug)
            {
                Cv2.ImShow("Source", image);
                Cv2.WaitKey(1); // do events
            }

            var gray     = new Mat();
            var channels = image.Channels();

            if (channels > 1)
            {
                Cv2.CvtColor(image, gray, ColorConversionCodes.BGRA2GRAY);
            }
            else
            {
                image.CopyTo(gray);
            }


            // compute the Scharr gradient magnitude representation of the images
            // in both the x and y direction
            var gradX = new Mat();

            Cv2.Sobel(gray, gradX, MatType.CV_32F, xorder: 1, yorder: 0, ksize: -1);
            //Cv2.Scharr(gray, gradX, MatType.CV_32F, xorder: 1, yorder: 0);

            var gradY = new Mat();

            Cv2.Sobel(gray, gradY, MatType.CV_32F, xorder: 0, yorder: 1, ksize: -1);
            //Cv2.Scharr(gray, gradY, MatType.CV_32F, xorder: 0, yorder: 1);

            // subtract the y-gradient from the x-gradient
            var gradient = new Mat();

            Cv2.Subtract(gradX, gradY, gradient);
            Cv2.ConvertScaleAbs(gradient, gradient);

            if (debug)
            {
                Cv2.ImShow("Gradient", gradient);
                Cv2.WaitKey(1); // do events
            }


            // blur and threshold the image
            var blurred = new Mat();

            Cv2.Blur(gradient, blurred, new Size(9, 9));

            var threshImage = new Mat();

            Cv2.Threshold(blurred, threshImage, thresh, 255, ThresholdTypes.Binary);

            if (debug)
            {
                Cv2.ImShow("Thresh", threshImage);
                Cv2.WaitKey(1); // do events
            }


            // construct a closing kernel and apply it to the thresholded image
            var kernel = Cv2.GetStructuringElement(MorphShapes.Rect, new Size(21, 7));
            var closed = new Mat();

            Cv2.MorphologyEx(threshImage, closed, MorphTypes.Close, kernel);

            if (debug)
            {
                Cv2.ImShow("Closed", closed);
                Cv2.WaitKey(1); // do events
            }


            // perform a series of erosions and dilations
            Cv2.Erode(closed, closed, null, iterations: 4);
            Cv2.Dilate(closed, closed, null, iterations: 4);

            if (debug)
            {
                Cv2.ImShow("Erode & Dilate", closed);
                Cv2.WaitKey(1); // do events
            }


            //find the contours in the thresholded image, then sort the contours
            //by their area, keeping only the largest one

            Point[][]        contours;
            HierarchyIndex[] hierarchyIndexes;
            Cv2.FindContours(
                closed,
                out contours,
                out hierarchyIndexes,
                mode: RetrievalModes.CComp,
                method: ContourApproximationModes.ApproxSimple);

            if (contours.Length == 0)
            {
                //   throw new NotSupportedException("Couldn't find any object in the image.");
                Console.WriteLine("Couldn't find any object in the image.");
                return(barcoderesult);
            }

            var contourIndex       = 0;
            var previousArea       = 0;
            var biggestContourRect = Cv2.BoundingRect(contours[0]);

            while ((contourIndex >= 0))
            {
                var contour = contours[contourIndex];

                var boundingRect     = Cv2.BoundingRect(contour); //Find bounding rect for each contour
                var boundingRectArea = boundingRect.Width * boundingRect.Height;
                if (boundingRectArea > previousArea)
                {
                    biggestContourRect = boundingRect;
                    previousArea       = boundingRectArea;
                }

                contourIndex = hierarchyIndexes[contourIndex].Next;
            }

            /*biggestContourRect.Width += 10;
             * biggestContourRect.Height += 10;
             * biggestContourRect.Left -= 5;
             * biggestContourRect.Top -= 5;*/


            var barcode = new Mat(image, biggestContourRect); //Crop the image

            Cv2.CvtColor(barcode, barcode, ColorConversionCodes.BGRA2GRAY);

            _cropimgMat = barcode;

            //  Cv2.ImShow("Barcode", barcode);

            // Cv2.WaitKey(1); // do events

            var barcodeClone = barcode.Clone();

            if (delaycount1 < _dectdelay)
            {
                delaycount1   = delaycount1 + 1;
                barcoderesult = new BarcodeInfo()
                {
                    Text   = String.Empty,
                    Format = "waiting detecting"
                };
                return(barcoderesult);
            }

            delaycount1 = 0;

            barcoderesult = GetBarcodeText(barcodeClone);

            if (string.IsNullOrWhiteSpace(barcoderesult.Text))
            {
                Console.WriteLine("Enhancing the barcode...");
                //Cv2.AdaptiveThreshold(barcode, barcode, 255,
                //AdaptiveThresholdType.GaussianC, ThresholdType.Binary, 9, 1);
                //var th = 119;
                var th = 100;
                Cv2.Threshold(barcode, barcode, th, 255, ThresholdTypes.Tozero);
                Cv2.Threshold(barcode, barcode, th, 255, ThresholdTypes.Binary);
                barcoderesult = GetBarcodeText(barcode);
            }

            Cv2.Rectangle(image,
                          new Point(biggestContourRect.X, biggestContourRect.Y),
                          new Point(biggestContourRect.X + biggestContourRect.Width, biggestContourRect.Y + biggestContourRect.Height),
                          new Scalar(0, 255, 0),
                          2);

            if (debug)
            {
                Cv2.ImShow("Segmented Source", image);
                Cv2.WaitKey(1); // do events
            }

            //Cv2.WaitKey(0);
            //Cv2.DestroyAllWindows();

            return(barcoderesult);
        }
示例#29
0
        private BarcodeInfo DecodeBarcodeText(System.Drawing.Bitmap barcodeBitmap)
        {
            var tmpbnarcode = new BarcodeInfo();

            try
            {
                var source = new BitmapLuminanceSource(barcodeBitmap);

                // using http://zxingnet.codeplex.com/
                // PM> Install-Package ZXing.Net
                var reader = new BarcodeReader(null, null, ls => new GlobalHistogramBinarizer(ls))
                {
                    AutoRotate  = true,
                    TryInverted = true,
                    Options     = new DecodingOptions
                    {
                        TryHarder = true,
                        //PureBarcode = true,

                        /*PossibleFormats = new List<BarcodeFormat>
                         * {
                         *  BarcodeFormat.CODE_128
                         *  //BarcodeFormat.EAN_8,
                         *  //BarcodeFormat.CODE_39,
                         *  //BarcodeFormat.UPC_A
                         * }*/
                    }
                };

                //var newhint = new KeyValuePair<DecodeHintType, object>(DecodeHintType.ALLOWED_EAN_EXTENSIONS, new Object());
                //reader.Options.Hints.Add(newhint);

                var result = reader.Decode(source);
                if (result == null)
                {
                    Console.WriteLine("Decode failed.");
                    tmpbnarcode.Format = "Decode failed.";
                    tmpbnarcode.Text   = String.Empty;
                    return(tmpbnarcode);
                }

                Console.WriteLine("BarcodeFormat: {0}", result.BarcodeFormat);
                Console.WriteLine("Result: {0}", result.Text);

                tmpbnarcode.Format = result.BarcodeFormat.ToString();
                tmpbnarcode.Text   = result.Text;

                //   var writer = new BarcodeWriter
                //   {
                //      Format = result.BarcodeFormat,
                //      Options = { Width = 200, Height = 50, Margin = 4},
                //       Renderer = new ZXing.Rendering.BitmapRenderer()
                //  };
                //  var barcodeImage = writer.Write(result.Text);
                //   Cv2.ImShow("BarcodeWriter", barcodeImage.ToMat());

                return(tmpbnarcode);
            }
            catch (Exception e)
            {
                tmpbnarcode.Format = "Decode failed.";
                tmpbnarcode.Text   = String.Empty;
                return(tmpbnarcode);
                // Console.WriteLine(e);
                //  throw;
            }
        }
        private async void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            FormGrid.IsEnabled = false;
            var errorMessage = "Harap isi semua kolom berikut: \n";
            var anyError     = false;

            if (string.IsNullOrWhiteSpace(OrderNo.Text) || string.IsNullOrWhiteSpace(OrderNo.Text))
            {
                anyError      = true;
                errorMessage += "- Nomor Order\n";
            }

            //if (string.IsNullOrWhiteSpace(LotNoTextBox.Text))
            //{
            //    anyError = true;
            //    errorMessage += "- Nomor Lot\n";
            //}

            //decimal.TryParse(QuantityTextBox.Text, out var quantity);
            //if (string.IsNullOrWhiteSpace(QuantityTextBox.Text) || quantity <= 0)
            //{
            //    anyError = true;
            //    errorMessage += "- Quantity\n";
            //}

            //var quantity = QuantityDecimalUpDown.Value.GetValueOrDefault();

            if (anyError)
            {
                MessageBox.Show(errorMessage);
            }
            else
            {
                pb.Visibility = Visibility.Visible;
                //var viewModel = new ProductViewModel(
                //    string.Empty,
                //    string.Empty,
                //    string.Empty,
                //    string.Empty,
                //    LotNoTextBox.Text,
                //    "YARN",
                //    string.Empty,
                //    string.Empty,
                //    YarnTypePrefixTextBox.Text + YarnTypeSuffixTextbox.Text,
                //    string.Empty,
                //    "BALE",
                //    QuantityDecimalUpDown.Value.GetValueOrDefault(),
                //    "PALET"
                //    );
                var barcodeList = await PackingInventoryService.GetBarcodeInfoByOrderNo(OrderNo.Text, false);



                _barcodes   = new List <BarcodeInfo>();
                BarcodeList = new ObservableCollection <BarcodeInfo>();
                foreach (var barcode in barcodeList)
                {
                    var printedListJson = _cache.StringGet(barcode.productionOrder.no);
                    var printedList     = new List <string>();

                    if (!string.IsNullOrWhiteSpace(printedListJson))
                    {
                        printedList = JsonConvert.DeserializeObject <List <string> >(printedListJson, new JsonSerializerSettings()
                        {
                            MissingMemberHandling = MissingMemberHandling.Ignore
                        });
                    }

                    if (printedList != null && printedList.Count > 0)
                    {
                        barcode.productPackingCodes = barcode.productPackingCodes.Where(element => !printedList.Contains(element)).ToList();
                    }

                    foreach (var packingCode in barcode.productPackingCodes)
                    {
                        var barcodeInfo = new BarcodeInfo()
                        {
                            Color = barcode.color,
                            MaterialConstructionName = barcode.materialConstruction.name,
                            MaterialName             = barcode.material.name,
                            OrderNo          = barcode.productionOrder.no,
                            PackingCode      = packingCode,
                            PackingLength    = barcode.productPackingLength.ToString(),
                            PackingType      = barcode.productPackingType,
                            YarnMaterialName = barcode.yarnMaterial.name,
                            UOMSKU           = barcode.uomUnit
                        };
                        _barcodes.Add(barcodeInfo);
                        //BarcodeList.Add(barcodeInfo);
                    }

                    if (BarcodeList.Count > 0 && !string.IsNullOrWhiteSpace(PackingSizeFilter.Text))
                    {
                        if (double.TryParse(PackingSizeFilter.Text, out var packingSize))
                        {
                            _barcodes = _barcodes.Where(element => element.PackingLength == packingSize.ToString()).ToList();
                        }
                    }

                    foreach (var _barcode in _barcodes)
                    {
                        BarcodeList.Add(_barcode);
                    }
                }


                ////if (barcode != null && !string.IsNullOrWhiteSpace(barcode.PackingCode))
                //if (barcode != null /*&& !string.IsNullOrWhiteSpace(barcode.PackingCode)*/)
                //    {
                //    LotNoTextBox.Text = string.Empty;
                //    YarnTypePrefixTextBox.Text = string.Empty;
                //    YarnTypeSuffixTextbox.Text = string.Empty;
                //    //QuantityTextBox.Text = string.Empty;
                //    QuantityDecimalUpDown.Value = null;

                //    _barcodes.Add(barcode);
                //    BarcodeListView.Items.Add(barcode);
                //}

                BarcodeGrid.ItemsSource = BarcodeList;
                pb.Visibility           = Visibility.Hidden;
            }
            FormGrid.IsEnabled = true;

            //MessageBox.Show()
        }
示例#31
0
 public void CopyTo(BarcodeInfo obj)
 {
     obj.ExistBarcode = ExistBarcode;
     obj.Pattern = Pattern;
     obj.Length = Length;
 }
示例#32
0
        /// <summary>
        /// hàm thực hiện việc xử lý thông tin in phiếu
        /// </summary>
        /// <param name="DT"></param>
        private void ProcessData(ref DataTable DT)
        {
            try
            {
                foreach (DataRow drv in DT.Rows)
                {
                    if (Utility.sDbnull(drv["PID"], "-1") == "-1")
                    {
                        drv["PID"] = Utility.sDbnull(drv["Barcode"], "");
                    }
                }
                DT.AcceptChanges();

                Utility.AddColumToDataTable(ref DT, "BarcodeImg", typeof(byte[]));
                Utility.AddColumToDataTable(ref DT, "sTitleReport", typeof(string));
                Utility.AddColumToDataTable(ref DT, "sSex", typeof(string));
                Utility.AddColumToDataTable(ref DT, "Nguoidung", typeof(string));
                Utility.AddColumToDataTable(ref DT, "logo", typeof(byte[]));
                string path = "";
                if (File.Exists(@"logo\logo.bmp"))
                {
                    path = @"logo\logo.bmp";
                }
                if (File.Exists(@"logo\logo.jpg"))
                {
                    path = @"logo\logo.jpg";
                }
                if (File.Exists(@"logo\logo.png"))
                {
                    path = @"logo\logo.png";
                }
                var logoBytes = new byte[] {};
                if (path != "")
                {
                    logoBytes = Utility.bytGetImage(path);
                }
                var    arrayList    = new ArrayList();
                string sTitleReport = "";
                foreach (DataRow dr in DT.Rows)
                {
                    dr["BarcodeImg"] =
                        Utility.GenerateBarCode(
                            BarcodeInfo.CreateNewBarcode(Utility.sDbnull(dr["Barcode"], "0000000000")));
                    dr["logo"]          = logoBytes;
                    dr["TESTTYPE_NAME"] = Utility.sDbnull(dr["TESTTYPE_NAME"], "").ToUpper();

                    if (dr["Sex"] == DBNull.Value)
                    {
                        dr["sSex"] = "";
                    }
                    else if (Utility.Int32Dbnull(dr["Sex"]) == 1)
                    {
                        //  dr["Normal_Level"] = dr["Normal_Level"];
                        dr["sSex"] = "Nam";
                    }
                    else
                    {
                        //dr["Normal_Level"] = dr["Normal_LevelW"];
                        dr["sSex"] = "Nữ";
                    }

                    arrayList.Add(dr[TResultDetail.Columns.TestDetailId].ToString());


                    dr["PID"]          = Utility.sDbnull(dr["PID"]) + Utility.sDbnull(dr[TTestInfo.Columns.TestTypeId], "-1");
                    sTitleReport       = dr[TTestTypeList.Columns.TestTypeName].ToString().ToUpper();
                    sTitleReport       = sTitleReport.Replace("XÉT NGHIỆM", "");
                    dr["sTitleReport"] = sTitleReport;
                    dr["Nguoidung"]    = Utilities.gv_sUID;
                }
                DT.AcceptChanges();

                new Update(TResultDetail.Schema)
                .Set(TResultDetail.Columns.ParaStatus).EqualTo(1)
                .Where(TResultDetail.Columns.TestDetailId).In(arrayList).Execute();
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
示例#33
0
        private void InPhieuChiDinh(bool IsQuick, string sTitleReport, DateTime NgayIn)
        {
            int    strPatient_ID = -1;
            var    DTPrint       = new DataTable();
            string vTestTypeId   = GetCheckTestType();
            string vTestID       = GetcheckTestID();

            if (vTestTypeId == "-1")
            {
                Utility.ShowMsg("Chưa chọn loại xét nghiệm để in");
                return;
            }

            //if (grdList.GetCheckedRows().Length > 0)
            //{
            //    foreach (GridEXRow gridExRow in grdList.GetCheckedRows())
            //    {
            //        strPatient_ID += "," + Utility.Int32Dbnull(gridExRow.Cells["Patient_ID"].Value, -1);
            //    }
            //    strPatient_ID = strPatient_ID.Remove(0, 1);
            //}
            //else
            {
                strPatient_ID = Utility.Int32Dbnull(grdList.GetValue("Patient_ID"));
            }
            DTPrint =
                SPs.InPhieuChiDinhXetNghiem(strPatient_ID, vTestTypeId, vTestID).GetDataSet().Tables[0];
            if (DTPrint.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy bản ghi nào", "Thông báo");
                return;
            }
            string tieude = "", reportname = "";
            var    crpt    = Utility.GetReport("crpt_InPhieuChiDinhXetNghiem", ref tieude, ref reportname);
            var    objForm = new frmPrintPreview(sTitleReport, crpt, true, DTPrint.Rows.Count <= 0 ? false : true);

            Utility.UpdateLogotoDatatable(ref DTPrint);
            Utility.AddColumToDataTable(ref DTPrint, "BarcodeImg", typeof(byte[]));
            foreach (DataRow dr in DTPrint.Rows)
            {
                dr["BarcodeImg"] =
                    Utility.GenerateBarCode(
                        BarcodeInfo.CreateNewBarcode(Utility.sDbnull(dr["Barcode"], "0000000000")));
            }
            try
            {
                DTPrint.AcceptChanges();
                crpt.SetDataSource(DTPrint);
                objForm.crptViewer.ReportSource = crpt;
                objForm.crptTrinhKyName         = Path.GetFileName(reportname);
                Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(NgayIn));
                Utility.SetParameterValue(crpt, "sTitleReport", sTitleReport);
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                if (!IsQuick)
                {
                    objForm.ShowDialog();
                    // Utility.DefaultNow(this);
                }
                else
                {
                    objForm.addTrinhKy_OnFormLoad();
                    crpt.PrintOptions.PrinterName = printDocument.PrinterSettings.PrinterName;
                    crpt.PrintToPrinter(0, true, 0, 0);
                    crpt.Dispose();
                    CleanTemporaryFolders();
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.ToString());
            }
        }
示例#34
0
        /// <summary>
        /// Sets the barcode parameter.
        /// </summary>
        private void SetBarcodeParameter()
        {
            _barcodeInfo = StandardBarcodes.GetBarcodeInfo(_code);

            // license
            // put in your license code here
            //_myBarcode.License("Licensee Name", LicenseType.DeveloperOrWeb, 1, "hex code goes here", TBarCodeProduct.Barcode2D);

            _myBarcode.Dpi = GetValidatedDPI(_dpi);

            // set barcode font
            _myBarcode.FontName = "Arial";

            // workaround for "Not Implemented Bug"!!
            _myBarcode.MultipleBarcodes.StructuredAppendMode = StructuredAppendMode.None;

            // --- BARCODE DATA ---

            if (String.IsNullOrEmpty(_data))
            throw new Exception("No bar code data specified");

            // auto correct for Code-39: leading/trailing asterisks are not allowed
            if (_barcodeInfo.BarcodeType == BarcodeType.Code39
            || _barcodeInfo.BarcodeType == BarcodeType.Code39Extended)
            {
            char[] trims = { '*' };
            _data = _data.Trim(trims);
            }

            if (_translateEscape == "on")
            _myBarcode.TranslateEscapeSequences = true;

            _myBarcode.Data = _data;

            // --- BAR CODE TYPE ---

            _myBarcode.BarcodeType = _barcodeInfo.BarcodeType;

            SetComposite();

            // --- BAR CODE SIZE ---

            SetModuleWidth();

            SetBarcodeSize();

            _myBarcode.HumanReadableText = _humanReadableText;

            _myBarcode.IsTextVisible = _printDataText;

            SetRotation();
        }