/// <summary> /// 更新一条数据 /// </summary> public void UpdateM_GoodsSkuInfo(M_GoodsSkuInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_M_GoodsSkuInfo set "); strSql.Append("m_ConfigInfoID=@m_ConfigInfoID,"); strSql.Append("m_Type=@m_Type,"); strSql.Append("m_ObjID=@m_ObjID,"); strSql.Append("sku_id=@sku_id,"); strSql.Append("num_iid=@num_iid,"); strSql.Append("properties=@properties,"); strSql.Append("quantity=@quantity,"); strSql.Append("price=@price,"); strSql.Append("outer_id=@outer_id,"); strSql.Append("created=@created,"); strSql.Append("modified=@modified,"); strSql.Append("[status]=@status"); strSql.Append(" where m_GoodsSkuInfoID=@m_GoodsSkuInfoID "); SqlParameter[] parameters = { new SqlParameter("@m_GoodsSkuInfoID", SqlDbType.Int, 4), new SqlParameter("@m_ConfigInfoID", SqlDbType.Int, 4), new SqlParameter("@m_Type", SqlDbType.Int, 4), new SqlParameter("@m_ObjID", SqlDbType.Int, 4), new SqlParameter("@sku_id", SqlDbType.Int, 4), new SqlParameter("@num_iid", SqlDbType.BigInt), new SqlParameter("@properties", SqlDbType.VarChar, 512), new SqlParameter("@quantity", SqlDbType.Int, 4), new SqlParameter("@price", SqlDbType.Money, 8), new SqlParameter("@outer_id", SqlDbType.VarChar, 50), new SqlParameter("@created", SqlDbType.DateTime), new SqlParameter("@modified", SqlDbType.DateTime), new SqlParameter("@status", SqlDbType.VarChar, 50) }; parameters[0].Value = model.m_GoodsSkuInfoID; parameters[1].Value = model.m_ConfigInfoID; parameters[2].Value = model.m_Type; parameters[3].Value = model.m_ObjID; parameters[4].Value = model.sku_id; parameters[5].Value = model.num_iid; parameters[6].Value = model.properties; parameters[7].Value = model.quantity; parameters[8].Value = model.price; parameters[9].Value = model.outer_id; parameters[10].Value = model.created; parameters[11].Value = model.modified; parameters[12].Value = model.status; DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters); }
/// <summary> /// 增加一条数据 /// </summary> public int AddM_GoodsSkuInfo(M_GoodsSkuInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_M_GoodsSkuInfo("); strSql.Append("m_ConfigInfoID,m_Type,m_ObjID,sku_id,num_iid,properties,quantity,price,outer_id,created,modified,[status])"); strSql.Append(" values ("); strSql.Append("@m_ConfigInfoID,@m_Type,@m_ObjID,@sku_id,@num_iid,@properties,@quantity,@price,@outer_id,@created,@modified,@status)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@m_ConfigInfoID", SqlDbType.Int, 4), new SqlParameter("@m_Type", SqlDbType.Int, 4), new SqlParameter("@m_ObjID", SqlDbType.Int, 4), new SqlParameter("@sku_id", SqlDbType.Int, 4), new SqlParameter("@num_iid", SqlDbType.BigInt), new SqlParameter("@properties", SqlDbType.VarChar, 512), new SqlParameter("@quantity", SqlDbType.Int, 4), new SqlParameter("@price", SqlDbType.Money, 8), new SqlParameter("@outer_id", SqlDbType.VarChar, 50), new SqlParameter("@created", SqlDbType.DateTime), new SqlParameter("@modified", SqlDbType.DateTime), new SqlParameter("@status", SqlDbType.VarChar, 50) }; parameters[0].Value = model.m_ConfigInfoID; parameters[1].Value = model.m_Type; parameters[2].Value = model.m_ObjID; parameters[3].Value = model.sku_id; parameters[4].Value = model.num_iid; parameters[5].Value = model.properties; parameters[6].Value = model.quantity; parameters[7].Value = model.price; parameters[8].Value = model.outer_id; parameters[9].Value = model.created; parameters[10].Value = model.modified; parameters[11].Value = model.status; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj == null) { return(-1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public M_GoodsSkuInfo GetM_GoodsSkuInfoModel(int m_GoodsSkuInfoID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 m_GoodsSkuInfoID,m_ConfigInfoID,m_Type,m_ObjID,sku_id,num_iid,properties,quantity,price,outer_id,created,modified,[status] from tb_M_GoodsSkuInfo "); strSql.Append(" where m_GoodsSkuInfoID=@m_GoodsSkuInfoID "); SqlParameter[] parameters = { new SqlParameter("@m_GoodsSkuInfoID", SqlDbType.Int, 4) }; parameters[0].Value = m_GoodsSkuInfoID; M_GoodsSkuInfo model = new M_GoodsSkuInfo(); DataSet ds = DbHelper.ExecuteDataset(CommandType.Text, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["m_GoodsSkuInfoID"].ToString() != "") { model.m_GoodsSkuInfoID = int.Parse(ds.Tables[0].Rows[0]["m_GoodsSkuInfoID"].ToString()); } if (ds.Tables[0].Rows[0]["m_ConfigInfoID"].ToString() != "") { model.m_ConfigInfoID = int.Parse(ds.Tables[0].Rows[0]["m_ConfigInfoID"].ToString()); } if (ds.Tables[0].Rows[0]["m_Type"].ToString() != "") { model.m_Type = int.Parse(ds.Tables[0].Rows[0]["m_Type"].ToString()); } if (ds.Tables[0].Rows[0]["m_ObjID"].ToString() != "") { model.m_ObjID = int.Parse(ds.Tables[0].Rows[0]["m_ObjID"].ToString()); } if (ds.Tables[0].Rows[0]["sku_id"].ToString() != "") { model.sku_id = int.Parse(ds.Tables[0].Rows[0]["sku_id"].ToString()); } if (ds.Tables[0].Rows[0]["num_iid"].ToString() != "") { model.num_iid = int.Parse(ds.Tables[0].Rows[0]["num_iid"].ToString()); } model.properties = ds.Tables[0].Rows[0]["properties"].ToString(); if (ds.Tables[0].Rows[0]["quantity"].ToString() != "") { model.quantity = int.Parse(ds.Tables[0].Rows[0]["quantity"].ToString()); } if (ds.Tables[0].Rows[0]["price"].ToString() != "") { model.price = decimal.Parse(ds.Tables[0].Rows[0]["price"].ToString()); } model.outer_id = ds.Tables[0].Rows[0]["outer_id"].ToString(); if (ds.Tables[0].Rows[0]["created"].ToString() != "") { model.created = DateTime.Parse(ds.Tables[0].Rows[0]["created"].ToString()); } if (ds.Tables[0].Rows[0]["modified"].ToString() != "") { model.modified = DateTime.Parse(ds.Tables[0].Rows[0]["modified"].ToString()); } model.status = ds.Tables[0].Rows[0]["status"].ToString(); return(model); } else { return(null); } }