//��Gridview protected void GridViewDataBind(int TypeID,string Key) { ExtendBLL.Rule rule = new ExtendBLL.Rule(); DataSet ds = new DataSet(); ds = rule.GetRuleInfo(TypeID, Key); RuleGridView.DataSource = ds; RuleGridView.DataBind(); }
protected void BindRuleInfo(int ID) { ExtendBLL.Rule rule = new ExtendBLL.Rule(); DataSet ds = new DataSet(); ds = rule.GetList("[ID]=" + ID); labFileNum.Text = ds.Tables[0].Rows[0]["Rule_CodeNum"].ToString(); LabTitle.Text = ds.Tables[0].Rows[0]["Rule_Title"].ToString(); LabComent.Text = ds.Tables[0].Rows[0]["Rule_Content"].ToString(); LabDanWei.Text = ds.Tables[0].Rows[0]["Rule_OutputUnit"].ToString(); }
//删除 protected void Delete_OnClick(object sender, EventArgs e) { ExtendBLL.Rule rule = new ExtendBLL.Rule(); try { rule.Delete(int.Parse(IDHF.Value)); Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('删除成功!');refreshParent();wincolse();</script>"); } catch { Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('删除失败!');refreshParent();wincolse();</script>"); } }
//ɾ�� protected void Delete_OnClick(object sender, EventArgs e) { ExtendBLL.Rule rule = new ExtendBLL.Rule(); int count = RuleGridView.Rows.Count; bool IsDel = false; for (int i = 0; i < count; i++) { CheckBox cb = (CheckBox)RuleGridView.Rows[i].FindControl("SelectCB"); if (cb.Checked == true) { IsDel = true; rule.Delete(int.Parse(RuleGridView.DataKeys[i].Value.ToString())); } } if (IsDel) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('ɾ���ɹ�!')</script>"); GridViewDataBind(int.Parse(RuleTypeDDL.SelectedValue), KeyTBX.Text); } }
//�жϹ����ƶ��ĺ��Ƿ��Ѵ��� protected bool IsCode(string code) { ExtendBLL.Rule rule = new ExtendBLL.Rule(); DataSet ds = new DataSet(); if (ViewState["ID"] != null) { ds = rule.GetList(" Rule_CodeNum='" + code + "' and [ID]<>" + int.Parse(ViewState["ID"].ToString())); } else { ds = rule.GetList("Rule_CodeNum='" + code + "'"); } if (ds.Tables[0].Rows.Count== 0) { return false; } else { return true; } }
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("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 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>"); } }