/// <summary> /// get table record /// <summary> /// <param name=ver>ver</param> /// <param name=out emsg>return error message</param> ///<returns>get a record detail of sysmodifylog</returns> public modSysModifyLog GetItem(string ver, out string emsg) { try { //Execute a query to read the categories string sql = string.Format("select ver,title,modify_content,update_user,update_time from sys_modify_log where ver='{0}' order by ver", ver); using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { if (rdr.Read()) { modSysModifyLog model = new modSysModifyLog(); model.Version = dalUtility.ConvertToString(rdr["ver"]); model.Title = dalUtility.ConvertToString(rdr["title"]); model.ModifyContent = dalUtility.ConvertToString(rdr["modify_content"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_time"]); emsg = null; return(model); } else { emsg = "Error on read data"; return(null); } } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }
/// <summary> /// get all sysmodifylog /// <summary> /// <param name=out emsg>return error message</param> ///<returns>details of all sysmodifylog</returns> public BindingCollection <modSysModifyLog> GetIList(out string emsg) { try { BindingCollection <modSysModifyLog> modellist = new BindingCollection <modSysModifyLog>(); //Execute a query to read the categories string sql = "select ver,title,modify_content,update_user,update_time from sys_modify_log order by update_time desc"; using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { while (rdr.Read()) { modSysModifyLog model = new modSysModifyLog(); model.Version = dalUtility.ConvertToString(rdr["ver"]); model.Title = dalUtility.ConvertToString(rdr["title"]); model.ModifyContent = dalUtility.ConvertToString(rdr["modify_content"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_time"]); modellist.Add(model); } } emsg = null; return(modellist); } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }
private void DBGrid_SelectionChanged(object sender, EventArgs e) { if (DBGrid.CurrentRow != null) { modSysModifyLog mod = (modSysModifyLog)DBGrid.CurrentRow.DataBoundItem; txtVersion.Text = mod.Version.ToString(); txtTitle.Text = mod.Title; txtContent.Text = mod.ModifyContent; FindText = mod.Version.ToString(); } }
protected override void Find() { for (int i = 0; i < DBGrid.Rows.Count; i++) { modSysModifyLog mod = (modSysModifyLog)DBGrid.Rows[i].DataBoundItem; if (mod.Version.ToString().CompareTo(FindText) == 0) { DBGrid.CurrentCell = DBGrid.Rows[i].Cells[0]; return; } } }
protected override bool Save() { try { this.Cursor = Cursors.WaitCursor; if (string.IsNullOrEmpty(txtVersion.Text.Trim())) { MessageBox.Show(clsTranslate.TranslateString("Version") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtVersion.Focus(); return(false); } modSysModifyLog mod = new modSysModifyLog(txtVersion.Text.Trim(), txtTitle.Text.Trim(), txtContent.Text.Trim(), Util.UserId, DateTime.Now); bool ret = false; if (_status == 1) { ret = _dal.Insert(mod, out Util.emsg); } else if (_status == 2) { ret = _dal.Update(txtVersion.Text.Trim(), mod, out Util.emsg); } if (ret) { Util.ChangeStatus(this, true); LoadData(); FindText = txtVersion.Text.Trim(); Find(); } return(ret); } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } finally { this.Cursor = Cursors.Default; } }
/// <summary> /// update a sysmodifylog /// <summary> /// <param name=ver>ver</param> /// <param name=mod>model object of sysmodifylog</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Update(string ver, modSysModifyLog mod, out string emsg) { try { string sql = string.Format("update sys_modify_log set title='{0}',modify_content='{1}',update_user='******', update_time=getdate() where ver='{3}'", mod.Title, mod.ModifyContent, mod.UpdateUser, ver); int i = SqlHelper.ExecuteNonQuery(sql); if (i > 0) { emsg = null; return(true); } else { emsg = "Unknown error when ExecuteNonQuery!"; return(false); } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(false); } }
/// <summary> /// insert a sysmodifylog /// <summary> /// <param name=mod>model object of sysmodifylog</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Insert(modSysModifyLog mod, out string emsg) { try { string sql = string.Format("insert into sys_modify_log(ver,title,modify_content,update_user,update_time)values('{0}','{1}','{2}','{3}',getdate())", mod.Version, mod.Title, mod.ModifyContent, mod.UpdateUser); int i = SqlHelper.ExecuteNonQuery(sql); if (i > 0) { emsg = null; return(true); } else { emsg = "Unknown error when ExecuteNonQuery!"; return(false); } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(false); } }