Пример #1
0
 private void btnUpload_Click(object sender, EventArgs e)
 {
     try
     {
         FileDataSet dataset  = this.fileDataSet;
         string      fileType = "档案";
         if (tabbedControlGroup1.SelectedTabPageIndex == 1)
         {
             fileType = "合同";
             dataset  = this.HTfileDataSet;
         }
         else
         {
             dataset  = this.fileDataSet;
             fileType = "档案";
         }
         DataRowView rv = tW_ClientBindingSource.Current as DataRowView;
         if (rv == null)
         {
             return;
         }
         string fkID = rv["客户名称ID"].ToString();
         openFileDialog.DefaultExt  = "图片文件 (*.jpg)|*.jpg;*.jpeg;*.png";
         openFileDialog.Filter      = "图片文件 (*.jpg)|*.jpg;*.jpeg;*.png";
         openFileDialog.Multiselect = true;
         if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             string[] fileNames = openFileDialog.FileNames;
             splash.ShowWaitForm();
             foreach (string fileName in fileNames)
             {
                 this.splash.SetWaitFormCaption("上传文件");
                 this.splash.SetWaitFormDescription("正在上传文件…");
                 FileStream fileStream = new FileStream(fileName, FileMode.Open);
                 fileStream.Seek(0, SeekOrigin.Begin);
                 Byte[] fileByte = new Byte[(int)fileStream.Length]; //转换字节流
                 fileStream.Read(fileByte, 0, fileByte.Length);
                 dataset.AddImage(fileByte, fileName, fileType, fkID);
                 dataset.SaveImage();
             }
         }
     }
     catch (Exception ex)
     {
         UserMessages.ShowInfoBox(ex.Message);
     }
     finally
     {
         if (splash.IsSplashFormVisible)
         {
             splash.CloseWaitForm();
         }
     }
 }
Пример #2
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            try
            {
                FileDataSet dataset  = this.fileDataSet;
                string      fileType = "档案";

                DataRowView rv = tW_BusinessRegBindingSource.Current as DataRowView;
                if (rv == null)
                {
                    return;
                }
                bool wqSP = false;
                if (!string.IsNullOrEmpty(rv["外勤审批确认"].ToString()))
                {
                    wqSP = bool.Parse(rv["外勤审批确认"].ToString());
                }
                if (wqSP)
                {
                    UserMessages.ShowInfoBox("审批完成不能修改文件!");
                    return;
                }

                string clientName = rv["公司预核名称"].ToString();
                string fkID       = businessDataSet.GetClientId(clientName);
                if (string.IsNullOrEmpty(fkID))
                {
                    UserMessages.ShowInfoBox("公司名称不存在客户信息中!");
                    return;
                }
                openFileDialog.DefaultExt  = "图片文件 (*.jpg)|*.jpg;*.jpeg;*.png";
                openFileDialog.Filter      = "图片文件 (*.jpg)|*.jpg;*.jpeg;*.png";
                openFileDialog.Multiselect = true;
                if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string[] fileNames = openFileDialog.FileNames;
                    splash.ShowWaitForm();
                    foreach (string fileName in fileNames)
                    {
                        this.splash.SetWaitFormCaption("上传文件");
                        this.splash.SetWaitFormDescription("正在上传文件…");
                        FileStream fileStream = new FileStream(fileName, FileMode.Open);
                        fileStream.Seek(0, SeekOrigin.Begin);
                        Byte[] fileByte = new Byte[(int)fileStream.Length]; //转换字节流
                        fileStream.Read(fileByte, 0, fileByte.Length);
                        dataset.AddImage(fileByte, fileName, fileType, fkID);
                        dataset.SaveImage();
                    }
                }
            }
            catch (Exception ex)
            {
                UserMessages.ShowInfoBox(ex.Message);
            }
            finally
            {
                if (splash.IsSplashFormVisible)
                {
                    splash.CloseWaitForm();
                }
            }
        }