public override GroupBuyInfo GetGroupBuy(int groupBuyId)
        {
            GroupBuyInfo info             = null;
            DbCommand    sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM distro_GroupBuy WHERE GroupBuyId=@GroupBuyId AND DistributorUserId=@DistributorUserId;SELECT * FROM distro_GroupBuyCondition WHERE GroupBuyId=@GroupBuyId AND DistributorUserId=@DistributorUserId");

            this.database.AddInParameter(sqlStringCommand, "GroupBuyId", DbType.Int32, groupBuyId);
            this.database.AddInParameter(sqlStringCommand, "DistributorUserId", DbType.Int32, HiContext.Current.SiteSettings.UserId.Value);
            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (reader.Read())
                {
                    info = DataMapper.PopulateGroupBuy(reader);
                }
                reader.NextResult();
                while (reader.Read())
                {
                    GropBuyConditionInfo item = new GropBuyConditionInfo {
                        Count = (int)reader["Count"],
                        Price = (decimal)reader["Price"]
                    };
                    info.GroupBuyConditions.Add(item);
                }
            }
            return(info);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public GroupBuyInfo GetGroupBuy(int groupBuyId)
        {
            GroupBuyInfo info             = null;
            DbCommand    sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM vw_Hishop_GroupBuy WHERE GroupBuyId=@GroupBuyId;SELECT * FROM Hishop_GroupBuyCondition WHERE GroupBuyId=@GroupBuyId");

            this.database.AddInParameter(sqlStringCommand, "GroupBuyId", DbType.Int32, groupBuyId);
            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (reader.Read())
                {
                    info = DataMapper.PopulateGroupBuy(reader);
                }
                reader.NextResult();
                while (reader.Read())
                {
                    GropBuyConditionInfo item = new GropBuyConditionInfo
                    {
                        Count = (int)reader["Count"],
                        Price = (decimal)reader["Price"]
                    };
                    info.GroupBuyConditions.Add(item);
                }
            }
            return(info);
        }
Esempio n. 4
0
        public override GroupBuyInfo GetProductGroupBuyInfo(int productId)
        {
            GroupBuyInfo groupBuyInfo = null;

            System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM distro_GroupBuy WHERE ProductId=@ProductId AND DistributorUserId=@DistributorUserId AND Status = @Status; SELECT * FROM distro_GroupBuyCondition WHERE GroupBuyId=(SELECT GroupBuyId FROM distro_GroupBuy WHERE ProductId=@ProductId AND DistributorUserId=@DistributorUserId AND Status=@Status)");
            this.database.AddInParameter(sqlStringCommand, "ProductId", System.Data.DbType.Int32, productId);
            this.database.AddInParameter(sqlStringCommand, "DistributorUserId", System.Data.DbType.Int32, HiContext.Current.SiteSettings.UserId.Value);
            this.database.AddInParameter(sqlStringCommand, "Status", System.Data.DbType.Int32, 1);
            using (System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (dataReader.Read())
                {
                    groupBuyInfo = DataMapper.PopulateGroupBuy(dataReader);
                }
                dataReader.NextResult();
                while (dataReader.Read())
                {
                    GropBuyConditionInfo gropBuyConditionInfo = new GropBuyConditionInfo();
                    gropBuyConditionInfo.Count = (int)dataReader["Count"];
                    gropBuyConditionInfo.Price = (decimal)dataReader["Price"];
                    if (groupBuyInfo != null)
                    {
                        groupBuyInfo.GroupBuyConditions.Add(gropBuyConditionInfo);
                    }
                }
            }
            return(groupBuyInfo);
        }
Esempio n. 5
0
        public override GroupBuyInfo GetGroupBuy(int groupBuyId)
        {
            GroupBuyInfo groupBuyInfo = null;

            System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_GroupBuy WHERE GroupBuyId=@GroupBuyId;SELECT * FROM Hishop_GroupBuyCondition WHERE GroupBuyId=@GroupBuyId");
            this.database.AddInParameter(sqlStringCommand, "GroupBuyId", System.Data.DbType.Int32, groupBuyId);
            using (System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (dataReader.Read())
                {
                    groupBuyInfo = DataMapper.PopulateGroupBuy(dataReader);
                }
                dataReader.NextResult();
                while (dataReader.Read())
                {
                    GropBuyConditionInfo gropBuyConditionInfo = new GropBuyConditionInfo();
                    gropBuyConditionInfo.Count = (int)dataReader["Count"];
                    gropBuyConditionInfo.Price = (decimal)dataReader["Price"];
                    groupBuyInfo.GroupBuyConditions.Add(gropBuyConditionInfo);
                }
            }
            return(groupBuyInfo);
        }
Esempio n. 6
0
        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);
            }
        }
Esempio n. 7
0
        private void btnUpdateGroupBuy_Click(object sender, EventArgs e)
        {
            int          num2;
            int          num3;
            decimal      num4;
            GroupBuyInfo groupBuy = new GroupBuyInfo
            {
                GroupBuyId = this.groupBuyId
            };
            string str = string.Empty;

            if (this.dropGroupBuyProduct.SelectedValue > 0)
            {
                if ((PromoteHelper.GetGroupBuy(this.groupBuyId).ProductId != this.dropGroupBuyProduct.SelectedValue.Value) && PromoteHelper.ProductGroupBuyExist(this.dropGroupBuyProduct.SelectedValue.Value))
                {
                    this.ShowMsg("已经存在此商品的团购活动,并且活动正在进行中", false);
                    return;
                }
                groupBuy.ProductId = this.dropGroupBuyProduct.SelectedValue.Value;
            }
            else
            {
                str = str + Formatter.FormatErrorMessage("请选择团购商品");
            }
            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) && (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 = 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 (PromoteHelper.UpdateGroupBuy(groupBuy))
            {
                this.ShowMsg("编辑团购活动成功", true);
            }
            else
            {
                this.ShowMsg("编辑团购活动失败", true);
            }
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        private void btnAddGroupBuy_Click(object sender, EventArgs e)
        {
            int          num;
            int          num2;
            decimal      num3;
            GroupBuyInfo groupBuy = new GroupBuyInfo();
            string       str      = string.Empty;

            if (this.dropGroupBuyProduct.SelectedValue > 0)
            {
                if (PromoteHelper.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;
            }
            if (!string.IsNullOrEmpty(this.txtNeedPrice.Text))
            {
                decimal num4;
                if (decimal.TryParse(this.txtNeedPrice.Text.Trim(), out num4))
                {
                    groupBuy.NeedPrice = num4;
                }
                else
                {
                    str = str + Formatter.FormatErrorMessage("违约金填写格式不正确");
                }
            }
            if (int.TryParse(this.txtMaxCount.Text.Trim(), out num))
            {
                groupBuy.MaxCount = num;
            }
            else
            {
                str = str + Formatter.FormatErrorMessage("限购数量不能为空,只能为整数");
            }
            GropBuyConditionInfo item = new GropBuyConditionInfo();

            if (int.TryParse(this.txtCount.Text.Trim(), out num2))
            {
                item.Count = num2;
            }
            else
            {
                str = str + Formatter.FormatErrorMessage("团购满足数量不能为空,只能为整数");
            }
            if (decimal.TryParse(this.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))
            {
                this.ShowMsg(str, false);
            }
            else
            {
                groupBuy.Content = this.txtContent.Text;
                if (PromoteHelper.AddGroupBuy(groupBuy))
                {
                    this.ShowMsg("添加团购活动成功", true);
                }
                else
                {
                    this.ShowMsg("添加团购活动失败", true);
                }
            }
        }