/// <summary> /// 第一个符合条件的仓位 /// </summary> /// <param name="strWhere"></param> /// <returns></returns> public WareProductViewME GetConditionedModel(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * FROM WareProductView"); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } DataSet ds = _dbAssist.Query(strSql.ToString()); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { WareProductViewME model = new WareProductViewME(); if (ds.Tables[0].Rows[0]["productType"] != null && ds.Tables[0].Rows[0]["productType"].ToString() != "") { model.productType = ds.Tables[0].Rows[0]["productType"].ToString(); } if (ds.Tables[0].Rows[0]["productID"] != null && ds.Tables[0].Rows[0]["productID"].ToString() != "") { model.productID = ds.Tables[0].Rows[0]["productID"].ToString(); } if (ds.Tables[0].Rows[0]["name"] != null && ds.Tables[0].Rows[0]["name"].ToString() != "") { model.name = ds.Tables[0].Rows[0]["name"].ToString(); } if (ds.Tables[0].Rows[0]["process"] != null && ds.Tables[0].Rows[0]["process"].ToString() != "") { model.process = ds.Tables[0].Rows[0]["process"].ToString(); } if (ds.Tables[0].Rows[0]["param1"] != null && ds.Tables[0].Rows[0]["param1"].ToString() != "") { model.param1 = int.Parse(ds.Tables[0].Rows[0]["param1"].ToString()); } if (ds.Tables[0].Rows[0]["param2"] != null && ds.Tables[0].Rows[0]["param2"].ToString() != "") { model.param2 = int.Parse(ds.Tables[0].Rows[0]["param2"].ToString()); } if (ds.Tables[0].Rows[0]["houseID"] != null && ds.Tables[0].Rows[0]["houseID"].ToString() != "") { model.houseID = int.Parse(ds.Tables[0].Rows[0]["houseID"].ToString()); } if (ds.Tables[0].Rows[0]["houseLayerID"] != null && ds.Tables[0].Rows[0]["houseLayerID"].ToString() != "") { model.houseLayerID = int.Parse(ds.Tables[0].Rows[0]["houseLayerID"].ToString()); } if (ds.Tables[0].Rows[0]["houseRowID"] != null && ds.Tables[0].Rows[0]["houseRowID"].ToString() != "") { model.houseRowID = int.Parse(ds.Tables[0].Rows[0]["houseRowID"].ToString()); } if (ds.Tables[0].Rows[0]["houseColumnID"] != null && ds.Tables[0].Rows[0]["houseColumnID"].ToString() != "") { model.houseColumnID = int.Parse(ds.Tables[0].Rows[0]["houseColumnID"].ToString()); } if (ds.Tables[0].Rows[0]["useStatus"] != null && ds.Tables[0].Rows[0]["useStatus"].ToString() != "") { model.useStatus = int.Parse(ds.Tables[0].Rows[0]["useStatus"].ToString()); } return model; } else return null; }
/// <summary> /// 得到一个对象实体 /// </summary> public WareProductViewME GetModel(int houseID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 productType,productID,name,process,param1,param2,houseID,houseLayerID,houseRowID,houseColumnID,useStatus from WareProductView "); strSql.Append(" where houseID=@houseID "); SqlParameter[] parameters = { new SqlParameter("@houseID", SqlDbType.Int,4)}; parameters[0].Value = houseID; WareProductViewME model = new WareProductViewME(); DataSet ds = _dbAssist.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["productType"] != null && ds.Tables[0].Rows[0]["productType"].ToString() != "") { model.productType = ds.Tables[0].Rows[0]["productType"].ToString(); } if (ds.Tables[0].Rows[0]["productID"] != null && ds.Tables[0].Rows[0]["productID"].ToString() != "") { model.productID = ds.Tables[0].Rows[0]["productID"].ToString(); } if (ds.Tables[0].Rows[0]["name"] != null && ds.Tables[0].Rows[0]["name"].ToString() != "") { model.name = ds.Tables[0].Rows[0]["name"].ToString(); } if (ds.Tables[0].Rows[0]["process"] != null && ds.Tables[0].Rows[0]["process"].ToString() != "") { model.process = ds.Tables[0].Rows[0]["process"].ToString(); } if (ds.Tables[0].Rows[0]["param1"] != null && ds.Tables[0].Rows[0]["param1"].ToString() != "") { model.param1 = int.Parse(ds.Tables[0].Rows[0]["param1"].ToString()); } if (ds.Tables[0].Rows[0]["param2"] != null && ds.Tables[0].Rows[0]["param2"].ToString() != "") { model.param2 = int.Parse(ds.Tables[0].Rows[0]["param2"].ToString()); } if (ds.Tables[0].Rows[0]["houseID"] != null && ds.Tables[0].Rows[0]["houseID"].ToString() != "") { model.houseID = int.Parse(ds.Tables[0].Rows[0]["houseID"].ToString()); } if (ds.Tables[0].Rows[0]["houseLayerID"] != null && ds.Tables[0].Rows[0]["houseLayerID"].ToString() != "") { model.houseLayerID = int.Parse(ds.Tables[0].Rows[0]["houseLayerID"].ToString()); } if (ds.Tables[0].Rows[0]["houseRowID"] != null && ds.Tables[0].Rows[0]["houseRowID"].ToString() != "") { model.houseRowID = int.Parse(ds.Tables[0].Rows[0]["houseRowID"].ToString()); } if (ds.Tables[0].Rows[0]["houseColumnID"] != null && ds.Tables[0].Rows[0]["houseColumnID"].ToString() != "") { model.houseColumnID = int.Parse(ds.Tables[0].Rows[0]["houseColumnID"].ToString()); } if (ds.Tables[0].Rows[0]["useStatus"] != null && ds.Tables[0].Rows[0]["useStatus"].ToString() != "") { model.useStatus = int.Parse(ds.Tables[0].Rows[0]["useStatus"].ToString()); } return model; } else { return null; } }