示例#1
0
 protected void Insert_fields(object sender, EntityDataSourceChangingEventArgs e)
 {
     YASA_PL.Customer_Files c = (YASA_PL.Customer_Files)e.Entity;
     if (c != null)
     {
         c.Date_created_modified = DateTime.Now;
         if (c.filePath != null)
         {
             c.File_extension = c.filePath.Substring(c.filePath.LastIndexOf(".") + 1).ToLower();
             //add file size information
             String             fileUrl = "~/files/" + c.filePath;
             String             path    = Server.MapPath(fileUrl);
             System.IO.FileInfo fi      = null;
             fi          = new System.IO.FileInfo(path);
             c.File_size = Math.Round(Convert.ToDecimal(fi.Length / 1048576), 2);
         }
         if (c.Customer_OrderId != null)
         {
             redirectlink = "~/Customer_OrderSet/Details.aspx?Id=" + c.Customer_OrderId + "&fileedited=true";
         }
         if (c.Customer_Part_IndexId != null)
         {
             redirectlink = "~/Customer_Part_IndexSet/Details.aspx?Id=" + c.Customer_Part_IndexId + "&fileedited=true";
         }
         if (c.Customer_Product_IndexId != null)
         {
             redirectlink = "~/Customer_Product_IndexSet/Details.aspx?Id=" + c.Customer_Product_IndexId + "&fileedited=true";
         }
     }
 }
 protected void Insert_fields(object sender, EntityDataSourceChangingEventArgs e)
 {
     YASA_PL.Customer_Files c = (YASA_PL.Customer_Files)e.Entity;
     if (c != null)
     {
         c.UserId = Convert.ToInt32(HttpContext.Current.User.Identity.Name);
         c.Date_created_modified = DateTime.Now;
         if (c.filePath != null)
         {
             c.File_extension = c.filePath.Substring(c.filePath.LastIndexOf(".") + 1).ToLower();
             //add file size information
             String             fileUrl = "~/files/" + c.filePath;
             String             path    = Server.MapPath(fileUrl);
             System.IO.FileInfo fi      = null;
             fi          = new System.IO.FileInfo(path);
             c.File_size = Math.Round(Convert.ToDecimal(fi.Length / 1048576.0), 2);
         }
     }
 }