protected void Page_Load(object sender, EventArgs e) { string sn = ""; string id = ""; if (Request.QueryString["sn"] != null && Request.QueryString["id"] != null) { sn = Request.QueryString["sn"].ToString(); id = Request.QueryString["id"].ToString(); if (!IsPostBack) { this.dsCont.FilterExpression = "JobNo='" + sn + "'"; this.dsContTrip.FilterExpression = "JobNo='" + sn + "'"; Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(C2.CtmAttachment), "Id='" + id + "'"); C2.CtmAttachment obj = C2.Manager.ORManager.GetObject(query) as C2.CtmAttachment; DataTable tab = new DataTable(); tab.Columns.Add("RefNo"); tab.Columns.Add("ContainerNo"); tab.Columns.Add("TripId"); tab.Columns.Add("FileName"); tab.Columns.Add("FileNote"); tab.Columns.Add("FilePath"); tab.Columns.Add("ImgPath"); string path = obj.FilePath; string filePath = obj.FilePath; string imgPath = obj.ImgPath; string uploadType = obj.FileType; string url = Request.Url.ToString().Replace("http://", ""); //if (url.IndexOf("192.168") == -1) //imgPath = "http://" + url.Substring(0, url.IndexOf("/")) + imgPath.ToLower().Replace(".jpg", "_thumb.jpg"); if (uploadType.ToLower() != "image") { imgPath = "http://" + url.Substring(0, url.IndexOf("/")) + "/Images/LOGO.jpg"; } //filePath = "http://" + url.Substring(0, url.IndexOf("/")) + filePath; DataRow row = tab.NewRow(); row["RefNo"] = sn; row["ContainerNo"] = obj.ContainerNo; row["TripId"] = obj.TripId; row["FileName"] = obj.FileName; row["FileNote"] = obj.FileNote; row["ImgPath"] = imgPath; row["FilePath"] = filePath; tab.Rows.Add(row); this.grid.DataSource = tab; this.grid.DataBind(); } OnLoad(sn); } }
public void AddFile(string type, string code, string _name, string desc) { C2.CtmAttachment photo = new C2.CtmAttachment(); photo.JobType = Request.QueryString["Type"].ToString(); photo.FileName = _name; photo.RefNo = cmb_DoNo.Text; photo.ContainerNo = SafeValue.SafeString(Request.QueryString["ContNo"]); //photo.conterno = cmb_ContNo.Text; photo.JobNo = code; photo.FileNote = desc; photo.FileType = type; photo.FilePath = GetFilePath(this.txt_Sn.Text, this.cmb_ContNo.Text, this.cmb_DoNo.Text) + _name; photo.CreateBy = HttpContext.Current.User.Identity.Name; photo.CreateDateTime = DateTime.Now.ToLocalTime(); Manager.ORManager.StartTracking(photo, Wilson.ORMapper.InitialState.Inserted); Manager.ORManager.PersistChanges(photo); }
private string UploadFile() { string s = "Save Successful!"; try { int id = SafeValue.SafeInt(Request.QueryString["id"], 0); for (int i = 0; i < list.Count; i++) { try { string sn = list[i].sn; string contNo = list[i].contNo; string doNo = list[i].doNo; string fileName = list[i].fileName; string rmk = list[i].rmk; //string path = photo.MoveFile(sn, contNo, doNo, fileName); C2.CtmAttachment job = C2.Manager.ORManager.GetObject <C2.CtmAttachment>(id); //job.OrderNo = sn; job.ContainerNo = contNo; job.TripId = SafeValue.SafeInt(doNo, 0); //job.Name = fileName; //job.Path = path; //if (fileName.Substring(index + 1).ToLower() == "pdf") // job.UploadType = "File"; //else // job.UploadType = "image"; job.FileNote = rmk; C2.Manager.ORManager.StartTracking(job, Wilson.ORMapper.InitialState.Updated); C2.Manager.ORManager.PersistChanges(job); } catch (Exception ex) { } } } catch (Exception ex) { s = "Save Fail!" + ex.Message; } return(s); }