Example #1
0
        private void gv_Attachment_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                if (gv_Attachment.FocusedRowHandle < 0)
                {
                    return;
                }
                FileUtils.ClearDirectory(Application.StartupPath + "\\Temp");
                var imageId  = Convert.ToInt32(gv_Attachment.GetFocusedRowCellValue("Id"));
                var fileName = gv_Attachment.GetFocusedRowCellValue("Name").ToString();

                var attachementBll   = new EqptAttachment();
                var attachementModel = attachementBll.GetModel(imageId);

                var fs = new FileStream(Application.StartupPath + "\\Temp\\" + fileName, FileMode.OpenOrCreate);
                var bw = new BinaryWriter(fs);
                bw.Write(attachementModel.Attachment, 0, attachementModel.Attachment.Length);
                bw.Close();
                fs.Close();


                Process.Start(Application.StartupPath + "\\Temp\\" + fileName);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("打开出错!", "提示");
            }
        }
Example #2
0
        private void btn_DownloadAttachment_Click(object sender, EventArgs e)
        {
            if (gv_Attachment.FocusedRowHandle < 0)
            {
                XtraMessageBox.Show("当前未选中任何附件!", "提示");
                return;
            }
            var attachmentId   = Convert.ToInt32(gv_Attachment.GetFocusedRowCellValue("Id"));
            var attachmentName = gv_Attachment.GetFocusedRowCellValue("Name").ToString();
            var saveFileDialog = new SaveFileDialog()
            {
                Filter = string.Format("*.{0}|*.{0}", Path.GetExtension(attachmentName)), FileName = attachmentName
            };

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                var eqptAttachmentBll   = new EqptAttachment();
                var eqptAttachmentModel = eqptAttachmentBll.GetModel(attachmentId);
                var fs = new FileStream(saveFileDialog.FileName, FileMode.OpenOrCreate);
                var bw = new BinaryWriter(fs);
                bw.Write(eqptAttachmentModel.Attachment, 0, eqptAttachmentModel.Attachment.Length);
                bw.Close();
                fs.Close();

                XtraMessageBox.Show("下载成功!", "提示");
            }
        }
Example #3
0
        private void gv_Attachment_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                if (gv_Attachment.FocusedRowHandle < 0) return;
                FileUtils.ClearDirectory(Application.StartupPath + "\\Temp");
                var imageId = Convert.ToInt32(gv_Attachment.GetFocusedRowCellValue("Id"));
                var fileName = gv_Attachment.GetFocusedRowCellValue("Name").ToString();

                var attachementBll = new EqptAttachment();
                var attachementModel = attachementBll.GetModel(imageId);

                var fs = new FileStream(Application.StartupPath + "\\Temp\\" + fileName, FileMode.OpenOrCreate);
                var bw = new BinaryWriter(fs);
                bw.Write(attachementModel.Attachment, 0, attachementModel.Attachment.Length);
                bw.Close();
                fs.Close();

                Process.Start(Application.StartupPath + "\\Temp\\" + fileName);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("打开出错!", "提示");
            }
        }
Example #4
0
        private void btn_DownloadAttachment_Click(object sender, EventArgs e)
        {
            if(gv_Attachment.FocusedRowHandle<0)
            {
                XtraMessageBox.Show("当前未选中任何附件!", "提示");
                return;
            }
            var attachmentId = Convert.ToInt32(gv_Attachment.GetFocusedRowCellValue("Id"));
            var attachmentName = gv_Attachment.GetFocusedRowCellValue("Name").ToString();
            var saveFileDialog = new SaveFileDialog()
                                     {Filter = string.Format("*.{0}|*.{0}", Path.GetExtension(attachmentName)),FileName = attachmentName};
            if(saveFileDialog.ShowDialog()==DialogResult.OK)
            {
                var eqptAttachmentBll = new EqptAttachment();
                var eqptAttachmentModel = eqptAttachmentBll.GetModel(attachmentId);
                var fs = new FileStream(saveFileDialog.FileName, FileMode.OpenOrCreate);
                var bw = new BinaryWriter(fs);
                bw.Write(eqptAttachmentModel.Attachment, 0, eqptAttachmentModel.Attachment.Length);
                bw.Close();
                fs.Close();

                XtraMessageBox.Show("下载成功!", "提示");
            }
        }