public static void SaveRemarks(ListView lv, string remarks) { int newRemarksID; IDataParameter[] parameters = new System.Data.IDataParameter[4]; //实例化参数对象 parameters[0] = new SqlParameter("@Remarks", remarks); //参数对象赋值 parameters[1] = new SqlParameter("@Founder", "songxi"); //需改成变量change parameters[2] = new SqlParameter("@newRemarksID", SqlDbType.Int); parameters[3] = new SqlParameter("@returnMessage", string.Empty); parameters[2].Direction = ParameterDirection.Output; parameters[3].Direction = ParameterDirection.Output; BaseSQL.RunProcedure("GetNewRemarksID", parameters); newRemarksID = Convert.ToInt32(parameters[2].Value);// FrmAddRemarksDAO.sqlLlist.Clear(); foreach (ListViewItem lvi in lv.SelectedItems) { //项目或文档ID int itemID = Convert.ToInt32(lvi.Tag); try { //如果是文件夹 if (lvi.SubItems[4].Text == "folder") { //获得项目列表 DataTable dt = FrmProjectDocumentDAO.GetAllLevelProjects(itemID); //项目下的所有项目 foreach (DataRow dr in dt.Rows) { //调用保存【项目备注】方法 FrmAddRemarksDAO.SaveProjectsRemarks_AddSql(Convert.ToInt32(dr["projectID"]), newRemarksID); } //获得文件列表 dt = FrmProjectDocumentDAO.GetAllLevelDocuments(itemID); //项目下的所有文件 foreach (DataRow dr in dt.Rows) { //调用保存【文档备注】方法 FrmAddRemarksDAO.SaveDocumentsRemarks_AddSql(Convert.ToInt32(dr["documentID"]), newRemarksID); } } else//如果是文件 { DataRow dr; dr = FrmProjectDocumentDAO.GetDocumentInfo(itemID); //调用保存【文档备注】方法 FrmAddRemarksDAO.SaveDocumentsRemarks_AddSql(Convert.ToInt32(dr["documentID"]), newRemarksID); } BaseSQL.ExecuteSqlTran(FrmAddRemarksDAO.sqlLlist); } catch (Exception e) { MessageBox.Show(e.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <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> /// <returns></returns> //public static DataTable GetAppointProjectNode() //{ // string sql = "select * from BS_Department where ParentDepartmentNo is null "; //根部门,其父部门id为null // DataTable dt = BaseSQL.GetTableBySql(sql); // return dt; //} /// <summary> /// 获取子项目节点数据 /// </summary> /// <returns></returns> //public static DataTable GetAppointChildProjectNode(string strParentDepartmentNo) //{ // string sql = "select * from BS_Department where ParentDepartmentNo ='" + strParentDepartmentNo + "'"; // DataTable dt = BaseSQL.GetTableBySql(sql); // return dt; //} /// <summary> /// 删除选择的文件(做删除标记) /// </summary> /// <param name="documentID"></param> public static void DeleteSelFile(int documentID) { sqlLlist.Clear(); string sql = "update a set a.deleted=1 from SA_Documents a where a.documentID =" + documentID; sqlLlist.Add(sql); sql = "update a set a.deleted=1 from SA_DocumentsInProjects a where a.documentID =" + documentID; sqlLlist.Add(sql); BaseSQL.ExecuteSqlTran(sqlLlist); }
/// <summary> /// 删除选定行数据 /// </summary> /// <param name="strBussinessCategory"></param> public static bool DeleteRemarksInfoData(int remarksID) { try { sqlLlist.Clear(); string sql = @"delete from SA_remarksInfo where remarksId =" + remarksID; sqlLlist.Add(sql); sql = @"delete from SA_ProjectsRemarks where remarksId =" + remarksID; sqlLlist.Add(sql); sql = @"delete from SA_DocumentsRemarks where remarksId =" + remarksID; sqlLlist.Add(sql); BaseSQL.ExecuteSqlTran(sqlLlist); return(true); } catch (Exception ex) { ExceptionHandler.HandleException("删除选定行数据错误。", ex); return(false); } }
/// <summary> /// 更新【检入】文件版本字段 /// </summary> /// <param name="documentID"></param> public static void UpdateCheckInRevisionNo(int documentID, Int64 fileSize, DateTime fileDate, int latestRevisionNo) { try { sqlLlist.Clear(); string sql = "update a set a.latestRevisionNo=latestRevisionNo+1 " + "from SA_Documents a where a.DocumentID=" + documentID; sqlLlist.Add(sql); //增加文档版本信息 sql = "insert into SA_Revisions(documentID,RevNr,date,UserID,fileSize,fileDate) " + "values(" + documentID + "," + latestRevisionNo + ",'" + 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 UpdateAddToFtpFlag(int documentID, Int64 fileSize, DateTime fileDate) { try { sqlLlist.Clear(); string sql = "update a set a.defValStored=1,a.userID=1,a.lockDomain='',a.lockPath='',a.latestRevisionNo=1 " + "from SA_Documents a where a.DocumentID=" + documentID; sqlLlist.Add(sql); //增加文档版本信息(添加到库时版本始终为1) sql = "insert into SA_Revisions(documentID,RevNr,date,UserID,fileSize,fileDate) " + "values(" + documentID + ", 1 ,'" + 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="strBussinessCategory"></param> public static bool DeleteRemarksInfoData(int remarksID) { try { sqlLlist.Clear(); string sql = @"delete from SA_remarksInfo where remarksId =" + remarksID; sqlLlist.Add(sql); sql = @"delete from SA_ProjectsRemarks where remarksId =" + remarksID; sqlLlist.Add(sql); sql = @"delete from SA_DocumentsRemarks where remarksId =" + remarksID; sqlLlist.Add(sql); BaseSQL.ExecuteSqlTran(sqlLlist); return(true); } catch (Exception ex) { MessageBox.Show(ex.Message, f.tsmiTs.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } }
/// <summary> /// 更新【检入】文件版本字段 /// </summary> /// <param name="documentID"></param> public static void UpdateCheckInRevisionNo(int documentID, Int64 fileSize, DateTime fileDate, int latestRevisionNo) { try { sqlLlist.Clear(); string sql = "update a set a.latestRevisionNo=latestRevisionNo+1 " + "from SA_Documents a where a.DocumentID=" + documentID; sqlLlist.Add(sql); //增加文档版本信息 sql = "insert into SA_Revisions(documentID,RevNr,date,UserID,fileSize,fileDate) " + "values(" + documentID + "," + latestRevisionNo + ",'" + DateTime.Now + "'," + SystemInfo.user.AutoId + "," + fileSize + ",'" + fileDate + "')";//change 90 sqlLlist.Add(sql); BaseSQL.ExecuteSqlTran(sqlLlist); } catch (Exception ex) { MessageBox.Show(ex.Message, f.tsmiTs.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 更新【添加入库】状态标记及相应字段,并增加版本信息 /// </summary> /// <param name="documentID"></param> public static void UpdateAddToFtpFlag(int documentID, Int64 fileSize, DateTime fileDate) { try { sqlLlist.Clear(); string sql = "update a set a.defValStored=1,a.userID=1,a.lockDomain='',a.lockPath='',a.latestRevisionNo=1 " + "from SA_Documents a where a.DocumentID=" + documentID; sqlLlist.Add(sql); //增加文档版本信息(添加到库时版本始终为1) sql = "insert into SA_Revisions(documentID,RevNr,date,UserID,fileSize,fileDate) " + "values(" + documentID + ", 1 ,'" + DateTime.Now + "'," + SystemInfo.user.AutoId + "," + fileSize + ",'" + fileDate + "')";//change 90 sqlLlist.Add(sql); BaseSQL.ExecuteSqlTran(sqlLlist); } catch (Exception ex) { MessageBox.Show(ex.Message, f.tsmiTs.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 取消报价单 /// </summary> /// <param name="lv"></param> public static void CancelQuotation(ListView lv) { sqlLlist.Clear(); int projectID = Convert.ToInt32(lv.SelectedItems[0].Tag); try { string sql = "update a set a.deleted=1 from SA_Quotation a where a.ProjectID=" + projectID; sqlLlist.Add(sql); //FolderType=1:普通文件夹;3:关联报价单 sql = "update a set a.FolderType=1 from SA_Projects a where a.ProjectID=" + projectID; sqlLlist.Add(sql); BaseSQL.ExecuteSqlTran(sqlLlist); } catch (Exception ex) { ExceptionHandler.HandleException("取消报价单错误。", ex); } }
/// <summary> /// 取消报价单 /// </summary> /// <param name="lv"></param> public static void CancelQuotation(ListView lv) { sqlLlist.Clear(); int projectID = Convert.ToInt32(lv.SelectedItems[0].Tag); try { string sql = "update a set a.deleted=1 from SA_Quotation a where a.ProjectID=" + projectID; sqlLlist.Add(sql); //FolderType=1:普通文件夹;3:关联报价单 sql = "update a set a.FolderType=1 from SA_Projects a where a.ProjectID=" + projectID; sqlLlist.Add(sql); BaseSQL.ExecuteSqlTran(sqlLlist); } catch (Exception ex) { MessageBox.Show(ex.Message, f.tsmiTs.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 生成报价单 /// </summary> /// <param name="lv"></param> public static void CreateQuotation(ListView lv) { sqlLlist.Clear(); int projectID = Convert.ToInt32(lv.SelectedItems[0].Tag); try { string sql = "insert into SA_quotation(quotationNo,SN,projectID,year) " + "values('" + FrmProjectDocumentBLL.CreateQuotationNo() + "'," + BaseSQL.GetMaxID("SN", "SA_quotation", "year", DateTime.Now.Year) + "," + projectID + "," + DateTime.Now.Year + ")"; sqlLlist.Add(sql); sql = "update a set a.FolderType=3 from SA_Projects a where a.ProjectID=" + projectID; sqlLlist.Add(sql); BaseSQL.ExecuteSqlTran(sqlLlist); } catch (Exception ex) { ExceptionHandler.HandleException("生成报价单错误。", ex); } }
/// <summary> /// 生成报价单 /// </summary> /// <param name="lv"></param> public static void CreateQuotation(ListView lv) { sqlLlist.Clear(); int projectID = Convert.ToInt32(lv.SelectedItems[0].Tag); try { string sql = "insert into SA_quotation(quotationNo,SN,projectID,year) " + "values('" + FrmProjectDocumentBLL.CreateQuotationNo() + "'," + BaseSQL.GetMaxID("SN", "SA_quotation", "year", DateTime.Now.Year) + "," + projectID + "," + DateTime.Now.Year + ")"; sqlLlist.Add(sql); sql = "update a set a.FolderType=3 from SA_Projects a where a.ProjectID=" + projectID; sqlLlist.Add(sql); BaseSQL.ExecuteSqlTran(sqlLlist); } catch (Exception ex) { MessageBox.Show(ex.Message, f.tsmiTs.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }