public void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(this.txtD_Name.Text.Trim().Length==0) { strErr+="健康知识文档名称不能为空!\\n"; } if(this.txtD_Url.Text.Trim().Length==0) { strErr+="健康知识文档地址不能为空!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int DocumentID=int.Parse(this.lblDocumentID.Text); string D_Name=this.txtD_Name.Text; string D_Url=this.txtD_Url.Text; Maticsoft.Model.education_Document model=new Maticsoft.Model.education_Document(); model.DocumentID=DocumentID; model.D_Name=D_Name; model.D_Url=D_Url; Maticsoft.BLL.education_Document bll=new Maticsoft.BLL.education_Document(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","list.aspx"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.education_Document model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update education_Document set "); strSql.Append("D_Name=@D_Name,"); strSql.Append("D_Url=@D_Url"); strSql.Append(" where DocumentID=@DocumentID"); SqlParameter[] parameters = { new SqlParameter("@D_Name", SqlDbType.NVarChar, 100), new SqlParameter("@D_Url", SqlDbType.VarChar, 2038), new SqlParameter("@DocumentID", SqlDbType.Int, 4) }; parameters[0].Value = model.D_Name; parameters[1].Value = model.D_Url; parameters[2].Value = model.DocumentID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtD_Name.Text.Trim().Length == 0) { strErr += "健康知识文档名称不能为空!\\n"; } if (this.txtD_Url.Text.Trim().Length == 0) { strErr += "健康知识文档地址不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string D_Name = this.txtD_Name.Text; string D_Url = this.txtD_Url.Text; Maticsoft.Model.education_Document model = new Maticsoft.Model.education_Document(); model.D_Name = D_Name; model.D_Url = D_Url; Maticsoft.BLL.education_Document bll = new Maticsoft.BLL.education_Document(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.education_Document model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into education_Document("); strSql.Append("D_Name,D_Url)"); strSql.Append(" values ("); strSql.Append("@D_Name,@D_Url)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@D_Name", SqlDbType.NVarChar, 100), new SqlParameter("@D_Url", SqlDbType.VarChar, 2038) }; parameters[0].Value = model.D_Name; parameters[1].Value = model.D_Url; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private void ShowInfo(int DocumentID) { Maticsoft.BLL.education_Document bll = new Maticsoft.BLL.education_Document(); Maticsoft.Model.education_Document model = bll.GetModel(DocumentID); this.lblDocumentID.Text = model.DocumentID.ToString(); this.txtD_Name.Text = model.D_Name; this.txtD_Url.Text = model.D_Url; }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.education_Document DataRowToModel(DataRow row) { Maticsoft.Model.education_Document model = new Maticsoft.Model.education_Document(); if (row != null) { if (row["DocumentID"] != null && row["DocumentID"].ToString() != "") { model.DocumentID = int.Parse(row["DocumentID"].ToString()); } if (row["D_Name"] != null) { model.D_Name = row["D_Name"].ToString(); } if (row["D_Url"] != null) { model.D_Url = row["D_Url"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.education_Document DataRowToModel(DataRow row) { Maticsoft.Model.education_Document model=new Maticsoft.Model.education_Document(); if (row != null) { if(row["DocumentID"]!=null && row["DocumentID"].ToString()!="") { model.DocumentID=int.Parse(row["DocumentID"].ToString()); } if(row["D_Name"]!=null) { model.D_Name=row["D_Name"].ToString(); } if(row["D_Url"]!=null) { model.D_Url=row["D_Url"].ToString(); } } return model; }
/// <summary> /// 点击确定按钮执行的方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { Maticsoft.BLL.education_Document education_Document_bll = new Maticsoft.BLL.education_Document(); Maticsoft.Model.education_Document education_Document_model = education_Document_bll.GetModel(DocumentID); if (education_Document_model == null) { education_Document_model = new Maticsoft.Model.education_Document(); } education_Document_model.D_Name = D_Name.Text; education_Document_model.D_UserID = UserData.GetUserDate.UserID; education_Document_model.D_DateTime = Convert.ToDateTime(DateTime.Now.ToShortDateString()); education_Document_model.D_Committee = UserData.GetUserDate.U_GroupID; switch (CMD) { case "New": CMD_Txt = "增加"; FileUpLoadCommon fc = new FileUpLoadCommon(Common.UpLoadDir + "Document/", false); bool flag = fc.SaveFile(D_Url, false); if (flag) { education_Document_model.D_Url = fc.newFileName; education_Document_model.DocumentID = education_Document_bll.Add(education_Document_model); } else { EventMessage.MessageBox(1, "操作失败", fc.errorMsg, Icon_Type.Error, Common.GetHomeBaseUrl("InfoManager.aspx?CMD=New")); } break; case "Edit": CMD_Txt = "修改"; education_Document_bll.Update(education_Document_model); break; } All_Title_Txt = CMD_Txt + App_Txt; EventMessage.MessageBox(1, "操作成功", string.Format("{1}ID({0})成功!", education_Document_model.DocumentID, All_Title_Txt), Icon_Type.OK, Common.GetHomeBaseUrl("default.aspx")); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.education_Document GetModel(int DocumentID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 DocumentID,D_Name,D_Url from education_Document "); strSql.Append(" where DocumentID=@DocumentID"); SqlParameter[] parameters = { new SqlParameter("@DocumentID", SqlDbType.Int, 4) }; parameters[0].Value = DocumentID; Maticsoft.Model.education_Document model = new Maticsoft.Model.education_Document(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.education_Document GetModel(int DocumentID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 DocumentID,D_Name,D_Url,D_UserID,D_DateTime,D_Committee from education_Document "); strSql.Append(" where DocumentID=@DocumentID"); SqlParameter[] parameters = { new SqlParameter("@DocumentID", SqlDbType.Int,4) }; parameters[0].Value = DocumentID; Maticsoft.Model.education_Document model=new Maticsoft.Model.education_Document(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }