/// <summary> /// 获得数据列表 /// </summary> public List <WSS.Model.SysLog> DataTableToList(DataTable dt) { List <WSS.Model.SysLog> modelList = new List <WSS.Model.SysLog>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { WSS.Model.SysLog model; for (int n = 0; n < rowsCount; n++) { model = new WSS.Model.SysLog(); if (dt.Rows[n]["F_ID"].ToString() != "") { model.F_ID = int.Parse(dt.Rows[n]["F_ID"].ToString()); } if (dt.Rows[n]["F_UserID"].ToString() != "") { model.F_UserID = int.Parse(dt.Rows[n]["F_UserID"].ToString()); } model.F_UserName = dt.Rows[n]["F_UserName"].ToString(); model.F_Note = dt.Rows[n]["F_Note"].ToString(); model.F_URL = dt.Rows[n]["F_URL"].ToString(); model.F_DateTime = dt.Rows[n]["F_DateTime"].ToString(); modelList.Add(model); } } return(modelList); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(WSS.Model.SysLog model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_SysLog("); strSql.Append("F_UserID,F_UserName,F_Note,F_URL,F_DateTime)"); strSql.Append(" values ("); strSql.Append("@F_UserID,@F_UserName,@F_Note,@F_URL,@F_DateTime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@F_UserID", SqlDbType.Int, 4), new SqlParameter("@F_UserName", SqlDbType.NChar, 16), new SqlParameter("@F_Note", SqlDbType.NChar, 10), new SqlParameter("@F_URL", SqlDbType.NChar, 10), new SqlParameter("@F_DateTime", SqlDbType.NChar, 10) }; parameters[0].Value = model.F_UserID; parameters[1].Value = model.F_UserName; parameters[2].Value = model.F_Note; parameters[3].Value = model.F_URL; parameters[4].Value = model.F_DateTime; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private void ShowInfo(int F_ID) { WSS.BLL.SysLog bll = new WSS.BLL.SysLog(); WSS.Model.SysLog model = bll.GetModel(F_ID); this.lblF_ID.Text = model.F_ID.ToString(); this.txtF_UserID.Text = model.F_UserID.ToString(); this.txtF_UserName.Text = model.F_UserName; this.txtF_Note.Text = model.F_Note; this.txtF_URL.Text = model.F_URL; this.txtF_DateTime.Text = model.F_DateTime; }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtF_UserID.Text)) { strErr += "用户ID格式错误!\\n"; } if (this.txtF_UserName.Text.Trim().Length == 0) { strErr += "用户名不能为空!\\n"; } if (this.txtF_Note.Text.Trim().Length == 0) { strErr += "备注不能为空!\\n"; } if (this.txtF_URL.Text.Trim().Length == 0) { strErr += "网页地址不能为空!\\n"; } if (this.txtF_DateTime.Text.Trim().Length == 0) { strErr += "时间不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int F_ID = int.Parse(this.lblF_ID.Text); int F_UserID = int.Parse(this.txtF_UserID.Text); string F_UserName = this.txtF_UserName.Text; string F_Note = this.txtF_Note.Text; string F_URL = this.txtF_URL.Text; string F_DateTime = this.txtF_DateTime.Text; WSS.Model.SysLog model = new WSS.Model.SysLog(); model.F_ID = F_ID; model.F_UserID = F_UserID; model.F_UserName = F_UserName; model.F_Note = F_Note; model.F_URL = F_URL; model.F_DateTime = F_DateTime; WSS.BLL.SysLog bll = new WSS.BLL.SysLog(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public WSS.Model.SysLog GetModel(int F_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 F_ID,F_UserID,F_UserName,F_Note,F_URL,F_DateTime from T_SysLog "); strSql.Append(" where F_ID=@F_ID"); SqlParameter[] parameters = { new SqlParameter("@F_ID", SqlDbType.Int, 4) }; parameters[0].Value = F_ID; WSS.Model.SysLog model = new WSS.Model.SysLog(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["F_ID"].ToString() != "") { model.F_ID = int.Parse(ds.Tables[0].Rows[0]["F_ID"].ToString()); } if (ds.Tables[0].Rows[0]["F_UserID"].ToString() != "") { model.F_UserID = int.Parse(ds.Tables[0].Rows[0]["F_UserID"].ToString()); } if (ds.Tables[0].Rows[0]["F_UserName"] != null) { model.F_UserName = ds.Tables[0].Rows[0]["F_UserName"].ToString(); } if (ds.Tables[0].Rows[0]["F_Note"] != null) { model.F_Note = ds.Tables[0].Rows[0]["F_Note"].ToString(); } if (ds.Tables[0].Rows[0]["F_URL"] != null) { model.F_URL = ds.Tables[0].Rows[0]["F_URL"].ToString(); } if (ds.Tables[0].Rows[0]["F_DateTime"] != null) { model.F_DateTime = ds.Tables[0].Rows[0]["F_DateTime"].ToString(); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(WSS.Model.SysLog model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_SysLog set "); strSql.Append("F_UserID=@F_UserID,"); strSql.Append("F_UserName=@F_UserName,"); strSql.Append("F_Note=@F_Note,"); strSql.Append("F_URL=@F_URL,"); strSql.Append("F_DateTime=@F_DateTime"); strSql.Append(" where F_ID=@F_ID"); SqlParameter[] parameters = { new SqlParameter("@F_UserID", SqlDbType.Int, 4), new SqlParameter("@F_UserName", SqlDbType.NChar, 16), new SqlParameter("@F_Note", SqlDbType.NChar, 10), new SqlParameter("@F_URL", SqlDbType.NChar, 10), new SqlParameter("@F_DateTime", SqlDbType.NChar, 10), new SqlParameter("@F_ID", SqlDbType.Int, 4) }; parameters[0].Value = model.F_UserID; parameters[1].Value = model.F_UserName; parameters[2].Value = model.F_Note; parameters[3].Value = model.F_URL; parameters[4].Value = model.F_DateTime; parameters[5].Value = model.F_ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(WSS.Model.SysLog model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(WSS.Model.SysLog model) { return(dal.Add(model)); }