private void grdGroupBuyList_RowDeleting(object sender, GridViewDeleteEventArgs e) { GroupBuyInfo groupBuy = SubsitePromoteHelper.GetGroupBuy((int)grdGroupBuyList.DataKeys[e.RowIndex].Value); if ((groupBuy.Status == GroupBuyStatus.UnderWay) || (groupBuy.Status == GroupBuyStatus.EndUntreated)) { ShowMsg("团购活动正在进行中或结束未处理,不允许删除", false); } else if (SubsitePromoteHelper.DeleteGroupBuy((int)grdGroupBuyList.DataKeys[e.RowIndex].Value)) { BindGroupBuy(); ShowMsg("成功删除了选择的团购活动", true); } else { ShowMsg("删除失败", false); } }
private void grdGroupBuyList_RowDeleting(object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e) { GroupBuyInfo groupBuy = SubsitePromoteHelper.GetGroupBuy((int)this.grdGroupBuyList.DataKeys[e.RowIndex].Value); if (groupBuy.Status != GroupBuyStatus.UnderWay) { if (groupBuy.Status != GroupBuyStatus.EndUntreated) { if (SubsitePromoteHelper.DeleteGroupBuy((int)this.grdGroupBuyList.DataKeys[e.RowIndex].Value)) { this.BindGroupBuy(); this.ShowMsg("成功删除了选择的团购活动", true); return; } this.ShowMsg("删除失败", false); return; } } this.ShowMsg("团购活动正在进行中或结束未处理,不允许删除", false); }
protected void Page_Load(object sender, EventArgs e) { if (!int.TryParse(base.Request.QueryString["groupBuyId"], out groupBuyId)) { base.GotoResourceNotFound(); } else { if (!base.IsPostBack) { dropGroupBuyProduct.DataBind(); dropCategories.DataBind(); GroupBuyInfo groupBuy = SubsitePromoteHelper.GetGroupBuy(groupBuyId); if (SubsitePromoteHelper.GetOrderCount(groupBuyId) > 0) { dropGroupBuyProduct.Enabled = false; } if (groupBuy == null) { base.GotoResourceNotFound(); } else { if (groupBuy.Status == GroupBuyStatus.EndUntreated) { btnFail.Visible = true; btnSuccess.Visible = true; } if (groupBuy.Status == GroupBuyStatus.UnderWay) { btnFinish.Visible = true; } LoadGroupBuy(groupBuy); } } } }
private void dlstOrders_ItemCommand(object sender, System.Web.UI.WebControls.DataListCommandEventArgs e) { OrderInfo orderInfo = SubsiteSalesHelper.GetOrderInfo(e.CommandArgument.ToString()); if (orderInfo != null) { if (e.CommandName == "CONFIRM_PAY" && orderInfo.CheckAction(OrderActions.SELLER_CONFIRM_PAY)) { int num = 0; int num2 = 0; int num3 = 0; if (orderInfo.CountDownBuyId > 0) { CountDownInfo countDownInfo = SubsitePromoteHelper.GetCountDownInfo(orderInfo.CountDownBuyId); if (countDownInfo == null || countDownInfo.EndDate < System.DateTime.Now) { this.ShowMsg("当前的订单为限时抢购订单,此活动已结束,所以不能支付", false); return; } } if (orderInfo.GroupBuyId > 0) { GroupBuyInfo groupBuy = SubsitePromoteHelper.GetGroupBuy(orderInfo.GroupBuyId); if (groupBuy != null) { if (groupBuy.Status == GroupBuyStatus.UnderWay) { num2 = SubsitePromoteHelper.GetOrderCount(orderInfo.GroupBuyId); num = groupBuy.MaxCount; num3 = orderInfo.GetGroupBuyOerderNumber(); if (num < num2 + num3) { this.ShowMsg("当前的订单为团购订单,订购数量已超过订购总数,所以不能支付", false); return; } goto IL_DB; } } this.ShowMsg("当前的订单为团购订单,此团购活动已结束,所以不能支付", false); return; } IL_DB: if (SubsiteSalesHelper.ConfirmPay(orderInfo)) { DebitNote debitNote = new DebitNote(); debitNote.NoteId = Globals.GetGenerateId(); debitNote.OrderId = e.CommandArgument.ToString(); debitNote.Operator = Hidistro.Membership.Context.HiContext.Current.User.Username; debitNote.Remark = "后台" + debitNote.Operator + "支付成功"; SubsiteSalesHelper.SaveDebitNote(debitNote); if (orderInfo.GroupBuyId > 0 && num == num2 + num3) { SubsitePromoteHelper.SetGroupBuyEndUntreated(orderInfo.GroupBuyId); } this.BindOrders(); int num4 = orderInfo.UserId; if (num4 == 1100) { num4 = 0; } Hidistro.Membership.Core.IUser user = Hidistro.Membership.Context.Users.GetUser(num4); Messenger.OrderPayment(user, orderInfo.OrderId, orderInfo.GetTotal()); orderInfo.OnPayment(); this.ShowMsg("成功的确认了订单收款", true); return; } this.ShowMsg("确认订单收款失败", false); return; } else { if (e.CommandName == "FINISH_TRADE" && orderInfo.CheckAction(OrderActions.SELLER_FINISH_TRADE)) { if (SubsiteSalesHelper.ConfirmOrderFinish(orderInfo)) { this.BindOrders(); this.ShowMsg("成功的完成了该订单", true); return; } this.ShowMsg("完成订单失败", false); return; } else { if (e.CommandName == "CREATE_PURCHASEORDER" && orderInfo.CheckAction(OrderActions.SUBSITE_CREATE_PURCHASEORDER)) { if (SubsiteSalesHelper.CreatePurchaseOrder(orderInfo)) { this.BindOrders(); this.ShowMsg("生成采购单成功", true); return; } this.ShowMsg(" 生成采购单失败", false); } } } } }
protected 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 ((SubsitePromoteHelper.GetGroupBuy(groupBuyId).ProductId != dropGroupBuyProduct.SelectedValue.Value) && SubsitePromoteHelper.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 = Globals.HtmlEncode(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 (SubsitePromoteHelper.UpdateGroupBuy(groupBuy)) { ShowMsg("编辑团购活动成功", true); } else { ShowMsg("编辑团购活动失败", true); } }
private void dlstOrders_ItemCommand(object sender, DataListCommandEventArgs e) { OrderInfo orderInfo = SubsiteSalesHelper.GetOrderInfo(e.CommandArgument.ToString()); if (orderInfo != null) { if ((e.CommandName == "CONFIRM_PAY") && orderInfo.CheckAction(OrderActions.SELLER_CONFIRM_PAY)) { int maxCount = 0; int orderCount = 0; int groupBuyOerderNumber = 0; if (orderInfo.GroupBuyId > 0) { GroupBuyInfo groupBuy = SubsitePromoteHelper.GetGroupBuy(orderInfo.GroupBuyId); if ((groupBuy == null) || (groupBuy.Status != GroupBuyStatus.UnderWay)) { ShowMsg("当前的订单为团购订单,此团购活动已结束,所以不能支付", false); return; } orderCount = SubsitePromoteHelper.GetOrderCount(orderInfo.GroupBuyId); maxCount = groupBuy.MaxCount; groupBuyOerderNumber = orderInfo.GetGroupBuyOerderNumber(); if (maxCount < (orderCount + groupBuyOerderNumber)) { ShowMsg("当前的订单为团购订单,订购数量已超过订购总数,所以不能支付", false); return; } } if (SubsiteSalesHelper.ConfirmPay(orderInfo)) { if ((orderInfo.GroupBuyId > 0) && (maxCount == (orderCount + groupBuyOerderNumber))) { SubsitePromoteHelper.SetGroupBuyEndUntreated(orderInfo.GroupBuyId); } BindOrders(); int userId = orderInfo.UserId; if (userId == 0x44c) { userId = 0; } Messenger.OrderPayment(Users.GetUser(userId), orderInfo.OrderId, orderInfo.GetTotal()); orderInfo.OnPayment(); ShowMsg("成功的确认了订单收款", true); } else { ShowMsg("确认订单收款失败", false); } } else if ((e.CommandName == "FINISH_TRADE") && orderInfo.CheckAction(OrderActions.SELLER_FINISH_TRADE)) { if (SubsiteSalesHelper.ConfirmOrderFinish(orderInfo)) { BindOrders(); ShowMsg("成功的完成了该订单", true); } else { ShowMsg("完成订单失败", false); } } else if ((e.CommandName == "CREATE_PURCHASEORDER") && orderInfo.CheckAction(OrderActions.SUBSITE_CREATE_PURCHASEORDER)) { if (SubsiteSalesHelper.CreatePurchaseOrder(orderInfo)) { BindOrders(); ShowMsg("生成采购单成功", true); } else { ShowMsg(" 生成采购单失败", false); } } } }
protected void Page_Load(object sender, System.EventArgs e) { if (!string.IsNullOrEmpty(base.Request["isCallback"]) && base.Request["isCallback"] == "true") { int productId; if (int.TryParse(base.Request["productId"], out productId)) { string priceByProductId = SubsitePromoteHelper.GetPriceByProductId(productId); if (priceByProductId.Length > 0) { base.Response.Clear(); base.Response.ContentType = "application/json"; base.Response.Write("{ "); base.Response.Write("\"Status\":\"OK\","); base.Response.Write(string.Format("\"Price\":\"{0}\"", decimal.Parse(priceByProductId).ToString("F2"))); base.Response.Write("}"); base.Response.End(); return; } } } else { if (!int.TryParse(base.Request.QueryString["groupBuyId"], out this.groupBuyId)) { base.GotoResourceNotFound(); return; } this.btnUpdateGroupBuy.Click += new System.EventHandler(this.btnUpdateGroupBuy_Click); this.btnFail.Click += new System.EventHandler(this.btnFail_Click); this.btnSuccess.Click += new System.EventHandler(this.btnSuccess_Click); this.btnFinish.Click += new System.EventHandler(this.btnFinish_Click); if (!base.IsPostBack) { this.dropGroupBuyProduct.DataBind(); this.dropCategories.DataBind(); this.HourDropDownList1.DataBind(); this.drophours.DataBind(); GroupBuyInfo groupBuy = SubsitePromoteHelper.GetGroupBuy(this.groupBuyId); if (SubsitePromoteHelper.GetOrderCount(this.groupBuyId) > 0) { this.dropGroupBuyProduct.Enabled = false; } if (groupBuy == null) { base.GotoResourceNotFound(); return; } if (groupBuy.Status == GroupBuyStatus.EndUntreated) { this.btnFail.Visible = true; this.btnSuccess.Visible = true; } if (groupBuy.Status == GroupBuyStatus.UnderWay) { this.btnFinish.Visible = true; } this.LoadGroupBuy(groupBuy); } } }
private void btnUpdateGroupBuy_Click(object sender, System.EventArgs e) { GroupBuyInfo groupBuyInfo = new GroupBuyInfo(); groupBuyInfo.GroupBuyId = this.groupBuyId; string text = string.Empty; if (this.dropGroupBuyProduct.SelectedValue > 0) { GroupBuyInfo groupBuy = SubsitePromoteHelper.GetGroupBuy(this.groupBuyId); if (groupBuy.ProductId != this.dropGroupBuyProduct.SelectedValue.Value && SubsitePromoteHelper.ProductGroupBuyExist(this.dropGroupBuyProduct.SelectedValue.Value)) { this.ShowMsg("已经存在此商品的团购活动,并且活动正在进行中", false); return; } groupBuyInfo.ProductId = this.dropGroupBuyProduct.SelectedValue.Value; } else { text += Formatter.FormatErrorMessage("请选择团购商品"); } if (!this.calendarEndDate.SelectedDate.HasValue) { text += Formatter.FormatErrorMessage("请选择结束日期"); } else { groupBuyInfo.EndDate = this.calendarEndDate.SelectedDate.Value.AddHours((double)this.HourDropDownList1.SelectedValue.Value); if (System.DateTime.Compare(groupBuyInfo.EndDate, System.DateTime.Now) <= 0 && groupBuyInfo.Status == GroupBuyStatus.UnderWay) { text += Formatter.FormatErrorMessage("结束日期必须要晚于今天日期"); } else { if (System.DateTime.Compare(this.calendarStartDate.SelectedDate.Value.AddHours((double)this.drophours.SelectedValue.Value), groupBuyInfo.EndDate) >= 0) { text += Formatter.FormatErrorMessage("开始日期必须要早于结束日期"); } else { groupBuyInfo.StartDate = this.calendarStartDate.SelectedDate.Value.AddHours((double)this.drophours.SelectedValue.Value); } } } if (!string.IsNullOrEmpty(this.txtNeedPrice.Text)) { decimal needPrice; if (decimal.TryParse(this.txtNeedPrice.Text.Trim(), out needPrice)) { groupBuyInfo.NeedPrice = needPrice; } else { text += Formatter.FormatErrorMessage("违约金填写格式不正确"); } } int maxCount; if (int.TryParse(this.txtMaxCount.Text.Trim(), out maxCount)) { groupBuyInfo.MaxCount = maxCount; } else { text += Formatter.FormatErrorMessage("限购数量不能为空,只能为整数"); } groupBuyInfo.Content = Globals.HtmlEncode(this.txtContent.Text); GropBuyConditionInfo gropBuyConditionInfo = new GropBuyConditionInfo(); int count; if (int.TryParse(this.txtCount.Text.Trim(), out count)) { gropBuyConditionInfo.Count = count; } else { text += Formatter.FormatErrorMessage("团购满足数量不能为空,只能为整数"); } decimal price; if (decimal.TryParse(this.txtPrice.Text.Trim(), out price)) { gropBuyConditionInfo.Price = price; } else { text += Formatter.FormatErrorMessage("团购价格不能为空,只能为数值类型"); } groupBuyInfo.GroupBuyConditions.Add(gropBuyConditionInfo); if (groupBuyInfo.MaxCount < groupBuyInfo.GroupBuyConditions[0].Count) { text += Formatter.FormatErrorMessage("限购数量必须大于等于满足数量 "); } if (!string.IsNullOrEmpty(text)) { this.ShowMsg(text, false); return; } if (SubsitePromoteHelper.UpdateGroupBuy(groupBuyInfo)) { this.ShowMsg("编辑团购活动成功", true); return; } this.ShowMsg("编辑团购活动失败", true); }
private void btnUpdateGroupBuy_Click(object sender, EventArgs e) { int num2; int num3; decimal num4; GroupBuyInfo groupBuy = new GroupBuyInfo(); groupBuy.GroupBuyId = this.groupBuyId; string str = string.Empty; if (this.dropGroupBuyProduct.SelectedValue > 0) { if ((SubsitePromoteHelper.GetGroupBuy(this.groupBuyId).ProductId != this.dropGroupBuyProduct.SelectedValue.Value) && SubsitePromoteHelper.ProductGroupBuyExist(this.dropGroupBuyProduct.SelectedValue.Value)) { this.ShowMsg("已经存在此商品的团购活动,并且活动正在进行中", false); return; } groupBuy.ProductId = this.dropGroupBuyProduct.SelectedValue.Value; } else { 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) && (groupBuy.Status == GroupBuyStatus.UnderWay)) { 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.IsNullOrEmpty(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("限购数量不能为空,只能为整数"); } groupBuy.Content = Globals.HtmlEncode(this.txtContent.Text); GropBuyConditionInfo item = new GropBuyConditionInfo(); if (int.TryParse(this.txtCount.Text.Trim(), out num3)) { item.Count = num3; } else { str = str + Formatter.FormatErrorMessage("团购满足数量不能为空,只能为整数"); } if (decimal.TryParse(this.txtPrice.Text.Trim(), out num4)) { item.Price = num4; } else { str = str + Formatter.FormatErrorMessage("团购价格不能为空,只能为数值类型"); } groupBuy.GroupBuyConditions.Add(item); if (groupBuy.MaxCount < groupBuy.GroupBuyConditions[0].Count) { str = str + Formatter.FormatErrorMessage("限购数量必须大于等于满足数量 "); } if (!string.IsNullOrEmpty(str)) { this.ShowMsg(str, false); } else if (SubsitePromoteHelper.UpdateGroupBuy(groupBuy)) { this.ShowMsg("编辑团购活动成功", true); } else { this.ShowMsg("编辑团购活动失败", true); } }
private void dlstOrders_ItemCommand(object sender, DataListCommandEventArgs e) { OrderInfo orderInfo = SubsiteSalesHelper.GetOrderInfo(e.CommandArgument.ToString()); if (orderInfo != null) { if ((e.CommandName == "CONFIRM_PAY") && orderInfo.CheckAction(OrderActions.SELLER_CONFIRM_PAY)) { int maxCount = 0; int orderCount = 0; int groupBuyOerderNumber = 0; if (orderInfo.CountDownBuyId > 0) { CountDownInfo countDownInfo = SubsitePromoteHelper.GetCountDownInfo(orderInfo.CountDownBuyId); if ((countDownInfo == null) || (countDownInfo.EndDate < DateTime.Now)) { this.ShowMsg("当前的订单为限时抢购订单,此活动已结束,所以不能支付", false); return; } } if (orderInfo.GroupBuyId > 0) { GroupBuyInfo groupBuy = SubsitePromoteHelper.GetGroupBuy(orderInfo.GroupBuyId); if ((groupBuy == null) || (groupBuy.Status != GroupBuyStatus.UnderWay)) { this.ShowMsg("当前的订单为团购订单,此团购活动已结束,所以不能支付", false); return; } orderCount = SubsitePromoteHelper.GetOrderCount(orderInfo.GroupBuyId); maxCount = groupBuy.MaxCount; groupBuyOerderNumber = orderInfo.GetGroupBuyOerderNumber(); if (maxCount < (orderCount + groupBuyOerderNumber)) { this.ShowMsg("当前的订单为团购订单,订购数量已超过订购总数,所以不能支付", false); return; } } if (SubsiteSalesHelper.ConfirmPay(orderInfo)) { DebitNote note = new DebitNote(); note.NoteId = Globals.GetGenerateId(); note.OrderId = e.CommandArgument.ToString(); note.Operator = HiContext.Current.User.Username; note.Remark = "后台" + note.Operator + "支付成功"; SubsiteSalesHelper.SaveDebitNote(note); if ((orderInfo.GroupBuyId > 0) && (maxCount == (orderCount + groupBuyOerderNumber))) { SubsitePromoteHelper.SetGroupBuyEndUntreated(orderInfo.GroupBuyId); } this.BindOrders(); int userId = orderInfo.UserId; if (userId == 0x44c) { userId = 0; } Messenger.OrderPayment(Users.GetUser(userId), orderInfo.OrderId, orderInfo.GetTotal()); orderInfo.OnPayment(); this.ShowMsg("成功的确认了订单收款", true); } else { this.ShowMsg("确认订单收款失败", false); } } else if ((e.CommandName == "FINISH_TRADE") && orderInfo.CheckAction(OrderActions.SELLER_FINISH_TRADE)) { if (SubsiteSalesHelper.ConfirmOrderFinish(orderInfo)) { this.BindOrders(); this.ShowMsg("成功的完成了该订单", true); } else { this.ShowMsg("完成订单失败", false); } } else if ((e.CommandName == "CREATE_PURCHASEORDER") && orderInfo.CheckAction(OrderActions.SUBSITE_CREATE_PURCHASEORDER)) { if (SubsiteSalesHelper.CreatePurchaseOrder(orderInfo)) { this.BindOrders(); this.ShowMsg("生成采购单成功", true); } else { this.ShowMsg(" 生成采购单失败", false); } } } }