/// <summary> /// 更新一条数据 /// </summary> public bool Update(Haikan.SchoolProjectsCore.MDB.Model.HFile model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update HFile set "); strSql.Append("EnterpriseName=@EnterpriseName,"); strSql.Append("EnterpriseFile=@EnterpriseFile,"); strSql.Append("ContractFile=@ContractFile,"); strSql.Append("InvoiceFile=@InvoiceFile,"); strSql.Append("ProjectFile=@ProjectFile,"); strSql.Append("IsDele=@IsDele"); strSql.Append(" where FileID=@FileID"); SqlParameter[] parameters = { new SqlParameter("@EnterpriseName", SqlDbType.VarChar, 255), new SqlParameter("@EnterpriseFile", SqlDbType.VarChar, 255), new SqlParameter("@ContractFile", SqlDbType.VarChar, 255), new SqlParameter("@InvoiceFile", SqlDbType.VarChar, 255), new SqlParameter("@ProjectFile", SqlDbType.VarChar, 255), new SqlParameter("@IsDele", SqlDbType.VarChar, 255), new SqlParameter("@FileID", SqlDbType.Int, 4) }; parameters[0].Value = model.EnterpriseName; parameters[1].Value = model.EnterpriseFile; parameters[2].Value = model.ContractFile; parameters[3].Value = model.InvoiceFile; parameters[4].Value = model.ProjectFile; parameters[5].Value = model.IsDele; parameters[6].Value = model.FileID; int rows = DbHelperSql.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Haikan.SchoolProjectsCore.MDB.Model.HFile DataRowToModel(DataRow row) { Haikan.SchoolProjectsCore.MDB.Model.HFile model = new Haikan.SchoolProjectsCore.MDB.Model.HFile(); if (row != null) { if (row["FileID"] != null && row["FileID"].ToString() != "") { model.FileID = int.Parse(row["FileID"].ToString()); } if (row["EnterpriseName"] != null) { model.EnterpriseName = row["EnterpriseName"].ToString(); } if (row["EnterpriseFile"] != null) { model.EnterpriseFile = row["EnterpriseFile"].ToString(); } if (row["ContractFile"] != null) { model.ContractFile = row["ContractFile"].ToString(); } if (row["InvoiceFile"] != null) { model.InvoiceFile = row["InvoiceFile"].ToString(); } if (row["ProjectFile"] != null) { model.ProjectFile = row["ProjectFile"].ToString(); } if (row["IsDele"] != null) { model.IsDele = row["IsDele"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Haikan.SchoolProjectsCore.MDB.Model.HFile model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into HFile("); strSql.Append("EnterpriseName,EnterpriseFile,ContractFile,InvoiceFile,ProjectFile,IsDele)"); strSql.Append(" values ("); strSql.Append("@EnterpriseName,@EnterpriseFile,@ContractFile,@InvoiceFile,@ProjectFile,@IsDele)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@EnterpriseName", SqlDbType.VarChar, 255), new SqlParameter("@EnterpriseFile", SqlDbType.VarChar, 255), new SqlParameter("@ContractFile", SqlDbType.VarChar, 255), new SqlParameter("@InvoiceFile", SqlDbType.VarChar, 255), new SqlParameter("@ProjectFile", SqlDbType.VarChar, 255), new SqlParameter("@IsDele", SqlDbType.VarChar, 255) }; parameters[0].Value = model.EnterpriseName; parameters[1].Value = model.EnterpriseFile; parameters[2].Value = model.ContractFile; parameters[3].Value = model.InvoiceFile; parameters[4].Value = model.ProjectFile; parameters[5].Value = model.IsDele; object obj = DbHelperSql.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Haikan.SchoolProjectsCore.MDB.Model.HFile GetModel(int FileID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 FileID,EnterpriseName,EnterpriseFile,ContractFile,InvoiceFile,ProjectFile,IsDele from HFile "); strSql.Append(" where FileID=@FileID"); SqlParameter[] parameters = { new SqlParameter("@FileID", SqlDbType.Int, 4) }; parameters[0].Value = FileID; Haikan.SchoolProjectsCore.MDB.Model.HFile model = new Haikan.SchoolProjectsCore.MDB.Model.HFile(); DataSet ds = DbHelperSql.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }