private void setParameter(iSqlParameter[] parms, MeProfileInfo info) { try { int i = -1; parms[++i].Value = CFunctions.SetDBString(info.Address); parms[++i].Value = CFunctions.SetDBString(info.Zipcode); parms[++i].Value = CFunctions.SetDBString(info.State); parms[++i].Value = info.Nationalid; parms[++i].Value = info.Cityid; parms[++i].Value = info.Districtid; parms[++i].Value = CFunctions.SetDBString(info.Phone); parms[++i].Value = CFunctions.SetDBString(info.About); parms[++i].Value = CFunctions.SetDBString(info.Blog); parms[++i].Value = CFunctions.SetDBString(info.Homepage); parms[++i].Value = CFunctions.SetDBString(info.Facebook); parms[++i].Value = CFunctions.SetDBString(info.Twitter); parms[++i].Value = CFunctions.SetDBString(info.Youtube); parms[++i].Value = CFunctions.SetDBString(info.Flickr); parms[++i].Value = CFunctions.SetDBString(info.Skype); parms[++i].Value = CFunctions.SetDBString(info.Yahoo); parms[++i].Value = CFunctions.SetDBDatetime(info.Birthday); parms[++i].Value = CFunctions.SetDBString(info.Profession); parms[++i].Value = info.Id; return; } catch (Exception ex) { throw ex; } }
private MeProfileInfo getDataReader(iSqlDataReader dar) { try { int i = -1; MeProfileInfo info = new MeProfileInfo(); info.Address = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Zipcode = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.State = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Nationalid = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i); info.Nationalname = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Cityid = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i); info.Cityname = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Districtid = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i); info.Districtname = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Phone = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.About = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Blog = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Homepage = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Facebook = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Twitter = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Youtube = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Flickr = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Skype = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Yahoo = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Birthday = dar.IsDBNull(++i) ? new DateTime(0) : dar.GetDateTime(i); info.Profession = 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, MeProfileInfo 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(MeProfileInfo 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; } }