using System;
using System.Data;
using System.IO;
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 EnterpriseNET.BusinessLogicLayer;
using EnterpriseNET.DataAccessHelper;
using EnterpriseNET.CommonComponent;

public partial class enet0769_admin_add_project_case : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btn_Ok_Click(object sender, EventArgs e)
    {
        Hashtable ht = new Hashtable();
        ht.Add("ProjectName", SqlStringConstructor.GetQuotedString(ProjectName.Text));
        ht.Add("ProjectContent", SqlStringConstructor.GetQuotedString(FCKeditor1.Value));

        //附件名,以当前时间为文件名前缀,确保文件名没有重复
        string affixFileName = myfileAdd.Value.Trim();
        int ShowFileSize = Convert.ToInt32(myfileAdd.PostedFile.ContentLength.ToString()) / 1024;
        string ShowFileType = affixFileName.Substring(affixFileName.LastIndexOf(".") + 1).ToLower();
        int idx = affixFileName.LastIndexOf('\\');
        affixFileName = affixFileName.Substring(idx + 1);
        string fileName = "";
        if (affixFileName != "")
        {
            if (ShowFileType == "jpg" || ShowFileType == "swf" || ShowFileType == "gif" || ShowFileType == "bmp" || ShowFileType == "png" || ShowFileType == "xls" || ShowFileType == "xlsx" || ShowFileType == "doc" || ShowFileType == "docx" || ShowFileType == "pdf" || ShowFileType == "rar" || ShowFileType == "zip" || ShowFileType == "txt" || ShowFileType == "chm")
            {
                //Ticks属性的值为自 0001 年 1 月 1 日午夜 12:00 以来所经过时间以 100 毫微秒为间隔表示时的数字。
                //fileName = System.DateTime.Now.Ticks.ToString() + affixFileName;
                //fileName = affixFileName;
                fileName = System.DateTime.Now.Ticks.ToString() + "." + ShowFileType;
                ht.Add("PicPathBig", SqlStringConstructor.GetQuotedString(fileName));
                //ht.Add("FileSize", SqlStringConstructor.GetQuotedString(Convert.ToString(ShowFileSize)));
                //ht.Add("FileType", SqlStringConstructor.GetQuotedString(ShowFileType));

                myfileAdd.PostedFile.SaveAs(Server.MapPath("~//upimage//affix//") + fileName);

                ProjectCase projectCase = new ProjectCase();
                projectCase.Add(ht);

                Response.Redirect("add_project_case_prs.aspx");
            }
            else
            {
                Response.Write("<Script Language=JavaScript>alert(\"该文件不允许上传！\")</Script>");
            }
        }
        else
        {
            Response.Write("<Script Language=JavaScript>alert(\"请选择上传文件！\")</Script>");
        }

    
    }

   
}
