//ɾ������ protected void DeleteAttach() { string[] strArray = AttachItemID.Value.Split(','); LabMS.BLL.AttachmentItem attIte = new LabMS.BLL.AttachmentItem(); if (AttachItemID.Value!="") { for (int i = 0; i < strArray.Length; i++) { attIte.Delete(int.Parse(strArray[i])); } } }
/// <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 void AttachItemDataBind() { LabMS.BLL.ProjectApp Application = new LabMS.BLL.ProjectApp(); LabMS.Model.ProjectApp applicationmodel = new LabMS.Model.ProjectApp(); 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 Attach_ID = 0; if (applicationmodel.App_Attachment != null) { Attach_ID = applicationmodel.App_Attachment.Value; ls = AttachItem.GetModelList("Item_Type ='1' and Attach_ID=" + Attach_ID); 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; } } } }
// protected void Gv_DataBind(LabMS.Model.Attachment attach) { if (attach.Attach_Name == "") { string type=""; if (!string.IsNullOrEmpty(Request.QueryString["Type"])) { if (IsNumber(Request.QueryString["Type"])) { type = Request.QueryString["Type"].Trim(); } } else { type = ""; } LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem(); List<LabMS.Model.AttachmentItem> ls = new List<LabMS.Model.AttachmentItem>(); if (type != "") { ls = AttachItem.GetModelList("Attach_ID=" + attach.ID + " and Item_Type=" + type); } else { ls = AttachItem.GetModelList("Attach_ID=" + attach.ID); } Gv_FileItem.DataSource = ls; Gv_FileItem.DataBind(); Gv_FileItem.Visible = true; } else { List<LabMS.Model.Attachment> ls = new List<LabMS.Model.Attachment>(); ls.Add(attach); Gv_File.DataSource = ls; Gv_File.DataBind(); Gv_File.Visible = true; } }
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; }
private void FileItemDownload(int itemID) { if (itemID == 0) { lb_Error.Text = "������������"; return; } System.IO.Stream iStream = null; try { //�����ļ�ȫ·���� LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem(); LabMS.Model.AttachmentItem itemmodel = new LabMS.Model.AttachmentItem(); itemmodel = AttachItem.GetModel(itemID); string fullpath = Server.MapPath("../" + itemmodel.Item_Address); string fileName = itemmodel.Item_Name; string NameTemp = ""; if (Request.Browser.Browser == "IE") { NameTemp = HttpUtility.UrlEncode(fileName); NameTemp = NameTemp.Replace("+", "%20"); } else { NameTemp = fileName; NameTemp = NameTemp.Replace(" ", ""); } Response.Clear(); Response.Charset = "UTF-8"; Response.Buffer = true; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.HeaderEncoding = System.Text.Encoding.UTF8; Response.AppendHeader("Content-Disposition", "attachment;filename=" + NameTemp); Response.ContentType = "application/octet-stream"; byte[] buffer = new byte[100000]; int iLength; long dataToRead; iStream = new FileStream(fullpath, FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read); dataToRead = iStream.Length; while (dataToRead > 0) { if (Response.IsClientConnected) { iLength = iStream.Read(buffer, 0, 100000); Response.BinaryWrite(buffer); Response.Flush(); buffer = new byte[100000]; dataToRead = dataToRead - iLength; } else { dataToRead = -1; } } } catch (Exception ex) { lb_Error.Text = ex.Message; } finally { if (iStream != null) { iStream.Close(); } } }
protected void Gv_FileList_DataBinds() { if (HF_QueryString != QueryString || QueryString <= 0) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>window.location.href='~/err.aspx?Message=��ѯ�ַ�������';</script>"); return; } if (QueryString != 0) { 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 || model.App_Attachment != 0) { LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem(); List<LabMS.Model.AttachmentItem> ls = new List<LabMS.Model.AttachmentItem>(); if (model.App_Attachment != null) { ls = AttachItem.GetModelList("Attach_ID=" + model.App_Attachment.Value + " and Item_Type=1"); } Gv_FileList.DataSource = ls; Gv_FileList.DataBind(); } } else { lb_Error.Text = "��ѯ�ַ�������"; } }
protected void Gv_File_DataBind() { if (!string.IsNullOrEmpty(Request.QueryString["ID"])) { if (IsNumber(Request.QueryString["ID"].Trim())) { int num=0; if (int.TryParse(Request.QueryString["ID"].Trim(), out num)) { LabMS.BLL.AttachmentItem AttachmentItem = new LabMS.BLL.AttachmentItem(); List<LabMS.Model.AttachmentItem> ls = new List<LabMS.Model.AttachmentItem>(); LabMS.Model.OpentProject openprojectmodel = new LabMS.Model.OpentProject(); LabMS.BLL.OpentProject OpenProject = new LabMS.BLL.OpentProject(); openprojectmodel= OpenProject.GetModel(num); if (openprojectmodel != null) { if (openprojectmodel.Attachment != null) { ls = AttachmentItem.GetModelList("Attach_ID=" + openprojectmodel.Attachment); } } Gv_File.DataSource = ls; Gv_File.DataBind(); } } } }
protected void Page_Load(object sender, EventArgs e) { strPagePrivilege.Add("GZZD"); strPageUserType.Add("mana"); if (Request.QueryString["ID"] == null) { if (!IsPostBack) { List<LabMS.Model.Dictionary> list = new List<LabMS.Model.Dictionary>(); //���ƶȷ��� list = DictionaryDropdownlist("118"); RuleKindDDL.DataSource = list; RuleKindDDL.DataBind(); //��¼�뵥λ LabDropdowlist(); } } else { label1.Visible = false; label2.Visible = true; if (!IsPostBack) { int ID; string strID = Request.QueryString["ID"].ToString(); if (int.TryParse(strID, out ID)) { ViewState["ID"] = ID; ExtendBLL.Rule rule = new ExtendBLL.Rule(); DataSet ds = new DataSet(); ds = rule.GetList("[ID]=" + ID); CodeNumTBX.Text = ds.Tables[0].Rows[0]["Rule_CodeNum"].ToString(); TitleTBX.Text = ds.Tables[0].Rows[0]["Rule_Title"].ToString(); SubTitleTBX.Text = ds.Tables[0].Rows[0]["Rule_SubTitle"].ToString(); KeyTBX.Text = ds.Tables[0].Rows[0]["Rule_KeyWord"].ToString(); OutputUnitTBX.Text = ds.Tables[0].Rows[0]["Rule_OutputUnit"].ToString(); ResourceContent.Text = LabMS.Common.codehelper.Decode(ds.Tables[0].Rows[0]["Rule_Content"].ToString());//���� ModifyDateTBX.Text = string.Format("{0:d}", ds.Tables[0].Rows[0]["Rule_Date"].ToString());//���� List<LabMS.Model.Dictionary> dic = new List<LabMS.Model.Dictionary>(); //�������ֵ� dic = DictionaryDropdownlist("118"); RuleKindDDL.DataSource = dic; RuleKindDDL.DataBind(); RuleKindDDL.SelectedValue = ds.Tables[0].Rows[0]["Rule_Type"].ToString(); //��¼�뵥λ LabDropdowlist(); InputUnitDDL.SelectedValue = ds.Tables[0].Rows[0]["Rule_InputUnit"].ToString(); //��ȡ�ļ��б� string strHTML = ""; if (ds.Tables[0].Rows[0]["AttachmentID"].ToString() != "") { AttachIDHF.Value = ds.Tables[0].Rows[0]["AttachmentID"].ToString(); LabMS.BLL.AttachmentItem attIte = new LabMS.BLL.AttachmentItem(); List<LabMS.Model.AttachmentItem> attIteModelList = new List<LabMS.Model.AttachmentItem>(); attIteModelList = attIte.GetModelList("Attach_ID=" + int.Parse(ds.Tables[0].Rows[0]["AttachmentID"].ToString())); strHTML += "<table>"; for (int i = 0; i < attIteModelList.Count; i++) { strHTML += "<tr>"; strHTML += "<td style='display:none;'>"; strHTML += attIteModelList[i].ID; strHTML += "</td>"; strHTML += "<td>"; strHTML += "<a>"; strHTML += "ɾ��"; strHTML += "</a>"; strHTML += "</td>"; strHTML += "<td>"; strHTML += attIteModelList[i].Item_Name; strHTML += "</td>"; strHTML += "</tr>"; } strHTML += "</table>"; filehtml.Value = strHTML; } } else { SaveBtn.Visible = false; ERRLbl.Text = "ϵͳ�쳣��IDֵ���Ϸ���"; ERRLbl.Visible = true; } } } ModifyDateTBX.Attributes.Add("onclick", "c.showMoreDay = false;c.show(this);"); ModifyDateTBX.Attributes.Add("readOnly", "-1"); }
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 Page_Load(object sender, EventArgs e) { strPagePrivilege.Add("ZJSYS"); strPageUserType.Add("mana"); if (Request.QueryString["ID"] == null) { concel.Visible = false; addsublab.Visible = false; tt1.Visible = false; LabName = "ʵ����"; if (!IsPostBack) { List<LabMS.Model.Dictionary> list = new List<LabMS.Model.Dictionary>(); //��ʵ����� list = DictionaryDropdownlist("111"); LabKindDDL.DataSource = list; LabKindDDL.DataBind(); //��ʵ������ list = DictionaryDropdownlist("112"); LabTypeDDL.DataSource = list; LabTypeDDL.DataBind(); //��ʵ�鼶�� list = DictionaryDropdownlist("113"); LabLevelDDL.DataSource = list; LabLevelDDL.DataBind(); //�������� list = DictionaryDropdownlist("114"); AwardLevelDDL.DataSource = list; AwardLevelDDL.DataBind(); //��ʵ����״̬ list = DictionaryDropdownlist("115"); StatusDDL.DataSource = list; StatusDDL.DataBind(); //������ѧ�� //SubjectDropdownlist(); } } else { if (!IsPostBack) { int ID; string strID = Request.QueryString["ID"].ToString(); if (int.TryParse(strID, out ID)) { //if (Page.Request.QueryString["flag"] !=null ) //{ // SaveBtn.Visible = false; // concel.Visible = true; //} //else //{ // concel.Visible = true; // addsublab.Visible = true; //} LabMS.BLL.Lab lab = new LabMS.BLL.Lab(); LabMS.Model.Lab labModel = new LabMS.Model.Lab(); List<LabMS.Model.Dictionary> list = new List<LabMS.Model.Dictionary>(); IDHF.Value = ID.ToString();//�洢IDֵ //��ȡʵ������Ϣ ͨ��ID labModel = lab.GetModel(ID); LabNumTBX.Text = labModel.Lab_Code;//��� LabNameTBX.Text = labModel.Lab_Name;//���� LabName = labModel.Lab_Name; DateTBX.Text = string.Format("{0:d}", labModel.Lab_SetupTime.ToString());//���� ManagerTBX.Text = labModel.Lab_InCharge;//������ TelTBX.Text = labModel.Lab_Phone;//�绰 CurriculumTBX.Text = labModel.Lab_Curriculum;//�е��γ� NumTXB.Text = labModel.Lab_ApprovalCode;//���ĺ� ProfessionTBX.Text = labModel.Lab_Professional;//����רҵ ProjectNumTBX.Text = labModel.Lab_ProjectNum.ToString();//���������� InvestmentTBX.Text = labModel.Lab_Investment.ToString();//Ͷ�ʶ� SubjectTBX.Text = labModel.Lab_Disciplines;//����ѧ�� AwardNumTBX.Text = labModel.Lab_StAwardNum.ToString();//���� //��ȡ�ļ��б� string strHTML = ""; if (labModel.Lab_Summary!= null) { AttachIDHF.Value = labModel.Lab_Summary.ToString(); LabMS.BLL.AttachmentItem attIte = new LabMS.BLL.AttachmentItem(); List<LabMS.Model.AttachmentItem> attIteModelList = new List<LabMS.Model.AttachmentItem>(); attIteModelList = attIte.GetModelList("Attach_ID=" + int.Parse(labModel.Lab_Summary.ToString())); strHTML += "<table>"; for (int i = 0; i < attIteModelList.Count; i++) { strHTML += "<tr>"; strHTML += "<td style='display:none;'>"; strHTML += attIteModelList[i].ID; strHTML += "</td>"; strHTML += "<td>"; strHTML += "<a>"; strHTML += "ɾ��"; strHTML += "</a>"; strHTML += "</td>"; strHTML += "<td>"; strHTML += attIteModelList[i].Item_Name; strHTML += "</td>"; strHTML += "</tr>"; } strHTML += "</table>"; filehtml.Value = strHTML; } //��ʵ����� list = DictionaryDropdownlist("111"); LabKindDDL.DataSource = list; LabKindDDL.DataBind(); LabKindDDL.SelectedValue = labModel.Lab_Category; //��ʵ������ list = DictionaryDropdownlist("112"); LabTypeDDL.DataSource = list; LabTypeDDL.DataBind(); LabTypeDDL.SelectedValue = labModel.Lab_Type; //��ʵ�鼶�� list = DictionaryDropdownlist("113"); LabLevelDDL.DataSource = list; LabLevelDDL.DataBind(); LabLevelDDL.SelectedValue = labModel.Lab_Level; //�������� list = DictionaryDropdownlist("114"); AwardLevelDDL.DataSource = list; AwardLevelDDL.DataBind(); AwardLevelDDL.SelectedValue = labModel.Lab_AwardLevel; //��ʵ����״̬ list = DictionaryDropdownlist("115"); StatusDDL.DataSource = list; StatusDDL.DataBind(); StatusDDL.SelectedValue = labModel.Lab_State; //������ѧ�� //SubjectDropdownlist(); //DepartmentDDL.SelectedValue = labModel.Lab_Curriculum; //����ʵ������Ϣ SubLabInfo_GridView(ID); SubLabGridView.Visible = true; } else { SaveBtn.Visible = false; ERRLbl.Text = "ϵͳ�쳣��IDֵ���Ϸ���"; ERRLbl.Visible = true; addsublab.Visible = false; } } } DateTBX.Attributes.Add("onclick", "c.showMoreDay = false;c.show(this);"); DateTBX.Attributes.Add("readOnly", "-1"); RoomAreaTBX.Attributes.Add("readOnly", "-1"); SubjectTBX.Attributes.Add("readOnly", "-1"); }
//�ύ�½�ʵ�������� 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) { #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 void Gv_FileList_DataBinds() { if (!string.IsNullOrEmpty(Request.QueryString["ID"])) { int ID = 0; int AttachID=0; if (int.TryParse(Request.QueryString["ID"].ToString(), out ID)) { if (ID != 0) { if (HFQueryString != ID) { 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(); applicationmodel = Application.GetModel(ID); LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem(); List<LabMS.Model.AttachmentItem> ls = new List<LabMS.Model.AttachmentItem>(); if (applicationmodel.App_Attachment != null) { AttachID = applicationmodel.App_Attachment.Value; if (AttachID != 0) { ls = AttachItem.GetModelList("Attach_ID=" + AttachID.ToString()); } } //if (ls.Count != 0) //{ // for (int n = 0; n < ls.Count; n++) // { // ls[n].Item_Name = ls[n].Item_Name.Substring(0,ls[n].Item_Name.LastIndexOf("_")); // } //} Gv_FileList.DataSource = ls; Gv_FileList.DataBind(); } } } }
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 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 AttachItemDataBind() { if (!string.IsNullOrEmpty(Request.QueryString["ID"])) { int ID = 0; if (int.TryParse(Request.QueryString["ID"], out ID)) { LabMS.BLL.OpentProject OpenProject = new LabMS.BLL.OpentProject(); LabMS.Model.OpentProject openprojectmodel = new LabMS.Model.OpentProject(); LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem(); List<LabMS.Model.AttachmentItem> ls = new List<LabMS.Model.AttachmentItem>(); openprojectmodel = OpenProject.GetModel(ID); if (openprojectmodel != null) { if (openprojectmodel.Attachment != null) { int Attach_ID = openprojectmodel.Attachment.Value; if (Attach_ID != 0) { ls = AttachItem.GetModelList("Attach_ID=" + Attach_ID); 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; } } } } } } }
protected void Page_Load(object sender, EventArgs e) { strPagePrivilege.Add("GZZD"); if (UserType == "student" || UserType == "teacher") { modifybtn.Visible = false; DeleteBtn.Visible = false; } if (Request.QueryString["ID"] != null) { if (!IsPostBack) { int ID; string strID = Request.QueryString["ID"].ToString(); if (int.TryParse(strID, out ID)) { IDHF.Value = ID.ToString(); ExtendBLL.Rule rule = new ExtendBLL.Rule(); DataSet ds = new DataSet(); ds = rule.GetList("[ID]=" + ID); CodeNumLbl.Text = ds.Tables[0].Rows[0]["Rule_CodeNum"].ToString(); TitleLbl.Text = ds.Tables[0].Rows[0]["Rule_Title"].ToString(); SubTitleLbl.Text = ds.Tables[0].Rows[0]["Rule_SubTitle"].ToString(); KeyLbl.Text = ds.Tables[0].Rows[0]["Rule_KeyWord"].ToString(); OutputUnitLbl.Text = ds.Tables[0].Rows[0]["Rule_OutputUnit"].ToString(); ResourceContentLbl.Text = ds.Tables[0].Rows[0]["Rule_Content"].ToString();//内容 ModifyDateLbl.Text = string.Format("{0:d}", ds.Tables[0].Rows[0]["Rule_Date"].ToString());//日期 List<LabMS.Model.Dictionary> dic = new List<LabMS.Model.Dictionary>(); //绑定数据字典 dic = DictionaryDropdownlist("118"); RuleKindDDL.DataSource = dic; RuleKindDDL.DataBind(); RuleKindDDL.SelectedValue = ds.Tables[0].Rows[0]["Rule_Type"].ToString(); //绑定录入单位 LabDropdowlist(); InputUnitDDL.SelectedValue = ds.Tables[0].Rows[0]["Rule_InputUnit"].ToString(); //获取文件列表 string strHTML = ""; if (ds.Tables[0].Rows[0]["AttachmentID"].ToString() != "") { LabMS.BLL.AttachmentItem attIte = new LabMS.BLL.AttachmentItem(); List<LabMS.Model.AttachmentItem> attIteModelList = new List<LabMS.Model.AttachmentItem>(); attIteModelList = attIte.GetModelList("Attach_ID=" + int.Parse(ds.Tables[0].Rows[0]["AttachmentID"].ToString())); for (int i = 0; i < attIteModelList.Count; i++) { strHTML += "<a onclick='downloadfile(" + attIteModelList[i].ID + ")'>"; strHTML += attIteModelList[i].Item_Name; strHTML += "</a>"; strHTML += "<br/>"; } filehtml.InnerHtml = strHTML; } } else { ERRLbl.Text = "系统异常,ID值不合法!"; ERRLbl.Visible = true; modifybtn.Visible = false; DeleteBtn.Visible = false; } } } else { ERRLbl.Text = "系统异常,ID值不合法!"; ERRLbl.Visible = true; modifybtn.Visible = false; DeleteBtn.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { strPagePrivilege.Add("SYSXX"); if (UserType == "student" || UserType == "teacher") { modeify.Visible = false; DeleteBtn.Visible = false; addsublab.Visible = false; } if (Request.QueryString["ID"] == null) { ERRLbl.Text = "系统异常,URL参数为空!"; ERRLbl.Visible = true; modeify.Visible = false; DeleteBtn.Visible = false; addsublab.Visible = false; } else { if (Page.Request.QueryString["flag"] != null) { modeify.Visible = false; DeleteBtn.Visible = false; addsublab.Visible = false; } if (!IsPostBack) { int ID; string strID = Request.QueryString["ID"].ToString(); if (int.TryParse(strID, out ID)) { LabMS.BLL.Lab lab = new LabMS.BLL.Lab(); LabMS.Model.Lab labModel = new LabMS.Model.Lab(); List<LabMS.Model.Dictionary> list = new List<LabMS.Model.Dictionary>(); string[] strArray = new string[2]; IDHF.Value = ID.ToString();//存储ID值 //获取实验室信息 通过ID labModel = lab.GetModel(ID); LabNumLbl.Text = labModel.Lab_Code;//编号 LabNameLbl.Text = labModel.Lab_Name;//名字 LabName = labModel.Lab_Name; DateLbl.Text = string.Format("{0:d}", labModel.Lab_SetupTime.ToString());//日期 ManagerLbl.Text = labModel.Lab_InCharge;//负责人 TelLbl.Text = labModel.Lab_Phone;//电话 CurriculumLbl.Text = labModel.Lab_Curriculum;//承担课程 NumLbl.Text = labModel.Lab_ApprovalCode;//批准文号 ProfessionLbl.Text = labModel.Lab_Professional;//面向专业 ProjectNumLbl.Text = labModel.Lab_ProjectNum.ToString();//科研任务数 InvestmentLbl.Text = labModel.Lab_Investment.ToString();//投资额 SubjectLbl.Text = labModel.Lab_Disciplines;//所属学科 AwardNumLbl.Text = labModel.Lab_StAwardNum.ToString();//获奖数 StatementLbl.Text = labModel.Lab_Statement;//备注 //获取文件列表 string strHTML = ""; if (labModel.Lab_Summary != null) { LabMS.BLL.AttachmentItem attIte = new LabMS.BLL.AttachmentItem(); List<LabMS.Model.AttachmentItem> attIteModelList = new List<LabMS.Model.AttachmentItem>(); attIteModelList = attIte.GetModelList("Attach_ID=" + int.Parse(labModel.Lab_Summary.ToString())); for (int i = 0; i < attIteModelList.Count; i++) { strHTML += "<a onclick='downloadfile("+attIteModelList[i].ID+")'>"; strHTML += attIteModelList[i].Item_Name; strHTML += "</a>"; strHTML += "<br/>"; } filehtml.InnerHtml = strHTML; } //绑定实验类别 list = DictionaryDropdownlist("111"); LabKindDDL.DataSource = list; LabKindDDL.DataBind(); LabKindDDL.SelectedValue = labModel.Lab_Category; //绑定实验类型 list = DictionaryDropdownlist("112"); LabTypeDDL.DataSource = list; LabTypeDDL.DataBind(); LabTypeDDL.SelectedValue = labModel.Lab_Type; //绑定实验级别 list = DictionaryDropdownlist("113"); LabLevelDDL.DataSource = list; LabLevelDDL.DataBind(); LabLevelDDL.SelectedValue = labModel.Lab_Level; //绑定奖励级别 list = DictionaryDropdownlist("114"); AwardLevelDDL.DataSource = list; AwardLevelDDL.DataBind(); AwardLevelDDL.SelectedValue = labModel.Lab_AwardLevel; //绑定实验室状态 list = DictionaryDropdownlist("115"); StatusDDL.DataSource = list; StatusDDL.DataBind(); StatusDDL.SelectedValue = labModel.Lab_State; //绑定子实验室信息 SubLabInfo_GridView(ID); SubLabGridView.Visible = true; } else { ERRLbl.Text = "系统异常,ID值不合法!"; ERRLbl.Visible = true; modeify.Visible = false; DeleteBtn.Visible = false; addsublab.Visible = false; } } } }