Example #1
0
 protected void btFile_Click(object sender, EventArgs e)
 {
     //ProductFile產品檔案
     if (fuFile.HasFile)
     {
         string filename       = WebUtility.ChangeFileNameAsRandom(fuFile.FileName);
         string ServerFilename = WebUtility.MergePathAndFileName(filename, Tools.GetAppSettings("ProductDLTempPath"));
         fuFile.SaveAs(ServerFilename);
         if (Session["pdinfo"] == null)
         {
             pdDlInfos = new List <ProductDownloadInfo>();
         }
         else
         {
             pdDlInfos = (List <ProductDownloadInfo>)Session["pdinfo"];
         }
         ProductDownloadInfo info = new ProductDownloadInfo();
         info.pd_name = filename;
         pdDlInfos.Add(info);
         tfBLL.InsertTempFiles("product", Tools.GetAppSettings("ProductDLTempPath") + filename);
         Session["pdinfo"]     = pdDlInfos;
         rpDownload.DataSource = pdDlInfos;
         rpDownload.DataBind();
     }
     else
     {
         this.ShowMessage(this.Getmessage("30011"));
     }
 }
Example #2
0
    public void Delete(int pd_id)
    {
        ProductDownloadInfo info = GetFileWithKey(pd_id);

        if (File.Exists(HttpContext.Current.Server.MapPath(Tools.GetAppSettings("ProductDLTruePath") + info.pd_name)))
        {
            File.Delete(HttpContext.Current.Server.MapPath(Tools.GetAppSettings("ProductDLTruePath") + info.pd_name));
        }
        db.Delete(pd_id);
    }
Example #3
0
    public List <ProductDownloadInfo> GetallFilesWithProduct(int p_id)
    {
        List <ProductDownloadInfo> infos = new List <ProductDownloadInfo>();
        IDataReader reader = db.GetallFilesWithProduct(p_id).CreateDataReader();

        while (reader.Read())
        {
            infos.Add(ProductDownloadInfo.Populate(reader));
        }
        return(infos);
    }
Example #4
0
    public ProductDownloadInfo GetFileWithKey(int pd_id)
    {
        ProductDownloadInfo info   = new ProductDownloadInfo();
        IDataReader         reader = db.GetFilesWithkey(pd_id).CreateDataReader();

        if (reader.Read())
        {
            info = ProductDownloadInfo.Populate(reader);
        }
        return(info);
    }
Example #5
0
 protected void rpDownload_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "Delete")
     {
         PddBLL.Delete(int.Parse(e.CommandArgument.ToString()));
     }
     if (e.CommandName == "Update")
     {
         ProductDownloadInfo info = PddBLL.GetFileWithKey(int.Parse(e.CommandArgument.ToString()));
         hfDownloadFile.Value = info.pd_name;
     }
     rpDownload.DataSource = PddBLL.GetallFilesWithProduct(Tools.GetInt32SafeFromQueryString(this.Page, "id", 0));
     rpDownload.DataBind();
 }
Example #6
0
 private void InsertProductDownload(int ProductID)
 {
     for (int i = 0; i < rpDownload.Items.Count; i++)
     {
         HyperLink          hyPath = (HyperLink)rpDownload.Items[i].FindControl("hytempPath");
         System.IO.FileInfo file   = new System.IO.FileInfo(Server.MapPath(hyPath.NavigateUrl));
         if (file.Exists)
         {
             file.CopyTo(Server.MapPath(Tools.GetAppSettings("ProductDLTruePath") + hyPath.Text));
         }
         ProductDownloadInfo pddInfo = new ProductDownloadInfo();
         pddInfo.p_id          = ProductID;
         pddInfo.pd_name       = hyPath.Text;
         pddInfo.pd_type       = hyPath.Text;
         pddInfo.pd_value      = "";
         pddInfo.pd_createdate = DateTime.Now;
         pddBLL.Insert(pddInfo);
     }
 }
Example #7
0
 protected void btFile_Click(object sender, EventArgs e)
 {
     if (fuFile.HasFile)
     {
         string filename       = WebUtility.ChangeFileNameAsRandom(fuFile.FileName);
         string ServerFilename = WebUtility.MergePathAndFileName(filename, Tools.GetAppSettings("ProductDLTruePath"));
         fuFile.SaveAs(ServerFilename);
         ProductDownloadInfo info = new ProductDownloadInfo();
         info.pd_name = filename;
         info.pd_type = filename;
         info.p_id    = Tools.GetInt32SafeFromQueryString(this.Page, "id", 0);
         PddBLL.Insert(info);
         rpDownload.DataSource = PddBLL.GetallFilesWithProduct(Tools.GetInt32SafeFromQueryString(this.Page, "id", 0));
         rpDownload.DataBind();
     }
     else
     {
         this.ShowMessage("請選擇一個檔案");
     }
 }
Example #8
0
 public int Insert(ProductDownloadInfo info)
 {
     return(db.Insert(info.p_id, info.pd_name, info.pd_type, info.pd_value, info.pd_createdate));
 }