private void BarkodOkuma_Load(object sender, EventArgs e) { PrintDocument doc = new PrintDocument(); Ean13Barcode2005.Ean13 barkod = new Ean13Barcode2005.Ean13(); barkod.Height = 30f; barkod.Width = 70f; barkod.FontSize = 16f; //bu kod barkodun ilk 2 hanesi -ülke kodu barkod.CountryCode = "86"; //Bu kod üretici-imalatçı numarası -bu kısımın legal illegal gibi durumları da var barkod.ManufacturerCode = "95525"; //Bu kod ürün kodu barkod.ProductCode = UrunKodu(); //Bu kısım boş geçilsede birşey değişmiyor EAN-13 te zaten 12 veri okuyorsunuz ,bu sayı barkodun sonunda oluyor. kontrol kodu barkod.ChecksumDigit = "0"; pbBarkod.Image = barkod.CreateBitmap(); txtBarkod.Text = barkod.ToString(); urun = new UrunRepo().GetAll().FirstOrDefault(x => x.UrunBarkod == txtBarkod.Text); if (urun != null) { lblUrunAdi.Visible = true; lblUrunAdi.Text = "Gelen ürün: " + urun.UrunAdi; lblUrunAdi.Location = new Point((this.Width / 2) - 5 * (lblUrunAdi.Text.Length), lblUrunAdi.Location.Y); } this.ActiveControl = txtBarkod; txtBarkod.Focus(); txtBarkod.Select(0, 0); txtBarkod.SelectionStart = txtBarkod.MaxLength; }
/// <summary> /// Método busca por um produto a partir do EAN informado /// </summary> /// <param name="EAN">EAN sendo verificado dígito verificado, permitido somente com 13 dígitos</param> /// <returns>Produto localizado a partir do EAN informado</returns> public NetProduto BuscaProduto(String EAN) { ///Validação dos dados. if (EAN.Trim().Equals("")) { throw new Exception("EAN não informado."); } Ean13Barcode2005.Ean13 ean = new Ean13Barcode2005.Ean13(); if (EAN.Length > 13) { throw new Exception("EAN só pode conter 13 dígitos."); } if (EAN.Length < 13) { EAN = "0000000000000" + EAN; EAN = new Uteis().direita(EAN, 13); } if (!ean.chekDigitoEAN(EAN)) { throw new Exception("Código EAN inválido."); } //Busca NetProduto resporta = _daoProduto.BuscaEAN(EAN); if (resporta == null) { throw new Exception("Não foi localizado nenhum produto com o EAN informado."); } return(resporta); }
public override void Init(ClientUI.UserObjectEventArgs args) { base.Init(args); searchString = Convert.ToString(args.data["SEARCH_STRING"]); infoAboutId = Convert.ToUInt64(args.data["INFO_ABOUT"]); String codeString = Convert.ToString(infoAboutId); int len = codeString.Length; for (int i = 0; i < 13 - len; ++i) { codeString = "0" + codeString; } String countryCode = codeString.Substring(0, 2); String manCode = codeString.Substring(2, 5); String prodCode = codeString.Substring(7, 5); String checkSum = codeString.Substring(12); Ean13Barcode2005.Ean13 ean13 = new Ean13Barcode2005.Ean13(countryCode, manCode, prodCode, checkSum); ean13.Scale = 2.0F; Bitmap bmp = ean13.CreateBitmap(); Rectangle rect = new Rectangle(0, 95, 270, 100); Bitmap cropped = bmp.Clone(rect, bmp.PixelFormat); pictureBox.Image = cropped; Database.FullPersonInfo fpInfo = getDatabase().getPersonInfo(infoAboutId); DataTable table = new DataTable(); getDatabase().fillWithPoliceProperties(infoAboutId, table); baseTableView.DataSource = table; baseTableView.Columns["ID"].Visible = false; baseTableView.Columns["NAME"].Width = 200; codeBox.Text = Convert.ToString(infoAboutId); nameBox.Text = fpInfo.name; switch (fpInfo.gender) { case Database.FullPersonInfo.Gender.Male: genderBox.Text = "Мужской"; break; case Database.FullPersonInfo.Gender.Female: genderBox.Text = "Женский"; break; default: genderBox.Text = "Неизвестно"; break; } }
public void ApplyFilter(string Filter) { if (null != Filter && Filter.Trim() != string.Empty) { string[] words = Filter.Trim().ToUpper().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); Predicate<Tovar> findPredicate = (Tovar t) => { Ean13Barcode2005.Ean13 ean = new Ean13Barcode2005.Ean13("0", t.ID_Tovar.ToString()); string searchSource = t.Kod.ToString() + "|" + t.NameTovar.ToUpper() + "|" + t.Group.Name.ToUpper() + "|" + t.CinaProdazh.ToString() + "|" + t.Partner.NamePartner.ToUpper() + "|" + t.ID_Tovar.ToString().PadLeft(12, '0') + ean.ChecksumDigit; foreach (string w in words) if (!searchSource.Contains(w)) return false; return true; }; currentTovarList = allTovarList.FindAll(findPredicate); } else currentTovarList = new List<Tovar>(allTovarList); if (null != PropertyChanged) PropertyChanged(this, new PropertyChangedEventArgs("TovarList")); if (currentTovarList != null && currentTovarList.Count > 0) SelectedTovar = currentTovarList[0]; }