public override List <BundlingItemInfo> GetBundlingItemsByID(int bundlingID) { StringBuilder builder = new StringBuilder(); builder.Append("SELECT [BundlingID] ,a.[ProductId] ,[SkuId] ,[ProductNum], productName, "); builder.Append(" (select saleprice FROM Hishop_SKUs c where c.SkuId= a.SkuId ) as ProductPrice"); builder.Append(" FROM Hishop_BundlingProductItems a JOIN Hishop_Products p ON a.ProductID = p.ProductId where BundlingID=@BundlingID AND p.SaleStatus = 1"); DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString()); this.database.AddInParameter(sqlStringCommand, "BundlingID", DbType.Int32, bundlingID); List <BundlingItemInfo> list = new List <BundlingItemInfo>(); using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand)) { while (reader.Read()) { BundlingItemInfo item = new BundlingItemInfo(); item.ProductID = (int)reader["ProductID"]; item.ProductNum = (int)reader["ProductNum"]; item.SkuId = (string)reader["SkuId"]; item.ProductName = (string)reader["ProductName"]; item.ProductPrice = (decimal)reader["ProductPrice"]; item.BundlingID = bundlingID; list.Add(item); } } return(list); }
protected void btnEditBindProduct_Click(object sender, System.EventArgs e) { if (string.IsNullOrEmpty(base.Request.Form["selectProductsinfo"])) { this.ShowMsg("获取绑定商品信息错误", false); return; } if (string.IsNullOrEmpty(this.txtBindName.Text) || string.IsNullOrEmpty(this.txtNum.Text) || string.IsNullOrEmpty(this.txtSalePrice.Text)) { this.ShowMsg("你的资料填写不完整", false); return; } BundlingInfo bundlingInfo = new BundlingInfo(); bundlingInfo.BundlingID = this.bundlingid; bundlingInfo.AddTime = System.DateTime.Now; bundlingInfo.Name = this.txtBindName.Text; bundlingInfo.Price = System.Convert.ToDecimal(this.txtSalePrice.Text); bundlingInfo.SaleStatus = System.Convert.ToInt32(this.radstock.SelectedValue); bundlingInfo.Num = System.Convert.ToInt32(this.txtNum.Text); if (!string.IsNullOrEmpty(this.txtShortDescription.Text)) { bundlingInfo.ShortDescription = this.txtShortDescription.Text; } string text = base.Request.Form["selectProductsinfo"]; string[] array = text.Split(new char[] { ',' }); System.Collections.Generic.List <BundlingItemInfo> list = new System.Collections.Generic.List <BundlingItemInfo>(); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text2 = array2[i]; BundlingItemInfo bundlingItemInfo = new BundlingItemInfo(); string[] array3 = text2.Split(new char[] { '|' }); bundlingItemInfo.ProductID = System.Convert.ToInt32(array3[0]); bundlingItemInfo.SkuId = array3[1]; bundlingItemInfo.ProductNum = System.Convert.ToInt32(array3[2]); list.Add(bundlingItemInfo); } bundlingInfo.BundlingItemInfos = list; if (PromoteHelper.UpdateBundlingProduct(bundlingInfo)) { this.ShowMsg("修改绑定商品成功", true); this.BindEditBindProduct(); return; } this.ShowMsg("修改绑定商品错误", false); }
protected void btnEditBindProduct_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(base.Request.Form["selectProductsinfo"])) { this.ShowMsg("获取绑定商品信息错误", false); } else if ((!string.IsNullOrEmpty(this.txtBindName.Text) && !string.IsNullOrEmpty(this.txtNum.Text)) && !string.IsNullOrEmpty(this.txtSalePrice.Text)) { BundlingInfo bundlingInfo = new BundlingInfo(); bundlingInfo.BundlingID = this.bundlingid; bundlingInfo.AddTime = DateTime.Now; bundlingInfo.Name = this.txtBindName.Text; bundlingInfo.Price = Convert.ToDecimal(this.txtSalePrice.Text); bundlingInfo.SaleStatus = Convert.ToInt32(this.radstock.SelectedValue); bundlingInfo.Num = Convert.ToInt32(this.txtNum.Text); if (!string.IsNullOrEmpty(this.txtShortDescription.Text)) { bundlingInfo.ShortDescription = this.txtShortDescription.Text; } string[] strArray = base.Request.Form["selectProductsinfo"].Split(new char[] { ',' }); List <BundlingItemInfo> list = new List <BundlingItemInfo>(); foreach (string str2 in strArray) { BundlingItemInfo item = new BundlingItemInfo(); string[] strArray2 = str2.Split(new char[] { '|' }); item.ProductID = Convert.ToInt32(strArray2[0]); item.SkuId = strArray2[1]; item.ProductNum = Convert.ToInt32(strArray2[2]); list.Add(item); } bundlingInfo.BundlingItemInfos = list; if (SubsitePromoteHelper.UpdateBundlingProduct(bundlingInfo)) { this.ShowMsg("修改绑定商品成功", true); this.BindEditBindProduct(); } else { this.ShowMsg("修改绑定商品错误", false); } } else { this.ShowMsg("你的资料填写不完整", false); } }
public BundlingInfo GetBundlingInfo(int bundlingID) { BundlingInfo bundlingInfo = null; StringBuilder stringBuilder = new StringBuilder("SELECT * FROM Ecshop_BundlingProducts WHERE BundlingID=@BundlingID;"); stringBuilder.Append("SELECT [BundlingID] ,a.[ProductId] ,[SkuId] ,[ProductNum], productName,"); stringBuilder.Append(" (select saleprice FROM Ecshop_SKUs c where c.SkuId= a.SkuId ) as ProductPrice"); stringBuilder.Append(" FROM Ecshop_BundlingProductItems a JOIN Ecshop_Products p ON a.ProductID = p.ProductId where BundlingID=@BundlingID AND p.SaleStatus = 1"); DbCommand sqlStringCommand = this.database.GetSqlStringCommand(stringBuilder.ToString()); this.database.AddInParameter(sqlStringCommand, "BundlingID", DbType.Int32, bundlingID); List <BundlingItemInfo> list = new List <BundlingItemInfo>(); using (IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand)) { if (dataReader.Read()) { bundlingInfo = DataMapper.PopulateBindInfo(dataReader); } dataReader.NextResult(); while (dataReader.Read()) { BundlingItemInfo bundlingItemInfo = new BundlingItemInfo(); bundlingItemInfo.ProductID = (int)dataReader["ProductID"]; bundlingItemInfo.ProductNum = (int)dataReader["ProductNum"]; if (dataReader["SkuId"] != DBNull.Value) { bundlingItemInfo.SkuId = (string)dataReader["SkuId"]; } if (dataReader["ProductName"] != DBNull.Value) { bundlingItemInfo.ProductName = (string)dataReader["ProductName"]; } if (dataReader["ProductPrice"] != DBNull.Value) { bundlingItemInfo.ProductPrice = (decimal)dataReader["ProductPrice"]; } bundlingItemInfo.BundlingID = bundlingID; list.Add(bundlingItemInfo); } } bundlingInfo.BundlingItemInfos = list; return(bundlingInfo); }