/// <summary> /// 更新一条数据 /// </summary> public bool Update(StockDetailModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update StockDetail set "); strSql.Append("StockListID=@StockListID,"); strSql.Append("TrayID=@TrayID,"); strSql.Append("CoreCode=@CoreCode,"); strSql.Append("CorePositionID=@CorePositionID,"); strSql.Append("CoreQualitySign=@CoreQualitySign,"); strSql.Append("Remarks=@Remarks"); strSql.Append(" where StockDetailID=@StockDetailID"); SqlParameter[] parameters = { new SqlParameter("@StockListID", SqlDbType.BigInt, 8), new SqlParameter("@TrayID", SqlDbType.NVarChar, 50), new SqlParameter("@CoreCode", SqlDbType.NVarChar, 50), new SqlParameter("@CorePositionID", SqlDbType.Int, 4), new SqlParameter("@CoreQualitySign", SqlDbType.Int, 4), new SqlParameter("@Remarks", SqlDbType.NVarChar, 100), new SqlParameter("@StockDetailID", SqlDbType.BigInt, 8) }; parameters[0].Value = model.StockListID; parameters[1].Value = model.TrayID; parameters[2].Value = model.CoreCode; parameters[3].Value = model.CorePositionID; parameters[4].Value = model.CoreQualitySign; parameters[5].Value = model.Remarks; parameters[6].Value = model.StockDetailID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public StockDetailModel DataRowToModel(DataRow row) { StockDetailModel model = new StockDetailModel(); if (row != null) { if (row["StockDetailID"] != null && row["StockDetailID"].ToString() != "") { model.StockDetailID = long.Parse(row["StockDetailID"].ToString()); } if (row["StockListID"] != null && row["StockListID"].ToString() != "") { model.StockListID = long.Parse(row["StockListID"].ToString()); } if (row["TrayID"] != null) { model.TrayID = row["TrayID"].ToString(); } if (row["CoreCode"] != null) { model.CoreCode = row["CoreCode"].ToString(); } if (row["CorePositionID"] != null && row["CorePositionID"].ToString() != "") { model.CorePositionID = int.Parse(row["CorePositionID"].ToString()); } if (row["CoreQualitySign"] != null && row["CoreQualitySign"].ToString() != "") { model.CoreQualitySign = int.Parse(row["CoreQualitySign"].ToString()); } if (row["Remarks"] != null) { model.Remarks = row["Remarks"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public long Add(StockDetailModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into StockDetail("); strSql.Append("StockListID,TrayID,CoreCode,CorePositionID,CoreQualitySign,Remarks)"); strSql.Append(" values ("); strSql.Append("@StockListID,@TrayID,@CoreCode,@CorePositionID,@CoreQualitySign,@Remarks)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@StockListID", SqlDbType.BigInt, 8), new SqlParameter("@TrayID", SqlDbType.NVarChar, 50), new SqlParameter("@CoreCode", SqlDbType.NVarChar, 50), new SqlParameter("@CorePositionID", SqlDbType.Int, 4), new SqlParameter("@CoreQualitySign", SqlDbType.Int, 4), new SqlParameter("@Remarks", SqlDbType.NVarChar, 100) }; parameters[0].Value = model.StockListID; parameters[1].Value = model.TrayID; parameters[2].Value = model.CoreCode; parameters[3].Value = model.CorePositionID; parameters[4].Value = model.CoreQualitySign; parameters[5].Value = model.Remarks; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt64(obj)); } }
public StockDetailModel GetModelByTrayID(string trayID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 StockDetailID,StockListID,TrayID,CoreCode,CorePositionID,CoreQualitySign,Remarks from StockDetail "); strSql.Append(" where TrayID=@TrayID"); SqlParameter[] parameters = { new SqlParameter("@TrayID", SqlDbType.NVarChar) }; parameters[0].Value = trayID; StockDetailModel model = new StockDetailModel(); 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 bool Update(StockDetailModel model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public long Add(StockDetailModel model) { return(dal.Add(model)); }