protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (string.IsNullOrEmpty(MSG)) { sourceFile = BP.WF.Glo.CCFlowAppPath + "DataUser/ImgAth/Def.jpg"; string myPK = this.ImgAths + "_" + this.MyPK; BP.Sys.FrmImgAthDB imgDB = new BP.Sys.FrmImgAthDB(); imgDB.MyPK = myPK; imgDB.RetrieveFromDBSources(); if (imgDB != null && !string.IsNullOrEmpty(imgDB.FileFullName)) { if (System.IO.File.Exists(Server.MapPath(imgDB.FileFullName))) { sourceFile = imgDB.FileFullName; } } sourceImg.Value = sourceFile; newImgUrl.Value = sourceFile; Page.ClientScript.RegisterStartupScript(this.GetType(), "js", "<script>ImageCut('" + sourceFile + "','" + W + "','" + H + "' )</script>"); } else { sourceImg.Value = MSG; newImgUrl.Value = MSG; Page.ClientScript.RegisterStartupScript(this.GetType(), "js", "<script>ImageCut('" + MSG + "','" + W + "','" + H + "' )</script>"); } } }
//确定按钮 protected void btnSubmit_Click(object sender, EventArgs e) { sourceFile = sourceImg.Value; string myName = this.ImgAths + "_" + this.MyPK; string type = sourceFile.Substring(sourceFile.LastIndexOf(".") + 1); //得到文件后缀名 FileInfo fileInfo = new FileInfo(Server.MapPath(sourceFile)); float fileSize = 0; if (fileInfo.Exists) { fileSize = float.Parse(fileInfo.Length.ToString()); } BP.Sys.FrmImgAthDB imgDB = new BP.Sys.FrmImgAthDB(); imgDB.FK_MapData = this.FK_MapData; imgDB.FK_FrmImgAth = this.ImgAths; imgDB.RefPKVal = this.MyPK; imgDB.FileFullName = sourceFile; imgDB.FileName = myName; imgDB.FileExts = type; imgDB.FileSize = fileSize; imgDB.RDT = DateTime.Now.ToString("yyyy-MM-dd mm:HH"); imgDB.Rec = BP.Web.WebUser.No; imgDB.RecName = BP.Web.WebUser.Name; try { imgDB.Save(); } catch { imgDB.CheckPhysicsTable(); imgDB.Save(); } CopyFile(newImgUrl.Value, BP.WF.Glo.CCFlowAppPath + "DataUser/ImgAth/Data/" + myName + ".png"); this.WinClose(newImgUrl.Value); }