/// <summary> /// 更新一条数据 /// </summary> public bool Update(WTCJ.Model.Common_Data model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Common_Data set "); strSql.Append("DataText=@DataText,"); strSql.Append("DataValue=@DataValue,"); strSql.Append("DataType=@DataType,"); strSql.Append("OrderBy=@OrderBy,"); strSql.Append("Remark=@Remark,"); strSql.Append("CreateBy=@CreateBy,"); strSql.Append("CreateTime=@CreateTime,"); strSql.Append("UpdateBy=@UpdateBy,"); strSql.Append("UpdateTime=@UpdateTime"); strSql.Append(" where DataID=@DataID "); SqlParameter[] parameters = { new SqlParameter("@DataText", SqlDbType.VarChar, 100), new SqlParameter("@DataValue", SqlDbType.VarChar, 50), new SqlParameter("@DataType", SqlDbType.VarChar, 100), new SqlParameter("@OrderBy", SqlDbType.Int, 4), new SqlParameter("@Remark", SqlDbType.VarChar, 200), new SqlParameter("@CreateBy", SqlDbType.VarChar, 36), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@UpdateBy", SqlDbType.VarChar, 36), new SqlParameter("@UpdateTime", SqlDbType.DateTime), new SqlParameter("@DataID", SqlDbType.VarChar, 36) }; parameters[0].Value = model.DataText; parameters[1].Value = model.DataValue; parameters[2].Value = model.DataType; parameters[3].Value = model.OrderBy; parameters[4].Value = model.Remark; parameters[5].Value = model.CreateBy; parameters[6].Value = model.CreateTime; parameters[7].Value = model.UpdateBy; parameters[8].Value = model.UpdateTime; parameters[9].Value = model.DataID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WTCJ.Model.Common_Data DataRowToModel(DataRow row) { WTCJ.Model.Common_Data model = new WTCJ.Model.Common_Data(); if (row != null) { if (row["DataID"] != null) { model.DataID = row["DataID"].ToString(); } if (row["DataText"] != null) { model.DataText = row["DataText"].ToString(); } if (row["DataValue"] != null) { model.DataValue = row["DataValue"].ToString(); } if (row["DataType"] != null) { model.DataType = row["DataType"].ToString(); } if (row["OrderBy"] != null && row["OrderBy"].ToString() != "") { model.OrderBy = int.Parse(row["OrderBy"].ToString()); } if (row["Remark"] != null) { model.Remark = row["Remark"].ToString(); } if (row["CreateBy"] != null) { model.CreateBy = row["CreateBy"].ToString(); } if (row["CreateTime"] != null && row["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(row["CreateTime"].ToString()); } if (row["UpdateBy"] != null) { model.UpdateBy = row["UpdateBy"].ToString(); } if (row["UpdateTime"] != null && row["UpdateTime"].ToString() != "") { model.UpdateTime = DateTime.Parse(row["UpdateTime"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(WTCJ.Model.Common_Data model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Common_Data("); strSql.Append("DataID,DataText,DataValue,DataType,OrderBy,Remark,CreateBy,CreateTime,UpdateBy,UpdateTime)"); strSql.Append(" values ("); strSql.Append("@DataID,@DataText,@DataValue,@DataType,@OrderBy,@Remark,@CreateBy,@CreateTime,@UpdateBy,@UpdateTime)"); SqlParameter[] parameters = { new SqlParameter("@DataID", SqlDbType.VarChar, 36), new SqlParameter("@DataText", SqlDbType.VarChar, 100), new SqlParameter("@DataValue", SqlDbType.VarChar, 50), new SqlParameter("@DataType", SqlDbType.VarChar, 100), new SqlParameter("@OrderBy", SqlDbType.Int, 4), new SqlParameter("@Remark", SqlDbType.VarChar, 200), new SqlParameter("@CreateBy", SqlDbType.VarChar, 36), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@UpdateBy", SqlDbType.VarChar, 36), new SqlParameter("@UpdateTime", SqlDbType.DateTime) }; parameters[0].Value = model.DataID; parameters[1].Value = model.DataText; parameters[2].Value = model.DataValue; parameters[3].Value = model.DataType; parameters[4].Value = model.OrderBy; parameters[5].Value = model.Remark; parameters[6].Value = model.CreateBy; parameters[7].Value = model.CreateTime; parameters[8].Value = model.UpdateBy; parameters[9].Value = model.UpdateTime; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WTCJ.Model.Common_Data GetModel(string DataID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 DataID,DataText,DataValue,DataType,OrderBy,Remark,CreateBy,CreateTime,UpdateBy,UpdateTime from Common_Data "); strSql.Append(" where DataID=@DataID "); SqlParameter[] parameters = { new SqlParameter("@DataID", SqlDbType.VarChar, 36) }; parameters[0].Value = DataID; WTCJ.Model.Common_Data model = new WTCJ.Model.Common_Data(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }