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

public partial class webXabara_shop_popAdd : System.Web.UI.Page
{
    XabaraCom xc = new XabaraCom();
    dbDataFunction db = new dbDataFunction();
    webPublic wp = new webPublic();

    protected void Page_Load(object sender, EventArgs e)
    {        
        xc.CheckAdminLogin("");

        if (!IsPostBack)
        {
            FormCheck fCheck = new FormCheck();
            idRegExpre.ValidationExpression = fCheck.RegExpressionValidator("number", 0, 0, false);
            idRegExpre.ErrorMessage = fCheck.RegExpressionValidator("number", 0, 0, true);
            dayRegExpre.ValidationExpression = fCheck.RegExpressionValidator("number", 0, 0, false);
            dayRegExpre.ErrorMessage = fCheck.RegExpressionValidator("number", 0, 0, true);
        }
    }

    protected void taobaoKe_Click(object sender, EventArgs e)
    {
        DataTable dt;
        //订单系统中的唯一订单号匹配
        string payID = DateTime.Now.ToString("yyyyMMddHHmmss") + xc.GetRnd("123", 5);
        string num_iid = ids.Text.Trim();
        string[] strValue = new string[20];

        //插入预订商品
        string strDim = "@payID,@keyWord,@num_iid,@buyDays,@adFrom,@adTo,@postDate,@postIP,@postID,@flagID";

        strValue[0] = payID;
        strValue[1] = keyWord.Text;
        strValue[2] = num_iid;
        strValue[3] = days.Text;
        strValue[4] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        strValue[5] = DateTime.Now.AddDays(xc.SafeNum(days.Text)).ToString("yyyy-MM-dd HH:mm:ss");
        strValue[6] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        strValue[7] = xc.GetIP();
        strValue[8] = "sys";
        strValue[9] = "1";

        dt = db.getDataTable("select * from taobaopop where num_iid=" + num_iid);
        if (dt.Rows.Count > 0)
        {
            db.InsertUpdateDB("taobaopop", strDim, strValue, "num_iid=" + num_iid);
        }
        else
        {
            db.InsertUpdateDB("taobaopop", strDim, strValue, "");
        }
        dt.Dispose();

        wp.insertPOP(num_iid, xc.SafeNum(days.Text));

        Response.Redirect("pop.aspx", true);
    }
}