예제 #1
0
        private void btnUpdateDisk_Click(object sender, EventArgs e)
        {
            if (this.dataGridView.SelectedRows.Count != 1)
            {
                MessageBox.Show("请选中一行!", "提示", MessageBoxButtons.OK);
                return;
            }

            String diskDescribe = this.dataGridView.SelectedRows[0].Cells[1].Value.ToString();

            FolderBrowserDialog dlg = new FolderBrowserDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                if (!dlg.SelectedPath.EndsWith(":\\"))
                {
                    MessageBox.Show("请选择磁盘根目录!", "提示", MessageBoxButtons.OK);
                    return;
                }

                if (MessageBox.Show(
                        string.Format("确定要更新磁盘 \'{0}\' 通过实际磁盘 \'{1}\' 吗?",
                                      diskDescribe, dlg.SelectedPath), "提示",
                        MessageBoxButtons.OKCancel,
                        MessageBoxIcon.Question) ==
                    DialogResult.Cancel)
                {
                    return;
                }

                int deleteFilmNumber = sqlData.DeleteByDiskDescribeFromFilmInfo(diskDescribe);
                int deleteDiskNumber = sqlData.DeleteByDiskDescribeFromDiskInfo(diskDescribe);

                bool bBriefScan = this.checkBoxBriefScan.Checked;
                int  setLayer   = Convert.ToInt32(this.tbeLayer.Text);

                ProgressForm progressForm = new ProgressForm(new ThreadScanDisk(
                                                                 dlg.SelectedPath, diskDescribe, this.cbScanMedia.Checked,
                                                                 bBriefScan ? setLayer : Int32.MaxValue,
                                                                 new ThreadScanDisk.ThreadSacnDiskCallback(ThreaScanDiskResult),
                                                                 sqlData));
                progressForm.ShowDialog();

                this.needReFillRamData = true;

                gridViewData = ConvertDiskInfoToGrid(sqlData.GetAllDataFromDiskInfo());
                this.dataGridView.DataSource = gridViewData;

                string extraMsg = string.Empty;
                if (bBriefScan && bCompleteScan)
                {
                    extraMsg = string.Format("\n设定扫描层数 {0} 足以进行完全扫描!", setLayer);
                }
                MessageBox.Show(String.Format("更新磁盘 \'{0}\' 完成!{1}", diskDescribe, extraMsg),
                                "提示", MessageBoxButtons.OK);
            }
        }