/// <summary> /// 删除实体 /// </summary> /// <param name="param">删除条件实体</param> /// <returns></returns> public WCFAddUpdateResult DelInfo(Sys_AttachFilesParam param) { this.CheckSession(); WCFAddUpdateResult ret = new WCFAddUpdateResult(); int affect = 0; try { #region 判断 if (param.AttachGuID == null) { throw new WarnException("请指定附件GUID!"); } #endregion WhereClip whereClip = GetWhereClip(param); Sys_AttachFilesResult info = new Sys_AttachFilesResult(); info.IsDeleted = true; affect = this.Update <Sys_AttachFilesResult>(info, whereClip); #region 设置返回值 ret.Key = affect; #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); } return(ret); }
public Sys_AttachFilesResult GetInfo(Sys_AttachFilesParam param) { Sys_AttachFilesResult ret = new Sys_AttachFilesResult(); ExeResult rst = new ExeResult(); rst = this.Execute("ZNLCRM.BLL.Sys.Sys_AttachFilesBLL", "GetInfo", param); ret = rst == null ? new Sys_AttachFilesResult() : rst.Result as Sys_AttachFilesResult; return(ret); }
/// <summary> /// 获取一条信息记录 /// </summary> /// <param name="param"></param> /// <returns></returns> public Sys_AttachFilesResult GetInfo(Sys_AttachFilesParam param) { this.CheckSession(); Sys_AttachFilesResult rst = new Sys_AttachFilesResult(); #region 判断 if (param.AttachGuID == null) { throw new WarnException("请指定附件GUID!"); } #endregion #region 获取实体 rst = this.Select <Sys_AttachFilesResult>(GetWhereClip(param)); #endregion return(rst); }
private void tsbImport_Click(object sender, EventArgs e) { //this.ShowWaitting(enuWaitMsgType.Other); List <Sys_AttachFilesResult> rstList = new List <Sys_AttachFilesResult>(); Sys_AttachFilesResult result = null; ofdAttach.Multiselect = true; ofdAttach.FileNames.Initialize(); if (ofdAttach.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (ofdAttach.FileNames.Length > 0) { try { foreach (string fileName in ofdAttach.FileNames) { string fileSuffix = string.Empty; string attachName = string.Empty; int fileSize = 0; byte[] file = null; byte[] tbnFile = null; if (!string.IsNullOrEmpty(fileName)) { if (!File.Exists(fileName)) { throw new Exception(string.Format("{0}文件不存在", fileName)); } using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { int length = (int)fs.Length; if (length > 4 * 1024 * 1024) { throw new Exception(string.Format("文件{0}大小超过4M,禁止上传!", fileName)); } file = new byte[fs.Length]; fs.Seek(0, SeekOrigin.Begin); fs.Read(file, 0, length); //生成缩略图 try { tbnFile = ZNLCRM.Utility.UITools.MakeThumbnail(fs, 100, 0, "W"); } catch (Exception ex) { } fs.Close(); fileSize = length; } if (file != null) { attachName = Path.GetFileNameWithoutExtension(fileName); // 附件名 fileSuffix = Path.GetExtension(fileName); //附件后缀 result = new Sys_AttachFilesResult(); result.AttachType = AttachType.Bill; result.FileSize = fileSize; result.FileSuffix = fileSuffix; result.AttachName = attachName; result.File = file; result.TBNFile = tbnFile; rstList.Add(result); } } } } catch (Exception ex) { this.ShowMessage(ex.Message); return; } rstList = fileLogic.UploadAttach(rstList); addOrModifyList.AddRange(rstList); bsAttach.DataSource = addOrModifyList; dgvAttach.DataSource = null; dgvAttach.DataSource = bsAttach; } } //this.HideWaitting(); }