/// <summary> /// 获取修改时插入历史表的sql /// </summary> /// <param name="modelInfo"></param> /// <returns></returns> protected override string GetInsertUpdateHistorySql(XModelBase modelInfo) { XTaskAttachmentInfo info = modelInfo as XTaskAttachmentInfo; string sql = "Insert Into " + this.HistoryTableName + "(RID,MainId,FileName,FileDesc,Remark,InputUserId,InputTime,UpdateUserId,UpdateTime,OperateUserId,Operate,OperateTime,NewID) SELECT RID,MainId,FileName,FileDesc,Remark,InputUserId,InputTime,UpdateUserId,UpdateTime,'" + info.UpdateUserId + "','修改',getdate(),newid() FROM " + this.TableName + " WHERE " + this.PrimaryKey + "='" + info.RID + "'"; return(sql); }
/// <summary> /// 获取插入sql /// </summary> /// <param name="modelInfo"></param> /// <returns></returns> public override string GetInsertSql(XModelBase modelInfo) { XTaskAttachmentInfo info = modelInfo as XTaskAttachmentInfo; string sql = "Insert Into " + this.TableName + "(RID,MainId,FileName,FileDesc,Remark,InputUserId,InputTime,UpdateUserId,UpdateTime)Values('{0}','{1}','{2}','{3}','{4}','{5}',{6},'{7}',{8})"; sql = String.Format(sql, info.RID, info.MainId, info.FileName, info.FileDesc, info.Remark, info.InputUserId, this.GetServerTimeFuncion(), info.UpdateUserId, this.GetServerTimeFuncion()); return(sql); }
/// <summary> /// 自定义修改校验 /// </summary> /// <param name="modelInfo"></param> /// <returns></returns> protected override string GetValidateUpdateCustom(XModelBase modelInfo) { string validateInfo = string.Empty; XTaskAttachmentInfo taskattachment = modelInfo as XTaskAttachmentInfo; if (taskattachment == null) { return(this.GetNotRightType()); } return(string.Empty); }
/// <summary> /// 获取更新Sql /// </summary> /// <param name="modelInfo"></param> /// <returns></returns> public override string GetUpdateSql(XModelBase modelInfo) { string sql = String.Empty; XTaskAttachmentInfo info = modelInfo as XTaskAttachmentInfo; sql = "Update " + this.TableName + " Set MainId='{0}',FileName='{1}',FileDesc='{2}',Remark='{3}',UpdateUserId='{4}',UpdateTime={5} Where RID='{6}'"; sql = string.Format(sql, info.MainId, info.FileName, info.FileDesc, info.Remark, info.UpdateUserId, this.GetServerTimeFuncion(), info.RID); return(sql); }
/// <summary> /// 预览附件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void cmdPreviewAttach_Click(object sender, Janus.Windows.UI.CommandBars.CommandEventArgs e) { if (this.grdTaskAttach.CurrentRow != null && this.grdTaskAttach.CurrentRow.RowType != Janus.Windows.GridEX.RowType.Record) { XMessageBox.ShowError("请选择要预览附件的记录!"); return; } XTaskAttachmentInfo model = this.grdTaskAttach.CurrentRow.DataRow as XTaskAttachmentInfo; string mainId = model.RID; XFilePreviewTool.Preview(mainId); }
protected override string GetDetailDeleteSql(string key, XModelBase detailInfo) { string sqlDelteDetail = string.Empty; switch (key) { case "grdFiles": XTaskAttachmentInfo attachInfo = detailInfo as XTaskAttachmentInfo; sqlDelteDetail += "DELETE FROM TaskAttachment WHERE RID='" + attachInfo.ID + "';"; sqlDelteDetail += "DELETE FROM FileAttachment WHERE FileId='" + attachInfo.ID + "';"; break; } return(sqlDelteDetail); }
/// <summary> /// 将数据行转换为实体 /// </summary> /// <param name="modelRow">数据行记录</param> /// <returns>实体信息</returns> protected override void DataRow2ModelBase(XModelBase modelInfo, DataRow modelRow) { XTaskAttachmentInfo info = modelInfo as XTaskAttachmentInfo; info.ID = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "RID")); //主键 info.RID = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "RID")); //主键 info.MainId = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "MainId")); //任务主键 info.FileName = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "FileName")); //附件名称 info.FileDesc = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "FileDesc")); //附件描述 info.Remark = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "Remark")); //备注 info.InputUserId = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "InputUserId")); //录入人 info.InputTime = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "InputTime")); //录入时间 info.UpdateUserId = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "UpdateUserId")); //修改人 info.UpdateTime = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "UpdateTime")); //修改信息 }
/// <summary> /// 下载附件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void cmdDownloadAttach_Click(object sender, Janus.Windows.UI.CommandBars.CommandEventArgs e) { if (this.grdTaskAttach.CurrentRow != null && this.grdTaskAttach.CurrentRow.RowType != Janus.Windows.GridEX.RowType.Record) { XMessageBox.ShowError("请选择要下载附件的记录!"); return; } XTaskAttachmentInfo model = this.grdTaskAttach.CurrentRow.DataRow as XTaskAttachmentInfo; string mainId = model.RID; bool isExist = this.m_FileAttachBusiness.IsFileExist(mainId); if (!isExist) { XMessageBox.ShowError("未找到附件!"); return; } FolderBrowserDialog fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string fileName = this.m_FileAttachBusiness.DownloadFile(mainId, fbd.SelectedPath); if (fileName != string.Empty) { XMessageBox.ShowRemindMessage("下载完成!"); } else { XMessageBox.ShowError("下载失败!"); } } }