/// <summary> /// 增加一条数据 /// </summary> public bool Add(ECAMSDataAccess.LogicStoreAreaModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into LogicStoreArea("); strSql.Append("LogicStoreAreaID,LogicStoreAreaCode,LogicStoreAreaName,LogicStoreAreaType,LogicStoreAreaDescribe,LogicStoreAreaSign)"); strSql.Append(" values ("); strSql.Append("@LogicStoreAreaID,@LogicStoreAreaCode,@LogicStoreAreaName,@LogicStoreAreaType,@LogicStoreAreaDescribe,@LogicStoreAreaSign)"); SqlParameter[] parameters = { new SqlParameter("@LogicStoreAreaID", SqlDbType.Int, 4), new SqlParameter("@LogicStoreAreaCode", SqlDbType.NVarChar, 50), new SqlParameter("@LogicStoreAreaName", SqlDbType.NVarChar, 50), new SqlParameter("@LogicStoreAreaType", SqlDbType.NVarChar, 50), new SqlParameter("@LogicStoreAreaDescribe", SqlDbType.NVarChar, 50), new SqlParameter("@LogicStoreAreaSign", SqlDbType.Int, 4) }; parameters[0].Value = model.LogicStoreAreaID; parameters[1].Value = model.LogicStoreAreaCode; parameters[2].Value = model.LogicStoreAreaName; parameters[3].Value = model.LogicStoreAreaType; parameters[4].Value = model.LogicStoreAreaDescribe; parameters[5].Value = model.LogicStoreAreaSign; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public ECAMSDataAccess.LogicStoreAreaModel DataRowToModel(DataRow row) { ECAMSDataAccess.LogicStoreAreaModel model = new ECAMSDataAccess.LogicStoreAreaModel(); if (row != null) { if (row["LogicStoreAreaID"] != null && row["LogicStoreAreaID"].ToString() != "") { model.LogicStoreAreaID = int.Parse(row["LogicStoreAreaID"].ToString()); } if (row["LogicStoreAreaCode"] != null) { model.LogicStoreAreaCode = row["LogicStoreAreaCode"].ToString(); } if (row["LogicStoreAreaName"] != null) { model.LogicStoreAreaName = row["LogicStoreAreaName"].ToString(); } if (row["LogicStoreAreaType"] != null) { model.LogicStoreAreaType = row["LogicStoreAreaType"].ToString(); } if (row["LogicStoreAreaDescribe"] != null) { model.LogicStoreAreaDescribe = row["LogicStoreAreaDescribe"].ToString(); } if (row["LogicStoreAreaSign"] != null && row["LogicStoreAreaSign"].ToString() != "") { model.LogicStoreAreaSign = int.Parse(row["LogicStoreAreaSign"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ECAMSDataAccess.LogicStoreAreaModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update LogicStoreArea set "); strSql.Append("LogicStoreAreaCode=@LogicStoreAreaCode,"); strSql.Append("LogicStoreAreaName=@LogicStoreAreaName,"); strSql.Append("LogicStoreAreaType=@LogicStoreAreaType,"); strSql.Append("LogicStoreAreaDescribe=@LogicStoreAreaDescribe,"); strSql.Append("LogicStoreAreaSign=@LogicStoreAreaSign"); strSql.Append(" where LogicStoreAreaID=@LogicStoreAreaID "); SqlParameter[] parameters = { new SqlParameter("@LogicStoreAreaCode", SqlDbType.NVarChar, 50), new SqlParameter("@LogicStoreAreaName", SqlDbType.NVarChar, 50), new SqlParameter("@LogicStoreAreaType", SqlDbType.NVarChar, 50), new SqlParameter("@LogicStoreAreaDescribe", SqlDbType.NVarChar, 50), new SqlParameter("@LogicStoreAreaSign", SqlDbType.Int, 4), new SqlParameter("@LogicStoreAreaID", SqlDbType.Int, 4) }; parameters[0].Value = model.LogicStoreAreaCode; parameters[1].Value = model.LogicStoreAreaName; parameters[2].Value = model.LogicStoreAreaType; parameters[3].Value = model.LogicStoreAreaDescribe; parameters[4].Value = model.LogicStoreAreaSign; parameters[5].Value = model.LogicStoreAreaID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public ECAMSDataAccess.LogicStoreAreaModel GetModel(int LogicStoreAreaID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 LogicStoreAreaID,LogicStoreAreaCode,LogicStoreAreaName,LogicStoreAreaType,LogicStoreAreaDescribe,LogicStoreAreaSign from LogicStoreArea "); strSql.Append(" where LogicStoreAreaID=@LogicStoreAreaID "); SqlParameter[] parameters = { new SqlParameter("@LogicStoreAreaID", SqlDbType.Int, 4) }; parameters[0].Value = LogicStoreAreaID; ECAMSDataAccess.LogicStoreAreaModel model = new ECAMSDataAccess.LogicStoreAreaModel(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }