/// 导出按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOut_Click(object sender, EventArgs e) { Response.ClearContent(); string filename = Funs.GetNewFileName(); Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("现场驾驶员管理" + filename, System.Text.Encoding.UTF8) + ".xls"); Response.ContentType = "application/excel"; Response.ContentEncoding = System.Text.Encoding.UTF8; this.Grid1.PageSize = 500; this.BindGrid(); Response.Write(GetGridTableHtml(Grid1)); Response.End(); }
/// 导出按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOut_Click(object sender, EventArgs e) { Response.ClearContent(); string filename = Funs.GetNewFileName(); Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("行政管理检查记录" + filename, System.Text.Encoding.UTF8) + ".xls"); Response.ContentType = "application/excel"; Response.ContentEncoding = System.Text.Encoding.UTF8; this.Grid1.PageSize = 500; this.BindGrid(); Response.Write(GetGridTableHtml(Grid1)); Response.End(); BLL.LogService.AddSys_Log(this.CurrUser, string.Empty, string.Empty, BLL.Const.ManageCheckMenuId, Const.BtnOut); }
/// <summary> /// 扫描文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnImageMagnify_Click(object sender, EventArgs e) { try { DeviceManager manager = new DeviceManagerClass(); Device device = null; foreach (DeviceInfo info in manager.DeviceInfos) { if (info.Type != WiaDeviceType.ScannerDeviceType) { continue; } device = info.Connect(); break; } Item item = device.Items[1]; CommonDialogClass cdc = new WIA.CommonDialogClass(); ImageFile imageFile = null; imageFile = cdc.ShowAcquireImage(WIA.WiaDeviceType.ScannerDeviceType, WIA.WiaImageIntent.TextIntent, WIA.WiaImageBias.MaximizeQuality, "{00000000-0000-0000-0000-000000000000}", true, true, false); if (imageFile != null) { var buffer = imageFile.FileData.get_BinaryData() as byte[]; using (MemoryStream ms = new MemoryStream()) { ms.Write(buffer, 0, buffer.Length); string filePath = Server.MapPath("~/") + AttachPath; ///文件夹 if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } string name = "\\"; var menu = BLL.SysMenuService.GetSysMenuByMenuId(this.MenuId); if (menu != null) { name += menu.MenuName; } name += Funs.GetNewFileName() + ".jpg"; string url = filePath + name; if (!string.IsNullOrEmpty(url)) { using (FileStream fs = new FileStream(url, FileMode.Create, FileAccess.Write)) { ms.WriteTo(fs); string attachUrl = AttachPath + name; if (!string.IsNullOrEmpty(attachUrl)) { attachUrl = attachUrl.Replace('/', '\\'); } string oldSrouce = string.Empty; string FullPath = string.Empty; Model.AttachFile att = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == this.ToKeyId); if (att != null && !string.IsNullOrEmpty(att.AttachUrl)) { FullPath = att.AttachUrl + "," + attachUrl; oldSrouce = att.AttachSource; } else { FullPath = attachUrl; } string source = BLL.UploadFileService.GetSourceByAttachUrl(attachUrl, buffer.Length, oldSrouce); //this.SaveData(source, FullPath); ///保存方法 Session[sessionName] = JArray.Parse(source); } this.BindGrid(); ShowNotify("扫描完成!", MessageBoxIcon.Success); } } } } catch { ShowNotify("请检查扫描仪是否连接正确!", MessageBoxIcon.Warning); } }