public static bool CloseTransaction(OrderInfo order) { ManagerHelper.CheckPrivilege(Privilege.EditOrders); if (!order.CheckAction(OrderActions.SELLER_CLOSE)) { return(false); } order.OrderStatus = OrderStatus.Closed; bool flag = new OrderDao().UpdateOrder(order, null); if (order.GroupBuyId > 0) { GroupBuyInfo groupBuy = GroupBuyHelper.GetGroupBuy(order.GroupBuyId); groupBuy.SoldCount -= order.GetGroupBuyProductQuantity(); GroupBuyHelper.UpdateGroupBuy(groupBuy); } string itemStr = "'" + string.Join("','", order.LineItems.Keys) + "'"; new OrderDao().UpdateItemsStatus(order.OrderId, 4, itemStr); if (flag) { EventLogs.WriteOperationLog(Privilege.EditOrders, string.Format(CultureInfo.InvariantCulture, "关闭了订单“{0}”", new object[] { order.OrderId })); } return(flag); }
private void lkbtnDeleteCheck_Click(object sender, System.EventArgs e) { int?nullable = null; foreach (System.Web.UI.WebControls.GridViewRow row in this.grdGroupBuyList.Rows) { System.Web.UI.WebControls.CheckBox box = (System.Web.UI.WebControls.CheckBox)row.FindControl("checkboxCol"); if (box.Checked) { nullable = new int?(nullable.GetValueOrDefault()); int groupBuyId = System.Convert.ToInt32(this.grdGroupBuyList.DataKeys[row.RowIndex].Value, System.Globalization.CultureInfo.InvariantCulture); GroupBuyInfo groupBuy = GroupBuyHelper.GetGroupBuy(groupBuyId); if (groupBuy.Status != GroupBuyStatus.UnderWay && groupBuy.Status != GroupBuyStatus.EndUntreated) { nullable = new int?(nullable.GetValueOrDefault() + 1); GroupBuyHelper.DeleteGroupBuy(groupBuyId); } } } if (nullable.HasValue) { this.BindGroupBuy(); this.ShowMsg(string.Format("成功删除{0}条团购活动", nullable), true); } else { this.ShowMsg("请先选择需要删除的团购活动", false); } }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(base.Request["isCallback"]) && (base.Request["isCallback"] == "true")) { int num; if (int.TryParse(base.Request["productId"], out num)) { string priceByProductId = GroupBuyHelper.GetPriceByProductId(num); 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(); } } } else if (!int.TryParse(base.Request.QueryString["groupBuyId"], out this.groupBuyId)) { base.GotoResourceNotFound(); } else { this.btnUpdateGroupBuy.Click += new EventHandler(this.btnUpdateGroupBuy_Click); this.btnFail.Click += new EventHandler(this.btnFail_Click); this.btnSuccess.Click += new EventHandler(this.btnSuccess_Click); this.btnFinish.Click += new EventHandler(this.btnFinish_Click); if (!base.IsPostBack) { this.HourDropDownList1.DataBind(); this.drophours.DataBind(); GroupBuyInfo groupBuy = GroupBuyHelper.GetGroupBuy(this.groupBuyId); decimal productSalePrice = ProductHelper.GetProductSalePrice(groupBuy.ProductId); if (GroupBuyHelper.GetOrderCount(this.groupBuyId) > 0) { this.addProduct.Visible = false; } if (groupBuy == null) { base.GotoResourceNotFound(); } else { 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, productSalePrice); } } } }
private void grdGroupBuyList_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e) { if (e.Row.RowType == System.Web.UI.WebControls.DataControlRowType.DataRow) { FormatedMoneyLabel label = (FormatedMoneyLabel)e.Row.FindControl("lblCurrentPrice"); int groupBuyId = System.Convert.ToInt32(this.grdGroupBuyList.DataKeys[e.Row.RowIndex].Value.ToString()); int prodcutQuantity = int.Parse(System.Web.UI.DataBinder.Eval(e.Row.DataItem, "ProdcutQuantity").ToString()); label.Money = GroupBuyHelper.GetCurrentPrice(groupBuyId, prodcutQuantity); } }
private void btnSuccess_Click(object sender, EventArgs e) { if (GroupBuyHelper.SetGroupBuyStatus(this.groupBuyId, GroupBuyStatus.Success)) { this.btnFail.Visible = false; this.btnSuccess.Visible = false; this.ShowMsg("成功设置团购活动为成功状态", true); } else { this.ShowMsg("设置团购活动状态失败", true); } }
private void btnOrder_Click(object sender, System.EventArgs e) { foreach (System.Web.UI.WebControls.GridViewRow row in this.grdGroupBuyList.Rows) { int result = 0; System.Web.UI.WebControls.TextBox box = (System.Web.UI.WebControls.TextBox)row.FindControl("txtSequence"); if (int.TryParse(box.Text.Trim(), out result)) { int groupBuyId = (int)this.grdGroupBuyList.DataKeys[row.RowIndex].Value; GroupBuyHelper.SwapGroupBuySequence(groupBuyId, result); } } this.BindGroupBuy(); }
private void btnFinish_Click(object sender, EventArgs e) { if (GroupBuyHelper.SetGroupBuyEndUntreated(this.groupBuyId)) { this.btnFail.Visible = true; this.btnSuccess.Visible = true; this.btnFinish.Visible = false; this.ShowMsg("成功设置团购活动为结束状态", true); } else { this.ShowMsg("设置团购活动状态失败", true); } }
private void grdGroupBuyList_RowDeleting(object sender, GridViewDeleteEventArgs e) { GroupBuyInfo groupBuy = GroupBuyHelper.GetGroupBuy((int)this.grdGroupBuyList.DataKeys[e.RowIndex].Value); if ((groupBuy.StartDate < DateTime.Now) && ((groupBuy.Status == GroupBuyStatus.UnderWay) || (groupBuy.Status == GroupBuyStatus.EndUntreated))) { this.ShowMsg("团购活动正在进行中或结束未处理,不允许删除", false); } else if (GroupBuyHelper.DeleteGroupBuy((int)this.grdGroupBuyList.DataKeys[e.RowIndex].Value)) { this.BindGroupBuy(); this.ShowMsg("成功删除了选择的团购活动", true); } else { this.ShowMsg("删除失败", false); } }
public static bool CloseTransaction(OrderInfo order) { ManagerHelper.CheckPrivilege(Privilege.EditOrders); order.OrderStatus = OrderStatus.Closed; bool flag = new OrderDao().UpdateOrder(order, null); if (order.GroupBuyId > 0) { GroupBuyInfo groupBuy = GroupBuyHelper.GetGroupBuy(order.GroupBuyId); groupBuy.SoldCount -= order.GetGroupBuyProductQuantity(); GroupBuyHelper.UpdateGroupBuy(groupBuy); } if (flag) { EventLogs.WriteOperationLog(Privilege.EditOrders, string.Format(CultureInfo.InvariantCulture, "关闭了订单“{0}”", new object[] { order.OrderId })); } return(flag); }
private void BindGroupBuy() { GroupBuyQuery query = new GroupBuyQuery { ProductName = this.productName, PageIndex = this.pager.PageIndex, PageSize = this.pager.PageSize, SortBy = "DisplaySequence", SortOrder = SortAction.Desc }; int num = 0; if (int.TryParse(base.Request.QueryString["state"], out num)) { query.State = num; } DbQueryResult groupBuyList = GroupBuyHelper.GetGroupBuyList(query); this.grdGroupBuyList.DataSource = groupBuyList.Data; this.grdGroupBuyList.DataBind(); this.pager.TotalRecords = groupBuyList.TotalRecords; this.pager1.TotalRecords = groupBuyList.TotalRecords; }
public static bool EnsureRefund(string orderId, string Operator, string adminRemark, int refundType, bool accept) { RefundDao dao = new RefundDao(); RefundInfo byOrderId = dao.GetByOrderId(orderId); byOrderId.Operator = Operator; byOrderId.AdminRemark = adminRemark; byOrderId.HandleTime = DateTime.Now; byOrderId.HandleStatus = accept ? RefundInfo.Handlestatus.Refunded : RefundInfo.Handlestatus.Refused; byOrderId.OrderId = orderId; OrderInfo orderInfo = OrderHelper.GetOrderInfo(orderId); using (TransactionScope scope = new TransactionScope()) { OrderHelper.SetOrderState(orderId, accept ? OrderStatus.Refunded : OrderStatus.BuyerAlreadyPaid); dao.UpdateByOrderId(byOrderId); if (orderInfo.GroupBuyId > 0) { GroupBuyHelper.RefreshGroupFinishBuyState(orderInfo.GroupBuyId); } scope.Complete(); } return(true); }
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); } } }