Пример #1
0
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     int num;
     GiftInfo entity = new GiftInfo();
     if (!int.TryParse(txtNeedPoint.Text.Trim(), out num))
     {
         ShowMsg("兑换所需积分不能为空,大小0-10000之间", false);
     }
     else
     {
         entity.GiftId = Id;
         entity.NeedPoint = num;
         entity.Name = txtGiftName.Text.Trim();
         entity.Title = txtGiftTitle.Text.Trim();
         entity.Meta_Description = txtTitleDescription.Text.Trim();
         entity.Meta_Keywords = txtTitleKeywords.Text.Trim();
         Globals.EntityCoding(entity, false);
         if (SubsiteGiftHelper.UpdateMyGifts(entity))
         {
             ShowMsg("成功修改了一件礼品的基本信息", true);
         }
         else
         {
             ShowMsg("修改件礼品的基本信息失败", true);
         }
     }
 }
Пример #2
0
 public override bool AddOrderGift(string orderId, GiftInfo gift, int quantity, DbTransaction dbTran)
 {
     DbCommand sqlStringCommand = database.GetSqlStringCommand("select * from distro_OrderGifts where OrderId=@OrderId AND GiftId=@GiftId");
     database.AddInParameter(sqlStringCommand, "OrderId", DbType.String, orderId);
     database.AddInParameter(sqlStringCommand, "GiftId", DbType.Int32, gift.GiftId);
     using (IDataReader reader = database.ExecuteReader(sqlStringCommand))
     {
         while (reader.Read())
         {
             DbCommand command2 = database.GetSqlStringCommand("update distro_OrderGifts set Quantity=@Quantity where OrderId=@OrderId AND GiftId=@GiftId");
             database.AddInParameter(command2, "OrderId", DbType.String, orderId);
             database.AddInParameter(command2, "GiftId", DbType.Int32, gift.GiftId);
             database.AddInParameter(command2, "Quantity", DbType.Int32, ((int)reader["Quantity"]) + quantity);
             if (dbTran != null)
             {
                 return (database.ExecuteNonQuery(command2, dbTran) == 1);
             }
             return (database.ExecuteNonQuery(command2) == 1);
         }
         DbCommand command = database.GetSqlStringCommand("INSERT INTO distro_OrderGifts(OrderId,GiftId,DistributorUserId,GiftName,CostPrice,ThumbnailsUrl,Quantity) VALUES(@OrderId,@GiftId,@DistributorUserId,@GiftName,@CostPrice,@ThumbnailsUrl,@Quantity)");
         database.AddInParameter(command, "OrderId", DbType.String, orderId);
         database.AddInParameter(command, "GiftId", DbType.Int32, gift.GiftId);
         database.AddInParameter(command, "DistributorUserId", DbType.Int32, HiContext.Current.User.UserId);
         database.AddInParameter(command, "GiftName", DbType.String, gift.Name);
         database.AddInParameter(command, "CostPrice", DbType.Currency, gift.PurchasePrice);
         database.AddInParameter(command, "ThumbnailsUrl", DbType.String, gift.ThumbnailUrl40);
         database.AddInParameter(command, "Quantity", DbType.Int32, quantity);
         if (dbTran != null)
         {
             return (database.ExecuteNonQuery(command, dbTran) == 1);
         }
         return (database.ExecuteNonQuery(command) == 1);
     }
 }
Пример #3
0
 public static bool DeleteGift(int giftId)
 {
     GiftInfo info2 = new GiftInfo();
     info2.GiftId = giftId;
     GiftInfo gift = info2;
     return (PromotionsProvider.Instance().CreateUpdateDeleteGift(gift, DataProviderAction.Delete) == GiftActionStatus.Success);
 }
Пример #4
0
 public static bool AddOrderGift(OrderInfo order, GiftInfo gift, int quantity)
 {
     bool flag;
     using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
     {
         connection.Open();
         DbTransaction dbTran = connection.BeginTransaction();
         try
         {
             if (!SubsiteSalesProvider.Instance().AddOrderGift(order.OrderId, gift, quantity, dbTran))
             {
                 dbTran.Rollback();
                 return false;
             }
             bool flag2 = false;
             foreach (OrderGiftInfo info in order.Gifts)
             {
                 if (info.GiftId == gift.GiftId)
                 {
                     flag2 = true;
                     info.Quantity += quantity;
                 }
             }
             if (!flag2)
             {
                 OrderGiftInfo item = new OrderGiftInfo();
                 item.GiftId = gift.GiftId;
                 item.OrderId = order.OrderId;
                 item.GiftName = gift.Name;
                 item.Quantity = quantity;
                 item.CostPrice = gift.PurchasePrice;
                 item.ThumbnailsUrl = gift.ThumbnailUrl40;
                 order.Gifts.Add(item);
             }
             if (!SubsiteSalesProvider.Instance().UpdateOrderAmount(order, dbTran))
             {
                 dbTran.Rollback();
                 return false;
             }
             dbTran.Commit();
             flag = true;
         }
         catch
         {
             dbTran.Rollback();
             flag = false;
         }
         finally
         {
             connection.Close();
         }
     }
     return flag;
 }
Пример #5
0
 void LoadPageSearch(GiftInfo gift)
 {
     if (!string.IsNullOrEmpty(gift.Meta_Keywords))
     {
         MetaTags.AddMetaKeywords(gift.Meta_Keywords, HiContext.Current.Context);
     }
     if (!string.IsNullOrEmpty(gift.Meta_Description))
     {
         MetaTags.AddMetaDescription(gift.Meta_Description, HiContext.Current.Context);
     }
     if (!string.IsNullOrEmpty(gift.Title))
     {
         PageTitle.AddTitle(gift.Title, HiContext.Current.Context);
     }
     else
     {
         PageTitle.AddTitle(gift.Name, HiContext.Current.Context);
     }
 }
Пример #6
0
 public abstract GiftActionStatus CreateUpdateDeleteGift(GiftInfo gift, DataProviderAction action);
Пример #7
0
 public static GiftActionStatus UpdateGift(GiftInfo gift)
 {
     Globals.EntityCoding(gift, true);
     return PromotionsProvider.Instance().CreateUpdateDeleteGift(gift, DataProviderAction.Update);
 }
Пример #8
0
 public override GiftInfo GetMyGiftsDetails(int Id)
 {
     GiftInfo entity = new GiftInfo();
     DbCommand sqlStringCommand = database.GetSqlStringCommand("select d_Name as [Name],d_Title as Title,d_Meta_Description as Meta_Description,d_Meta_Keywords as Meta_Keywords,d_NeedPoint as NeedPoint,GiftId,ShortDescription,Unit, LongDescription,CostPrice,ImageUrl, ThumbnailUrl40,ThumbnailUrl60,ThumbnailUrl100,ThumbnailUrl160, ThumbnailUrl180, ThumbnailUrl220, ThumbnailUrl310, ThumbnailUrl410, PurchasePrice,MarketPrice,IsDownLoad from vw_distro_Gifts where d_DistributorUserId=@DistributorUserId and GiftId=@Id");
     database.AddInParameter(sqlStringCommand, "DistributorUserId", DbType.Int32, HiContext.Current.User.UserId);
     database.AddInParameter(sqlStringCommand, "Id", DbType.Int32, Id);
     using (IDataReader reader = database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             entity = DataMapper.PopulateGift(reader);
         }
     }
     Globals.EntityCoding(entity, false);
     return entity;
 }
Пример #9
0
 public static bool DownLoadGift(GiftInfo giftInfo)
 {
     return SubsitePromotionsProvider.Instance().DownLoadGift(giftInfo);
 }
Пример #10
0
 public override bool UpdateMyGifts(GiftInfo giftInfo)
 {
     DbCommand sqlStringCommand = database.GetSqlStringCommand("update distro_Gifts set [Name]=@Name,ShortDescription=@ShortDescription,Title=@Title,Meta_Description=@Meta_Description,Meta_Keywords=@Meta_Keywords,NeedPoint=@NeedPoint where GiftId=@Id and DistributorUserId=@DistributorUserId");
     database.AddInParameter(sqlStringCommand, "Name", DbType.String, giftInfo.Name);
     database.AddInParameter(sqlStringCommand, "ShortDescription", DbType.String, giftInfo.ShortDescription);
     database.AddInParameter(sqlStringCommand, "Title", DbType.String, giftInfo.Title);
     database.AddInParameter(sqlStringCommand, "Meta_Description", DbType.String, giftInfo.Meta_Description);
     database.AddInParameter(sqlStringCommand, "Meta_Keywords", DbType.String, giftInfo.Meta_Keywords);
     database.AddInParameter(sqlStringCommand, "NeedPoint", DbType.Int32, giftInfo.NeedPoint);
     database.AddInParameter(sqlStringCommand, "Id", DbType.Int32, giftInfo.GiftId);
     database.AddInParameter(sqlStringCommand, "DistributorUserId", DbType.Int32, HiContext.Current.User.UserId);
     return (database.ExecuteNonQuery(sqlStringCommand) >= 1);
 }
Пример #11
0
 public abstract bool DownLoadGift(GiftInfo giftinfo);
Пример #12
0
 public abstract bool UpdateMyGifts(GiftInfo giftInfo);
Пример #13
0
 public static bool UpdateMyGifts(GiftInfo giftInfo)
 {
     return SubsitePromotionsProvider.Instance().UpdateMyGifts(giftInfo);
 }
Пример #14
0
 public static bool AddOrderGift(OrderInfo order, GiftInfo giftinfo, int quantity)
 {
     bool flag;
     ManagerHelper.CheckPrivilege(Privilege.EditOrders);
     using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
     {
         connection.Open();
         DbTransaction dbTran = connection.BeginTransaction();
         try
         {
             SalesProvider provider = SalesProvider.Instance();
             OrderGiftInfo item = new OrderGiftInfo();
             item.OrderId = order.OrderId;
             item.Quantity = quantity;
             item.GiftName = giftinfo.Name;
             decimal costPrice = item.CostPrice;
             item.CostPrice = Convert.ToDecimal(giftinfo.CostPrice);
             item.GiftId = giftinfo.GiftId;
             item.ThumbnailsUrl = giftinfo.ThumbnailUrl40;
             bool flag2 = false;
             foreach (OrderGiftInfo info2 in order.Gifts)
             {
                 if (giftinfo.GiftId == info2.GiftId)
                 {
                     flag2 = true;
                     info2.Quantity = quantity;
                     break;
                 }
             }
             if (!flag2)
             {
                 order.Gifts.Add(item);
             }
             if (!provider.AddOrderGift(order.OrderId, item, quantity, dbTran))
             {
                 dbTran.Rollback();
                 return false;
             }
             if (!provider.UpdateOrderAmount(order, dbTran))
             {
                 dbTran.Rollback();
                 return false;
             }
             dbTran.Commit();
             flag = true;
         }
         catch
         {
             dbTran.Rollback();
             flag = false;
         }
         finally
         {
             connection.Close();
         }
     }
     if (flag)
     {
         EventLogs.WriteOperationLog(Privilege.EditOrders, string.Format(CultureInfo.InvariantCulture, "成功的为订单号为\"{0}\"的订单添加了礼品", new object[] { order.OrderId }));
     }
     return flag;
 }
