Exemple #1
0
 public Maticsoft.Model.Shop.Gift.Gifts GetModel(int GiftId)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("select  top 1 GiftId,CategoryID,Name,ShortDescription,Unit,Weight,LongDescription,Title,Meta_Description,Meta_Keywords,ThumbnailsUrl,InFocusImageUrl,CostPrice,MarketPrice,SalePrice,Stock,NeedPoint,NeedGrade,SaleCounts,CreateDate,Enabled from Shop_Gifts ");
     builder.Append(" where GiftId=@GiftId");
     SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@GiftId", SqlDbType.Int, 4) };
     cmdParms[0].Value = GiftId;
     Maticsoft.Model.Shop.Gift.Gifts gifts = new Maticsoft.Model.Shop.Gift.Gifts();
     DataSet set = DbHelperSQL.Query(builder.ToString(), cmdParms);
     if (set.Tables[0].Rows.Count <= 0)
     {
         return null;
     }
     if ((set.Tables[0].Rows[0]["GiftId"] != null) && (set.Tables[0].Rows[0]["GiftId"].ToString() != ""))
     {
         gifts.GiftId = int.Parse(set.Tables[0].Rows[0]["GiftId"].ToString());
     }
     if ((set.Tables[0].Rows[0]["CategoryID"] != null) && (set.Tables[0].Rows[0]["CategoryID"].ToString() != ""))
     {
         gifts.CategoryID = int.Parse(set.Tables[0].Rows[0]["CategoryID"].ToString());
     }
     if ((set.Tables[0].Rows[0]["Name"] != null) && (set.Tables[0].Rows[0]["Name"].ToString() != ""))
     {
         gifts.Name = set.Tables[0].Rows[0]["Name"].ToString();
     }
     if ((set.Tables[0].Rows[0]["ShortDescription"] != null) && (set.Tables[0].Rows[0]["ShortDescription"].ToString() != ""))
     {
         gifts.ShortDescription = set.Tables[0].Rows[0]["ShortDescription"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Unit"] != null) && (set.Tables[0].Rows[0]["Unit"].ToString() != ""))
     {
         gifts.Unit = set.Tables[0].Rows[0]["Unit"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Weight"] != null) && (set.Tables[0].Rows[0]["Weight"].ToString() != ""))
     {
         gifts.Weight = int.Parse(set.Tables[0].Rows[0]["Weight"].ToString());
     }
     if ((set.Tables[0].Rows[0]["LongDescription"] != null) && (set.Tables[0].Rows[0]["LongDescription"].ToString() != ""))
     {
         gifts.LongDescription = set.Tables[0].Rows[0]["LongDescription"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Title"] != null) && (set.Tables[0].Rows[0]["Title"].ToString() != ""))
     {
         gifts.Title = set.Tables[0].Rows[0]["Title"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Meta_Description"] != null) && (set.Tables[0].Rows[0]["Meta_Description"].ToString() != ""))
     {
         gifts.Meta_Description = set.Tables[0].Rows[0]["Meta_Description"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Meta_Keywords"] != null) && (set.Tables[0].Rows[0]["Meta_Keywords"].ToString() != ""))
     {
         gifts.Meta_Keywords = set.Tables[0].Rows[0]["Meta_Keywords"].ToString();
     }
     if ((set.Tables[0].Rows[0]["ThumbnailsUrl"] != null) && (set.Tables[0].Rows[0]["ThumbnailsUrl"].ToString() != ""))
     {
         gifts.ThumbnailsUrl = set.Tables[0].Rows[0]["ThumbnailsUrl"].ToString();
     }
     if ((set.Tables[0].Rows[0]["InFocusImageUrl"] != null) && (set.Tables[0].Rows[0]["InFocusImageUrl"].ToString() != ""))
     {
         gifts.InFocusImageUrl = set.Tables[0].Rows[0]["InFocusImageUrl"].ToString();
     }
     if ((set.Tables[0].Rows[0]["CostPrice"] != null) && (set.Tables[0].Rows[0]["CostPrice"].ToString() != ""))
     {
         gifts.CostPrice = new decimal?(decimal.Parse(set.Tables[0].Rows[0]["CostPrice"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["MarketPrice"] != null) && (set.Tables[0].Rows[0]["MarketPrice"].ToString() != ""))
     {
         gifts.MarketPrice = new decimal?(decimal.Parse(set.Tables[0].Rows[0]["MarketPrice"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["SalePrice"] != null) && (set.Tables[0].Rows[0]["SalePrice"].ToString() != ""))
     {
         gifts.SalePrice = new decimal?(decimal.Parse(set.Tables[0].Rows[0]["SalePrice"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["Stock"] != null) && (set.Tables[0].Rows[0]["Stock"].ToString() != ""))
     {
         gifts.Stock = new int?(int.Parse(set.Tables[0].Rows[0]["Stock"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["NeedPoint"] != null) && (set.Tables[0].Rows[0]["NeedPoint"].ToString() != ""))
     {
         gifts.NeedPoint = int.Parse(set.Tables[0].Rows[0]["NeedPoint"].ToString());
     }
     if ((set.Tables[0].Rows[0]["NeedGrade"] != null) && (set.Tables[0].Rows[0]["NeedGrade"].ToString() != ""))
     {
         gifts.NeedGrade = int.Parse(set.Tables[0].Rows[0]["NeedGrade"].ToString());
     }
     if ((set.Tables[0].Rows[0]["SaleCounts"] != null) && (set.Tables[0].Rows[0]["SaleCounts"].ToString() != ""))
     {
         gifts.SaleCounts = int.Parse(set.Tables[0].Rows[0]["SaleCounts"].ToString());
     }
     if ((set.Tables[0].Rows[0]["CreateDate"] != null) && (set.Tables[0].Rows[0]["CreateDate"].ToString() != ""))
     {
         gifts.CreateDate = DateTime.Parse(set.Tables[0].Rows[0]["CreateDate"].ToString());
     }
     if ((set.Tables[0].Rows[0]["Enabled"] != null) && (set.Tables[0].Rows[0]["Enabled"].ToString() != ""))
     {
         if ((set.Tables[0].Rows[0]["Enabled"].ToString() == "1") || (set.Tables[0].Rows[0]["Enabled"].ToString().ToLower() == "true"))
         {
             gifts.Enabled = true;
             return gifts;
         }
         gifts.Enabled = false;
     }
     return gifts;
 }
Exemple #2
0
 private void GetProdictInfo()
 {
     int num = 0;
     if (!string.IsNullOrWhiteSpace(this.DropParentId.SelectedValue.Trim()))
     {
         num = int.Parse(this.DropParentId.SelectedValue);
     }
     string text = this.txtProductName.Text;
     string str2 = this.txtUnit.Text;
     decimal? nullable = new decimal?(Globals.SafeDecimal(this.txtMarketPrice.Text, (decimal) 0M));
     decimal? nullable2 = new decimal?(Globals.SafeDecimal(this.txtCostPrice.Text, (decimal) 0M));
     decimal? nullable3 = new decimal?(Globals.SafeDecimal(this.txtSalePrice.Text, (decimal) 0M));
     int num2 = Globals.SafeInt(this.txtWeight.Text, 0);
     int num3 = Globals.SafeInt(this.txtStock.Text, 0);
     int num4 = Globals.SafeInt(this.txtPoints.Text, 0);
     string str3 = this.txtShortDescription.Text;
     string str4 = this.txtDescription.Text;
     string str5 = this.txtMeta_Title.Text;
     string str6 = this.txtMeta_Description.Text;
     string str7 = this.txtMeta_Keywords.Text;
     string format = this.hfImage.Value;
     string str9 = this.thfImage.Value;
     if (!string.IsNullOrWhiteSpace(str3))
     {
         str3 = Globals.HtmlEncodeForSpaceWrap(str3);
     }
     Maticsoft.Model.Shop.Gift.Gifts model = new Maticsoft.Model.Shop.Gift.Gifts {
         Name = text,
         CategoryID = num,
         Unit = str2,
         CostPrice = nullable2,
         NeedPoint = num4,
         SaleCounts = 0,
         SalePrice = nullable3,
         Stock = new int?(num3),
         Weight = num2,
         MarketPrice = nullable,
         CreateDate = DateTime.Now,
         Enabled = Globals.SafeBool(this.rblUpselling.SelectedValue, false),
         ShortDescription = str3,
         LongDescription = str4,
         Title = str5,
         Meta_Description = str6,
         Meta_Keywords = str7,
         ThumbnailsUrl = string.Format(format, ""),
         InFocusImageUrl = string.Format(str9, "T_")
     };
     if (this.GiftBll.Add(model) > 0)
     {
         base.Response.Redirect("GiftsList.aspx");
     }
     else
     {
         MessageBox.Show(this, "保存失败! 请重试.");
     }
 }
Exemple #3
0
 public List<Maticsoft.Model.Shop.Gift.Gifts> DataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.Shop.Gift.Gifts> list = new List<Maticsoft.Model.Shop.Gift.Gifts>();
     int count = dt.Rows.Count;
     if (count > 0)
     {
         for (int i = 0; i < count; i++)
         {
             Maticsoft.Model.Shop.Gift.Gifts item = new Maticsoft.Model.Shop.Gift.Gifts();
             if ((dt.Rows[i]["GiftId"] != null) && (dt.Rows[i]["GiftId"].ToString() != ""))
             {
                 item.GiftId = int.Parse(dt.Rows[i]["GiftId"].ToString());
             }
             if ((dt.Rows[i]["CategoryID"] != null) && (dt.Rows[i]["CategoryID"].ToString() != ""))
             {
                 item.CategoryID = int.Parse(dt.Rows[i]["CategoryID"].ToString());
             }
             if ((dt.Rows[i]["Name"] != null) && (dt.Rows[i]["Name"].ToString() != ""))
             {
                 item.Name = dt.Rows[i]["Name"].ToString();
             }
             if ((dt.Rows[i]["ShortDescription"] != null) && (dt.Rows[i]["ShortDescription"].ToString() != ""))
             {
                 item.ShortDescription = dt.Rows[i]["ShortDescription"].ToString();
             }
             if ((dt.Rows[i]["Unit"] != null) && (dt.Rows[i]["Unit"].ToString() != ""))
             {
                 item.Unit = dt.Rows[i]["Unit"].ToString();
             }
             if ((dt.Rows[i]["Weight"] != null) && (dt.Rows[i]["Weight"].ToString() != ""))
             {
                 item.Weight = int.Parse(dt.Rows[i]["Weight"].ToString());
             }
             if ((dt.Rows[i]["LongDescription"] != null) && (dt.Rows[i]["LongDescription"].ToString() != ""))
             {
                 item.LongDescription = dt.Rows[i]["LongDescription"].ToString();
             }
             if ((dt.Rows[i]["Title"] != null) && (dt.Rows[i]["Title"].ToString() != ""))
             {
                 item.Title = dt.Rows[i]["Title"].ToString();
             }
             if ((dt.Rows[i]["Meta_Description"] != null) && (dt.Rows[i]["Meta_Description"].ToString() != ""))
             {
                 item.Meta_Description = dt.Rows[i]["Meta_Description"].ToString();
             }
             if ((dt.Rows[i]["Meta_Keywords"] != null) && (dt.Rows[i]["Meta_Keywords"].ToString() != ""))
             {
                 item.Meta_Keywords = dt.Rows[i]["Meta_Keywords"].ToString();
             }
             if ((dt.Rows[i]["ThumbnailsUrl"] != null) && (dt.Rows[i]["ThumbnailsUrl"].ToString() != ""))
             {
                 item.ThumbnailsUrl = dt.Rows[i]["ThumbnailsUrl"].ToString();
             }
             if ((dt.Rows[i]["InFocusImageUrl"] != null) && (dt.Rows[i]["InFocusImageUrl"].ToString() != ""))
             {
                 item.InFocusImageUrl = dt.Rows[i]["InFocusImageUrl"].ToString();
             }
             if ((dt.Rows[i]["CostPrice"] != null) && (dt.Rows[i]["CostPrice"].ToString() != ""))
             {
                 item.CostPrice = new decimal?(decimal.Parse(dt.Rows[i]["CostPrice"].ToString()));
             }
             if ((dt.Rows[i]["MarketPrice"] != null) && (dt.Rows[i]["MarketPrice"].ToString() != ""))
             {
                 item.MarketPrice = new decimal?(decimal.Parse(dt.Rows[i]["MarketPrice"].ToString()));
             }
             if ((dt.Rows[i]["SalePrice"] != null) && (dt.Rows[i]["SalePrice"].ToString() != ""))
             {
                 item.SalePrice = new decimal?(decimal.Parse(dt.Rows[i]["SalePrice"].ToString()));
             }
             if ((dt.Rows[i]["Stock"] != null) && (dt.Rows[i]["Stock"].ToString() != ""))
             {
                 item.Stock = new int?(int.Parse(dt.Rows[i]["Stock"].ToString()));
             }
             if ((dt.Rows[i]["NeedPoint"] != null) && (dt.Rows[i]["NeedPoint"].ToString() != ""))
             {
                 item.NeedPoint = int.Parse(dt.Rows[i]["NeedPoint"].ToString());
             }
             if ((dt.Rows[i]["NeedGrade"] != null) && (dt.Rows[i]["NeedGrade"].ToString() != ""))
             {
                 item.NeedGrade = int.Parse(dt.Rows[i]["NeedGrade"].ToString());
             }
             if ((dt.Rows[i]["SaleCounts"] != null) && (dt.Rows[i]["SaleCounts"].ToString() != ""))
             {
                 item.SaleCounts = int.Parse(dt.Rows[i]["SaleCounts"].ToString());
             }
             if ((dt.Rows[i]["CreateDate"] != null) && (dt.Rows[i]["CreateDate"].ToString() != ""))
             {
                 item.CreateDate = DateTime.Parse(dt.Rows[i]["CreateDate"].ToString());
             }
             if ((dt.Rows[i]["Enabled"] != null) && (dt.Rows[i]["Enabled"].ToString() != ""))
             {
                 if ((dt.Rows[i]["Enabled"].ToString() == "1") || (dt.Rows[i]["Enabled"].ToString().ToLower() == "true"))
                 {
                     item.Enabled = true;
                 }
                 else
                 {
                     item.Enabled = false;
                 }
             }
             list.Add(item);
         }
     }
     return list;
 }