private void DGV_Parts_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                object item = DGV_Parts.SelectedItem;
                ID = (DGV_Parts.SelectedCells[0].Column.GetCellContent(item) as TextBlock).Text;

                if (RoleType == "Administrator" || RoleType == "Manager")
                {
                    if (DGV_Parts.Items.IsEmpty)
                    {
                        addParts = new AddParts();
                        Parts_page.Navigate(addParts);
                    }

                    else
                    {
                        upParts = new UpdateParts();
                        upParts.txt_Brand.Text        = (DGV_Parts.SelectedCells[1].Column.GetCellContent(item) as TextBlock).Text;
                        upParts.txt_Manufacturer.Text = (DGV_Parts.SelectedCells[3].Column.GetCellContent(item) as TextBlock).Text;
                        upParts.txt_Price.Text        = (DGV_Parts.SelectedCells[2].Column.GetCellContent(item) as TextBlock).Text;
                        upParts.ID         = ID;
                        upParts.Department = Department;

                        Parts_page.Navigate(upParts);
                    }
                }

                connect.SelectMotorPic(int.Parse(ID));
                byte[]       data = (byte[])connect.set.Tables[0].Rows[0][1];
                MemoryStream strm = new MemoryStream();
                strm.Write(data, 0, data.Length);
                strm.Position = 0;

                System.Drawing.Image imgs = System.Drawing.Image.FromStream(strm);
                BitmapImage          bi   = new BitmapImage();

                bi.BeginInit();
                MemoryStream ms = new MemoryStream();

                imgs.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
                strm.Seek(0, SeekOrigin.Begin);

                bi.StreamSource = strm;
                bi.EndInit();
                im.Source = bi;
            }
            catch (Exception)
            {
            }
        }
Esempio n. 2
0
        private void Can_AddParts_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            viewparts = new ViewParts();
            addparts  = new AddParts();

            viewparts.Parts_page = null;
            DependencyObject currParent = VisualTreeHelper.GetParent(this);

            while (currParent != null && viewparts.Parts_page == null)
            {
                viewparts.Parts_page = currParent as Frame;
                currParent           = VisualTreeHelper.GetParent(currParent);
            }

            if (viewparts.Parts_page != null)
            {
                viewparts.Parts_page.Source = new Uri("AddParts.xaml", UriKind.Relative);
            }
        }