using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Mall.Member
{
    public partial class Member_Fav : System.Web.UI.Page
    {
       public string str_html = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            BLL.Models.MemberModels models_member = new BLL.Models.MemberModels();
            string _Username = models_member.CheckUserId();
            string _userid = models_member.GetuserInfoByFiter(" 1=1 and username='" + _Username + "' ").Rows[0]["id"].ToString();
            BLL.Models.MCartModels models_cart = new BLL.Models.MCartModels();
            string _id = Request["id"] == null ? string.Empty : Request["id"].ToString();
            string _edit = Request["edit"] == null ? string.Empty : Request["edit"].ToString();
            if (string.IsNullOrEmpty(_id) != true || _edit == "ok")
            {
                models_member.SetFav(_userid, _id);
            }
            string favs = models_cart.GetMyFav(_userid);
            
            StringBuilder str_htmlb = new StringBuilder();
            if (string.IsNullOrEmpty(favs))
            {

                str_htmlb.Append("<tr bgcolor='#FFFFFF'><td colspan='6' height='30' align='center' valign='middle'>暂无内容</td></tr> ");

            }
            else
            {
                BLL.Models.ProductModels model_product = new BLL.Models.ProductModels();
                DataTable dt = new DataTable();
                dt = model_product.GetProductByFiter("0", " id in (" + "0" + favs + ") ");
                foreach (DataRow dr in dt.Rows)
                {

                    str_htmlb.Append("<tr bgcolor='#FFFFFF'><td height='30' align='center' valign='middle'> <input name='Id' type='CheckBox' value='");
                    str_htmlb.Append(dr["id"].ToString());
                    str_htmlb.Append("' checked></td>");
                    str_htmlb.Append("<td height='30' align='center' valign='middle'><font color='B0266D'><A href='/index/views?ProductId=");
                    str_htmlb.Append(dr["id"].ToString());
                    str_htmlb.Append(" ' target=_blank>");
                    str_htmlb.Append(dr["productname"].ToString());
                    str_htmlb.Append("</a></font></td><td align='center' class='shich_cont'>");
                    str_htmlb.Append((Convert.ToDecimal(dr["price"].ToString()) * Convert.ToDecimal("1.3")).ToString());
                    str_htmlb.Append("</td>");
                    str_htmlb.Append("<td align='center'><font color='#FF0000'><SPAN class=hy_cont><font color=#FF3300>");
                    str_htmlb.Append(dr["price"].ToString());
                    str_htmlb.Append("</font></SPAN></font></td></tr>");

                }



            }
            str_html = str_htmlb.ToString();
           

        }
    }
}