public bool insertData(RegisterProjectData entity) { StringBuilder sql = new StringBuilder("INSERT INTO "); sql.Append(TableNameRegisterProject); sql.Append(" (" + GetSqlColumns() + ") VALUES ('"); sql.Append(dbEncode(entity.Name) + "','"); sql.Append(dbEncode(entity.Location) + "','"); sql.Append(dbEncode(entity.Description) + "','"); sql.Append(dbEncode(entity.ContactPerson) + "','"); sql.Append(dbEncode(entity.Email) + "','"); sql.Append(dbEncode(entity.Telephone) + "','"); sql.Append(dbEncode(entity.Cellphone) + "','"); sql.Append(dbEncode(entity.Website) + "','"); sql.Append(dbEncode(entity.FundingSource) + "',"); sql.Append(dbEncode(entity.CreatedDateTime) + ",'"); sql.Append(dbEncode(entity.ClientIp) + "');"); int newId = this.RunInsertQuery(sql.ToString()); if (newId > -1) { entity.Id = newId; return(true); } return(false); }
protected void rowToData(DataRow dr, RegisterProjectData entity) { entity.Id = Convert.ToInt32(dr["ProjectId"]); entity.Name = dr["Name"].ToString(); entity.Location = dr["Location"].ToString(); entity.Description = dr["Description"].ToString(); entity.ContactPerson = dr["ContactPerson"].ToString(); entity.Email = dr["Email"].ToString(); entity.Telephone = dr["Telephone"].ToString(); entity.Cellphone = dr["Cellphone"].ToString(); entity.Website = dr["Website"].ToString(); entity.FundingSource = dr["FundingSource"].ToString(); entity.CreatedDateTime = Convert.ToDateTime(dr["CreatedDateTime"]); entity.ClientIp = dr["ClientIp"].ToString(); }
public List <RegisterProjectData> fetchAll() { List <RegisterProjectData> list = new List <RegisterProjectData>(); DataSet ds = fetchAllAsDataSet(); if (this.hasRows(ds) == false) { return(list); } foreach (DataRow dr in ds.Tables[0].Rows) { RegisterProjectData entity = new RegisterProjectData(); rowToData(dr, entity); list.Add(entity); } return(list); }