예제 #1
0
 private void searchtxt_changed(object sender, TextChangedEventArgs e)
 {
     using (var context = new UniContext())
     {
         item = context.Inventars.Where(i => i.Barcode == searchtxt.Text).FirstOrDefault();
         if (item != null)
         {
             ShowView();
             var inventar = new Checked
             {
                 ChechkedTime = DateTime.Now,
                 Inventar     = item,
             };
             context.CheckedItem.Add(inventar);
             context.SaveChanges();
         }
     }
 }
예제 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(saysave.Text) |
                String.IsNullOrEmpty(mssave.Text) |
                rooms == null |
                items == null |
                binas == null |
                string.IsNullOrEmpty(otaqsave.SelectedValue.ToString()) |
                string.IsNullOrEmpty(inventarsave.SelectedValue.ToString()) |
                string.IsNullOrEmpty(binasave.SelectedValue.ToString())
                )
            {
                ersave.Content = "Bütün xanaları Doldurun";
                return;
            }
            using (var context = new UniContext())
            {
                roomId = (int)otaqsave.SelectedValue;
                itemId = (int)inventarsave.SelectedValue;
                binaId = (int)binasave.SelectedValue;



                if (!int.TryParse(saysave.Text, out say))
                {
                    say = 1;
                }

                if (!int.TryParse(ilsave.Text, out il))
                {
                    il = 0;
                }


                var r        = context.Rooms.Find(roomId);
                var b        = context.Binas.Find(binaId);
                var inventar = new Inventar
                {
                    SN         = snsave.Text,
                    Count      = say,
                    Year       = il,
                    Person     = mssave.Text,
                    Note       = new TextRange(qeydsave.Document.ContentStart, qeydsave.Document.ContentEnd).Text,
                    CreateDate = DateTime.Now,
                    Room       = r,
                    Bina       = b,
                    Item       = context.Items.Find(itemId),
                };
                var inven = context.Inventars.Add(inventar);
                try
                {
                    context.SaveChanges();
                    string barkod = ("SB" + r.Name + "R" + b.Name + "F" + "-" + inven.InventarID).Replace(" ", String.Empty);
                    inven.Barcode = barkod;
                    context.SaveChanges();
                    updateGridData();
                    snsave.Clear();
                    qeydsave.Document.Blocks.Clear();
                    mssave.Clear();
                    saysave.Clear();
                    ilsave.Clear();
                    ersave.Content = "Yaddaşa verildi";

                    string dataDir = System.AppDomain.CurrentDomain.BaseDirectory;


                    ersave.Content = "Şəkil düzəlir..";
                    BarcodeLib.Barcode   ba  = new BarcodeLib.Barcode();
                    System.Drawing.Image img = ba.Encode(BarcodeLib.TYPE.CODE128, barkod, System.Drawing.Color.Black, System.Drawing.Color.White, 450, 180);
                    if (!Directory.Exists("C:/barkodlar/"))
                    {
                        Directory.CreateDirectory("C:/barkodlar/");
                    }
                    if (!Directory.Exists("C:/barkodlar/" + r.Name))
                    {
                        Directory.CreateDirectory("C:/barkodlar/" + r.Name);
                    }
                    if (!Directory.Exists("C:/barkodlar/" + r.Name + "/" + b.Name))
                    {
                        Directory.CreateDirectory("C:/barkodlar/" + r.Name + "/" + b.Name);
                    }
                    for (int i = 0; i < say; i++)
                    {
                        img.Save("C:/" + "/barkodlar/" + r.Name + "/" + b.Name + "/" + barkod + "c" + i + ".png", ImageFormat.Png);
                    }

                    barimage.Source = new BitmapImage(new Uri("C:/" + "/barkodlar/" + r.Name + "/" + b.Name + "/" + barkod + "c0" + ".png"));
                    ersave.Content  = "yadda saxlanıldı";
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                    ersave.Content = ex;
                }
            }
        }