public override int AddGroupBuy(GroupBuyInfo groupBuy, DbTransaction dbTran) { DbCommand sqlStringCommand = database.GetSqlStringCommand("DECLARE @DisplaySequence AS INT SELECT @DisplaySequence = (CASE WHEN MAX(DisplaySequence) IS NULL THEN 1 ELSE MAX(DisplaySequence) + 1 END) FROM distro_GroupBuy;INSERT INTO distro_GroupBuy(ProductId,DistributorUserId,NeedPrice,EndDate,MaxCount,Content,Status,DisplaySequence) VALUES(@ProductId,@DistributorUserId,@NeedPrice,@EndDate,@MaxCount,@Content,@Status,@DisplaySequence); SELECT @@IDENTITY"); database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, groupBuy.ProductId); database.AddInParameter(sqlStringCommand, "DistributorUserId", DbType.Int32, HiContext.Current.User.UserId); database.AddInParameter(sqlStringCommand, "NeedPrice", DbType.Currency, groupBuy.NeedPrice); database.AddInParameter(sqlStringCommand, "EndDate", DbType.DateTime, groupBuy.EndDate); database.AddInParameter(sqlStringCommand, "MaxCount", DbType.Int32, groupBuy.MaxCount); database.AddInParameter(sqlStringCommand, "Content", DbType.String, groupBuy.Content); database.AddInParameter(sqlStringCommand, "Status", DbType.Int32, 1); object obj2 = null; if (dbTran != null) { obj2 = database.ExecuteScalar(sqlStringCommand, dbTran); } else { obj2 = database.ExecuteScalar(sqlStringCommand); } if (obj2 != null) { return Convert.ToInt32(obj2); } return 0; }
public static bool AddGroupBuy(GroupBuyInfo groupBuy) { bool flag; Globals.EntityCoding(groupBuy, true); using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { if (new GroupBuyDao().AddGroupBuy(groupBuy, dbTran) <= 0) { dbTran.Rollback(); return false; } dbTran.Commit(); flag = true; } catch { dbTran.Rollback(); flag = false; } finally { connection.Close(); } } return flag; }
public static bool AddGroupBuy(GroupBuyInfo groupBuy) { bool flag; using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { int groupBuyId = SubsitePromotionsProvider.Instance().AddGroupBuy(groupBuy, dbTran); if (groupBuyId <= 0) { dbTran.Rollback(); return false; } if (!SubsitePromotionsProvider.Instance().AddGroupBuyCondition(groupBuyId, groupBuy.GroupBuyConditions, dbTran)) { dbTran.Rollback(); return false; } dbTran.Commit(); flag = true; } catch (Exception) { dbTran.Rollback(); flag = false; } finally { connection.Close(); } } return flag; }
public static GroupBuyInfo PopulateGroupBuy(IDataReader reader) { if (null == reader) { return null; } GroupBuyInfo info = new GroupBuyInfo { GroupBuyId = (int) reader["GroupBuyId"], ProductId = (int) reader["ProductId"] }; if (DBNull.Value != reader["NeedPrice"]) { info.NeedPrice = (decimal) reader["NeedPrice"]; } info.MaxCount = (int) reader["MaxCount"]; info.StartDate = (DateTime) reader["StartDate"]; info.EndDate = (DateTime) reader["EndDate"]; if (DBNull.Value != reader["Content"]) { info.Content = (string) reader["Content"]; } info.Status = (GroupBuyStatus) ((int) reader["Status"]); info.Price = (decimal) reader["Price"]; info.Count = (int) reader["Count"]; info.SoldCount = (int) reader["SoldCount"]; return info; }
private void LoadGroupBuy(GroupBuyInfo groupBuy) { txtCount.Text = groupBuy.GroupBuyConditions[0].Count.ToString(); txtPrice.Text = groupBuy.GroupBuyConditions[0].Price.ToString("F"); txtContent.Text = Globals.HtmlDecode(groupBuy.Content); txtMaxCount.Text = groupBuy.MaxCount.ToString(); txtNeedPrice.Text = groupBuy.NeedPrice.ToString("F"); calendarEndDate.SelectedDate = new DateTime?(groupBuy.EndDate); dropGroupBuyProduct.SelectedValue = new int?(groupBuy.ProductId); }
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); } }
public abstract int AddGroupBuy(GroupBuyInfo groupBuy, DbTransaction dbTran);
public abstract bool UpdateGroupBuy(GroupBuyInfo groupBuy, DbTransaction dbTran);
void LoadProductGroupBuyInfo(GroupBuyInfo groupBuy) { int orderCount = ProductBrowser.GetOrderCount(groupBuy.GroupBuyId); decimal currentPrice = ProductBrowser.GetCurrentPrice(groupBuy.GroupBuyId, orderCount); this.litCount.Text = orderCount.ToString(); this.lblCurrentSalePrice.Money = currentPrice; this.lblNeedPrice.Money = groupBuy.NeedPrice; this.litMaxCount.Text = groupBuy.MaxCount.ToString(); this.litContent.Text = groupBuy.Content; this.lblTotalPrice.Value = new decimal?(currentPrice); this.lblEndTime.Time = groupBuy.EndDate; this.litRemainTime.Text = "待实现"; this.litNeedCount.Text = groupBuy.GroupBuyConditions[0].Count.ToString(); }
public static bool UpdateGroupBuy(GroupBuyInfo groupBuy) { bool flag; Globals.EntityCoding(groupBuy, true); using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { if (!PromotionsProvider.Instance().UpdateGroupBuy(groupBuy, dbTran)) { dbTran.Rollback(); return false; } if (!PromotionsProvider.Instance().DeleteGroupBuyCondition(groupBuy.GroupBuyId, dbTran)) { dbTran.Rollback(); return false; } if (!PromotionsProvider.Instance().AddGroupBuyCondition(groupBuy.GroupBuyId, groupBuy.GroupBuyConditions, dbTran)) { dbTran.Rollback(); return false; } dbTran.Commit(); flag = true; } catch (Exception) { dbTran.Rollback(); flag = false; } finally { connection.Close(); } } return flag; }
public override bool UpdateGroupBuy(GroupBuyInfo groupBuy, DbTransaction dbTran) { DbCommand sqlStringCommand = database.GetSqlStringCommand("UPDATE distro_GroupBuy SET ProductId=@ProductId,NeedPrice=@NeedPrice,EndDate=@EndDate,MaxCount=@MaxCount,Content=@Content WHERE GroupBuyId=@GroupBuyId AND DistributorUserId=@DistributorUserId"); database.AddInParameter(sqlStringCommand, "GroupBuyId", DbType.Int32, groupBuy.GroupBuyId); database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, groupBuy.ProductId); database.AddInParameter(sqlStringCommand, "NeedPrice", DbType.Currency, groupBuy.NeedPrice); database.AddInParameter(sqlStringCommand, "EndDate", DbType.DateTime, groupBuy.EndDate); database.AddInParameter(sqlStringCommand, "MaxCount", DbType.Int32, groupBuy.MaxCount); database.AddInParameter(sqlStringCommand, "Content", DbType.String, groupBuy.Content); database.AddInParameter(sqlStringCommand, "DistributorUserId", DbType.Int32, HiContext.Current.User.UserId); if (dbTran != null) { return (database.ExecuteNonQuery(sqlStringCommand, dbTran) == 1); } return (database.ExecuteNonQuery(sqlStringCommand) == 1); }
private void btnAddGroupBuy_Click(object sender, EventArgs e) { int num2; int num3; decimal num4; GroupBuyInfo groupBuy = new GroupBuyInfo(); string str = string.Empty; if (!this.calendarStartDate.SelectedDate.HasValue) { str = str + Formatter.FormatErrorMessage("请选择开始日期"); } if (!this.calendarEndDate.SelectedDate.HasValue) { str = str + Formatter.FormatErrorMessage("请选择结束日期"); } else { groupBuy.EndDate = this.calendarEndDate.SelectedDate.Value.AddHours((double) this.HourDropDownList1.SelectedValue.Value); if (DateTime.Compare(groupBuy.EndDate, DateTime.Now) < 0) { str = str + Formatter.FormatErrorMessage("结束日期必须要晚于今天日期"); } else if (DateTime.Compare(this.calendarStartDate.SelectedDate.Value.AddHours((double) this.drophours.SelectedValue.Value), groupBuy.EndDate) >= 0) { str = str + Formatter.FormatErrorMessage("开始日期必须要早于结束日期"); } else { groupBuy.StartDate = this.calendarStartDate.SelectedDate.Value.AddHours((double) this.drophours.SelectedValue.Value); } } if (!string.IsNullOrWhiteSpace(this.txtNeedPrice.Text)) { decimal num; if (decimal.TryParse(this.txtNeedPrice.Text.Trim(), out num)) { groupBuy.NeedPrice = num; } else { str = str + Formatter.FormatErrorMessage("违约金填写格式不正确"); } } if (int.TryParse(this.txtMaxCount.Text.Trim(), out num2)) { groupBuy.MaxCount = num2; } else { str = str + Formatter.FormatErrorMessage("限购数量不能为空,只能为整数"); } if (int.TryParse(this.txtCount.Text.Trim(), out num3)) { groupBuy.Count = num3; } else { str = str + Formatter.FormatErrorMessage("团购满足数量不能为空,只能为整数"); } if (decimal.TryParse(this.txtPrice.Text.Trim(), out num4)) { groupBuy.Price = num4; } else { str = str + Formatter.FormatErrorMessage("团购价格不能为空,只能为数值类型"); } if (groupBuy.MaxCount < groupBuy.Count) { str = str + Formatter.FormatErrorMessage("限购数量必须大于等于满足数量 "); } if (!string.IsNullOrWhiteSpace(this.ProductId.Text)) { int num5; if (int.TryParse(this.ProductId.Text.Trim(), out num5)) { groupBuy.ProductId = num5; } } else { str = str + Formatter.FormatErrorMessage("未选择商品"); } if (GroupBuyHelper.ProductGroupBuyExist(groupBuy.ProductId)) { this.ShowMsg("已经存在此商品的团购活动,并且活动正在进行中", false); } else if (!string.IsNullOrEmpty(str)) { this.ShowMsg(str, false); } else { groupBuy.Content = this.txtContent.Text; if (GroupBuyHelper.AddGroupBuy(groupBuy)) { this.ShowMsg("添加团购活动成功", true); } else { this.ShowMsg("添加团购活动失败", true); } } }
public bool UpdateGroupBuy(GroupBuyInfo groupBuy, DbTransaction dbTran) { DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE Hishop_GroupBuy SET ProductId=@ProductId,NeedPrice=@NeedPrice,Count=@Count,Price=@Price,StartDate=@StartDate,EndDate=@EndDate,MaxCount=@MaxCount,Content=@Content,soldCount=@soldcout WHERE GroupBuyId=@GroupBuyId"); this.database.AddInParameter(sqlStringCommand, "GroupBuyId", DbType.Int32, groupBuy.GroupBuyId); this.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, groupBuy.ProductId); this.database.AddInParameter(sqlStringCommand, "NeedPrice", DbType.Currency, groupBuy.NeedPrice); this.database.AddInParameter(sqlStringCommand, "StartDate", DbType.DateTime, groupBuy.StartDate); this.database.AddInParameter(sqlStringCommand, "EndDate", DbType.DateTime, groupBuy.EndDate); this.database.AddInParameter(sqlStringCommand, "MaxCount", DbType.Int32, groupBuy.MaxCount); this.database.AddInParameter(sqlStringCommand, "Content", DbType.String, groupBuy.Content); this.database.AddInParameter(sqlStringCommand, "soldcout", DbType.Int32, groupBuy.SoldCount); this.database.AddInParameter(sqlStringCommand, "Count", DbType.Int32, groupBuy.Count); this.database.AddInParameter(sqlStringCommand, "Price", DbType.Double, groupBuy.Price); if (dbTran != null) { return (this.database.ExecuteNonQuery(sqlStringCommand, dbTran) == 1); } return (this.database.ExecuteNonQuery(sqlStringCommand) == 1); }
private void LoadGroupBuy(GroupBuyInfo groupBuy, decimal salePrice) { this.txtCount.Text = groupBuy.Count.ToString(); this.txtPrice.Text = groupBuy.Price.ToString("F"); this.txtContent.Text = Globals.HtmlDecode(groupBuy.Content); this.txtMaxCount.Text = groupBuy.MaxCount.ToString(); this.txtNeedPrice.Text = groupBuy.NeedPrice.ToString("F"); this.calendarEndDate.SelectedDate = new DateTime?(groupBuy.EndDate.Date); this.calendarStartDate.SelectedDate = new DateTime?(groupBuy.StartDate.Date); this.drophours.SelectedValue = new int?(groupBuy.StartDate.Hour); this.HourDropDownList1.SelectedValue = new int?(groupBuy.EndDate.Hour); ProductInfo productBaseInfo = ProductHelper.GetProductBaseInfo(groupBuy.ProductId); this.productName.Text = productBaseInfo.ProductName; this.ProductId.Text = groupBuy.ProductId.ToString(); this.ViewState["oridProductId"] = groupBuy.ProductId; this.lblPrice.Text = salePrice.ToString("F2"); }
public static bool UpdateGroupBuy(GroupBuyInfo groupBuy) { bool flag; Globals.EntityCoding(groupBuy, true); Database database = DatabaseFactory.CreateDatabase(); GroupBuyDao dao = new GroupBuyDao(); using (DbConnection connection = database.CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { if (!dao.UpdateGroupBuy(groupBuy, dbTran)) { dbTran.Rollback(); return false; } dbTran.Commit(); flag = true; } catch (Exception) { dbTran.Rollback(); flag = false; } finally { connection.Close(); } } return flag; }