Exemple #1
0
        private void dataGridView_FileList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                RemoteInterface vRemoteInterface = new RemoteInterface(Program.LoginUserInfo.ID.Value, Program.LoginUserInfo.UserName, Program.LoginUserInfo.Token);
                DataTable       vDatsSource      = (DataTable)dataGridView_FileList.DataSource;
                int             vFileID          = (int)vDatsSource.Rows[e.RowIndex]["ID"];
                string          vFileName        = (string)vDatsSource.Rows[e.RowIndex]["FileName"];
                if (e.ColumnIndex == 5)
                {
                    ConfigFile vConfigFile   = new ConfigFile();
                    string     vDownloadPath = string.Format(@"{0}\{1}", vConfigFile.DownloadPath, vFileName);

                    if (vRemoteInterface.DownloadFile(vFileID, vDownloadPath))
                    {
                        if (MessageBox.Show("文件下载成功,是否打开?", "信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                        {
                            System.Diagnostics.Process.Start(vDownloadPath);
                        }
                    }
                    else
                    {
                        MessageBox.Show("文件下载失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                if (e.ColumnIndex == 6)
                {
                    if (MessageBox.Show("是否确认删除", "信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                    {
                        if (vRemoteInterface.DeleteFile(vFileID, vFileName))
                        {
                            dataGridView_FileList.Rows.RemoveAt(e.RowIndex);
                            ((DataTable)dataGridView_FileList.DataSource).Rows.RemoveAt(e.RowIndex);
                            ((DataTable)dataGridView_FileList.DataSource).AcceptChanges();
                        }
                        else
                        {
                            MessageBox.Show("删除文件失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
Exemple #2
0
 private void dataGridView_FileList_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 4)
     {
         FileInfo[]      vDatsSource      = (FileInfo[])dataGridView_FileList.DataSource;
         int             vFileID          = vDatsSource[e.RowIndex].ID;
         string          vFileName        = vDatsSource[e.RowIndex].FileName;
         ConfigFile      vConfigFile      = new ConfigFile();
         string          vDownloadPath    = string.Format(@"{0}\{1}", vConfigFile.DownloadPath, vFileName);
         RemoteInterface vRemoteInterface = new RemoteInterface(Program.LoginUserInfo.ID.Value, Program.LoginUserInfo.UserName, Program.LoginUserInfo.Token);
         if (vRemoteInterface.DownloadFile(vFileID, vDownloadPath))
         {
             if (MessageBox.Show("文件下载成功,是否打开?", "信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
             {
                 System.Diagnostics.Process.Start(vDownloadPath);
             }
         }
         else
         {
             MessageBox.Show("文件下载失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }