/// <summary> /// 更新数据 /// 作者:章建国 /// </summary> /// <param name="model">需要更新的模型</param> /// <returns></returns> public string UpdateDoc(tb_document model) { string flag = "0"; try { if (model != null && model.id > 0) { model.doc_UpdateDate = DateTime.Now; model.doc_UpdateUser = CurrentUserInfo.PersonnelID; #region tb_documentHistory添加历史数据 var documentHistory = new tb_document_History(); documentHistory.direct_Id = model.direct_Id; documentHistory.doc_Code = model.doc_Code; documentHistory.doc_CreateDate = model.doc_CreateDate; documentHistory.doc_CreateUser = model.doc_CreateUser; documentHistory.doc_Guid = model.doc_Guid; documentHistory.doc_Id = model.id; documentHistory.doc_KeyWord = model.doc_KeyWord; documentHistory.doc_Name = model.doc_Name; documentHistory.doc_Path = model.doc_Path; documentHistory.doc_Revo = model.doc_Revo; documentHistory.doc_Size = model.doc_Size; documentHistory.doc_Source = model.doc_Source; documentHistory.doc_Status = model.doc_Status; documentHistory.doc_Type = model.doc_Type; documentHistory.doc_UpdateDate = model.doc_UpdateDate; documentHistory.doc_UpdateUser = model.doc_UpdateUser; documentHistory.doc_URL = model.doc_URL; documentHistory.isDelete = model.isDelete; documentHistory.remark = model.remark; documentHistory.temp1 = model.temp1; documentHistory.temp2 = model.temp2; tb_document_HistoryBLL _docbllhistory = new tb_document_HistoryBLL(); _docbllhistory.Add(documentHistory); #endregion if (_docbll.Update(model)) { flag = "1"; } } } catch { flag = "0"; } return(flag); }
public string NewDoc(tb_document_History model) { string flag = "0"; try { model.doc_CreateDate = DateTime.Now; model.doc_CreateUser = CurrentUserInfo.PersonnelID; model.doc_UpdateDate = DateTime.Now; model.doc_UpdateUser = CurrentUserInfo.PersonnelID; model.doc_Size = (Convert.ToInt32(model.doc_Size) / 1000).ToString(); model.doc_Type = "体系文件"; if (_dochistorybll.Add(model) > 0) { flag = "1"; } } catch { flag = "0"; } return(flag); }
/// <summary> /// 得到一个对象实体 /// </summary> public tb_document_History GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,doc_Code,doc_Name,doc_Guid,direct_Id,doc_Type,doc_URL,doc_Size,doc_CreateUser,doc_UpdateUser,doc_CreateDate,doc_UpdateDate,isDelete,doc_Revo,doc_Source,doc_Path,temp1,temp2,remark,doc_Status,doc_KeyWord,doc_Id from tb_document_History "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; tb_document_History model = new tb_document_History(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(tb_document_History model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_document_History("); strSql.Append("doc_Code,doc_Name,doc_Guid,direct_Id,doc_Type,doc_URL,doc_Size,doc_CreateUser,doc_UpdateUser,doc_CreateDate,doc_UpdateDate,isDelete,doc_Revo,doc_Source,doc_Path,temp1,temp2,remark,doc_Status,doc_KeyWord,doc_Id)"); strSql.Append(" values ("); strSql.Append("@doc_Code,@doc_Name,@doc_Guid,@direct_Id,@doc_Type,@doc_URL,@doc_Size,@doc_CreateUser,@doc_UpdateUser,@doc_CreateDate,@doc_UpdateDate,@isDelete,@doc_Revo,@doc_Source,@doc_Path,@temp1,@temp2,@remark,@doc_Status,@doc_KeyWord,@doc_Id)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@doc_Code", SqlDbType.NVarChar, 100), new SqlParameter("@doc_Name", SqlDbType.NVarChar, 100), new SqlParameter("@doc_Guid", SqlDbType.VarChar, 100), new SqlParameter("@direct_Id", SqlDbType.Int, 4), new SqlParameter("@doc_Type", SqlDbType.VarChar, 10), new SqlParameter("@doc_URL", SqlDbType.NVarChar, -1), new SqlParameter("@doc_Size", SqlDbType.VarChar, 100), new SqlParameter("@doc_CreateUser", SqlDbType.Int, 4), new SqlParameter("@doc_UpdateUser", SqlDbType.Int, 4), new SqlParameter("@doc_CreateDate", SqlDbType.DateTime), new SqlParameter("@doc_UpdateDate", SqlDbType.DateTime), new SqlParameter("@isDelete", SqlDbType.Bit, 1), new SqlParameter("@doc_Revo", SqlDbType.VarChar, 100), new SqlParameter("@doc_Source", SqlDbType.VarChar, 300), new SqlParameter("@doc_Path", SqlDbType.NVarChar, -1), new SqlParameter("@temp1", SqlDbType.NVarChar, 300), new SqlParameter("@temp2", SqlDbType.NVarChar, 300), new SqlParameter("@remark", SqlDbType.Text), new SqlParameter("@doc_Status", SqlDbType.Int, 4), new SqlParameter("@doc_KeyWord", SqlDbType.NVarChar, 100), new SqlParameter("@doc_Id", SqlDbType.Int, 4) }; parameters[0].Value = model.doc_Code; parameters[1].Value = model.doc_Name; parameters[2].Value = model.doc_Guid; parameters[3].Value = model.direct_Id; parameters[4].Value = model.doc_Type; parameters[5].Value = model.doc_URL; parameters[6].Value = model.doc_Size; parameters[7].Value = model.doc_CreateUser; parameters[8].Value = model.doc_UpdateUser; parameters[9].Value = model.doc_CreateDate; parameters[10].Value = model.doc_UpdateDate; parameters[11].Value = model.isDelete; parameters[12].Value = model.doc_Revo; parameters[13].Value = model.doc_Source; parameters[14].Value = model.doc_Path; parameters[15].Value = model.temp1; parameters[16].Value = model.temp2; parameters[17].Value = model.remark; parameters[18].Value = model.doc_Status; parameters[19].Value = model.doc_KeyWord; parameters[20].Value = model.doc_Id; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public tb_document_History DataRowToModel(DataRow row) { tb_document_History model = new tb_document_History(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["doc_Code"] != null) { model.doc_Code = row["doc_Code"].ToString(); } if (row["doc_Name"] != null) { model.doc_Name = row["doc_Name"].ToString(); } if (row["doc_Guid"] != null) { model.doc_Guid = row["doc_Guid"].ToString(); } if (row["direct_Id"] != null && row["direct_Id"].ToString() != "") { model.direct_Id = int.Parse(row["direct_Id"].ToString()); } if (row["doc_Type"] != null) { model.doc_Type = row["doc_Type"].ToString(); } if (row["doc_URL"] != null) { model.doc_URL = row["doc_URL"].ToString(); } if (row["doc_Size"] != null) { model.doc_Size = row["doc_Size"].ToString(); } if (row["doc_CreateUser"] != null && row["doc_CreateUser"].ToString() != "") { model.doc_CreateUser = int.Parse(row["doc_CreateUser"].ToString()); } if (row["doc_UpdateUser"] != null && row["doc_UpdateUser"].ToString() != "") { model.doc_UpdateUser = int.Parse(row["doc_UpdateUser"].ToString()); } if (row["doc_CreateDate"] != null && row["doc_CreateDate"].ToString() != "") { model.doc_CreateDate = DateTime.Parse(row["doc_CreateDate"].ToString()); } if (row["doc_UpdateDate"] != null && row["doc_UpdateDate"].ToString() != "") { model.doc_UpdateDate = DateTime.Parse(row["doc_UpdateDate"].ToString()); } if (row["isDelete"] != null && row["isDelete"].ToString() != "") { if ((row["isDelete"].ToString() == "1") || (row["isDelete"].ToString().ToLower() == "true")) { model.isDelete = true; } else { model.isDelete = false; } } if (row["doc_Revo"] != null) { model.doc_Revo = row["doc_Revo"].ToString(); } if (row["doc_Source"] != null) { model.doc_Source = row["doc_Source"].ToString(); } if (row["doc_Path"] != null) { model.doc_Path = row["doc_Path"].ToString(); } if (row["temp1"] != null) { model.temp1 = row["temp1"].ToString(); } if (row["temp2"] != null) { model.temp2 = row["temp2"].ToString(); } if (row["remark"] != null) { model.remark = row["remark"].ToString(); } if (row["doc_Status"] != null && row["doc_Status"].ToString() != "") { model.doc_Status = int.Parse(row["doc_Status"].ToString()); } if (row["doc_KeyWord"] != null) { model.doc_KeyWord = row["doc_KeyWord"].ToString(); } if (row["doc_Id"] != null && row["doc_Id"].ToString() != "") { model.doc_Id = int.Parse(row["doc_Id"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(tb_document_History model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_document_History set "); strSql.Append("doc_Code=@doc_Code,"); strSql.Append("doc_Name=@doc_Name,"); strSql.Append("doc_Guid=@doc_Guid,"); strSql.Append("direct_Id=@direct_Id,"); strSql.Append("doc_Type=@doc_Type,"); strSql.Append("doc_URL=@doc_URL,"); strSql.Append("doc_Size=@doc_Size,"); strSql.Append("doc_CreateUser=@doc_CreateUser,"); strSql.Append("doc_UpdateUser=@doc_UpdateUser,"); strSql.Append("doc_CreateDate=@doc_CreateDate,"); strSql.Append("doc_UpdateDate=@doc_UpdateDate,"); strSql.Append("isDelete=@isDelete,"); strSql.Append("doc_Revo=@doc_Revo,"); strSql.Append("doc_Source=@doc_Source,"); strSql.Append("doc_Path=@doc_Path,"); strSql.Append("temp1=@temp1,"); strSql.Append("temp2=@temp2,"); strSql.Append("remark=@remark,"); strSql.Append("doc_Status=@doc_Status,"); strSql.Append("doc_KeyWord=@doc_KeyWord,"); strSql.Append("doc_Id=@doc_Id"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@doc_Code", SqlDbType.NVarChar, 100), new SqlParameter("@doc_Name", SqlDbType.NVarChar, 100), new SqlParameter("@doc_Guid", SqlDbType.VarChar, 100), new SqlParameter("@direct_Id", SqlDbType.Int, 4), new SqlParameter("@doc_Type", SqlDbType.VarChar, 10), new SqlParameter("@doc_URL", SqlDbType.NVarChar, -1), new SqlParameter("@doc_Size", SqlDbType.VarChar, 100), new SqlParameter("@doc_CreateUser", SqlDbType.Int, 4), new SqlParameter("@doc_UpdateUser", SqlDbType.Int, 4), new SqlParameter("@doc_CreateDate", SqlDbType.DateTime), new SqlParameter("@doc_UpdateDate", SqlDbType.DateTime), new SqlParameter("@isDelete", SqlDbType.Bit, 1), new SqlParameter("@doc_Revo", SqlDbType.VarChar, 100), new SqlParameter("@doc_Source", SqlDbType.VarChar, 300), new SqlParameter("@doc_Path", SqlDbType.NVarChar, -1), new SqlParameter("@temp1", SqlDbType.NVarChar, 300), new SqlParameter("@temp2", SqlDbType.NVarChar, 300), new SqlParameter("@remark", SqlDbType.Text), new SqlParameter("@doc_Status", SqlDbType.Int, 4), new SqlParameter("@doc_KeyWord", SqlDbType.NVarChar, 100), new SqlParameter("@doc_Id", SqlDbType.Int, 4), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.doc_Code; parameters[1].Value = model.doc_Name; parameters[2].Value = model.doc_Guid; parameters[3].Value = model.direct_Id; parameters[4].Value = model.doc_Type; parameters[5].Value = model.doc_URL; parameters[6].Value = model.doc_Size; parameters[7].Value = model.doc_CreateUser; parameters[8].Value = model.doc_UpdateUser; parameters[9].Value = model.doc_CreateDate; parameters[10].Value = model.doc_UpdateDate; parameters[11].Value = model.isDelete; parameters[12].Value = model.doc_Revo; parameters[13].Value = model.doc_Source; parameters[14].Value = model.doc_Path; parameters[15].Value = model.temp1; parameters[16].Value = model.temp2; parameters[17].Value = model.remark; parameters[18].Value = model.doc_Status; parameters[19].Value = model.doc_KeyWord; parameters[20].Value = model.doc_Id; parameters[21].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public string doDocCU(tb_document model) { string flag = "0"; try { if (model != null && model.id > 0) { model.doc_UpdateDate = DateTime.Now; model.doc_UpdateUser = CurrentUserInfo.PersonnelID; #region tb_documentHistory添加历史数据 var documentHistory = new tb_document_History(); documentHistory.direct_Id = model.direct_Id; documentHistory.doc_Code = model.doc_Code; documentHistory.doc_CreateDate = model.doc_CreateDate; documentHistory.doc_CreateUser = model.doc_CreateUser; documentHistory.doc_Guid = model.doc_Guid; documentHistory.doc_Id = model.id; documentHistory.doc_KeyWord = model.doc_KeyWord; documentHistory.doc_Name = model.doc_Name; documentHistory.doc_Path = model.doc_Path; documentHistory.doc_Revo = model.doc_Revo; documentHistory.doc_Size = model.doc_Size; documentHistory.doc_Source = model.doc_Source; documentHistory.doc_Status = model.doc_Status; documentHistory.doc_Type = model.doc_Type; documentHistory.doc_UpdateDate = model.doc_UpdateDate; documentHistory.doc_UpdateUser = model.doc_UpdateUser; documentHistory.doc_URL = model.doc_URL; documentHistory.isDelete = model.isDelete; documentHistory.remark = model.remark; documentHistory.temp1 = model.temp1; documentHistory.temp2 = model.temp2; tb_document_HistoryBLL _docbllhistory = new tb_document_HistoryBLL(); documentHistory.doc_Revo = (_docbllhistory.GetDocHistoryCountByDocID(documentHistory.doc_Id) + 1).ToString(); _docbllhistory.Add(documentHistory); #endregion if (_docbll.Update(model)) { flag = "1"; } } else { //model.doc_CreateDate = DateTime.Now; model.doc_CreateUser = CurrentUserInfo.PersonnelID; model.doc_UpdateDate = DateTime.Now; model.doc_UpdateUser = CurrentUserInfo.PersonnelID; //model.doc_Size = (Convert.ToInt32(model.doc_Size) / 1000).ToString(); model.doc_Type = Session["doc_Type"].ToString(); if (_docbll.Add(model) > 0) { flag = "1"; } } } catch { flag = "0"; } return(flag); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(tb_document_History model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(tb_document_History model) { return(dal.Add(model)); }