示例#1
0
        private void добавитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter           = "JPG files (*.jpg)|*.jpg| All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                System.IO.Stream FileOpened;
                if ((FileOpened = openFileDialog1.OpenFile()) != null)
                {
                    byte[] FileData = new byte[FileOpened.Length];
                    FileOpened.Read(FileData, 0, FileData.Length);
                    FileOpened.Close();

                    if (EventAddImage.Target != null)
                    {
                        EventAddImage.Invoke(FileData, null);
                    }
                }
                ;
            }
            ;
        }
示例#2
0
        public string OpenDBDialog(string defaultPath)
        {
            Stream FileOpened;

            System.Windows.Forms.OpenFileDialog openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
            openFileDialog1.Title            = "Укажите путь к файлу Базы Данных";
            openFileDialog1.InitialDirectory = defaultPath;
            openFileDialog1.Filter           = "DataBase files (*.mdb)|*.mdb| All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                CloseDB();
                if ((FileOpened = openFileDialog1.OpenFile()) != null)
                {
                    FileOpened.Close();
                    try
                    {
                        if (!OpenDB(openFileDialog1.FileName))
                        {
                            throw new Exception("Не удалось подключится к базе данных " + openFileDialog1.FileName);
                        }
                        return(openFileDialog1.FileName);
                    }
                    catch (Exception ex)
                    {
                        ErrorWork.ErrorProcess(ex);
                    };
                }
                ;
            }
            ;

            return("");
        }
示例#3
0
        private void сохранитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog SaveFileDialog1 = new SaveFileDialog();

            SaveFileDialog1.Filter           = "JPG files (*.jpg)|*.jpg| All files (*.*)|*.*";
            SaveFileDialog1.FilterIndex      = 1;
            SaveFileDialog1.RestoreDirectory = true;
            if (SaveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                System.IO.Stream FileOpened;
                if ((FileOpened = SaveFileDialog1.OpenFile()) != null)
                {
                    FileOpened.Close();
                    if (EventGetImage.Target != null)
                    {
                        EventGetImage.Invoke(new string[] { listViewImages.SelectedItems[0].ImageKey, SaveFileDialog1.FileName }, EventArgs.Empty);
                    }
                    else
                    {
                        listViewImages.LargeImageList.Images[listViewImages.LargeImageList.Images.IndexOfKey(listViewImages.SelectedItems[0].ImageKey)].Save(SaveFileDialog1.FileName);
                    }
                }
            }
        }