private void setParameter(iSqlParameter[] parms, MenutypeofInfo info) { try { int i = -1; parms[++i].Value = CFunctions.SetDBString(info.Code); parms[++i].Value = CFunctions.SetDBString(info.Name); parms[++i].Value = CFunctions.SetDBString(info.Path); parms[++i].Value = CFunctions.SetDBString(info.Note); parms[++i].Value = info.Insertbreak; parms[++i].Value = info.Status; parms[++i].Value = CFunctions.SetDBDatetime(info.Timeupdate); parms[++i].Value = CFunctions.SetDBString(info.Username); parms[++i].Value = CFunctions.install_keyword(info.Name); parms[++i].Value = info.Id; return; } catch (Exception ex) { throw ex; } }
private MenutypeofInfo getDataReader(iSqlDataReader dar) { try { int i = -1; MenutypeofInfo info = new MenutypeofInfo(); info.Code = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Name = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Path = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Note = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Insertbreak = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i); info.Status = dar.IsDBNull(++i) ? (int)CConstants.State.Status.Waitactive : dar.GetInt32(i); info.Timeupdate = dar.IsDBNull(++i) ? new DateTime(0) : dar.GetDateTime(i); info.Username = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Id = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i); return info; } catch (Exception ex) { throw ex; } }
private bool Saveitem(iSqlTransaction trans, MenutypeofInfo info) { try { if (trans == null || info == null) return false; string SQL = string.Empty; if (info.Id == 0) { SQL = SQL_INSERT; info.Id = (int)HELPER.getNewID(trans, TABLENAME); iSqlParameter[] parms = this.getParameter(SQL); this.setParameter(parms, info); HELPER.executeNonQuery(trans, iCommandType.Text, SQL, parms); } else if (HELPER.isExist(trans, TABLENAME, info.Id)) { SQL = SQL_UPDATE; iSqlParameter[] parms = this.getParameter(SQL); this.setParameter(parms, info); HELPER.executeNonQuery(trans, iCommandType.Text, SQL, parms); } else { SQL = SQL_INSERT; info.Id = (int)HELPER.getNewID(trans, TABLENAME); iSqlParameter[] parms = this.getParameter(SQL); this.setParameter(parms, info); HELPER.executeNonQuery(trans, iCommandType.Text, SQL, parms); } return true; } catch (Exception ex) { throw ex; } }
public bool Save(MenutypeofInfo info) { try { using (iSqlConnection iConn = HELPER.getConnect(HELPER.SQL_SYSTEM)) { using (iSqlTransaction trans = iConn.BeginTransaction()) { try { this.Saveitem(trans, info); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw ex; } } iConn.Close(); } return true; } catch (Exception ex) { throw ex; } }
private bool Load_Info(int iid) { try { MenutypeofInfo info = null; if (iid != 0) { info = (new CMenutypeof(CCommon.LANG)).Wcmm_Getinfo(iid); if (info != null) { lstError = new List<Errorobject>(); lstError = Form_GetError(lstError, Errortype.Notice, Definephrase.Save_notice, "[" + info.Id + "] " + info.Name, null); Master.Form_ShowError(lstError); } } if (info == null) info = new MenutypeofInfo(); chkSaveoption_golist.Checked = info.Id != 0; chkSaveoption_golang.Checked = info.Id == 0; txtId.Value = info.Id.ToString(); txtName.Text = info.Name; txtCode.Text = info.Code; txtNote.Text = info.Note; txtPath.Text = info.Path; chkInsertbreak.Checked = info.Insertbreak != 0; radStatus.SelectedValue = info.Status.ToString(); return true; } catch { return false; } }
private MenutypeofInfo Take() { try { int iid = 0; int.TryParse(txtId.Value, out iid); MenutypeofInfo info = (new CMenutypeof(CCommon.LANG)).Wcmm_Getinfo(iid); if (info == null) info = new MenutypeofInfo(); info.Id = iid; info.Name = txtName.Text.Trim(); info.Code = txtCode.Text.Trim(); info.Note = txtNote.Text.Trim(); info.Path = txtPath.Text.Trim(); info.Insertbreak = chkInsertbreak.Checked ? 1 : 0; info.Status = int.Parse(radStatus.SelectedValue); info.Username = CCommon.Get_CurrentUsername(); info.Timeupdate = DateTime.Now; return info; } catch { return null; } }
private bool Save_Lang(MenutypeofInfo info) { try { if (!CFunctions.IsMultiLanguage() || !chkSaveoption_golang.Checked) return false; int lang_num = CConstants.LANG_NUM; for (int i = 0; i < lang_num; i++) { string lang_val = ConfigurationSettings.AppSettings["LANG_" + i]; if (lang_val == CCommon.LANG) continue; MenutypeofInfo lang_info = info.copy(); lang_info.Id = 0; lang_info.Status = (int)CConstants.State.Status.Waitactive; (new CMenutypeof(lang_val)).Save(lang_info); } return true; } catch { return false; } }
private bool Save(MenutypeofInfo info) { try { if (info == null) return false; return (new CMenutypeof(CCommon.LANG)).Save(info); } catch { return false; } }