private void setParameter(iSqlParameter[] parms, BannerInfo info) { try { int i = -1; parms[++i].Value = CFunctions.SetDBString(info.Name); parms[++i].Value = CFunctions.SetDBString(info.Code); parms[++i].Value = info.Album; 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) + " " + CFunctions.install_keyword(info.Code); parms[++i].Value = info.Id; return; } catch (Exception ex) { throw ex; } }
private BannerInfo getDataReader(iSqlDataReader dar) { try { int i = -1; BannerInfo info = new BannerInfo(); info.Name = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Code = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Album = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i); info.Status = dar.IsDBNull(++i) ? 0 : 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); info.Rownumber = dar.IsDBNull(++i) ? 0 : dar.GetInt64(i); return info; } catch (Exception ex) { throw ex; } }
private bool Saveitem(iSqlTransaction trans, BannerInfo 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(BannerInfo 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 { BannerInfo info = null; if (iid != 0) { info = (new CBanner(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 BannerInfo(); 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; Displaysetting.Set(string.Empty, info.Status, 0); Filebanner.Bind_Files(iid, Webcmm.Id.Banner); return true; } catch { return false; } }
private BannerInfo Take() { try { int iid = 0; int.TryParse(txtId.Value, out iid); BannerInfo info = (new CBanner(CCommon.LANG)).Wcmm_Getinfo(iid); if (info == null) info = new BannerInfo(); info.Id = iid; info.Name = txtName.Text.Trim(); info.Code = txtCode.Text.Trim(); info.Status = Displaysetting.Get_Status(); info.Username = "******"; info.Timeupdate = DateTime.Now; return info; } catch { return null; } }
private bool Save_Lang(BannerInfo 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; BannerInfo lang_info = info.copy(); lang_info.Id = 0; lang_info.Status = (int)CConstants.State.Status.Waitactive; CBanner DALBanner = new CBanner(lang_val); if (DALBanner.Save(lang_info)) { if (lang_info.lFileattach != null && lang_info.lFileattach.Count > 0) if (new CFileattach(lang_val).Save(lang_info.lFileattach, lang_info.Id)) DALBanner.Updatenum(lang_info.Id.ToString(), Queryparam.Sqlcolumn.Album, lang_info.lFileattach.Count); } } return true; } catch { return false; } }
private bool Save(BannerInfo info) { try { if (info == null) return false; return (new CBanner(CCommon.LANG)).Save(info); } catch { return false; } }