private Dentist toDentist(IDataReader dataReader) { Dentist p = new Dentist(); p.UserId = GetStringSafe(dataReader, "userid"); p.FirstName = GetStringSafe(dataReader, "fname"); p.LastName = GetStringSafe(dataReader, "lname"); if (!dataReader.IsDBNull(dataReader.GetOrdinal("birthdate"))) { p.BirthDate = dataReader.GetDateTime(dataReader.GetOrdinal("birthdate")); } p.BirthPlace = GetStringSafe(dataReader, "birthplace"); p.Gender = GetStringSafe(dataReader, "gender"); p.Address1 = GetStringSafe(dataReader, "address1"); p.Address2 = GetStringSafe(dataReader, "address2"); p.City = GetStringSafe(dataReader, "city"); p.Phone = GetStringSafe(dataReader, "phone"); p.IsUser = (dataReader.IsDBNull(dataReader.GetOrdinal("isuser")) ? false: dataReader.GetBoolean(dataReader.GetOrdinal("isuser"))); return p; }
public bool InsertDentist (Dentist p) { string tableName = "dentist"; string columns = "(userid, fname, lname, birthdate, birthplace, gender,address1,address2,city,phone, created,createdBy)"; string values = "('" + p.UserId + "','" + p.FirstName + "','" + p.LastName + "','" + p.BirthDate.ToString(Smile.DATE_FORMAT) + "','" + p.BirthPlace + "','" + p.Gender + "','" + p.Address1 + "','" + p.Address2 + "','" + p.City + "','" + p.Phone + "','" + DateTime.Now.ToString(Smile.LONG_DATE_FORMAT) + "','"+User+"')"; string query = "INSERT INTO " + tableName + " " + columns + " values " + values + " ;"; if (this.OpenDentistConnection() == true) { IDbCommand cmd = getSqlCommand(query, dentistConnection); cmd.ExecuteNonQuery(); this.CloseDentistConnection(); return true; } return false; }
public void UpdateDentist (Dentist p) { string tableName = "dentist"; string setColumns = "fname = '" + p.FirstName + "', lname= '" + p.LastName + "', birthdate = '" + p.BirthDate.ToString(Smile.DATE_FORMAT) + "', birthplace= '" + p.BirthPlace + "', gender= '" + p.Gender + "',address1= '" + p.Address1 + "',address2= '" + p.Address2 + "',city= '" + p.City + "',phone= '" + p.Phone + "', modified = '" + DateTime.Now.ToString(Smile.LONG_DATE_FORMAT) + "', modifiedBy= '"+User+"' "; string query = "UPDATE " + tableName + " SET " + setColumns + " WHERE userid = '" + p.UserId+"'"; if (this.OpenDentistConnection() == true) { IDbCommand cmd = getSqlCommand(query, dentistConnection); cmd.ExecuteNonQuery(); this.CloseDentistConnection(); } }
internal bool InsertDefaultAdmin(string p) { string tableName = "smileuser"; string columns = "(userid, password, admin, created,createdBy)"; string values = "('root','" + CalculateMD5Hash(p)+ "',1,'" + DateTime.Now.ToString(Smile.LONG_DATE_FORMAT) + "','DENTALSMILE')"; string query = "INSERT INTO " + tableName + " " + columns + " values " + values + " ;"; if (this.OpenConnection() == true) { IDbCommand cmd = getSqlCommand(query, connection); cmd.ExecuteNonQuery(); this.CloseConnection(); Dentist d = new Dentist(); d.UserId = "root"; d.FirstName = "Root"; d.BirthDate = DateTime.Now; InsertDentist(d); return true; } return false; }