protected string GetAttachName(int ID) { LabMS.BLL.Attachment att = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attModel = new LabMS.Model.Attachment(); attModel = att.GetModel(ID); return attModel.Attach_Name; }
/// <summary> /// 返回一个AttachmentID /// </summary> /// <param></param> /// <returns></returns> protected int AttachmentSave() { int Attach_ID = 0; bool saved=false; if (HttpContext.Current.Request.Files.Count - 1 > 0) { try { int count = HttpContext.Current.Request.Files.Count; HttpFileCollection Files = HttpContext.Current.Request.Files; string savePath = HttpContext.Current.Request.MapPath(@"../Content/UpLoadFile/"); List<string> fileName = LabMS.Common.FileUpload.SaveFiles(Files, savePath); LabMS.BLL.Attachment Attachment = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attachmentmodel = new LabMS.Model.Attachment(); Attach_ID = Attachment.Add(attachmentmodel); if (Attach_ID != 0) { LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem(); LabMS.Model.AttachmentItem attachmentitemmodel; for (int n = 0; n < fileName.Count; n++) { if (fileName[n].Trim() != "") { attachmentitemmodel = new LabMS.Model.AttachmentItem(); attachmentitemmodel.Attach_ID = Attach_ID; attachmentitemmodel.Item_Address = "Content/UpLoadFile/" + fileName[n].Trim(); attachmentitemmodel.Item_Name = fileName[n].Substring(0, fileName[0].LastIndexOf("_")); attachmentitemmodel.Item_Type = "3"; AttachItem.Add(attachmentitemmodel); } } } saved = true; } catch (Exception ex) { lbErr.Text = ex.Message; } finally { if (saved == false) { } } } return Attach_ID; }
protected int UpLoadFile() { string savePath = HttpContext.Current.Request.MapPath(@"../Content/UpLoadFile/"); string Append = DateTime.Now.ToString("yyyyMMddhhmmss"); string FullPathFileName = savePath.Trim() + Append.Trim() + "_" + fp_Attachment.FileName.Trim(); int fileLength = fp_Attachment.PostedFile.ContentLength; if (fileLength == 0) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('文件:" + fp_Attachment.FileName + "为空文件,请重新上传!')</script>"); return 0; } else if (fileLength > 2000 * 1024) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('文件:" + fp_Attachment.FileName + "太大!,请重新上传')</script>"); return -1; } int attachID = -2; bool save = false; if (fp_Attachment.HasFile) { try { save = true; fp_Attachment.SaveAs(FullPathFileName); } catch { save = false; throw new Exception("File Save Error"); } } if (save) { LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attach = new LabMS.Model.Attachment(); attach.Attach_Name = fp_Attachment.FileName; attach.Attach_Address = "Content/UpLoadFile/" + fp_Attachment.FileName + "_" + Append.Trim() + fp_Attachment.FileName.Substring(fp_Attachment.FileName.LastIndexOf(".")); attach.Attach_Type = "1"; attachID = Attach.Add(attach); } return attachID; }
/// <summary> /// -1 ���ļ� -2 ��С����2M -3 û���ļ��ϴ� /// </summary> /// <returns></returns> protected int UpLoadFile() { if (fp_Attachment.HasFile) { string savePath = HttpContext.Current.Request.MapPath(@"../Content/UpLoadFile/"); string Append = DateTime.Now.ToString("yyyyMMddhhmmss"); string FullPathFileName = savePath.Trim() + fp_Attachment.FileName.Trim() + "_" + Append.Trim() + fp_Attachment.FileName.Substring(fp_Attachment.FileName.LastIndexOf(".")); int attachID = 0; int fileLength = fp_Attachment.PostedFile.ContentLength; bool save = false; try { if (fileLength == 0) { LabMS.Common.JShelper.JSAlert(Page, "FileFailed", "�ļ���" + fp_Attachment.FileName + "�ϴ�ʧ��,��Ϊ���ļ�Ϊ���ļ�!"); return -1; } else if (fileLength > 2000 * 1024) { LabMS.Common.JShelper.JSAlert(Page, "FileFailed", "�ļ���" + fp_Attachment.FileName + "�ϴ�ʧ��,��Ϊ���ļ���С����2M!"); return -2; } fp_Attachment.SaveAs(FullPathFileName); save = true; } catch { save = false; throw new Exception("File Save Error"); } if (save) { LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attach = new LabMS.Model.Attachment(); attach.Attach_Name = fp_Attachment.FileName; attach.Attach_Address = "Content/UpLoadFile/" + fp_Attachment.FileName + "_" + Append.Trim() + fp_Attachment.FileName.Substring(fp_Attachment.FileName.LastIndexOf(".")); attach.Attach_Type = "1"; attachID = Attach.Add(attach); //�γ̴�� } return attachID; } else { return -3; } }
/// <summary> /// -1 QueryID<0 0 Delete Error 1 Sucess /// </summary> /// <param name="QueryID"></param> /// <returns></returns> private int GuideBookDelete(int QueryID) { if (QueryID > 0) { try { LabMS.BLL.GuideBook GuideBook = new LabMS.BLL.GuideBook(); LabMS.Model.GuideBook GuideBookModel; List<LabMS.Model.GuideBook> ls = GuideBook.GetModelList("Guide_ProjectID=" + QueryID); if (ls.Count > 0) { GuideBookModel = ls[0]; if (GuideBookModel != null) { int? AttachID = GuideBookModel.Guide_AttachID; GuideBook.Delete(GuideBookModel.ID); if (AttachID.HasValue) { LabMS.BLL.Attachment Attachment = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attachmodel = Attachment.GetModel(AttachID.Value); if (attachmodel != null) { Attachment.Delete(attachmodel.ID); } } return 1; } } } catch(Exception ex) { return 0; } } return -1; }
protected void DataBinds() { if (QueryString != HF_QueryString || QueryString <= 0 || HF_QueryString <= 0) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('��ѯ�ַ�������');window.location.href='ProjectList.aspx';</script>"); return; } bool Ok=false; if (QueryString > 0) { try { LabMS.BLL.Project Project = new LabMS.BLL.Project(); LabMS.Model.Project projectmodel = Project.GetModel(QueryString); if (projectmodel != null) { LabMS.BLL.GuideBook GuideBook = new LabMS.BLL.GuideBook(); List<LabMS.Model.GuideBook> bookmodellist = GuideBook.GetModelList("Guide_ProjectID=" + QueryString.ToString()); if (bookmodellist.Count != 0) { LabMS.Model.GuideBook bookmodel = bookmodellist[0]; lb_Code.Text = bookmodel.Guide_BookCode; lb_Name.Text = bookmodel.Guide_BookName; lb_Editor.Text = bookmodel.Guide_Editor; lb_Press.Text = bookmodel.Guide_Editor; if (bookmodel.Guide_PublishTime != null) { lb_PublishTime.Text = bookmodel.Guide_PublishTime.Value.ToString("yyyy-MM"); } lb_Award.Text = bookmodel.Guide_Award; lt_Content.Text = bookmodel.Guide_Content; if (bookmodel.Guide_AttachID != null) { if (bookmodel.Guide_AttachID != 0) { LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment(); List<LabMS.Model.Attachment> lsModel = Attach.GetModelList("ID="+bookmodel.Guide_AttachID+" and Attach_Type= 2"); if (lsModel.Count != 0) { lk_DownLoad.Text = lsModel[0].Attach_Name; lk_DownLoad.CommandArgument = lsModel[0].ID.ToString() ; } else { lk_DownLoad.Visible = false; } } } } } } catch (Exception ex) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('���ݿ��ȡ����');window.location.href='ProjectList.aspx';</script>"); return; } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["ID"]) && Request.QueryString["Flag"] == "download") { if (!IsNumber(Request.QueryString["ID"])) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('查询字符串错误');window.close();</script>"); return; } LabMS.BLL.AttachmentItem attachItem = new LabMS.BLL.AttachmentItem(); LabMS.Model.AttachmentItem attachmodel = new LabMS.Model.AttachmentItem(); attachmodel = attachItem.GetModel(int.Parse(Request.QueryString["ID"].Trim())); FileItemDownload(attachmodel.ID, attachmodel.Item_Address, attachmodel.Item_Name); return; } else if (!string.IsNullOrEmpty(Request.QueryString["ID"]) && Request.QueryString["Flag"] == "attachdownload") { if (!IsNumber(Request.QueryString["ID"])) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('查询字符串错误');window.close();</script>"); return; } LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attachmodel = new LabMS.Model.Attachment(); attachmodel = Attach.GetModel(int.Parse(Request.QueryString["ID"].Trim())); FileItemDownload(attachmodel.ID, attachmodel.Attach_Address, attachmodel.Attach_Name); return; } if (!string.IsNullOrEmpty(Request.QueryString["ID"])) { if (!IsNumber(Request.QueryString["ID"])) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('查询字符串错误');window.close();</script>"); return; } LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attachmodel = new LabMS.Model.Attachment(); attachmodel = Attach.GetModel(int.Parse(Request.QueryString["ID"].Trim())); Gv_DataBind(attachmodel); } } //if (Request.QueryString["ID"] == null) //{ // Common.JShelper.JSAlert(Page, "err", "参数错误!"); // return; //} //else if (Request.QueryString["ID"] != null && Request.QueryString["type"] == null) //{ // int iTemp = 0; // string strID = Request.QueryString["ID"].ToString(); // if (!int.TryParse(strID, out iTemp)) // { // Common.JShelper.JSAlert(Page, "err", "参数错误!"); // return; // } // LabMS.Model.Attachment mattach = new LabMS.Model.Attachment(); // LabMS.BLL.Attachment battach = new LabMS.BLL.Attachment(); // mattach = battach.GetModel(iTemp); // if (mattach.Attach_Name == "") // { // Response.Redirect("DownloadFile.aspx?ID=" + strID + "&type=1"); // } // else // { // string FullFileName = mattach.Attach_Address; // string FileName = mattach.Attach_Name; // try // { // FullFileName = Server.MapPath("../" + FullFileName); // Context.Response.Buffer = true; // Context.Response.Clear(); // Context.Response.AppendHeader("Content-Disposition ", "attachment;filename= " + HttpUtility.UrlEncode(FullFileName, System.Text.Encoding.UTF8)); // Response.ContentType = "application/x-zip-compressed"; // Response.TransmitFile(FullFileName); // } // catch // { // Common.JShelper.JSAlert(Page, "err", "路径错误!"); // return; // } // Response.End(); // } //} //else if (Request.QueryString["ID"] != null && Request.QueryString["type"] != null) //{ // if (Request.QueryString["type"].ToString().Equals("1")) // { // List<LabMS.Model.AttachmentItem> listattchitem = new List<LabMS.Model.AttachmentItem>(); // LabMS.BLL.AttachmentItem battachitem = new LabMS.BLL.AttachmentItem(); // int iTemp = 0; // string strID = Request.QueryString["ID"].ToString(); // if (!int.TryParse(strID, out iTemp)) // { // Common.JShelper.JSAlert(Page, "err", "参数错误!"); // return; // } // listattchitem = battachitem.GetModelList("Attach_ID = " + strID); // foreach (LabMS.Model.AttachmentItem mai in listattchitem) // { // mai.Item_Address = "<a onclick=foo('DownloadFile.aspx?type=2&ID=" + mai.ID.ToString() + "')>点击下载</a>"; // } // gvFile.DataSource = listattchitem; // gvFile.DataBind(); // gvFile.Visible = true; // } // else if (Request.QueryString["type"].ToString().Equals("2")) // { // int iTemp = 0; // string strID = Request.QueryString["ID"].ToString(); // if (!int.TryParse(strID, out iTemp)) // { // Common.JShelper.JSAlert(Page, "err", "参数错误!"); // return; // } // LabMS.Model.AttachmentItem mattach = new LabMS.Model.AttachmentItem(); // LabMS.BLL.AttachmentItem battach = new LabMS.BLL.AttachmentItem(); // mattach = battach.GetModel(iTemp); // string FullFileName = mattach.Item_Address; // string FileName = mattach.Item_Name; // try // { // FullFileName = Server.MapPath("../" + FullFileName); // Context.Response.Buffer = true; // Context.Response.Clear(); // Context.Response.AppendHeader("Content-Disposition ", "attachment;filename= " + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8)); // Response.ContentType = "application/x-zip-compressed"; // Response.TransmitFile(FullFileName); // } // catch // { // Common.JShelper.JSAlert(Page, "err", "路径错误!"); // return; // } // Response.End(); // } //} }
protected void lk_DownLoad_Click(object sender, EventArgs e) { if (sender != null) { try { LinkButton lk = (LinkButton)sender; int ItemID = 0; if(!string.IsNullOrEmpty(lk.CommandArgument)) { if(int.TryParse(lk.CommandArgument,out ItemID)) { if (ItemID > 0) { LabMS.BLL.Attachment Attachment = new LabMS.BLL.Attachment(); LabMS.Model.Attachment model = Attachment.GetModel(ItemID); if (model != null) { if (model.Attach_Name != "" && model.Attach_Address != "") { FileItemDownload(ItemID, model.Attach_Address, model.Attach_Name); } } } } } } catch (Exception ex) { lb_Error.Text = ex.Message; } } }
protected void Submit_Click(object sender, EventArgs e) { #region Validation if (string.IsNullOrEmpty(App_ProjectCode.Text.Trim())) { LabMS.Common.JShelper.JSAlert(this, "�������ݴ���", "����д��Ŀ���"); return; } if (string.IsNullOrEmpty(App_Code.Text.Trim())) { LabMS.Common.JShelper.JSAlert(this, "�������ݴ���", "����д��Ŀ����"); return; } if (App_LabName.SelectedValue.Trim() == "0") { LabMS.Common.JShelper.JSAlert(this, "�������ݴ���", "ѡ��ʵ���Ҳ���Ϊ��"); return; } if (App_LabType.SelectedValue == "0") { LabMS.Common.JShelper.JSAlert(this, "�������ݴ���", "��Ŀ��ʵ�������Ͳ���Ϊ��"); return; } if (App_ConstructionType.SelectedValue == "0") { LabMS.Common.JShelper.JSAlert(this, "�������ݴ���", "��Ŀ�Ľ������Ͳ���Ϊ��"); return; } if (string.IsNullOrEmpty(App_AppTime.Text.Trim())) { LabMS.Common.JShelper.JSAlert(this, "�������ݴ���", "����ӵ�����ʱ�䲻��Ϊ��"); return; } if (string.IsNullOrEmpty(App_CompletionTime.Text.Trim())) { LabMS.Common.JShelper.JSAlert(this, "�������ݴ���", "����ӵ����ʱ�䲻��Ϊ��"); return; } if (string.IsNullOrEmpty(App_InCharge.Text.Trim())) { LabMS.Common.JShelper.JSAlert(this, "�������ݴ���", "��Ŀ�����˲���Ϊ��"); return; } else { if (System.Text.Encoding.Default.GetByteCount(App_InCharge.Text) > 50 ) { LabMS.Common.JShelper.JSAlert(this, "�������ݳ��ȴ���", "��Ŀ�������������Ȳ�����25�����֣�50��Ӣ���ַ�"); } } if (string.IsNullOrEmpty(App_Phone.Text.Trim())) { LabMS.Common.JShelper.JSAlert(this, "�������ݴ���", "��ϵ�绰����Ϊ��"); return; } if (string.IsNullOrEmpty(App_ApplyFinancing.Text.Trim())) { LabMS.Common.JShelper.JSAlert(this, "��Ҫ��������", "����д�������ʽ���Ϊ��"); return; } if (HttpContext.Current.Request.Files.Count - 1 <= 0) { LabMS.Common.JShelper.JSAlert(this, "��Ҫ������", "���ϴ������鸽��"); } int Index = int.Parse(tb_EIndex.Value); decimal tempde=0.0M; int temp=0; for (int i = 0; i < Index; i++) { if (!string.IsNullOrEmpty(Request.Form["code" + i+""]) && !string.IsNullOrEmpty(Request.Form["name" + i+""])) { if (string.IsNullOrEmpty(Request.Form["num" + i])) { LabMS.Common.JShelper.JSAlert(this, "error", "���������������ܿ�"); return; } else { if (!int.TryParse(Request.Form["num" + i], out temp)) { LabMS.Common.JShelper.JSAlert(this, "error", "����������������Ϊ����"); return; } } if (string.IsNullOrEmpty(Request.Form["unitprice" + i])) { LabMS.Common.JShelper.JSAlert(this, "error", "�����������۲���Ϊ�գ�Ӧ��Ϊ������С��"); return; } else { if (!decimal.TryParse(Request.Form["unitprice" + i], out tempde)) { LabMS.Common.JShelper.JSAlert(this, "error", "������������Ӧ��Ϊ������С����"); return; } } } } #endregion Validation LabMS.BLL.ProjectApp ProjectApp = new LabMS.BLL.ProjectApp(); LabMS.Model.ProjectApp model = new LabMS.Model.ProjectApp(); model.App_Code = App_Code.Text; string[] DateTimeList = { "yyyy/M/d tt hh:mm:ss", "yyyy/MM/dd tt hh:mm:ss", "yyyy/MM/dd HH:mm:ss", "yyyy/M/d HH:mm:ss", "yyyy/MM/dd", "yyyy-MM-dd hh:mm:ss", "yyyy-MM-dd", "yyyy-M-d" }; try { DateTime AppTime = DateTime.ParseExact(App_AppTime.Text, DateTimeList, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AllowInnerWhite); DateTime CompleteTime=DateTime.ParseExact(App_CompletionTime.Text, DateTimeList, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AllowInnerWhite); if (DateTime.Compare(AppTime, CompleteTime) <= 0) { model.App_AppTime = AppTime; model.App_CompletionTime = CompleteTime; } else { LabMS.Common.JShelper.JSAlert(this, "����ʱ���С����", "����ϸ�˶ԣ������ʱ��ʹ�С"); return; } } catch { LabMS.Common.JShelper.JSAlert(this, "����ʱ���ʽ����", "����ʱ���ʽ��������������"); return; } model.App_InCharge = App_InCharge.Text; model.App_Phone = App_Phone.Text; model.App_Location = App_Loction.Text.TrimEnd(); model.App_InstallCondition = App_InstallCondition.Text.TrimEnd(); model.App_Necessity = App_Necessity.Text.TrimEnd(); model.App_LabType = App_LabType.SelectedValue; model.App_ConstructionType = App_ConstructionType.SelectedValue; model.App_State = "SubmitNotYet"; model.LabID = Convert.ToInt32(App_LabName.SelectedValue.Trim()); model.App_Positions = tb_PositonCode.Text.Trim(); model.App_ApplyFinancing = Convert.ToInt32(App_ApplyFinancing.Text); model.App_ProjectCode = App_ProjectCode.Text.Trim(); int attachID=0; bool saved = false; if ((HttpContext.Current.Request.Files.Count-1)>0) { try { int count = HttpContext.Current.Request.Files.Count; HttpFileCollection Files = HttpContext.Current.Request.Files; string savePath = HttpContext.Current.Request.MapPath(@"../Content/UpLoadFile/"); List<string> fileNames = LabMS.Common.FileUpload.SaveFiles(Files, savePath); LabMS.Model.Attachment attachmodel = new LabMS.Model.Attachment(); LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment(); attachID = Attach.Add(attachmodel); if (attachID != 0) { LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem(); LabMS.Model.AttachmentItem itemmodel; for (int n = 0; n < fileNames.Count; n++) { if (fileNames[n].Trim() != "") { itemmodel = new LabMS.Model.AttachmentItem(); itemmodel.Item_Address = "Content/UpLoadFile/"+fileNames[n].Trim(); int index = fileNames[n].LastIndexOf("_"); itemmodel.Item_Name = fileNames[n].Substring(0, fileNames[n].LastIndexOf("_")); itemmodel.Attach_ID = attachID; itemmodel.Item_Type = "1"; AttachItem.Add(itemmodel); } } } saved = true; } catch { Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('�ϴ��ļ�ʱ��������ϵ����Ա��');window.location.href='ApplicationList.aspx'; </script>"); return; } } if (saved) { model.App_Attachment = attachID; } int appid = ProjectApp.Add(model); LabMS.Model.ConsumeApp consumeappmodel; LabMS.BLL.ConsumeApp ConsumeApp = new LabMS.BLL.ConsumeApp(); for (int i = 0; i < Index; i++) { consumeappmodel = new LabMS.Model.ConsumeApp(); int nums = 0; decimal unitprice = new decimal(); try { if (!string.IsNullOrEmpty(Request.Form["code" + i.ToString()+""]) ) { consumeappmodel.EquipType = Request.Form["code" + i]; consumeappmodel.EquipName = Request.Form["name" + i]; consumeappmodel.Model = Request.Form["model" + i]; consumeappmodel.Factory = Request.Form["factory" + i]; consumeappmodel.Argument = Request.Form["argument" + i]; decimal.TryParse(Request.Form["unitprice" + i], out unitprice); consumeappmodel.UnitPrice = unitprice; int.TryParse(Request.Form["num" + i], out nums); consumeappmodel.EquipNum = nums; consumeappmodel.AppID = appid; ConsumeApp.Add(consumeappmodel); } } catch (Exception ex) { LabMS.Common.JShelper.JSAlert(this, "header", ex.Message); return; } } Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('��������Ŀ�б�ҳ�棡');window.location.href='ApplicationList.aspx'; </script>"); return; }
//������Ϣ protected void SaveOnClick(object sender, EventArgs e) { if (CodeNumTBX.Text.Trim() == "") { Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('�������ĺţ�')</script>"); return; } if (TitleTBX.Text.Trim() == "") { Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('��������⣡')</script>"); return; } if (IsCode(CodeNumTBX.Text.ToString().Trim())) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('�Ѵ��ڸ��ĺźţ����������룡')</script>"); return; } LabMS.Model.Rule rule = new LabMS.Model.Rule(); //LabMS.BLL.Rule ruleinfo = new LabMS.BLL.Rule(); ExtendBLL.Rule ruleinfo = new ExtendBLL.Rule(); rule.Rule_CodeNum = CodeNumTBX.Text;//�ĺ� rule.Rule_Content = LabMS.Common.codehelper.Encode(ResourceContent.Text.Trim());//���� if (ModifyDateTBX.Text != "") { rule.Rule_Date = DateTime.Parse(ModifyDateTBX.Text);//���� } rule.Rule_InputUnit = InputUnitDDL.SelectedValue;//¼�뵥λ rule.Rule_KeyWord = KeyTBX.Text;//�ؼ��� rule.Rule_OutputUnit = OutputUnitTBX.Text.Trim();//���ĵ�λ rule.Rule_SubTitle = SubTitleTBX.Text.Trim();//�ӱ��� rule.Rule_Title = TitleTBX.Text.Trim();//���� rule.Rule_Type = RuleKindDDL.SelectedValue;//���� LabMS.BLL.Attachment att = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attModel = new LabMS.Model.Attachment(); int AttachID=0; if (AttachIDHF.Value != "") { AttachID = int.Parse(AttachIDHF.Value); } HttpFileCollection uploads = HttpContext.Current.Request.Files; if (uploads.Count > 1) { if (AttachIDHF.Value == "") { AttachID = att.Add(attModel); } for (int i = 0; i < uploads.Count; i++) { HttpPostedFile upload = uploads[i]; Random objRand = new Random(); System.DateTime date = DateTime.Now; int fileLength = upload.ContentLength; string filename = upload.FileName; string saveName = date.Year.ToString() + date.Month.ToString() + date.Day.ToString() + Convert.ToString(objRand.Next(99)) + upload.FileName; if (fileLength == 0) { continue; } //�ж��ļ���С�Ƿ�200K if (fileLength > (2000 * 1024)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('�ļ���" + filename + ",̫��(���ܳ���2M)��')</script>"); return; } string fileURL = "Content/UploadFile" + "/" + saveName; try { upload.SaveAs(Server.MapPath("../Content/UploadFile") + "/" + saveName); LabMS.BLL.AttachmentItem attIte = new LabMS.BLL.AttachmentItem(); LabMS.Model.AttachmentItem attIteModel = new LabMS.Model.AttachmentItem(); attIteModel.Attach_ID = AttachID; attIteModel.Item_Address = fileURL; attIteModel.Item_Name = filename; attIte.Add(attIteModel); } catch { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('����ļ�ʧ�ܣ�');</script>"); return; } } } if (AttachID == 0) { rule.AttachmentID = null;//���� } else { rule.AttachmentID = AttachID;//���� } if (ViewState["ID"] != null) { DeleteAttach();//ɾ������ rule.ID = int.Parse(ViewState["ID"].ToString()); ruleinfo.Update(rule); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('������Ϣ�ɹ���');refreshParent();window.close();</script>"); } else { ruleinfo.Add(rule);//���һ������Ϣ Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('������Ϣ�ɹ���');refreshParent();window.location.href='AddRule.aspx';</script>"); } }
protected bool SaveItem(LabMS.Model.ProjectApp applicationmodel) { bool save = false; if (applicationmodel != null) { int Attach_ID = 0; if (applicationmodel.App_Attachment == null) { if (HttpContext.Current.Request.Files.Count - 1 > 0) { LabMS.Model.Attachment attachmodel = new LabMS.Model.Attachment(); LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment(); applicationmodel.App_Attachment = Attach.Add(attachmodel); } } else { Attach_ID = applicationmodel.App_Attachment.Value; } if (Attach_ID != 0) { //ɾ�� try { LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem(); List<LabMS.Model.AttachmentItem> ls = new List<LabMS.Model.AttachmentItem>(); ls = AttachItem.GetModelList("Item_Type='1' and Attach_ID=" + Attach_ID); string[] array1 = itemIDs.Value.Split(','); if (array1[0] != "") { for (int i = 0; i < array1.Length; i++) { int itemid = 0; if (int.TryParse(array1[i], out itemid)) { AttachItem.Delete(itemid); } } } } catch(Exception ex) { lb_Error.Text = ex.Message; } //��� if (HttpContext.Current.Request.Files.Count-1 > 0) { try { LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem(); LabMS.Model.AttachmentItem itemmodel; HttpFileCollection Files = HttpContext.Current.Request.Files; string savePath = Request.MapPath(@"../Content/UpLoadFile/"); List<string> fileNames = LabMS.Common.FileUpload.SaveFiles(Files, savePath); for (int n = 0; n < fileNames.Count; n++) { itemmodel = new LabMS.Model.AttachmentItem(); itemmodel.Item_Address = "Content/UpLoadFile/" + fileNames[n].Trim(); int index = fileNames[n].LastIndexOf("_"); itemmodel.Item_Name = fileNames[n].Substring(0, fileNames[n].LastIndexOf("_")); itemmodel.Attach_ID = Attach_ID; itemmodel.Item_Type = "1"; AttachItem.Add(itemmodel); } save = true; } catch { save = false; } } } } return save; }
//��ȡ������Ϣ protected LabMS.Model.Attachment GetAttachmentInfo(int ID) { LabMS.BLL.Attachment attachment = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attach = new LabMS.Model.Attachment(); attach = attachment.GetModel(ID); return attach; }
protected bool AttachmentItemSave(LabMS.Model.OpentProject openprojectmodel) { if (openprojectmodel != null) { int Attach_ID = 0; if (openprojectmodel.Attachment != null) { Attach_ID = openprojectmodel.Attachment.Value; string[] array = itemIDs.Value.Split(','); if (array[0] != "") { for (int n = 0; n < array.Length; n++) { if (array[n] != "0") { LabMS.BLL.AttachmentItem Attach = new LabMS.BLL.AttachmentItem(); int itemID = 0; if (int.TryParse(array[n], out itemID)) { try { Attach.Delete(itemID); } catch { } } } } } } else { ///有上传文件 if (HttpContext.Current.Request.Files.Count - 1 > 0) { LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attamentmodel = new LabMS.Model.Attachment(); LabMS.BLL.OpentProject OpenProject = new LabMS.BLL.OpentProject(); try { Attach_ID = Attach.Add(attamentmodel); openprojectmodel.Attachment = Attach_ID; OpenProject.Update(openprojectmodel); } catch { lb_Error.Text = "保存上传文件错误"; } } } if (Attach_ID != 0) { return SaveItem(Attach_ID); } else { return false; } } return false; }
protected void btn_AddEval_Click(object sender, EventArgs e) { if (QueryString != HFQueryString || QueryString <= 0) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript' >alert('��ѯ�ַ�������');window.location.href='';</script>"); return; } int ID = QueryString; if (ID > 0) { try { bool save = false; LabMS.BLL.ProjectApp Application = new LabMS.BLL.ProjectApp(); LabMS.Model.ProjectApp model = Application.GetModel(ID); if (model != null) { if (HttpContext.Current.Request.Files.Count - 1 > 0) { int Attach_ID = model.App_Attachment.Value; if (model.App_Attachment == null) { LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attachmodel = new LabMS.Model.Attachment(); Attach_ID = Attach.Add(attachmodel); model.App_Attachment = Attach_ID; } else { int count = HttpContext.Current.Request.Files.Count; HttpFileCollection Files = HttpContext.Current.Request.Files; string savePath = HttpContext.Current.Request.MapPath(@"../Content/UpLoadFile/"); List<string> fileNames = LabMS.Common.FileUpload.SaveFiles(Files, savePath); if (Attach_ID != 0) { LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem(); LabMS.Model.AttachmentItem itemmodel; for (int n = 0; n < fileNames.Count; n++) { if (fileNames[n].Trim() != "") { itemmodel = new LabMS.Model.AttachmentItem(); itemmodel.Item_Address = "Content/UpLoadFile/" + fileNames[n].Trim(); int index = fileNames[n].LastIndexOf("_"); itemmodel.Item_Name = fileNames[n].Substring(0, fileNames[n].LastIndexOf("_")); itemmodel.Attach_ID = Attach_ID; itemmodel.Item_Type = "4"; AttachItem.Add(itemmodel); } } } save = true; } } else { Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript' >alert('�ļ�����Ϊ��');window.location.href='';</script>"); return; } model.App_ExamineView = tb_ExamineView.Text; model.App_State = "Examined"; model.App_AcceptanceTime = DateTime.Now; Application.Update(model); Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript' >if(window.confirm('�Ƿ��б�ҳ��')){window.location.href='AppExaminedList.aspx';}else{window.location.href=window.location.href;}</script>"); return; } } catch { Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript' >alert('���ݴ�ȡ����,����ϵ����Ա');window.location.href='';</script>"); return; } } }
//�ύ�½�ʵ�������� protected void Save_OnClick(object sender, EventArgs e) { if (LabNameTBX.Text.Trim() == "") { Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('������ʵ��������!')</script>"); return; } if (LabNumTBX.Text.Trim() == "") { Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('������ʵ���ұ��!')</script>"); return; } //�ж��Ƿ��Ѵ��ڸ�ʵ���ұ�� if (IsCode(LabNumTBX.Text.ToString().Trim())) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('�Ѵ��ڸ�ʵ���ұ�ţ����������룡')</script>"); return; } //�ϴ��ļ���ȡ����IDֵ //int id = UpdateFile(); //�ж��Ƿ����� //if (id == -1) //{ // Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('�ϴ�ʧ�ܣ��ϴ����ļ����ܴ���4M��')</script>"); // return; //} //��ȡʵ������Ϣ LabMS.Model.Lab lab = new LabMS.Model.Lab();//����һ��lab���� //if (id != 0) //{ // lab.Lab_Summary = id;//��ȡ���ID //} lab.Lab_Code = LabNumTBX.Text.ToString().Trim();//��ȡʵ���ұ�� lab.Lab_Name = LabNameTBX.Text.ToString().Trim();//��ȡʵ�������� lab.Lab_Category = LabKindDDL.SelectedValue.Trim();//��ȡʵ������� lab.Lab_Level = LabLevelDDL.SelectedValue.Trim();//��ȡʵ���Ҽ��� if (DateTBX.Text.Trim() != "") { lab.Lab_SetupTime = DateTime.Parse(DateTBX.Text.Trim());//��ȡʵ���ҽ������ } lab.Lab_InCharge = ManagerTBX.Text.ToString().Trim();//��ȡʵ���Ҹ����� lab.Lab_Phone = TelTBX.Text.ToString().Trim();//��ȡ��ϵ�绰 lab.Lab_State = StatusDDL.SelectedValue.Trim();//��ȡʹ��״̬ lab.Lab_Curriculum = CurriculumTBX.Text.ToString().Trim();//��ȡ��Ҫ�е��γ� lab.Lab_Type = LabTypeDDL.SelectedValue.Trim();//��ȡʵ�������� lab.Lab_Disciplines = SubjectTBX.Text.Trim();//��ȡ����ѧ�� lab.Lab_AwardLevel = AwardLevelDDL.SelectedValue.Trim();//��ȡ�������� lab.Lab_ApprovalCode = NumTXB.Text.ToString().Trim();//��ȡ���ĺ� lab.Lab_Professional = ProfessionTBX.Text.ToString().Trim();//��ȡ����רҵ lab.Lab_Statement = StatementTBX.Text.Trim();//��ע //��ȡ���м���Ŀ������ if (ProjectNumTBX.Text.ToString().Trim() != "") { int i; if (int.TryParse(ProjectNumTBX.Text.Trim(), out i)) { lab.Lab_ProjectNum = i; } else { Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('���м���Ŀ������ֻ����������!')</script>"); return; } } lab.Lab_Investment = InvestmentTBX.Text.ToString().Trim();//��ȡͶ�ʽ�� //ѧ������ if (AwardNumTBX.Text.ToString().Trim() != "") { int i; if (int.TryParse(AwardNumTBX.Text.Trim(), out i)) { lab.Lab_StAwardNum = i; } else { Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('ѧ������ֻ����������!')</script>"); return; } } //�ϴ����� LabMS.BLL.Attachment att = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attModel = new LabMS.Model.Attachment(); int AttachID = 0; if (AttachIDHF.Value != "") { AttachID = int.Parse(AttachIDHF.Value); } HttpFileCollection uploads = HttpContext.Current.Request.Files; if (uploads.Count > 1) { if (AttachIDHF.Value == "") { AttachID = att.Add(attModel); } for (int i = 1; i < uploads.Count; i++) { HttpPostedFile upload = uploads[i]; Random objRand = new Random(); System.DateTime date = DateTime.Now; int fileLength = upload.ContentLength; string filename = upload.FileName; string saveName = date.Year.ToString() + date.Month.ToString() + date.Day.ToString() + Convert.ToString(objRand.Next(99)) + upload.FileName; //if (fileLength == 0) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('�ļ���" + filename + "�ϴ�ʧ�ܣ���Ϊ���ļ�Ϊ���ļ���')</script>"); // continue; //} //�ж��ļ���С�Ƿ�2000K if (fileLength > (2000 * 1024)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('�ļ���" + filename + "�ϴ�ʧ�ܣ���Ϊ���ļ�̫��(���ܳ���2M)��')</script>"); return; } string fileURL = "Content/UploadFile/" + saveName; try { upload.SaveAs(Server.MapPath("../Content/UploadFile") + "/" + saveName); LabMS.BLL.AttachmentItem attIte = new LabMS.BLL.AttachmentItem(); LabMS.Model.AttachmentItem attIteModel = new LabMS.Model.AttachmentItem(); attIteModel.Attach_ID = AttachID; attIteModel.Item_Address = fileURL; attIteModel.Item_Name = filename; attIte.Add(attIteModel); } catch { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('����ļ�ʧ�ܣ�');</script>"); return; } } } if (AttachID == 0) { lab.Lab_Summary = null;//���� } else { lab.Lab_Summary = AttachID;//���� } //�ύ���� if (IDHF.Value != "0") { DeleteAttach();//ɾ������ lab.ID = int.Parse(IDHF.Value); LabMS.BLL.Lab labdata = new LabMS.BLL.Lab(); labdata.Update(lab); Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('���³ɹ���');refreshParent();window.close();</script>"); } else { LabMS.BLL.Lab labdata = new LabMS.BLL.Lab(); labdata.Add(lab); Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('��ӳɹ���');window.location.href='AddNewLab.aspx';</script>"); } }
protected void AttachItemDataBind() { if (QueryString != HF_QueryString || QueryString <= 0 || HF_QueryString <= 0) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript>window.location.href='err.aspx?Message=��ѯ�ַ�������'</script>"); return; } LabMS.BLL.ProjectApp Application = new LabMS.BLL.ProjectApp(); LabMS.Model.ProjectApp applicationmodel = new LabMS.Model.ProjectApp(); LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attachmodel = new LabMS.Model.Attachment(); LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem(); List<LabMS.Model.AttachmentItem> ls = new List<LabMS.Model.AttachmentItem>(); if (QueryString != 0) { applicationmodel = Application.GetModel(QueryString); int AttachID = 0; if (applicationmodel.App_Attachment != null) { AttachID = applicationmodel.App_Attachment.Value; ls = AttachItem.GetModelList("Item_Type ='2' and Attach_ID=" + AttachID); if (ls.Count != 0) { tb_ID.Value = AttachID.ToString(); } else { btn_download.Attributes.Add("style", "display:none"); } if (ls.Count != 0) { string strHTML = "<table>"; for (int i = 0; i < ls.Count; i++) { strHTML += "<tr>"; strHTML += "<td style='display:none;'>"; strHTML += ls[i].ID; strHTML += "</td>"; strHTML += "<td>"; strHTML += "<a>"; strHTML += "ɾ��"; strHTML += "</a>"; strHTML += "</td>"; strHTML += "<td>"; strHTML += ls[i].Item_Name; strHTML += "</td>"; strHTML += "</tr>"; } strHTML += "</table>"; itemlist.Value = strHTML; } } } else { Submit.Visible = false; lb_Error.Text = "ϵͳ�쳣����ѯ�ַ����쳣"; lb_Error.Visible = true; } }
protected void Submit_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(itemIDs.Value)) { string[] array1 = itemIDs.Value.Split(','); for (int m = 0; m < array1.Length; m++) { if (array1[m] != "0"||array1[m]!="") { LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem(); AttachItem.Delete(Convert.ToInt32(array1[m])); } } } int attachID = 0; if ((HttpContext.Current.Request.Files.Count - 1) > 0) { bool Result = false; try { LabMS.BLL.ProjectApp Application = new LabMS.BLL.ProjectApp(); LabMS.Model.ProjectApp model = new LabMS.Model.ProjectApp(); model = Application.GetModel(QueryString); if (model.App_Attachment == null) { attachID = 0; } else { attachID = model.App_Attachment.Value; } int count = HttpContext.Current.Request.Files.Count; HttpFileCollection Files = HttpContext.Current.Request.Files; string savePath = HttpContext.Current.Request.MapPath(@"../Content/UpLoadFile/"); List<string> fileNames = LabMS.Common.FileUpload.SaveFiles(Files, savePath); if (attachID == 0) { LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attachmodel = new LabMS.Model.Attachment(); attachID = Attach.Add(attachmodel); model.App_Attachment = attachID; } LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem(); LabMS.Model.AttachmentItem itemmodel; for (int n = 0; n < fileNames.Count; n++) { if (fileNames[n].Trim() != "") { itemmodel = new LabMS.Model.AttachmentItem(); itemmodel.Item_Address = "Content/UpLoadFile/" + fileNames[n].Trim(); itemmodel.Item_Name = fileNames[n].Substring(0, fileNames[n].LastIndexOf("_")); itemmodel.Attach_ID = attachID; itemmodel.Item_Type = "2"; AttachItem.Add(itemmodel); } } Result = true; Application.Update(model); } catch { Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('�ϴ��ļ�ʱ��������ϵ����Ա��');window.location.href=window.location.href; </script>"); return; } if (Result) { Build.Visible = true; } } else { Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('û�������飬��ѡ����������ϴ���'); </script>"); return; } Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>if(window.confirm('���������ɹ����Ƿ��б�')){ window.location.href='AppTaskList.aspx';}else{window.location.href=window.location.href;}</script>"); return; }
protected void Submit_Click(object sender, EventArgs e) { if (QueryString != HF_QueryString || QueryString <= 0 && HF_QueryString <= 0) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('��ѯ�ַ�������');window.location.href='projectlist.aspx';</script>"); return; } if (string.IsNullOrEmpty(txb_Code.Text)) { LabMS.Common.JShelper.JSAlert(this, "Error", "ָ����ı�Ų���Ϊ��"); return; } if (string.IsNullOrEmpty(txb_BooKName.Text)) { LabMS.Common.JShelper.JSAlert(this, "Error", "ָ��������Ʋ���Ϊ��"); return; } if (string.IsNullOrEmpty(txb_Editor.Text)) { LabMS.Common.JShelper.JSAlert(this, "Error", "ָ����ı༭����Ϊ��"); return; } if (string.IsNullOrEmpty(txb_Pub.Text)) { LabMS.Common.JShelper.JSAlert(this, "Error", "ָ����ij����粻��Ϊ��"); return; } LabMS.BLL.GuideBook GuideBook = new LabMS.BLL.GuideBook(); LabMS.Model.GuideBook Book = new LabMS.Model.GuideBook(); Book.Guide_BookName = txb_BooKName.Text; Book.Guide_BookCode = txb_Code.Text; Book.Guide_Editor = txb_Editor.Text; Book.Guide_Award = txb_Award.Text; Book.Guide_Press = txb_Pub.Text; Book.Guide_Content = txb_Content.Text; string[] DateTimeList = { "yyyy/M/d tt hh:mm:ss", "yyyy/MM/dd tt hh:mm:ss", "yyyy/MM/dd HH:mm:ss", "yyyy/M/d HH:mm:ss", "yyyy/MM/dd", "yyyy-MM-dd hh:mm:ss", "yyyy-MM-dd", "yyyy-M-d" }; DateTime StarTime = DateTime.ParseExact(txb_PubTime.Text.Trim(), DateTimeList, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AllowInnerWhite); Book.Guide_PublishTime = StarTime; Book.Guide_ProjectID = Convert.ToInt32(Request.QueryString["ID"].ToString()); if (fup_Attach.HasFile) { string savePath = HttpContext.Current.Request.MapPath(@"../Content/UpLoadFile/"); string Append = DateTime.Now.ToString("yyyyMMddhhmmss"); string FullPathFileName = savePath.Trim() + fup_Attach.FileName.Trim() + "_" + Append.Trim() + fup_Attach.FileName.Substring(fup_Attach.FileName.LastIndexOf(".")); bool save = true; int attachid = 0; if (fup_Attach.HasFile) { try { if (fup_Attach.PostedFile.ContentLength == 0) { LabMS.Common.JShelper.JSAlert(this, "�ļ��ϴ�ʧ��", "�ļ�����Ϊ��"); return; } fup_Attach.SaveAs(FullPathFileName); save = true; } catch { LabMS.Common.JShelper.JSAlert(this, "�ļ��ϴ�ʧ��", "�ļ��ϴ�ʧ��"); return; } } if (save) { LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attach = new LabMS.Model.Attachment(); attach.Attach_Name = fup_Attach.FileName; attach.Attach_Address = "Content/UpLoadFile/" + fup_Attach.FileName + "_" + Append.Trim() + fup_Attach.FileName.Substring(fup_Attach.FileName.LastIndexOf(".")); attach.Attach_Type = "2"; attachid = Attach.Add(attach); if (attachid > 0) { Book.Guide_AttachID = attachid; } } } try { GuideBook.Add(Book); } catch (Exception ex) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>;alert('���ָ����ʧ�ܣ�');refreshParent();window.location.href='ProjectPreview.aspx?ID=" + Request.QueryString["ID"].Trim() + "'</script>"); return; } Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>;alert('���ʵ��ָ����ɹ���');refreshParent();window.location.href='ProjectPreview.aspx?ID=" + Request.QueryString["ID"].Trim() + "'</script>"); return; }
protected void Submit_Click(object sender, EventArgs e) { LabMS.BLL.TeachingReform Reform = new LabMS.BLL.TeachingReform(); LabMS.Model.TeachingReform ReformItem = new LabMS.Model.TeachingReform(); ReformItem.Teach_Address = tb_Addres.Text; ReformItem.Teach_InCharge = tb_InCharge.Text; ReformItem.Teach_Mail = tb_Email.Text; ReformItem.Teach_ProjectName = tb_ProjectName.Text; ReformItem.Teach_UnitName = tb_UnitName.Text; ReformItem.Teach_UnitType = rbl_UnitType.SelectedValue; ReformItem.Teach_Phone = tb_Phone.Text; ReformItem.Teach_Time = DateTime.Now; ReformItem.Teach_DocType = ddl_ProjectType.SelectedValue.Trim(); string savePath = HttpContext.Current.Request.MapPath(@"../Content/UpLoadFile/"); string Append = DateTime.Now.ToString("yyyyMMddhhmmss"); string FullPathFileName = savePath.Trim() + Append.Trim()+"_" + fp_Attach.FileName.Trim(); int attachID = 0; bool save = true; if (fp_Attach.HasFile) { try { fp_Attach.SaveAs(FullPathFileName); } catch { save = false; throw new Exception("File Save Error"); } } if (save) { LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attach = new LabMS.Model.Attachment(); attach.Attach_Name = fp_Attach.FileName; attach.Attach_Address = FullPathFileName; attachID = Attach.Add(attach); } if(attachID!=0) { ReformItem.Teach_Attachment=attachID; } Reform.Add(ReformItem); Response.Redirect(@"\ProjectApp\TeachingReformList.aspx"); }