Пример #15
0
 public override bool DownLoadGift(GiftInfo gift)
 {
     DbCommand sqlStringCommand = database.GetSqlStringCommand("insert into distro_Gifts VALUES (@GiftId,@DistributorUserId,@Name,@ShortDescription,@Title,@Meta_Description,@Meta_Keywords,@NeedPoint)");
     database.AddInParameter(sqlStringCommand, "GiftId", DbType.Int32, gift.GiftId);
     database.AddInParameter(sqlStringCommand, "DistributorUserId", DbType.Int32, HiContext.Current.User.UserId);
     database.AddInParameter(sqlStringCommand, "Name", DbType.String, gift.Name);
     database.AddInParameter(sqlStringCommand, "ShortDescription", DbType.String, gift.ShortDescription);
     database.AddInParameter(sqlStringCommand, "Title", DbType.String, gift.Title);
     database.AddInParameter(sqlStringCommand, "Meta_Description", DbType.String, gift.Meta_Description);
     database.AddInParameter(sqlStringCommand, "Meta_Keywords", DbType.String, gift.Meta_Keywords);
     database.AddInParameter(sqlStringCommand, "NeedPoint", DbType.Int32, gift.NeedPoint);
     return (database.ExecuteNonQuery(sqlStringCommand) >= 1);
 }
Пример #16
0
 public static GiftInfo PopulateGift(IDataReader reader)
 {
     if (null == reader)
     {
         return null;
     }
     GiftInfo info = new GiftInfo();
     info.GiftId = (int) reader["GiftId"];
     info.Name = (DBNull.Value == reader["Name"]) ? null : ((string) reader["Name"]);
     info.ShortDescription = (DBNull.Value == reader["ShortDescription"]) ? null : ((string) reader["ShortDescription"]);
     info.Unit = (DBNull.Value == reader["Unit"]) ? null : ((string) reader["Unit"]);
     info.LongDescription = (DBNull.Value == reader["LongDescription"]) ? null : ((string) reader["LongDescription"]);
     info.Title = (DBNull.Value == reader["Title"]) ? null : ((string) reader["Title"]);
     info.Meta_Description = (DBNull.Value == reader["Meta_Description"]) ? null : ((string) reader["Meta_Description"]);
     info.Meta_Keywords = (DBNull.Value == reader["Meta_Keywords"]) ? null : ((string) reader["Meta_Keywords"]);
     if (DBNull.Value != reader["CostPrice"])
     {
         info.CostPrice = new decimal?((decimal) reader["CostPrice"]);
     }
     if (DBNull.Value != reader["ImageUrl"])
     {
         info.ImageUrl = (string) reader["ImageUrl"];
     }
     if (DBNull.Value != reader["ThumbnailUrl40"])
     {
         info.ThumbnailUrl40 = (string) reader["ThumbnailUrl40"];
     }
     if (DBNull.Value != reader["ThumbnailUrl60"])
     {
         info.ThumbnailUrl60 = (string) reader["ThumbnailUrl60"];
     }
     if (DBNull.Value != reader["ThumbnailUrl100"])
     {
         info.ThumbnailUrl100 = (string) reader["ThumbnailUrl100"];
     }
     if (DBNull.Value != reader["ThumbnailUrl160"])
     {
         info.ThumbnailUrl160 = (string) reader["ThumbnailUrl160"];
     }
     if (DBNull.Value != reader["ThumbnailUrl180"])
     {
         info.ThumbnailUrl180 = (string) reader["ThumbnailUrl180"];
     }
     if (DBNull.Value != reader["ThumbnailUrl220"])
     {
         info.ThumbnailUrl220 = (string) reader["ThumbnailUrl220"];
     }
     if (DBNull.Value != reader["ThumbnailUrl310"])
     {
         info.ThumbnailUrl310 = (string) reader["ThumbnailUrl310"];
     }
     if (DBNull.Value != reader["ThumbnailUrl410"])
     {
         info.ThumbnailUrl410 = (string) reader["ThumbnailUrl410"];
     }
     if (DBNull.Value != reader["PurchasePrice"])
     {
         info.PurchasePrice = (decimal) reader["PurchasePrice"];
     }
     if (DBNull.Value != reader["MarketPrice"])
     {
         info.MarketPrice = new decimal?((decimal) reader["MarketPrice"]);
     }
     info.NeedPoint = (int) reader["NeedPoint"];
     info.IsDownLoad = (bool) reader["IsDownLoad"];
     return info;
 }
