public static bool UpdateNumberById(int bargainDetialId, int number, out int relNumber) { bool flag = false; relNumber = number; BargainInfo bargainInfoByDetialId = BargainHelper.GetBargainInfoByDetialId(bargainDetialId); if (bargainInfoByDetialId != null) { int purchaseNumber = bargainInfoByDetialId.PurchaseNumber; int activityStock = bargainInfoByDetialId.ActivityStock - bargainInfoByDetialId.TranNumber; if (activityStock < relNumber) { relNumber = activityStock; } if (purchaseNumber < relNumber) { relNumber = purchaseNumber; } if (relNumber > 0) { flag = (new BargainDao()).UpdateNumberById(bargainDetialId, relNumber); } } return(flag); }
/// <summary> /// 更新一条砍价数据 /// </summary> /// <param name="model">砍价模型变量</param> public void UpdateBargain(BargainInfo model) { using (var conn = new SqlConnection(connectString)) { string sql = @"UPDATE Bargain Set [Name]=@Name, [StartDate]=@startDate,[EndDate]=@endDate,[LimitCount]=@limitCount,[NumberPeople]=@numberPeople,[ActivityRules]=@activityRules,[SuccessRate]=@successRate,[SalesVolume]=@SalesVolume,[Number]=@Number,[Status]=@Status WHERE [Id]=@id"; conn.Execute(sql, model); } }
/// <summary> /// 增加一条砍价数据 /// </summary> /// <param name="model">砍价模型变量</param> public int AddBargain(BargainInfo model) { using (var conn = new SqlConnection(connectString)) { string sql = @"INSERT INTO Bargain([Name],[StartDate],[EndDate],[LimitCount],[NumberPeople],[ActivityRules],[SuccessRate],[SalesVolume],[Number],[Status]) VALUES(@Name,@startDate,@endDate,@limitCount,@numberPeople,@activityRules,@successRate,@SalesVolume,@Number,@Status) SELECT @@identity" ; return(conn.Query <int>(sql, model).Single()); } }
public BargainInfo GetBargainInfoByDetialId(int bargainDetialId) { BargainInfo info = new BargainInfo(); DbCommand sqlStringCommand = this.database.GetSqlStringCommand("select * from Hishop_Bargain where id =(select BargainId from Hishop_BargainDetial where id=@id AND IsDelete=0) AND IsDelete=0"); this.database.AddInParameter(sqlStringCommand, "id", DbType.Int32, bargainDetialId); using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand)) { return(ReaderConvert.ReaderToModel <BargainInfo>(reader)); } }
public BargainInfo GetBargainInfo(int id) { BargainInfo info = new BargainInfo(); DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_Bargain WHERE id = @id AND IsDelete=0"); this.database.AddInParameter(sqlStringCommand, "id", DbType.Int32, id); using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand)) { return(ReaderConvert.ReaderToModel <BargainInfo>(reader)); } }
public BargainInfo GetBargainInfoByDetialId(int bargainDetialId) { BargainInfo result = new BargainInfo(); System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("select * from Hishop_Bargain where id =(select BargainId from Hishop_BargainDetial where id=@id AND IsDelete=0) AND IsDelete=0"); this.database.AddInParameter(sqlStringCommand, "id", System.Data.DbType.Int32, bargainDetialId); using (System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand)) { result = ReaderConvert.ReaderToModel <BargainInfo>(dataReader); } return(result); }
public BargainInfo GetBargainInfo(int id) { BargainInfo result = new BargainInfo(); System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_Bargain WHERE id = @id AND IsDelete=0"); this.database.AddInParameter(sqlStringCommand, "id", System.Data.DbType.Int32, id); using (System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand)) { result = ReaderConvert.ReaderToModel <BargainInfo>(dataReader); } return(result); }
/// <summary> /// 页面加载方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CheckAdminPower("ReadRecording", PowerCheckType.Single); //var bargain = BargainOrderBLL.ReadBargainOrder(RequestHelper.GetQueryString<int>("ID")); bargain = BargainBLL.ReadBargain(RequestHelper.GetQueryString <int>("ID")); var BargainDetailList = BargainDetailsBLL.ReadByBargainId(bargain.Id); foreach (var item in BargainDetailList) { var product = ProductBLL.Read(item.ProductID); if (product.Id > 0 && product.IsDelete == 0) { BargainDetail.Items.Add(new ListItem(product.Name, item.Id.ToString())); } } BargainDetail.Items.Insert(0, new ListItem { Text = "请选择", Value = "" }); //BargainDetail.SelectedIndexChanged += new System.EventHandler(BargainDetail_SelectedIndexChanged); if (!string.IsNullOrEmpty(BargainDetail.SelectedValue)) { foreach (var item in BargainOrderBLL.SearchBargainOrderList(new BargainOrderSearch() { BargainDetailsId = int.Parse(BargainDetail.SelectedValue) })) { var user = UserBLL.Read(item.UserId); user.UserName = System.Web.HttpUtility.UrlDecode(user.UserName, System.Text.Encoding.UTF8); BargainOrder.Items.Add(new ListItem(user.UserName, item.Id.ToString())); } } BargainOrder.Items.Insert(0, new ListItem { Text = "请选择", Value = "" }); #region MyRegion var bargainDetails = BargainDetailsBLL.ReadByBargainId(bargain.Id); foreach (var bdt in bargainDetails) { var bargain_orders = BargainOrderBLL.SearchBargainOrderList(new BargainOrderSearch { BargainDetailsId = bdt.Id }); b_orderids = b_orderids.Concat(bargain_orders.Select(k => k.Id)).ToList(); } #endregion BindData(); } }
/// <summary> /// 准备砍价模型 /// </summary> /// <param name="dr">Datareader</param> /// <param name="modelList">砍价的数据列表</param> public void PrepareBargainModel(SqlDataReader dr, List <BargainInfo> modelList) { while (dr.Read()) { BargainInfo model = new BargainInfo(); model.Id = dr.GetInt32(0); model.StartDate = dr.GetDateTime(1); model.EndDate = dr.GetDateTime(2); model.LimitCount = dr.GetInt32(3); model.NumberPeople = dr.GetInt32(4); model.ActivityRules = dr[5].ToString(); model.SuccessRate = dr.GetInt32(6); modelList.Add(model); } }
private void LoadData() { int result = 0; if (int.TryParse(this.Page.Request.QueryString["Id"], out result)) { BargainInfo bargainInfo = BargainHelper.GetBargainInfo(result); if (bargainInfo != null) { if (bargainInfo.ProductId > 0) { ProductInfo productDetails = ProductHelper.GetProductDetails(bargainInfo.ProductId); this.productImage.ImageUrl = string.IsNullOrEmpty(productDetails.ImageUrl1) ? "/utility/pics/none.gif" : productDetails.ImageUrl1; this.lbProductName.Text = productDetails.ProductName; this.lbtitle.Text = bargainInfo.Title; this.productInfoHtml = this.GetProductInfoHtml(productDetails); } this.txtTitle.Text = bargainInfo.Title; this.calendarStartDate.Text = bargainInfo.BeginDate.ToString(); this.calendarEndDate.Text = bargainInfo.EndDate.ToString(); this.hidpic.Value = bargainInfo.ActivityCover; this.hiddProductId.Value = bargainInfo.ProductId.ToString(); this.txtRemarks.Text = bargainInfo.Remarks; this.txtActivityStock.Text = bargainInfo.ActivityStock.ToString(); this.txtPurchaseNumber.Text = bargainInfo.PurchaseNumber.ToString(); this.txtInitialPrice.Text = bargainInfo.InitialPrice.ToString("f2"); this.txtFloorPrice.Text = bargainInfo.FloorPrice.ToString("f2"); this.ckIsCommission.Checked = bargainInfo.IsCommission; this.discount.Text = (((double)bargainInfo.CommissionDiscount) / 10.0).ToString(); if (bargainInfo.BargainType == 0) { this.rbtBargainTypeOne.Checked = true; this.rbtBargainTypeTwo.Checked = false; this.txtBargainTypeOneValue.Text = bargainInfo.BargainTypeMinVlue.ToString("f2"); } else { this.rbtBargainTypeOne.Checked = false; this.rbtBargainTypeTwo.Checked = true; this.txtBargainTypeTwoValue1.Text = bargainInfo.BargainTypeMinVlue.ToString("f2"); this.txtBargainTypeTwoValue2.Text = bargainInfo.BargainTypeMaxVlue.ToString("f2"); } } } }
private void LoadData() { if (this.Page.Request.QueryString["Id"] != null) { int id = int.Parse(this.Page.Request.QueryString["Id"]); BargainInfo bargainInfo = BargainHelper.GetBargainInfo(id); if (bargainInfo != null) { if (bargainInfo.ProductId > 0) { ProductInfo productDetails = ProductHelper.GetProductDetails(bargainInfo.ProductId); this.productImage.ImageUrl = (string.IsNullOrEmpty(productDetails.ImageUrl1) ? "/utility/pics/none.gif" : productDetails.ImageUrl1); this.lbproductName.Text = productDetails.ProductName; this.lbtitle.Text = bargainInfo.Title; this.productInfoHtml = this.GetProductInfoHtml(productDetails); } this.txtTitle.Text = bargainInfo.Title; this.calendarStartDate.Text = bargainInfo.BeginDate.ToString(); this.calendarEndDate.Text = bargainInfo.EndDate.ToString(); this.imgeProductName.ImageUrl = (string.IsNullOrEmpty(bargainInfo.ActivityCover) ? "/utility/pics/none.gif" : bargainInfo.ActivityCover); this.txtRemarks.Text = bargainInfo.Remarks; this.txtTranNumber.Text = bargainInfo.ActivityStock.ToString(); this.txtPurchaseNumber.Text = bargainInfo.PurchaseNumber.ToString(); this.txtFloorPrice.Text = bargainInfo.FloorPrice.ToString("f2"); this.txtInitialPrice.Text = bargainInfo.InitialPrice.ToString("f2"); this.ckIsCommission.Checked = bargainInfo.IsCommission; if (bargainInfo.BargainType == 0) { this.rbtBargainTypeOne.Checked = true; this.rbtBargainTypeTwo.Checked = false; this.txtBargainTypeOneValue.Text = bargainInfo.BargainTypeMinVlue.ToString("f2"); return; } this.rbtBargainTypeOne.Checked = false; this.rbtBargainTypeTwo.Checked = true; this.txtBargainTypeTwoValue1.Text = bargainInfo.BargainTypeMinVlue.ToString("f2"); this.txtBargainTypeTwoValue2.Text = bargainInfo.BargainTypeMaxVlue.ToString("f2"); } } }
public bool InsertBargain(BargainInfo bargain) { string query = "insert into Hishop_Bargain(Title,ActivityCover,BeginDate,EndDate,Remarks,CreateDate,ProductId,ActivityStock,PurchaseNumber,BargainType,BargainTypeMaxVlue,BargainTypeMinVlue,InitialPrice,IsCommission,FloorPrice) values(@Title,@ActivityCover,@BeginDate,@EndDate,@Remarks,@CreateDate,@ProductId,@ActivityStock,@PurchaseNumber,@BargainType,@BargainTypeMaxVlue,@BargainTypeMinVlue,@InitialPrice,@IsCommission,@FloorPrice)"; System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand(query); this.database.AddInParameter(sqlStringCommand, "Title", System.Data.DbType.String, bargain.Title); this.database.AddInParameter(sqlStringCommand, "ActivityCover", System.Data.DbType.String, bargain.ActivityCover); this.database.AddInParameter(sqlStringCommand, "BeginDate", System.Data.DbType.DateTime, bargain.BeginDate); this.database.AddInParameter(sqlStringCommand, "EndDate", System.Data.DbType.DateTime, bargain.EndDate); this.database.AddInParameter(sqlStringCommand, "CreateDate", System.Data.DbType.DateTime, bargain.CreateDate); this.database.AddInParameter(sqlStringCommand, "ProductId", System.Data.DbType.Int32, bargain.ProductId); this.database.AddInParameter(sqlStringCommand, "ActivityStock", System.Data.DbType.Int32, bargain.ActivityStock); this.database.AddInParameter(sqlStringCommand, "PurchaseNumber", System.Data.DbType.Int32, bargain.PurchaseNumber); this.database.AddInParameter(sqlStringCommand, "BargainType", System.Data.DbType.Int32, bargain.BargainType); this.database.AddInParameter(sqlStringCommand, "BargainTypeMaxVlue", System.Data.DbType.Double, bargain.BargainTypeMaxVlue); this.database.AddInParameter(sqlStringCommand, "BargainTypeMinVlue", System.Data.DbType.Double, bargain.BargainTypeMinVlue); this.database.AddInParameter(sqlStringCommand, "InitialPrice", System.Data.DbType.Decimal, bargain.InitialPrice); this.database.AddInParameter(sqlStringCommand, "IsCommission", System.Data.DbType.Boolean, bargain.IsCommission); this.database.AddInParameter(sqlStringCommand, "FloorPrice", System.Data.DbType.Decimal, bargain.FloorPrice); this.database.AddInParameter(sqlStringCommand, "Remarks", System.Data.DbType.String, bargain.Remarks); return(this.database.ExecuteNonQuery(sqlStringCommand) > 0); }
public bool UpdateBargain(BargainInfo bargain) { string query = "update Hishop_Bargain set Title=@Title,ActivityCover=@ActivityCover,BeginDate=@BeginDate,EndDate=@EndDate,Remarks=@Remarks,CreateDate=@CreateDate,ProductId=@ProductId,ActivityStock=@ActivityStock,PurchaseNumber=@PurchaseNumber,BargainType=@BargainType,BargainTypeMaxVlue=@BargainTypeMaxVlue,BargainTypeMinVlue=@BargainTypeMinVlue,InitialPrice=@InitialPrice,IsCommission=@IsCommission,FloorPrice=@FloorPrice where id=@id"; DbCommand sqlStringCommand = this.database.GetSqlStringCommand(query); this.database.AddInParameter(sqlStringCommand, "Title", DbType.String, bargain.Title); this.database.AddInParameter(sqlStringCommand, "ActivityCover", DbType.String, bargain.ActivityCover); this.database.AddInParameter(sqlStringCommand, "BeginDate", DbType.DateTime, bargain.BeginDate); this.database.AddInParameter(sqlStringCommand, "EndDate", DbType.DateTime, bargain.EndDate); this.database.AddInParameter(sqlStringCommand, "CreateDate", DbType.DateTime, bargain.CreateDate); this.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, bargain.ProductId); this.database.AddInParameter(sqlStringCommand, "ActivityStock", DbType.Int32, bargain.ActivityStock); this.database.AddInParameter(sqlStringCommand, "PurchaseNumber", DbType.Int32, bargain.PurchaseNumber); this.database.AddInParameter(sqlStringCommand, "BargainType", DbType.Int32, bargain.BargainType); this.database.AddInParameter(sqlStringCommand, "BargainTypeMaxVlue", DbType.Double, bargain.BargainTypeMaxVlue); this.database.AddInParameter(sqlStringCommand, "BargainTypeMinVlue", DbType.Double, bargain.BargainTypeMinVlue); this.database.AddInParameter(sqlStringCommand, "InitialPrice", DbType.Decimal, bargain.InitialPrice); this.database.AddInParameter(sqlStringCommand, "IsCommission", DbType.Boolean, bargain.IsCommission); this.database.AddInParameter(sqlStringCommand, "FloorPrice", DbType.Decimal, bargain.FloorPrice); this.database.AddInParameter(sqlStringCommand, "Remarks", DbType.String, bargain.Remarks); this.database.AddInParameter(sqlStringCommand, "id", DbType.String, bargain.Id); return(this.database.ExecuteNonQuery(sqlStringCommand) > 0); }
public static bool UpdateBargain(BargainInfo bargain) { return(new BargainDao().UpdateBargain(bargain)); }
protected override void AttachChildControls() { if (!int.TryParse(this.Page.Request.QueryString["id"], out this.bargainId)) { base.GotoResourceNotFound(""); } MemberInfo currentMember = MemberProcessor.GetCurrentMember(); if (currentMember != null) { BargainDetialInfo bargainDetialInfo = BargainHelper.GetBargainDetialInfo(this.bargainId, currentMember.UserId); if (bargainDetialInfo != null) { this.Page.Response.Redirect(string.Concat(new object[] { "InviteBargainDetial.aspx?bargainId=", this.bargainId, "&bargainDetialId=", bargainDetialInfo.Id, "&ReferralId=", this.Page.Request.QueryString["ReferralId"] })); } } this.litProdcutName = (Literal)this.FindControl("litProdcutName"); this.litShortDescription = (Literal)this.FindControl("litShortDescription"); this.litSalePrice = (Literal)this.FindControl("litSalePrice"); this.litFloorPrice = (Literal)this.FindControl("litFloorPrice"); this.litFloorPrice1 = (Literal)this.FindControl("litFloorPrice1"); this.litPurchaseNumber = (Literal)this.FindControl("litPurchaseNumber"); this.litParticipantNumber = (Literal)this.FindControl("litParticipantNumber"); this.litProductDesc = (Literal)this.FindControl("litProductDesc"); this.litProductConsultationTotal = (Literal)this.FindControl("litProductConsultationTotal"); this.litProductCommentTotal = (Literal)this.FindControl("litProductCommentTotal"); this.litStock = (Literal)this.FindControl("litStock"); this.hiddHasCollected = (HtmlInputHidden)this.FindControl("hiddHasCollected"); this.hiddProductId = (HtmlInputHidden)this.FindControl("hiddProductId"); this.hiddEndDate = (HtmlInputHidden)this.FindControl("hiddEndDate"); this.hiddPurchaseNumber = (HtmlInputHidden)this.FindControl("hiddPurchaseNumber"); this.skuSelector = (Common_SKUSelector)this.FindControl("skuSelector"); this.rptProductImages = (VshopTemplatedRepeater)this.FindControl("rptProductImages"); this.hideTitle = (HtmlInputHidden)this.FindControl("hideTitle"); this.hideImgUrl = (HtmlInputHidden)this.FindControl("hideImgUrl"); this.hideDesc = (HtmlInputHidden)this.FindControl("hideDesc"); bool flag = false; BargainInfo bargainInfo = BargainHelper.GetBargainInfo(this.bargainId); if (bargainInfo != null) { PageTitle.AddSiteNameTitle(bargainInfo.Title); this.litFloorPrice.Text = bargainInfo.FloorPrice.ToString("F2"); this.litFloorPrice1.Text = bargainInfo.FloorPrice.ToString("F2"); this.litSalePrice.Text = bargainInfo.InitialPrice.ToString("f2"); this.litPurchaseNumber.Text = (bargainInfo.ActivityStock - bargainInfo.TranNumber).ToString(); this.litParticipantNumber.Text = BargainHelper.HelpBargainCount(this.bargainId).ToString(); this.hiddEndDate.Value = bargainInfo.EndDate.ToString("yyyy:MM:dd:HH:mm:ss"); this.hiddPurchaseNumber.Value = bargainInfo.PurchaseNumber.ToString(); this.litStock.Text = bargainInfo.PurchaseNumber.ToString(); this.hideTitle.Value = bargainInfo.Title; this.hideDesc.Value = bargainInfo.Remarks.Replace("\n", " ").Replace("\r", ""); string activityCover = bargainInfo.ActivityCover; string str2 = string.Empty; Uri url = HttpContext.Current.Request.Url; if (!activityCover.StartsWith("http")) { str2 = url.Scheme + "://" + url.Host + ((url.Port == 80) ? "" : (":" + url.Port.ToString())); } if (bargainInfo.ProductId > 0) { this.skuSelector.ProductId = bargainInfo.ProductId; if (currentMember != null) { flag = ProductBrowser.CheckHasCollect(currentMember.UserId, bargainInfo.ProductId); } this.hiddHasCollected.SetWhenIsNotNull(flag ? "1" : "0"); ProductInfo productDetails = ProductHelper.GetProductDetails(bargainInfo.ProductId); if (productDetails == null) { this.Context.Response.Write("<script>alert('该商品不存在!');location.href='/default.aspx';</script>"); this.Context.Response.End(); } else { this.hiddProductId.Value = bargainInfo.ProductId.ToString(); this.litProdcutName.Text = productDetails.ProductName; this.litShortDescription.Text = productDetails.ProductShortName; this.hideImgUrl.Value = string.IsNullOrEmpty(productDetails.ThumbnailUrl60) ? (str2 + activityCover) : (str2 + productDetails.ThumbnailUrl60); this.litProductDesc.Text = productDetails.Description; //if (this.rptProductImages != null) //{ // string locationUrl = "javascript:;"; // SlideImage[] imageArray = new SlideImage[] { new SlideImage(productDetails.ImageUrl1, locationUrl), new SlideImage(productDetails.ImageUrl2, locationUrl), new SlideImage(productDetails.ImageUrl3, locationUrl), new SlideImage(productDetails.ImageUrl4, locationUrl), new SlideImage(productDetails.ImageUrl5, locationUrl) }; // if (CS$<>9__CachedAnonymousMethodDelegate1 == null) // { // CS$<>9__CachedAnonymousMethodDelegate1 = new Func<SlideImage, bool>(null, (IntPtr) <AttachChildControls>b__0); // } // this.rptProductImages.DataSource = Enumerable.Where<SlideImage>(imageArray, CS$<>9__CachedAnonymousMethodDelegate1); // this.rptProductImages.DataBind(); //} if (this.rptProductImages != null) { string locationUrl = "javascript:;"; SlideImage[] imageArray = new SlideImage[] { new SlideImage(productDetails.ImageUrl1, locationUrl), new SlideImage(productDetails.ImageUrl2, locationUrl), new SlideImage(productDetails.ImageUrl3, locationUrl), new SlideImage(productDetails.ImageUrl4, locationUrl), new SlideImage(productDetails.ImageUrl5, locationUrl) }; this.rptProductImages.DataSource = from item in imageArray where !string.IsNullOrWhiteSpace(item.ImageUrl) select item; this.rptProductImages.DataBind(); } int productConsultationsCount = ProductBrowser.GetProductConsultationsCount(bargainInfo.ProductId, false); this.litProductConsultationTotal.SetWhenIsNotNull(productConsultationsCount.ToString()); this.litProductCommentTotal.SetWhenIsNotNull(ProductBrowser.GetProductReviewsCount(bargainInfo.ProductId).ToString()); } } } }
public static bool InsertBargain(BargainInfo bargain) { return(new BargainDao().InsertBargain(bargain)); }
private void btnSave_Click(object sender, EventArgs e) { int num = Globals.RequestQueryNum("id"); string text = this.txtTitle.Text; if (string.IsNullOrWhiteSpace(text)) { this.ShowMsg("分享标题不能为空!", false); } else { string str2 = this.calendarStartDate.Text; string str3 = this.calendarEndDate.Text; if (string.IsNullOrWhiteSpace(str2) || string.IsNullOrWhiteSpace(str3)) { this.ShowMsg("活动时间不能为空!", false); } else if (DateTime.Parse(str2) >= DateTime.Parse(str3)) { this.ShowMsg("结束时间必须大于开始时间!", false); } else { string str4 = this.hidpic.Value; if (string.IsNullOrWhiteSpace(str4)) { this.ShowMsg("请先上传活动封面!", false); } else { string str5 = this.txtRemarks.Text; if (str5.Length > 200) { this.ShowMsg("活动说明不能超过200个字节!", false); } else { int productId = Globals.ToNum(this.hiddProductId.Value); if (productId <= 0) { this.ShowMsg("请先选择参加活动的产品!", false); } else { int num3 = Globals.ToNum(this.txtActivityStock.Text.Trim()); if (num3 <= 0) { this.ShowMsg("活动库存必须为大于0的正整数!", false); } else { int num4 = Globals.ToNum(this.txtPurchaseNumber.Text.Trim()); if (num4 <= 0) { this.ShowMsg("限购数量必须为大于0的正整数!", false); } else { float result = 0f; if (!float.TryParse(this.txtInitialPrice.Text, out result)) { this.ShowMsg("初始价格输入不正确!", false); } else { float num6 = 0f; if (!float.TryParse(this.txtFloorPrice.Text, out num6)) { this.ShowMsg("活动底价输入不正确!", false); } else if ((num6 <= 0f) || (result <= 0f)) { this.ShowMsg("活动底价必须或初始价格必须大于0!", false); } else if (result < num6) { this.ShowMsg("初始价格不能小于活动底价!", false); } else { long productSumStock = ProductHelper.GetProductSumStock(productId); if (num3 > productSumStock) { this.ShowMsg("活动库存不能大于商品库存!", false); } else if (num4 > num3) { this.ShowMsg("限购数量不能大于活动库存!", false); } else { bool flag = this.ckIsCommission.Checked; string str6 = this.discount.Text; if (flag && string.IsNullOrEmpty(str6)) { this.ShowMsg("请填写佣金折扣值!", false); } else if (flag && (str6 == "0")) { this.ShowMsg("佣金折扣值必须大于0!", false); } else { int num8 = this.rbtBargainTypeOne.Checked ? 0 : 1; BargainInfo bargain = new BargainInfo { Title = text, BeginDate = DateTime.Parse(str2), EndDate = DateTime.Parse(str3), ActivityCover = str4, Remarks = str5, ProductId = productId, ActivityStock = num3, PurchaseNumber = num4, TranNumber = 0, InitialPrice = (decimal)result, FloorPrice = (decimal)num6, BargainType = num8, CreateDate = DateTime.Now, IsCommission = this.ckIsCommission.Checked, CommissionDiscount = flag ? ((int)(float.Parse(str6) * 10f)) : 0 }; if (num8 == 0) { string str7 = this.txtBargainTypeOneValue.Text; if (string.IsNullOrWhiteSpace(str7)) { this.ShowMsg("每次砍掉价格不能为空!", false); return; } bargain.BargainTypeMinVlue = float.Parse(str7); } else { string str8 = this.txtBargainTypeTwoValue1.Text; string str9 = this.txtBargainTypeTwoValue2.Text; if (string.IsNullOrWhiteSpace(str8) || string.IsNullOrWhiteSpace(str9)) { this.ShowMsg("随机砍价最小值或最大值不能为空!", false); return; } float num9 = 0f; float num10 = 0f; if (!float.TryParse(str8, out num9)) { this.ShowMsg("随机砍价最小值必须为数值!", false); return; } if (!float.TryParse(str9, out num10)) { this.ShowMsg("随机砍价最大值必须为数值!", false); return; } if (num9 > num10) { this.ShowMsg("随机砍价最大值必须大于最小值!", false); return; } if ((num9 < 0f) || (num10 < 0f)) { this.ShowMsg("随机砍价最大值,最小值都必须大于零!", false); return; } bargain.BargainTypeMinVlue = num9; bargain.BargainTypeMaxVlue = num10; } if (num > 0) { bargain.Id = num; if (BargainHelper.UpdateBargain(bargain)) { this.ShowMsgAndReUrl("修改成功", true, "ManagerBargain.aspx?Type=0"); } } else if (BargainHelper.InsertBargain(bargain)) { this.ShowMsgAndReUrl("添加成功", true, "ManagerBargain.aspx?Type=0"); } } } } } } } } } } } } }
/// <summary> /// 增加一条砍价数据 /// </summary> /// <param name="model">砍价模型变量</param> public static int AddBargain(BargainInfo model) { model.Id = dal.AddBargain(model); return(model.Id); }
/// <summary> /// 更新一条砍价数据 /// </summary> /// <param name="model">砍价模型变量</param> public static void UpdateBargain(BargainInfo model) { dal.UpdateBargain(model); }
protected override void AttachChildControls() { if (!int.TryParse(this.Page.Request.QueryString["bargainId"], out this.bargainId)) { base.GotoResourceNotFound(""); } int num = int.Parse(this.Page.Request.QueryString["bargainDetialId"]); this.litProdcutName = (System.Web.UI.WebControls.Literal) this.FindControl("litProdcutName"); this.litShortDescription = (System.Web.UI.WebControls.Literal) this.FindControl("litShortDescription"); this.litSalePrice = (System.Web.UI.WebControls.Literal) this.FindControl("litSalePrice"); this.litFloorPrice = (System.Web.UI.WebControls.Literal) this.FindControl("litFloorPrice"); this.litPurchaseNumber = (System.Web.UI.WebControls.Literal) this.FindControl("litPurchaseNumber"); this.litParticipantNumber = (System.Web.UI.WebControls.Literal) this.FindControl("litParticipantNumber"); this.litProductDesc = (System.Web.UI.WebControls.Literal) this.FindControl("litProductDesc"); this.litProductConsultationTotal = (System.Web.UI.WebControls.Literal) this.FindControl("litProductConsultationTotal"); this.litProductCommentTotal = (System.Web.UI.WebControls.Literal) this.FindControl("litProductCommentTotal"); this.litStock = (System.Web.UI.WebControls.Literal) this.FindControl("litStock"); this.litPurcharseNum = (System.Web.UI.WebControls.Literal) this.FindControl("litPurcharseNum"); this.hiddHasCollected = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hiddHasCollected"); this.hiddProductId = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hiddProductId"); this.hiddEndDate = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hiddEndDate"); this.hiddPurchaseNumber = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hiddPurchaseNumber"); this.rptProductImages = (VshopTemplatedRepeater)this.FindControl("rptProductImages"); this.skuSelector = (Common_SKUSelector)this.FindControl("skuSelector"); this.hideTitle = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hideTitle"); this.hideImgUrl = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hideImgUrl"); this.hideDesc = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hideDesc"); MemberInfo currentMember = MemberProcessor.GetCurrentMember(); bool flag = false; BargainInfo bargainInfo = BargainHelper.GetBargainInfo(this.bargainId); BargainDetialInfo bargainDetialInfo = BargainHelper.GetBargainDetialInfo(num); if (bargainInfo != null) { PageTitle.AddSiteNameTitle(bargainInfo.Title); this.litFloorPrice.Text = bargainInfo.FloorPrice.ToString("F2"); this.litPurchaseNumber.Text = (bargainInfo.ActivityStock - bargainInfo.TranNumber).ToString(); this.litParticipantNumber.Text = BargainHelper.GetHelpBargainDetialCount(num).ToString(); this.hiddEndDate.Value = bargainInfo.EndDate.ToString("yyyy:MM:dd:HH:mm:ss"); this.hiddPurchaseNumber.Value = bargainInfo.PurchaseNumber.ToString(); this.litStock.Text = bargainInfo.PurchaseNumber.ToString(); this.litPurcharseNum.Text = bargainInfo.PurchaseNumber.ToString(); this.hideTitle.Value = bargainInfo.Title; this.hideDesc.Value = bargainInfo.Remarks.Replace("\n", " ").Replace("\r", ""); string activityCover = bargainInfo.ActivityCover; string str = string.Empty; System.Uri url = System.Web.HttpContext.Current.Request.Url; if (!activityCover.StartsWith("http")) { str = url.Scheme + "://" + url.Host + ((url.Port == 80) ? "" : (":" + url.Port.ToString())); } if (bargainDetialInfo != null) { this.litSalePrice.Text = bargainDetialInfo.Price.ToString("F2"); } if (bargainInfo.ProductId > 0) { this.skuSelector.ProductId = bargainInfo.ProductId; if (currentMember != null) { flag = ProductBrowser.CheckHasCollect(currentMember.UserId, bargainInfo.ProductId); } this.hiddHasCollected.SetWhenIsNotNull(flag ? "1" : "0"); ProductInfo productDetails = ProductHelper.GetProductDetails(bargainInfo.ProductId); this.hiddProductId.Value = bargainInfo.ProductId.ToString(); this.litProdcutName.Text = productDetails.ProductName; this.litShortDescription.Text = bargainInfo.Remarks; this.hideImgUrl.Value = (string.IsNullOrEmpty(productDetails.ThumbnailUrl60) ? (str + activityCover) : (str + productDetails.ThumbnailUrl60)); this.litProductDesc.Text = productDetails.Description; if (this.rptProductImages != null) { string locationUrl = "javascript:;"; SlideImage[] source = new SlideImage[] { new SlideImage(productDetails.ImageUrl1, locationUrl), new SlideImage(productDetails.ImageUrl2, locationUrl), new SlideImage(productDetails.ImageUrl3, locationUrl), new SlideImage(productDetails.ImageUrl4, locationUrl), new SlideImage(productDetails.ImageUrl5, locationUrl) }; this.rptProductImages.DataSource = from item in source where !string.IsNullOrWhiteSpace(item.ImageUrl) select item; this.rptProductImages.DataBind(); } int num2 = ProductBrowser.GetProductConsultationsCount(bargainInfo.ProductId, false); this.litProductConsultationTotal.SetWhenIsNotNull(num2.ToString()); num2 = ProductBrowser.GetProductReviewsCount(bargainInfo.ProductId); this.litProductCommentTotal.SetWhenIsNotNull(num2.ToString()); } } }
protected override void AttachChildControls() { if (!int.TryParse(this.Page.Request.QueryString["bargainId"], out this.bargainId)) { base.GotoResourceNotFound(""); } this.litProdcutName = (Literal)this.FindControl("litProdcutName"); this.litShortDescription = (Literal)this.FindControl("litShortDescription"); this.litSalePrice = (Literal)this.FindControl("litSalePrice"); this.litFloorPrice = (Literal)this.FindControl("litFloorPrice"); this.litFloorPrice1 = (Literal)this.FindControl("litFloorPrice1"); this.litPurchaseNumber = (Literal)this.FindControl("litPurchaseNumber"); this.litParticipantNumber = (Literal)this.FindControl("litParticipantNumber"); this.litProductDesc = (Literal)this.FindControl("litProductDesc"); this.litProductConsultationTotal = (Literal)this.FindControl("litProductConsultationTotal"); this.litProductCommentTotal = (Literal)this.FindControl("litProductCommentTotal"); this.litStock = (Literal)this.FindControl("litStock"); this.hiddHasCollected = (HtmlInputHidden)this.FindControl("hiddHasCollected"); this.hiddProductId = (HtmlInputHidden)this.FindControl("hiddProductId"); this.hideTitle = (HtmlInputHidden)this.FindControl("hideTitle"); this.hideImgUrl = (HtmlInputHidden)this.FindControl("hideImgUrl"); this.hideDesc = (HtmlInputHidden)this.FindControl("hideDesc"); this.hiddEndDate = (HtmlInputHidden)this.FindControl("hiddEndDate"); this.hiddPurchaseNumber = (HtmlInputHidden)this.FindControl("hiddPurchaseNumber"); this.skuSelector = (Common_SKUSelector)this.FindControl("skuSelector"); this.rptProductImages = (VshopTemplatedRepeater)this.FindControl("rptProductImages"); MemberInfo currentMember = MemberProcessor.GetCurrentMember(); bool flag = false; BargainInfo bargainInfo = BargainHelper.GetBargainInfo(this.bargainId); if (bargainInfo != null) { this.hideTitle.Value = bargainInfo.Title; this.hideDesc.Value = bargainInfo.Remarks; Uri url = HttpContext.Current.Request.Url; string activityCover = bargainInfo.ActivityCover; string str2 = string.Empty; if (!activityCover.StartsWith("http")) { str2 = url.Scheme + "://" + url.Host + ((url.Port == 80) ? "" : (":" + url.Port.ToString())); } int id = Globals.RequestQueryNum("bargainDetialId"); if (id > 0) { BargainDetialInfo bargainDetialInfo = BargainHelper.GetBargainDetialInfo(id); if ((currentMember == null) || (((currentMember != null) && (bargainDetialInfo != null)) && (bargainDetialInfo.UserId != currentMember.UserId))) { HttpContext.Current.Response.Redirect(string.Concat(new object[] { "HelpBargainDetial.aspx?bargainId=", this.bargainId, "&bargainDetialId=", id })); HttpContext.Current.Response.End(); } } PageTitle.AddSiteNameTitle(bargainInfo.Title); this.litFloorPrice.Text = bargainInfo.FloorPrice.ToString("F2"); this.litFloorPrice1.Text = bargainInfo.FloorPrice.ToString("F2"); this.litPurchaseNumber.Text = (bargainInfo.ActivityStock - bargainInfo.TranNumber).ToString(); this.litParticipantNumber.Text = BargainHelper.HelpBargainCount(this.bargainId).ToString(); this.hiddEndDate.Value = bargainInfo.EndDate.ToString("yyyy:MM:dd:HH:mm:ss"); this.hiddPurchaseNumber.Value = bargainInfo.PurchaseNumber.ToString(); this.litStock.Text = bargainInfo.PurchaseNumber.ToString(); if (bargainInfo.ProductId > 0) { this.skuSelector.ProductId = bargainInfo.ProductId; if (currentMember != null) { flag = ProductBrowser.CheckHasCollect(currentMember.UserId, bargainInfo.ProductId); } this.hiddHasCollected.SetWhenIsNotNull(flag ? "1" : "0"); ProductInfo productDetails = ProductHelper.GetProductDetails(bargainInfo.ProductId); this.hiddProductId.Value = bargainInfo.ProductId.ToString(); this.litProdcutName.Text = productDetails.ProductName; this.litShortDescription.Text = productDetails.ShortDescription; this.litSalePrice.Text = productDetails.MinSalePrice.ToString("f2"); this.litProductDesc.Text = productDetails.Description; this.hideImgUrl.Value = string.IsNullOrEmpty(productDetails.ThumbnailUrl60) ? (str2 + activityCover) : (str2 + productDetails.ThumbnailUrl60); if (this.rptProductImages != null) { string locationUrl = "javascript:;"; SlideImage[] imageArray = new SlideImage[] { new SlideImage(productDetails.ImageUrl1, locationUrl), new SlideImage(productDetails.ImageUrl2, locationUrl), new SlideImage(productDetails.ImageUrl3, locationUrl), new SlideImage(productDetails.ImageUrl4, locationUrl), new SlideImage(productDetails.ImageUrl5, locationUrl) }; this.rptProductImages.DataSource = from item in imageArray where !string.IsNullOrWhiteSpace(item.ImageUrl) select item; this.rptProductImages.DataBind(); } int productConsultationsCount = ProductBrowser.GetProductConsultationsCount(bargainInfo.ProductId, false); this.litProductConsultationTotal.SetWhenIsNotNull(productConsultationsCount.ToString()); this.litProductCommentTotal.SetWhenIsNotNull(ProductBrowser.GetProductReviewsCount(bargainInfo.ProductId).ToString()); } } else { HttpContext.Current.Response.Redirect("/default.aspx"); HttpContext.Current.Response.End(); } }
private void btnSave_Click(object sender, System.EventArgs e) { int num = Globals.RequestQueryNum("id"); string text = this.txtTitle.Text; if (string.IsNullOrWhiteSpace(text)) { this.ShowMsg("分享标题不能为空!", false); return; } string text2 = this.calendarStartDate.Text; string text3 = this.calendarEndDate.Text; if (string.IsNullOrWhiteSpace(text2) || string.IsNullOrWhiteSpace(text3)) { this.ShowMsg("活动时间不能为空!", false); return; } if (System.DateTime.Parse(text2) >= System.DateTime.Parse(text3)) { this.ShowMsg("结束时间必须大于开始时间!", false); return; } string value = this.hidpic.Value; if (string.IsNullOrWhiteSpace(value)) { this.ShowMsg("请先上传活动封面!", false); return; } string text4 = this.txtRemarks.Text; if (text4.Length > 200) { this.ShowMsg("活动说明不能超过200个字节!", false); return; } int num2 = Globals.ToNum(this.hiddProductId.Value); if (num2 <= 0) { this.ShowMsg("请先选择参加活动的产品!", false); return; } int num3 = Globals.ToNum(this.txtActivityStock.Text.Trim()); if (num3 <= 0) { this.ShowMsg("活动库存必须为大于0的正整数!", false); return; } int num4 = Globals.ToNum(this.txtPurchaseNumber.Text.Trim()); if (num4 <= 0) { this.ShowMsg("限购数量必须为大于0的正整数!", false); return; } float num5 = 0f; if (!float.TryParse(this.txtInitialPrice.Text, out num5)) { this.ShowMsg("初始价格输入不正确!", false); return; } float num6 = 0f; if (!float.TryParse(this.txtFloorPrice.Text, out num6)) { this.ShowMsg("活动底价输入不正确!", false); return; } if (num6 <= 0f || num5 <= 0f) { this.ShowMsg("活动底价必须或初始价格必须大于0!", false); return; } if (num5 < num6) { this.ShowMsg("初始价格不能小于活动底价!", false); return; } long productSumStock = ProductHelper.GetProductSumStock(num2); if ((long)num3 > productSumStock) { this.ShowMsg("活动库存不能大于商品库存!", false); return; } if (num4 > num3) { this.ShowMsg("限购数量不能大于活动库存!", false); return; } int num7 = this.rbtBargainTypeOne.Checked ? 0 : 1; BargainInfo bargainInfo = new BargainInfo(); bargainInfo.Title = text; bargainInfo.BeginDate = System.DateTime.Parse(text2); bargainInfo.EndDate = System.DateTime.Parse(text3); bargainInfo.ActivityCover = value; bargainInfo.Remarks = text4; bargainInfo.ProductId = num2; bargainInfo.ActivityStock = num3; bargainInfo.PurchaseNumber = num4; bargainInfo.TranNumber = 0; bargainInfo.InitialPrice = (decimal)num5; bargainInfo.FloorPrice = (decimal)num6; bargainInfo.BargainType = num7; bargainInfo.CreateDate = System.DateTime.Now; bargainInfo.IsCommission = this.ckIsCommission.Checked; if (num7 == 0) { string text5 = this.txtBargainTypeOneValue.Text; if (string.IsNullOrWhiteSpace(text5)) { this.ShowMsg("每次砍掉价格不能为空!", false); return; } bargainInfo.BargainTypeMinVlue = float.Parse(text5); } else { string text6 = this.txtBargainTypeTwoValue1.Text; string text7 = this.txtBargainTypeTwoValue2.Text; if (string.IsNullOrWhiteSpace(text6) || string.IsNullOrWhiteSpace(text7)) { this.ShowMsg("随机砍价最小值或最大值不能为空!", false); return; } float num8 = 0f; float num9 = 0f; if (!float.TryParse(text6, out num8)) { this.ShowMsg("随机砍价最小值必须为数值!", false); return; } if (!float.TryParse(text7, out num9)) { this.ShowMsg("随机砍价最大值必须为数值!", false); return; } if (num8 > num9) { this.ShowMsg("随机砍价最大值必须大于最小值!", false); return; } if (num8 < 0f || num9 < 0f) { this.ShowMsg("随机砍价最大值,最小值都必须大于零!", false); return; } bargainInfo.BargainTypeMinVlue = num8; bargainInfo.BargainTypeMaxVlue = num9; } if (num > 0) { bargainInfo.Id = num; bool flag = BargainHelper.UpdateBargain(bargainInfo); if (flag) { this.ShowMsgAndReUrl("修改成功", true, "ManagerBargain.aspx?Type=0"); return; } } else { bool flag2 = BargainHelper.InsertBargain(bargainInfo); if (flag2) { this.ShowMsgAndReUrl("添加成功", true, "ManagerBargain.aspx?Type=0"); } } }