예제 #1
0
 public override GroupBuyInfo GetProductGroupBuyInfo(int productId)
 {
     GroupBuyInfo info = null;
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_GroupBuy WHERE ProductId=@ProductId AND Status = @Status; SELECT * FROM Hishop_GroupBuyCondition WHERE GroupBuyId=(SELECT GroupBuyId FROM Hishop_GroupBuy WHERE ProductId=@ProductId AND Status = @Status)");
     this.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, productId);
     this.database.AddInParameter(sqlStringCommand, "Status", DbType.Int32, 1);
     using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             info = DataMapper.PopulateGroupBuy(reader);
         }
         reader.NextResult();
         while (reader.Read())
         {
             GropBuyConditionInfo item = new GropBuyConditionInfo();
             item.Count = (int) reader["Count"];
             item.Price = (decimal) reader["Price"];
             if (info != null)
             {
                 info.GroupBuyConditions.Add(item);
             }
         }
     }
     return info;
 }
예제 #2
0
 private void btnUpdateGroupBuy_Click(object sender, EventArgs e)
 {
     int num;
     int num2;
     decimal num3;
     GroupBuyInfo info3 = new GroupBuyInfo();
     info3.GroupBuyId = groupBuyId;
     GroupBuyInfo groupBuy = info3;
     string str = string.Empty;
     if (dropGroupBuyProduct.SelectedValue > 0)
     {
         if ((PromoteHelper.GetGroupBuy(groupBuyId).ProductId != dropGroupBuyProduct.SelectedValue.Value) && PromoteHelper.ProductGroupBuyExist(dropGroupBuyProduct.SelectedValue.Value))
         {
             ShowMsg("已经存在此商品的团购活动,并且活动正在进行中", false);
             return;
         }
         groupBuy.ProductId = dropGroupBuyProduct.SelectedValue.Value;
     }
     else
     {
         str = str + Formatter.FormatErrorMessage("请选择团购商品");
     }
     if (!calendarEndDate.SelectedDate.HasValue)
     {
         str = str + Formatter.FormatErrorMessage("请选择结束日期");
     }
     else
     {
         groupBuy.EndDate = calendarEndDate.SelectedDate.Value;
     }
     if (!string.IsNullOrEmpty(txtNeedPrice.Text))
     {
         decimal num4;
         if (decimal.TryParse(txtNeedPrice.Text.Trim(), out num4))
         {
             groupBuy.NeedPrice = num4;
         }
         else
         {
             str = str + Formatter.FormatErrorMessage("违约金填写格式不正确");
         }
     }
     if (int.TryParse(txtMaxCount.Text.Trim(), out num))
     {
         groupBuy.MaxCount = num;
     }
     else
     {
         str = str + Formatter.FormatErrorMessage("限购数量不能为空,只能为整数");
     }
     groupBuy.Content = txtContent.Text;
     GropBuyConditionInfo item = new GropBuyConditionInfo();
     if (int.TryParse(txtCount.Text.Trim(), out num2))
     {
         item.Count = num2;
     }
     else
     {
         str = str + Formatter.FormatErrorMessage("团购满足数量不能为空,只能为整数");
     }
     if (decimal.TryParse(txtPrice.Text.Trim(), out num3))
     {
         item.Price = num3;
     }
     else
     {
         str = str + Formatter.FormatErrorMessage("团购价格不能为空,只能为数值类型");
     }
     groupBuy.GroupBuyConditions.Add(item);
     if (groupBuy.MaxCount < groupBuy.GroupBuyConditions[0].Count)
     {
         str = str + Formatter.FormatErrorMessage("限购数量必须大于等于满足数量 ");
     }
     if (!string.IsNullOrEmpty(str))
     {
         ShowMsg(str, false);
     }
     else if (PromoteHelper.UpdateGroupBuy(groupBuy))
     {
         ShowMsg("编辑团购活动成功", true);
     }
     else
     {
         ShowMsg("编辑团购活动失败", true);
     }
 }
예제 #3
0
 public override GroupBuyInfo GetGroupBuy(int groupBuyId)
 {
     GroupBuyInfo info = null;
     DbCommand sqlStringCommand = database.GetSqlStringCommand("SELECT * FROM Hishop_GroupBuy WHERE GroupBuyId=@GroupBuyId;SELECT * FROM Hishop_GroupBuyCondition WHERE GroupBuyId=@GroupBuyId");
     database.AddInParameter(sqlStringCommand, "GroupBuyId", DbType.Int32, groupBuyId);
     using (IDataReader reader = database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             info = DataMapper.PopulateGroupBuy(reader);
         }
         reader.NextResult();
         while (reader.Read())
         {
             GropBuyConditionInfo item = new GropBuyConditionInfo();
             item.Count = (int)reader["Count"];
             item.Price = (decimal)reader["Price"];
             info.GroupBuyConditions.Add(item);
         }
     }
     return info;
 }