using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Mall.MCScriptManageServices
{
    public partial class AddProduct : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //["ID", "ProductName", "ClassId", "Price", "State", "Stock", "Brand", 
            //"Img_Logo", "Img_Big", "Intro", "Content", "AddDate", "ClickCount", "BuyCount", "UserName", "Point", "IsHtml", "Url"];
            string _ProductName = Request["ProductName"] == null ? "0" : Request["ProductName"].ToString();
            string _ClassId = Request["ClassId"] == null ? "" : Request["ClassId"].ToString();
            string _Price = Request["Price"] == null ? "0" : Request["Price"].ToString();
            string _State = Request["State"] == null ? "0" : Request["State"].ToString();
            string _Stock = Request["Stock"] == null ? "0" : Request["Stock"].ToString();
            string _Brand = Request["Brand"] == null ? "0" : Request["Brand"].ToString();
            string _Img_Logo = Request["Img_Logo"] == null ? "" : Request["Img_Logo"].ToString();
            string _Img_Big = Request["Img_Big"] == null ? "" : Request["Img_Big"].ToString();
            string _Intro = Request["Intro"] == null ? "" : Request["Intro"].ToString();
            string _Content = Request["Content"] == null ? "" : Request["Content"].ToString();
            string _AddDate = Request["AddDate"] == null ? DateTime.Now.ToString() : Request["AddDate"].ToString();
            string _ClickCount = Request["ClickCount"] == null ? "0" : Request["ClickCount"].ToString();
            string _BuyCount = Request["BuyCount"] == null ? "" : Request["BuyCount"].ToString();
            string _UserName = Request["UserName"] == null ? "0" : Request["UserName"].ToString();
            string _Point = Request["Point"] == null ? "0" : Request["Point"].ToString();
            string _IsHtml = Request["IsHtml"] == null ? "0" : Request["IsHtml"].ToString();
            string _Url = Request["Url"] == null ? "" : Request["Url"].ToString();
            string _IntroMore = Request["IntroMore"] == null ? "" : Request["IntroMore"].ToString();
            MODEL.MProduct modelp = new MODEL.MProduct();

            modelp.ProductName = _ProductName;
            modelp.Classid = Convert.ToInt32(_ClassId);
            modelp.Price = Convert.ToInt32(_Price);
            modelp.State = Convert.ToInt32(_State);
            modelp.Stock = Convert.ToInt32(_Stock);
            modelp.Brand = Convert.ToInt32(_Brand);
            modelp.Img_Logo = _Img_Logo;
            modelp.Img_Big = _Img_Big;
            modelp.Intro = _Intro.Replace("\r\n", "</br>").Replace("\r", "").Replace("\n", "");
            modelp.Content = _Content.Replace("\r\n", "</br>").Replace("\r", "").Replace("\n", "");
            modelp.AddDate = DateTime.Now;
            modelp.ClickCount = Convert.ToInt32(_ClickCount);
            modelp.BuyCount = Convert.ToInt32(_BuyCount);
            modelp.UserName = Convert.ToInt32(_UserName);
            modelp.Point = Convert.ToInt32(_Point);
            modelp.IntroMore = _IntroMore.Replace("\r\n", "</br>").Replace("\r", "").Replace("\n", "");
            modelp.IsHtml = false;
            modelp.Url = _Url;
            BLL.Models.ProductModels modelsps = new BLL.Models.ProductModels();
            bool ret = modelsps.AddProduct(modelp);
            string jsons = string.Empty;
            if (ret)
            {

                jsons = "{success:'true'}";

            }
            else
            {

                jsons = "{success:'false'}";
            }
            Response.Write(jsons);
        }
    }
}