Esempio n. 1
0
 private void Button_Click_4(object sender, RoutedEventArgs e)
 {
     using (var context = new UniContext())
     {
         if (!string.IsNullOrEmpty(adAdd.Text))
         {
             var item = new Item
             {
                 Name = adAdd.Text,
             };
             context.Items.Add(item);
         }
         if (!string.IsNullOrEmpty(inventarAdd.Text))
         {
             var room = new Room
             {
                 Name = inventarAdd.Text,
             };
             context.Rooms.Add(room);
         }
         if (!string.IsNullOrEmpty(binaAdd.Text))
         {
             var bina = new Bina
             {
                 Name = binaAdd.Text,
             };
             context.Binas.Add(bina);
         }
         context.SaveChanges();
         adAdd.Clear();
         inventarAdd.Clear();
         binaAdd.Clear();
         updateData();
     }
 }
Esempio n. 2
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            view.Visibility = Visibility.Visible;
            edit.Visibility = Visibility.Hidden;

            if (otaqedit.SelectedValue != null)
            {
                roomId = int.Parse(otaqedit.SelectedValue.ToString());
            }
            if (adedit.SelectedValue != null)
            {
                itemId = int.Parse(adedit.SelectedValue.ToString());
            }
            if (binaedit.SelectedValue != null)
            {
                binaId = int.Parse(binaedit.SelectedValue.ToString());
            }

            using (var context = new UniContext())
            {
                item        = context.Inventars.Where(i => i.Barcode == searchtxt.Text).FirstOrDefault();
                item.SN     = snedit.Text;
                item.Note   = new TextRange(qeydedit.Document.ContentStart, qeydedit.Document.ContentEnd).Text;
                item.Count  = int.Parse(sayedit.Text);
                item.Year   = int.Parse(iledit.Text);
                item.Person = msedit.Text;
                item.Room   = context.Rooms.Find(roomId);
                item.Item   = context.Items.Find(itemId);
                item.Bina   = context.Binas.Find(binaId);

                context.SaveChanges();
            }
            ShowView();
        }
Esempio n. 3
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();
         }
     }
 }
Esempio n. 4
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;
                }
            }
        }