Пример #1
0
        /// <summary>
        /// 選取檔案
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FileControl_FileFilterClick(object sender, EventArgs e)
        {
            FileControl    fileControl = sender as FileControl;
            OpenFileDialog ofd         = new OpenFileDialog
            {
                Title            = "請選擇上傳的檔案",
                Filter           = @"All Image And PDF Files|*.bmp;*.ico;*.gif;*.jpeg;*.jpg;*.png;*.tif;*.tiff;*.pdf",
                Multiselect      = false,
                RestoreDirectory = true
            };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                foreach (FileControl fc in FileUI)
                {
                    if (ofd.SafeFileName.Equals(fc.GetFileName()))
                    {
                        MessageBox.Show("檔案已存在,請更改檔名,或將覆蓋舊檔案後可上傳", "錯誤訊息");
                        return;
                    }
                }

                fileControl.SetFileInfo(ofd.FileName, ofd.SafeFileName);
            }
        }
Пример #2
0
        /// <summary>
        /// 移除檔案
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FileControl_BtnClick(object sender, EventArgs e)
        {
            FileControl fileControl = (FileControl)sender;

            FileUI.Remove(fileControl);
            splitContainer1.Panel1.Controls.Remove(fileControl);
            this.RepositionFiles();
        }
Пример #3
0
        /// <summary>
        /// 新增一個檔案
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NewFileBtn_Click(object sender, EventArgs e)
        {
            FileControl fileControl = new FileControl();

            fileControl.BtnClick        += FileControl_BtnClick;
            fileControl.FileFilterClick += FileControl_FileFilterClick;
            FileUI.Add(fileControl);
            splitContainer1.Panel1.Controls.Add(fileControl);

            this.RepositionFiles();
        }
Пример #4
0
        private void ShowData()
        {
            FileDB = Talent.GetInstance().SelectFiles(InterviewId, AttachedFileMode).Copy();
            if (!string.IsNullOrEmpty(Talent.GetInstance().ErrorMessage))
            {
                MessageBox.Show(Talent.GetInstance().ErrorMessage, "錯誤訊息");
                return;
            }

            List <AttachedFiles> list = FileDB.DataTableToList <AttachedFiles>();

            foreach (AttachedFiles attachedFiles in list)
            {
                FileControl fileControl = new FileControl();
                fileControl.BtnClick        += FileControl_BtnClick;
                fileControl.FileFilterClick += FileControl_FileFilterClick;
                fileControl.SetFileInfo(attachedFiles.File_Path, Path.GetFileName(attachedFiles.File_Path));
                FileUI.Add(fileControl);
                splitContainer1.Panel1.Controls.Add(fileControl);

                this.RepositionFiles();
            }
        }