Пример #17
0
 public override GiftActionStatus CreateUpdateDeleteGift(GiftInfo gift, DataProviderAction action)
 {
     if (null == gift)
     {
         return GiftActionStatus.UnknowError;
     }
     DbCommand storedProcCommand = database.GetStoredProcCommand("cp_Gift_CreateUpdateDelete");
     database.AddInParameter(storedProcCommand, "Action", DbType.Int32, (int)action);
     database.AddOutParameter(storedProcCommand, "Status", DbType.Int32, 4);
     if (DataProviderAction.Create != action)
     {
         database.AddInParameter(storedProcCommand, "GiftId", DbType.Int32, gift.GiftId);
     }
     else
     {
         database.AddOutParameter(storedProcCommand, "GiftId", DbType.Int32, 4);
     }
     if (DataProviderAction.Delete != action)
     {
         database.AddInParameter(storedProcCommand, "Name", DbType.String, gift.Name);
         database.AddInParameter(storedProcCommand, "ShortDescription", DbType.String, gift.ShortDescription);
         database.AddInParameter(storedProcCommand, "Unit", DbType.String, gift.Unit);
         database.AddInParameter(storedProcCommand, "LongDescription", DbType.String, gift.LongDescription);
         database.AddInParameter(storedProcCommand, "Title", DbType.String, gift.Title);
         database.AddInParameter(storedProcCommand, "Meta_Description", DbType.String, gift.Meta_Description);
         database.AddInParameter(storedProcCommand, "Meta_Keywords", DbType.String, gift.Meta_Keywords);
         database.AddInParameter(storedProcCommand, "CostPrice", DbType.Currency, gift.CostPrice);
         database.AddInParameter(storedProcCommand, "ImageUrl", DbType.String, gift.ImageUrl);
         database.AddInParameter(storedProcCommand, "ThumbnailUrl40", DbType.String, gift.ThumbnailUrl40);
         database.AddInParameter(storedProcCommand, "ThumbnailUrl60", DbType.String, gift.ThumbnailUrl60);
         database.AddInParameter(storedProcCommand, "ThumbnailUrl100", DbType.String, gift.ThumbnailUrl100);
         database.AddInParameter(storedProcCommand, "ThumbnailUrl160", DbType.String, gift.ThumbnailUrl160);
         database.AddInParameter(storedProcCommand, "ThumbnailUrl180", DbType.String, gift.ThumbnailUrl180);
         database.AddInParameter(storedProcCommand, "ThumbnailUrl220", DbType.String, gift.ThumbnailUrl220);
         database.AddInParameter(storedProcCommand, "ThumbnailUrl310", DbType.String, gift.ThumbnailUrl310);
         database.AddInParameter(storedProcCommand, "ThumbnailUrl410", DbType.String, gift.ThumbnailUrl410);
         database.AddInParameter(storedProcCommand, "PurchasePrice", DbType.Currency, gift.PurchasePrice);
         database.AddInParameter(storedProcCommand, "MarketPrice", DbType.Currency, gift.MarketPrice);
         database.AddInParameter(storedProcCommand, "NeedPoint", DbType.Int32, gift.NeedPoint);
         database.AddInParameter(storedProcCommand, "IsDownLoad", DbType.Boolean, gift.IsDownLoad);
     }
     database.ExecuteNonQuery(storedProcCommand);
     return (GiftActionStatus)((int)database.GetParameterValue(storedProcCommand, "Status"));
 }