Exemplo n.º 1
0
        private void updateData()
        {
            using (var context = new UniContext())
            {
                // Load all students and related enrollments
                rooms = context.Rooms.ToList();
                items = context.Items.ToList();
                binas = context.Binas.ToList();
                otaqsave.ItemsSource = rooms;

                otaqsave.DisplayMemberPath = "Name";
                otaqsave.SelectedValuePath = "RoomID";
                otaqsave.SelectedIndex     = 0;

                inventarsave.ItemsSource       = items;
                inventarsave.DisplayMemberPath = "Name";
                inventarsave.SelectedValuePath = "ItemID";
                inventarsave.SelectedIndex     = 0;

                binasave.ItemsSource       = binas;
                binasave.DisplayMemberPath = "Name";
                binasave.SelectedValuePath = "BinaId";
                binasave.SelectedIndex     = 0;
            }
        }
Exemplo n.º 2
0
        private void importfromexcel(object sender, RoutedEventArgs e)
        {
            Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel.Workbook    workbook;
            Microsoft.Office.Interop.Excel.Worksheet   worksheet;
            Microsoft.Office.Interop.Excel.Range       range;
            workbook  = excelApp.Workbooks.Open("C:/" + "testitem.xlsx");
            worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets["Test Sheet"];

            int column = 0;
            int row    = 0;

            range = worksheet.UsedRange;

            using (var context = new UniContext())
            {
                for (row = 2; row <= range.Rows.Count; row++)
                {
                    for (column = 1; column <= range.Columns.Count; column++)
                    {
                        Item itemObj = new Item
                        {
                            Name = (range.Cells[row, column] as Microsoft.Office.Interop.Excel.Range).Value2.ToString(),
                        };
                        context.Items.Add(itemObj);
                    }
                }
                context.SaveChangesAsync();
            }
            workbook.Close(true, Missing.Value, Missing.Value);
            excelApp.Quit();
        }
Exemplo n.º 3
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();
     }
 }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
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();
         }
     }
 }
Exemplo n.º 6
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;
                }
            }
        }