protected void Page_Load(object sender, EventArgs e) { strPagePrivilege.Add("ZDPGBZ"); strPageUserType.Add("mana"); if (Request.QueryString["ID"] == null && Request.QueryString["TitleID"]!=null) { if (!IsPostBack) { ViewState["TitleID"] = Request.QueryString["TitleID"]; } } else if (Request.QueryString["ID"] != null) { if (!IsPostBack) { int ID; if(int.TryParse(Request.QueryString["ID"].ToString(),out ID)) { LabMS.BLL.Standard sta = new LabMS.BLL.Standard(); LabMS.Model.Standard staModel = new LabMS.Model.Standard(); staModel = sta.GetModel(ID); ViewState["TitleID"] = staModel.EvTitleID; ViewState["ID"] = ID; BindData(ID); } } } else { ERRLbl.Text = "ϵͳ�쳣���������Ϸ���"; ERRLbl.Visible = true; SaveBtn.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { strPagePrivilege.Add("ZDPGBZ"); strPageUserType.Add("mana"); if (Request.QueryString["ID"] != null) { if (!IsPostBack) { int ID; if (int.TryParse(Request.QueryString["ID"].ToString(), out ID)) { LabMS.BLL.Standard sta = new LabMS.BLL.Standard(); LabMS.Model.Standard staModel = new LabMS.Model.Standard(); staModel = sta.GetModel(ID); IDHF.Value = ID.ToString(); BindData(ID); } else { ERRLbl.Text = "系统异常,参数不合法!"; ERRLbl.Visible = true; modifybtn.Visible = false; } } } else { ERRLbl.Text = "系统异常,参数不合法!"; ERRLbl.Visible = true; modifybtn.Visible = false; } }
//������ protected void BindData(int ID) { LabMS.BLL.Standard sta = new LabMS.BLL.Standard(); LabMS.Model.Standard staModel = new LabMS.Model.Standard(); staModel = sta.GetModel(ID); CodeTBX.Text = staModel.St_Num.ToString(); ContentTBX.Text = staModel.St_Content; StandardTBX.Text = staModel.St_Standard; MethodTBX.Text = staModel.St_Method; ExplainTBX.Text = staModel.St_Explain; }
//绑定数据 protected void BindData(int ID) { LabMS.BLL.Standard sta = new LabMS.BLL.Standard(); LabMS.Model.Standard staModel = new LabMS.Model.Standard(); staModel = sta.GetModel(ID); CodeLbl.Text = staModel.St_Num.ToString(); ContentLbl.Text = staModel.St_Content; StandardLbl.Text = staModel.St_Standard.Replace("\r\n","<br/>"); MethodLbl.Text = staModel.St_Method.Replace("\r\n", "<br/>"); ExplainLbl.Text = staModel.St_Explain.Replace("\r\n", "<br/>"); }
//处理List protected List<LabMS.Model.Standard> HandleList(List<LabMS.Model.Standard> list) { List<LabMS.Model.Standard> modelList = new List<LabMS.Model.Standard>(); for (int i = 0; i < list.Count; i++) { LabMS.Model.Standard sta = new LabMS.Model.Standard(); sta.EvTitleID = list[i].EvTitleID; sta.ID = list[i].ID; sta.St_Content = list[i].St_Content; sta.St_Explain = list[i].St_Explain.Replace("\r\n", "<br/>"); sta.St_Method = list[i].St_Method.Replace("\r\n", "<br/>"); sta.St_Num = list[i].St_Num; sta.St_Standard = list[i].St_Standard.Replace("\r\n", "<br/>"); modelList.Add(sta); } return modelList; }
//�������� protected void Save_OnClick(object sender, EventArgs e) { if (CodeTBX.Text.Trim() == "") { Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('��������ţ�')</script>"); return; } if (ContentTBX.Text.Trim() == "") { Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('�������������ݣ�')</script>"); return; } LabMS.BLL.Standard stan = new LabMS.BLL.Standard(); LabMS.Model.Standard stanModel = new LabMS.Model.Standard(); stanModel.St_Num = CodeTBX.Text.Trim();//��� stanModel.St_Content = ContentTBX.Text.Trim();//���� stanModel.St_Standard = StandardTBX.Text.Trim();//�� stanModel.St_Method = MethodTBX.Text.Trim();//���� stanModel.St_Explain = ExplainTBX.Text.Trim();//˵�� stanModel.St_Date = DateTime.Now;//���� if (ViewState["ID"] != null) { stanModel.EvTitleID = int.Parse(ViewState["TitleID"].ToString()); stanModel.ID = int.Parse(ViewState["ID"].ToString()); stan.Update(stanModel); Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('���³ɹ���');refreshParent();wincolse();</script>"); } else { stanModel.EvTitleID = int.Parse(ViewState["TitleID"].ToString()); stan.Add(stanModel); Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('��ӳɹ���');refreshParent();</script>"); } }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public LabMS.Model.Standard GetModel(int ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ID,St_Num,St_Content,St_Standard,St_Method,St_Explain,St_Date,EvTitleID from Standard "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4)}; parameters[0].Value = ID; LabMS.Model.Standard model=new LabMS.Model.Standard(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["ID"].ToString()!="") { model.ID=int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } model.St_Num=ds.Tables[0].Rows[0]["St_Num"].ToString(); model.St_Content=ds.Tables[0].Rows[0]["St_Content"].ToString(); model.St_Standard=ds.Tables[0].Rows[0]["St_Standard"].ToString(); model.St_Method=ds.Tables[0].Rows[0]["St_Method"].ToString(); model.St_Explain=ds.Tables[0].Rows[0]["St_Explain"].ToString(); if(ds.Tables[0].Rows[0]["St_Date"].ToString()!="") { model.St_Date=DateTime.Parse(ds.Tables[0].Rows[0]["St_Date"].ToString()); } if(ds.Tables[0].Rows[0]["EvTitleID"].ToString()!="") { model.EvTitleID=int.Parse(ds.Tables[0].Rows[0]["EvTitleID"].ToString()); } return model; } else { return null; } }