using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
//李斌 环球团队
namespace PanRoor
{
    public partial class XML : XMLX
    {
        XMLX bind = new XMLX();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["WtoRightName"] == null)
            {
                Response.Redirect("~/SYSADMIN/main/error.aspx?err=非法登陆!或系统超时，请刷新后重新登录");
            }
            if (!IsPostBack)
            {
                rb_NoAndOff.SelectedValue = bind.XMLRead("NoAndOff");
                this.Label1.Text = bind.XMLRead("DrawedImagePath");
                tb_Transparence.Text = bind.XMLRead("LucencyPercent");
                PicVal.Text = bind.XMLRead("PicVal");
                tb_PlaceX.Text = bind.XMLRead("RightSpace");
                tb_PlaceY.Text = bind.XMLRead("BottoamSpace");
            }
        }

        protected void But_Save_Click1(object sender, EventArgs e)
        {
            try
            {
                if (Convert.ToInt32(tb_Transparence.Text) > 100)
                {
                    Response.Write("<script>alert('透明度不支持大于100，请重设！');window.close()</script>");
                }

                else
                {
                    string fnameleft = this.img.FileName;
                    if (fnameleft != "")
                    {
                        string fpathleft = this.img.PostedFile.FileName;
                        string ftypeleft = this.img.PostedFile.ContentType;
                        string[] typeleft = ftypeleft.Split('/');
                        string[] fnleft = fnameleft.Split('.');
                        if (typeleft[0].ToString() != "image")
                        {
                            Response.Write("文件格式错误！");
                        }
                        else
                        {
                            string ptleft = Server.MapPath("~/upfile/Watermark/logo_cn.gif");
                            this.img.SaveAs(ptleft);
                            this.img.Dispose();
                        }

                    }
                        bind.CreateXML(rb_NoAndOff.SelectedValue, Label1.Text, tb_Transparence.Text, PicVal.Text, tb_PlaceX.Text, tb_PlaceY.Text);

                    Response.Write("<script>alert('保存成功！');window.close()</script>");
                }
            }
            catch
            {
                Response.Write("<script>alert('保存失败！');window.close()</script>");
            }
        }
    }
}