/// <summary> /// get table record /// <summary> /// <param name=credenceword>credenceword</param> /// <param name=out emsg>return error message</param> ///<returns>get a record detail of acccredenceword</returns> public modAccCredenceWord GetItem(string credenceword, out string emsg) { try { //Execute a query to read the categories string sql = string.Format("select credence_word,update_user,update_time from acc_credence_word where credence_word='{0}' order by credence_word", credenceword); using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { if (rdr.Read()) { modAccCredenceWord model = new modAccCredenceWord(); model.CredenceWord = dalUtility.ConvertToString(rdr["credence_word"]); 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 acccredenceword /// <summary> /// <param name=out emsg>return error message</param> ///<returns>details of all acccredenceword</returns> public BindingCollection <modAccCredenceWord> GetIList(out string emsg) { try { BindingCollection <modAccCredenceWord> modellist = new BindingCollection <modAccCredenceWord>(); //Execute a query to read the categories string sql = "select credence_word,update_user,update_time from acc_credence_word order by credence_word"; using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { while (rdr.Read()) { modAccCredenceWord model = new modAccCredenceWord(); model.CredenceWord = dalUtility.ConvertToString(rdr["credence_word"]); 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) { modAccCredenceWord mod = (modAccCredenceWord)DBGrid.CurrentRow.DataBoundItem; txtCredenceWord.Text = mod.CredenceWord; FindText = mod.CredenceWord; } }
protected override void Find() { for (int i = 0; i < DBGrid.Rows.Count; i++) { modAccCredenceWord mod = (modAccCredenceWord)DBGrid.Rows[i].DataBoundItem; if (mod.CredenceWord.CompareTo(FindText) == 0) { DBGrid.CurrentCell = DBGrid.Rows[i].Cells[0]; DBGrid_SelectionChanged(null, null); return; } } }
protected override bool Save() { try { this.Cursor = Cursors.WaitCursor; if (string.IsNullOrEmpty(txtCredenceWord.Text.Trim())) { MessageBox.Show(clsTranslate.TranslateString("Credence word") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCredenceWord.Focus(); return(false); } modAccCredenceWord mod = new modAccCredenceWord(txtCredenceWord.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(txtCredenceWord.Text, mod, out Util.emsg); } if (ret) { Util.ChangeStatus(this, true); DBGrid.Enabled = true; LoadData(); FindText = mod.CredenceWord; 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> /// insert a acccredenceword /// <summary> /// <param name=mod>model object of acccredenceword</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Insert(modAccCredenceWord mod, out string emsg) { try { string sql = string.Format("insert into acc_credence_word(credence_word,update_user,update_time)values('{0}','{1}',getdate())", mod.CredenceWord, 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); } }
/// <summary> /// update a acccredenceword /// <summary> /// <param name=credenceword>credenceword</param> /// <param name=mod>model object of acccredenceword</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Update(string credenceword, modAccCredenceWord mod, out string emsg) { try { string sql = string.Format("update acc_credence_word set update_user='******',update_time=getdate() where credence_word='{1}'", mod.UpdateUser, credenceword); 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); } }