/// <summary> /// 更新单据模板的版本号 /// </summary> public bool UpdateDocTemplet_Version(string tableNameStr, string docVersionStr) { string sqlStr = string.Format("Update BS_DocumentTemplet set DocVersion='{1}' where TableName='{0}'", tableNameStr, docVersionStr); int resultInt = BaseSQL.ExecuteSql(sqlStr); return(resultInt > 0); }
/// <summary> /// 在本地创建文档 /// </summary> /// <param name="documentName"></param> /// <param name="inProjectID"></param> public static void CreateDocmentToLocal(string documentName, int inProjectID, string lockPath, Int64 fileSize, DateTime fileDate) { string sql; string fileExtension; int fileExtensionID; string icoFileName; fileExtension = (Path.GetExtension(documentName)); if (fileExtension == ".exe" || fileExtension == "" || fileExtension == ".lnk") { icoFileName = Path.GetFileNameWithoutExtension(documentName); } else { icoFileName = Path.GetExtension(documentName).Substring(1); } try { //增加新的文件类型 sql = "insert into SA_FileExtension (Extension, Flags) " + "select '" + icoFileName + "', 0 where '" + icoFileName + "' not in (select Extension from SA_FileExtension ) "; BaseSQL.ExecuteSql(sql); //获得指定文件类型对应ID sql = "select a.ExtensionID from SA_FileExtension a " + "where a.extension like '" + icoFileName + "'"; fileExtensionID = Convert.ToInt32(BaseSQL.GetTableBySql(sql).Rows[0][0]); lockPath = Path.GetDirectoryName(lockPath); //增加文档信息【需将用户iD等改为变量】change int newDocumentID = BaseSQL.GetMaxID("documentID", "SA_Documents"); sqlLlist.Clear(); sql = "insert into SA_Documents(filename,busy,extensionID,deleted,flags," + "lockProject,userId,lockDomain,lockPath,lockDate,latestRevisionNo,objectTypeID,defValStored) " + "values('" + documentName + "', 0," + fileExtensionID + " , 0,0," + inProjectID + ",'" + SystemInfo.user.AutoId + "','pc-songxi','" + lockPath + "','" + DateTime.Now + "',0 ,1,0)";//'90':userID sqlLlist.Add(sql); //增加文档和项目关联关系信息 sql = "insert into SA_DocumentsInProjects(projectID,documentID,Deleted) " + "values(" + inProjectID + "," + newDocumentID + ",0)"; sqlLlist.Add(sql); //增加文档版本信息 sql = "insert into SA_Revisions(documentID,RevNr,date,UserID,fileSize,fileDate) " + "values(" + newDocumentID + ",0,'" + DateTime.Now + "'," + SystemInfo.user.AutoId + "," + fileSize + ",'" + fileDate + "')";//change 90 sqlLlist.Add(sql); BaseSQL.ExecuteSqlTran(sqlLlist); } catch (Exception ex) { ExceptionHandler.HandleException("在本地创建文档错误。", ex); } }
/// <summary> /// 更新文件打开标记 /// </summary> /// <param name="documentID"></param> public static void UpdateFileOpenFlag(int documentID) { try { string sql = "update a set a.lockOpened=1 " + "from SA_Documents a where a.DocumentID=" + documentID; BaseSQL.ExecuteSql(sql); } catch (Exception ex) { ExceptionHandler.HandleException("更新文件打开标记错误。", ex); } }
/// <summary> /// 更新【检入】状态标记及相应字段 /// </summary> /// <param name="documentID"></param> public static void UpdateCheckInFlag(int documentID) { try { string sql = "update a set a.userID=1,a.lockDomain='',a.lockPath='' " + "from SA_Documents a where a.DocumentID=" + documentID; BaseSQL.ExecuteSql(sql); } catch (Exception ex) { ExceptionHandler.HandleException("更新【检入】状态标记及相应字段错误。", ex); } }
/// <summary> /// 更新文件打开标记 /// </summary> /// <param name="documentID"></param> public static void UpdateFileOpenFlag(int documentID) { try { string sql = "update a set a.lockOpened=1 " + "from SA_Documents a where a.DocumentID=" + documentID; BaseSQL.ExecuteSql(sql); } catch (Exception ex) { MessageBox.Show(ex.Message, f.tsmiTs.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 更新【检入】状态标记及相应字段 /// </summary> /// <param name="documentID"></param> public static void UpdateCheckInFlag(int documentID) { try { string sql = "update a set a.userID=1,a.lockDomain='',a.lockPath='' " + "from SA_Documents a where a.DocumentID=" + documentID; BaseSQL.ExecuteSql(sql); } catch (Exception ex) { MessageBox.Show(ex.Message, f.tsmiTs.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 更新【检出】状态标记 /// </summary> /// <param name="documentID"></param> /// <param name="localPath"></param> /// <param name="userID"></param> /// <param name="lockDomain"></param> public static void UpdateCheckOutFlag(int documentID, string localPath, int userID, string lockDomain) { try { string sql = "update a set a.userID=" + userID + "," + "a.lockDomain='" + lockDomain + "'," + "a.lockPath='" + localPath + "' ," + "a.lockOpened=0 " + "from SA_Documents a where a.DocumentID=" + documentID; BaseSQL.ExecuteSql(sql); } catch (Exception ex) { ExceptionHandler.HandleException("更新【检出】状态标记错误。", ex); } }
/// <summary> /// 更新【检出】状态标记 /// </summary> /// <param name="documentID"></param> /// <param name="localPath"></param> /// <param name="userID"></param> /// <param name="lockDomain"></param> public static void UpdateCheckOutFlag(int documentID, string localPath, int userID, string lockDomain) { try { string sql = "update a set a.userID=" + userID + "," + "a.lockDomain='" + lockDomain + "'," + "a.lockPath='" + localPath + "' ," + "a.lockOpened=0 " + "from SA_Documents a where a.DocumentID=" + documentID; BaseSQL.ExecuteSql(sql); } catch (Exception ex) { MessageBox.Show(ex.Message, f.tsmiTs.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 将更改后的文件名(文件夹名)的更改同步到数据库 /// </summary> /// <param name="newName"></param> /// <param name="documentOrProjectID"></param> /// <param name="folderOrFile"></param> public static void RenameToDbAndXml(string newName, int documentOrProjectID, string folderOrFile, string newPath) { try { if (folderOrFile == "folder") { string sql = "update a set a.name='" + newName + "',a.path='" + newPath + "' " + "from SA_Projects a where a.ProjectID=" + documentOrProjectID; BaseSQL.ExecuteSql(sql); } else { string sql = "update a set a.Filename='" + newName + "' from SA_Documents a where a.documentID=" + documentOrProjectID; BaseSQL.ExecuteSql(sql); } } catch (Exception ex) { ExceptionHandler.HandleException("将更改后的文件名(文件夹名)的更改同步到数据库错误。", ex); } }
/// <summary> /// 将更改后的文件名(文件夹名)的更改同步到数据库 /// </summary> /// <param name="newName"></param> /// <param name="documentOrProjectID"></param> /// <param name="folderOrFile"></param> public static void RenameToDbAndXml(string newName, int documentOrProjectID, string folderOrFile, string newPath) { try { if (folderOrFile == "folder") { string sql = "update a set a.name='" + newName + "',a.path='" + newPath + "' " + "from SA_Projects a where a.ProjectID=" + documentOrProjectID; BaseSQL.ExecuteSql(sql); } else { string sql = "update a set a.Filename='" + newName + "' from SA_Documents a where a.documentID=" + documentOrProjectID; BaseSQL.ExecuteSql(sql); } } catch (Exception ex) { MessageBox.Show(ex.Message, f.tsmiTs.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 取消隐藏选择的文件(取消隐藏标记) /// </summary> /// <param name="documentID"></param> public static void UpdateCancelHideFlag(int documentID) { string sql = "update a set a.hidden=0 from SA_Documents a where a.documentID =" + documentID; BaseSQL.ExecuteSql(sql); }